Skip to content

Commit

Permalink
fix: refresh after chequebook withdraw deposit (#576)
Browse files Browse the repository at this point in the history
* fix: refresh after chequebook withdraw deposit

* refactor: remove extra catch
  • Loading branch information
Cafe137 committed Nov 7, 2022
1 parent 73f845a commit 6936098
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/containers/DepositModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { BigNumber } from 'bignumber.js'
import { ReactElement, useContext } from 'react'
import Download from 'remixicon-react/DownloadLineIcon'
import { Context as SettingsContext } from '../providers/Settings'

import WithdrawDepositModal from '../components/WithdrawDepositModal'
import { BigNumber } from 'bignumber.js'
import { Context as BeeContext } from '../providers/Bee'
import { Context as SettingsContext } from '../providers/Settings'

export default function DepositModal(): ReactElement {
const { beeDebugApi } = useContext(SettingsContext)
const { refresh } = useContext(BeeContext)

return (
<WithdrawDepositModal
Expand All @@ -16,10 +17,13 @@ export default function DepositModal(): ReactElement {
label="Deposit"
icon={<Download 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.depositTokens(amount.toString())
const transactionHash = await beeDebugApi.depositTokens(amount.toString())
refresh()

return transactionHash
}}
/>
)
Expand Down
9 changes: 7 additions & 2 deletions src/containers/WithdrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}}
/>
)
Expand Down

0 comments on commit 6936098

Please sign in to comment.