fix: withdraw/deposit converts from BZZ (10^16 base units) (#66)

* refactor: added toBZZbaseUnit function

* feat: added utility for attesting value is BZZ convertible to base units

* fix: conversion from 15 to 16 decimal places, added unsafe versions

* refactor: withdraw modal uses the safe conversion from BZZ

* refactor: added BigNumber and Token class to handle BZZ digits correctly

* refactor: extract deposit and withdraw functionality into single modal

* test: added tests for Token

* chore: removed unused component

* chore: addressed PR review, token decimal is now integer 0-18

* chore: added comment to clarify the value restriction on token amount
This commit is contained in:
Vojtech Simetka
2021-04-13 12:26:29 +02:00
committed by GitHub
parent 343e388498
commit 825772cf73
19 changed files with 411 additions and 238 deletions
+18
View File
@@ -0,0 +1,18 @@
import type { ReactElement } from 'react'
import { beeDebugApi } from '../services/bee'
import WDModal from '../components/WDModal'
import { BigNumber } from 'bignumber.js'
export default function DepositModal(): ReactElement {
return (
<WDModal
successMessage="Successful deposit."
errorMessage="Error with depositing"
dialogMessage="Specify the amount of BZZ you would like to withdraw from your node."
label="Deposit"
min={new BigNumber(0)}
action={beeDebugApi.chequebook.deposit}
/>
)
}
+18
View File
@@ -0,0 +1,18 @@
import type { ReactElement } from 'react'
import { beeDebugApi } from '../services/bee'
import WDModal from '../components/WDModal'
import { BigNumber } from 'bignumber.js'
export default function WithdrawModal(): ReactElement {
return (
<WDModal
successMessage="Successful withdrawl."
errorMessage="Error with withdrawing."
dialogMessage="Specify the amount of BZZ you would like to withdraw from your node."
label="Withdraw"
min={new BigNumber(0)}
action={beeDebugApi.chequebook.withdraw}
/>
)
}