feat: bee-js revamp (#690)
* chore: initial commit * refactor: remove unnecessary wrappers * style: add missing newline * chore: bump bee-js * chore: ignore any cast in fdp * fix: remove cid import * fix: make TextEncoder and TextDecoder available in jest * refactor: dedupe stamp ttl second conversion * refactor: use convenience methods from bee-js * feat: update to bee-js for restored ens support * fix: bump bee-js to get download fix * fix: resolve feed before downloading reference * fix: fix token displays * fix: fix token input modal error message * refactor: remove wallet balance provider * chore: remove dead code * refactor: upcoming bee js 0.15.0 (#692) * chore: initial commit * fix: do not break page when duration seconds is 0 * ci: remove cache * chore: upgrade bee-js * feat: bee-js and bee v2.6 compatibility * chore: switch upcoming/bee-js to ethersphere/bee-js
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Box, Tooltip, Typography } from '@material-ui/core'
|
||||
import { BZZ, DAI } from '@ethersphere/bee-js'
|
||||
import { Wallet } from 'ethers'
|
||||
import { useSnackbar } from 'notistack'
|
||||
import { ReactElement, useContext, useEffect, useState } from 'react'
|
||||
@@ -11,20 +12,19 @@ import ExpandableListItemKey from '../../components/ExpandableListItemKey'
|
||||
import { HistoryHeader } from '../../components/HistoryHeader'
|
||||
import { Loading } from '../../components/Loading'
|
||||
import { SwarmButton } from '../../components/SwarmButton'
|
||||
import { Token } from '../../models/Token'
|
||||
import { Context as BeeContext } from '../../providers/Bee'
|
||||
import { Context as SettingsContext } from '../../providers/Settings'
|
||||
import { Context as TopUpContext } from '../../providers/TopUp'
|
||||
import { Context as BalanceProvider } from '../../providers/WalletBalance'
|
||||
import { createGiftWallet } from '../../utils/desktop'
|
||||
import { ResolvedWallet } from '../../utils/wallet'
|
||||
|
||||
const GIFT_WALLET_FUND_DAI_AMOUNT = Token.fromDecimal('0.1', 18)
|
||||
const GIFT_WALLET_FUND_BZZ_AMOUNT = Token.fromDecimal('0.5', 16)
|
||||
const GIFT_WALLET_FUND_DAI_AMOUNT = DAI.fromDecimalString('0.1')
|
||||
const GIFT_WALLET_FUND_BZZ_AMOUNT = BZZ.fromDecimalString('0.5')
|
||||
|
||||
export default function Index(): ReactElement {
|
||||
const { giftWallets, addGiftWallet } = useContext(TopUpContext)
|
||||
const { rpcProvider, desktopUrl } = useContext(SettingsContext)
|
||||
const { balance } = useContext(BalanceProvider)
|
||||
const { walletBalance } = useContext(BeeContext)
|
||||
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [balances, setBalances] = useState<ResolvedWallet[]>([])
|
||||
@@ -67,13 +67,13 @@ export default function Index(): ReactElement {
|
||||
navigate(-1)
|
||||
}
|
||||
|
||||
if (!balance) {
|
||||
if (!walletBalance) {
|
||||
return <Loading />
|
||||
}
|
||||
|
||||
const notEnoughFundsCheck =
|
||||
balance.dai.toBigNumber.isLessThanOrEqualTo(GIFT_WALLET_FUND_DAI_AMOUNT.toBigNumber) ||
|
||||
balance.bzz.toBigNumber.isLessThan(GIFT_WALLET_FUND_BZZ_AMOUNT.toBigNumber)
|
||||
walletBalance.nativeTokenBalance.lte(GIFT_WALLET_FUND_DAI_AMOUNT) ||
|
||||
walletBalance.bzzBalance.lt(GIFT_WALLET_FUND_BZZ_AMOUNT)
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -86,10 +86,13 @@ export default function Index(): ReactElement {
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box mb={0.25}>
|
||||
<ExpandableListItem label="xDAI balance" value={`${balance.dai.toSignificantDigits(4)} xDAI`} />
|
||||
<ExpandableListItem
|
||||
label="xDAI balance"
|
||||
value={`${walletBalance.nativeTokenBalance.toSignificantDigits(4)} xDAI`}
|
||||
/>
|
||||
</Box>
|
||||
<Box mb={2}>
|
||||
<ExpandableListItem label="xBZZ balance" value={`${balance.bzz.toSignificantDigits(4)} xBZZ`} />
|
||||
<ExpandableListItem label="xBZZ balance" value={`${walletBalance.bzzBalance.toSignificantDigits(4)} xBZZ`} />
|
||||
</Box>
|
||||
<Box mb={4}>
|
||||
{balances.map((x, i) => (
|
||||
|
||||
Reference in New Issue
Block a user