feat: add wallet endpoint and display blockchain name (#492)

This commit is contained in:
Vojtech Simetka
2022-07-26 10:18:27 +02:00
committed by GitHub
parent 186d0352cf
commit fd11f0166d
3 changed files with 44 additions and 0 deletions
+11
View File
@@ -8,6 +8,7 @@ import {
NodeInfo,
Peer,
Topology,
WalletBalance,
} from '@ethersphere/bee-js'
import { createContext, ReactChild, ReactElement, useContext, useEffect, useState } from 'react'
import semver from 'semver'
@@ -65,6 +66,7 @@ interface ContextInterface {
peerCheques: LastChequesResponse | null
settlements: Settlements | null
chainState: ChainState | null
wallet: WalletBalance | null
latestBeeRelease: LatestBeeRelease | null
isLoading: boolean
lastUpdate: number | null
@@ -102,6 +104,7 @@ const initialValues: ContextInterface = {
peerCheques: null,
settlements: null,
chainState: null,
wallet: null,
latestBeeRelease: null,
isLoading: true,
lastUpdate: null,
@@ -204,6 +207,7 @@ export function Provider({ children }: Props): ReactElement {
const [settlements, setSettlements] = useState<Settlements | null>(null)
const [chainState, setChainState] = useState<ChainState | null>(null)
const [walletAddress, setWalletAddress] = useState<WalletAddress | null>(initialValues.balance)
const [wallet, setWallet] = useState<WalletBalance | null>(null)
const { latestBeeRelease } = useLatestBeeRelease()
@@ -356,6 +360,12 @@ export function Provider({ children }: Props): ReactElement {
.then(setChainState)
.catch(() => setChainState(null)),
// Wallet
beeDebugApi
.getWalletBalance({ timeout: TIMEOUT })
.then(setWallet)
.catch(() => setWallet(null)),
// Chequebook balance
chequeBalanceWrapper()
.then(setChequebookBalance)
@@ -446,6 +456,7 @@ export function Provider({ children }: Props): ReactElement {
peerCheques,
settlements,
chainState,
wallet,
latestBeeRelease,
isLoading,
lastUpdate,