refactor: replaced topology axios call with bee-js

This commit is contained in:
Vojtech Simetka
2021-04-02 10:44:44 +02:00
parent d711b4cd85
commit 53dd4e1741
8 changed files with 70 additions and 79 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import type { NodeAddresses, ChequebookAddressResponse, ChequebookBalanceResponse, BalanceResponse,
LastChequesResponse, AllSettlements, LastCashoutActionResponse, Health, Peer } from '@ethersphere/bee-js'
LastChequesResponse, AllSettlements, LastCashoutActionResponse, Health, Peer, Topology } from '@ethersphere/bee-js'
import { beeDebugApi, beeApi } from '../services/bee';
@@ -72,15 +72,15 @@ export const useApiNodeAddresses = () => {
}
export const useApiNodeTopology = () => {
const [nodeTopology, setNodeTopology] = useState({ baseAddr: '', bins: [""], connected: 0, depth: 0, nnLowWatermark: 0, population: 0, timestamp: ''})
const [isLoadingNodeTopology, setLoading] = useState<boolean>(false)
const [topology, setNodeTopology] = useState<Topology | null>(null)
const [isLoading, setLoading] = useState<boolean>(false)
const [error, setError] = useState<Error | null>(null)
useEffect(() => {
setLoading(true)
beeDebugApi.connectivity.topology()
.then(res => {
setNodeTopology(res.data)
setNodeTopology(res)
})
.catch(error => {
setError(error)
@@ -90,7 +90,7 @@ export const useApiNodeTopology = () => {
})
}, [])
return { nodeTopology, isLoadingNodeTopology, error } ;
return { topology, isLoading, error } ;
}
export const useApiChequebookAddress = () => {