fix: refresh after chequebook withdraw deposit (#576)

* fix: refresh after chequebook withdraw deposit

* refactor: remove extra catch
This commit is contained in:
Cafe137
2022-11-07 14:02:11 +01:00
committed by GitHub
parent 73f845a73a
commit 693609810d
2 changed files with 16 additions and 7 deletions
+7 -2
View File
@@ -2,10 +2,12 @@ import { BigNumber } from 'bignumber.js'
import { ReactElement, useContext } from 'react'
import Upload from 'remixicon-react/UploadLineIcon'
import WithdrawDepositModal from '../components/WithdrawDepositModal'
import { Context as BeeContext } from '../providers/Bee'
import { Context as SettingsContext } from '../providers/Settings'
export default function WithdrawModal(): ReactElement {
const { beeDebugApi } = useContext(SettingsContext)
const { refresh } = useContext(BeeContext)
return (
<WithdrawDepositModal
@@ -15,10 +17,13 @@ export default function WithdrawModal(): ReactElement {
label="Withdraw"
icon={<Upload size="1rem" />}
min={new BigNumber(0)}
action={(amount: bigint) => {
action={async (amount: bigint) => {
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid')
return beeDebugApi.withdrawTokens(amount.toString())
const transactionHash = await beeDebugApi.withdrawTokens(amount.toString())
refresh()
return transactionHash
}}
/>
)