feat: wait for postage stamp to be usable when bying it (#352)

* feat: wait for postage stamp to be usable when bying it

* refactor: simplified the waitUntilStampUsable function
This commit is contained in:
Vojtech Simetka
2022-04-29 16:42:29 +05:00
committed by GitHub
parent b6b9914548
commit 1e2face10e
2 changed files with 36 additions and 2 deletions
+9 -2
View File
@@ -9,7 +9,13 @@ import { SwarmTextInput } from '../../components/SwarmTextInput'
import { Context as BeeContext } from '../../providers/Bee'
import { Context as SettingsContext } from '../../providers/Settings'
import { Context as StampsContext } from '../../providers/Stamps'
import { calculateStampPrice, convertAmountToSeconds, convertDepthToBytes, secondsToTimeString } from '../../utils'
import {
calculateStampPrice,
convertAmountToSeconds,
convertDepthToBytes,
secondsToTimeString,
waitUntilStampUsable,
} from '../../utils'
import { getHumanReadableFileSize } from '../../utils/file'
interface FormValues {
@@ -82,7 +88,8 @@ export function PostageStampCreation({ onFinished }: Props): ReactElement {
const amount = BigInt(values.amount)
const depth = Number.parseInt(values.depth)
const options = values.label ? { label: values.label } : undefined
await beeDebugApi.createPostageBatch(amount.toString(), depth, options)
const batch = await beeDebugApi.createPostageBatch(amount.toString(), depth, options)
await waitUntilStampUsable(batch, beeDebugApi)
actions.resetForm()
await refresh()
onFinished()