1249c0df71
* 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
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { BZZ } from '@ethersphere/bee-js'
|
|
import { ReactElement, useContext } from 'react'
|
|
import Download from 'remixicon-react/DownloadLineIcon'
|
|
import WithdrawDepositModal from '../components/WithdrawDepositModal'
|
|
import { Context as BeeContext } from '../providers/Bee'
|
|
import { Context as SettingsContext } from '../providers/Settings'
|
|
|
|
interface Props {
|
|
onStarted: () => void
|
|
onFinished: () => void
|
|
}
|
|
|
|
export default function StakeModal({ onStarted, onFinished }: Props): ReactElement {
|
|
const { beeApi } = useContext(SettingsContext)
|
|
const { refresh } = useContext(BeeContext)
|
|
|
|
return (
|
|
<WithdrawDepositModal
|
|
successMessage="Successfully deposited stake."
|
|
errorMessage="Error with depositing"
|
|
dialogMessage="Specify the amount of xBZZ you would like to stake. Your first stake must be at least 10 xBZZ. This will lock your tokens."
|
|
label="Stake"
|
|
icon={<Download size="1rem" />}
|
|
min={BZZ.fromPLUR('1')}
|
|
action={async (amount: BZZ) => {
|
|
if (!beeApi) {
|
|
throw new Error('Bee URL is not valid')
|
|
}
|
|
|
|
onStarted()
|
|
|
|
try {
|
|
const transactionHash = await beeApi.depositStake(amount)
|
|
|
|
return transactionHash
|
|
} finally {
|
|
refresh()
|
|
onFinished()
|
|
}
|
|
}}
|
|
/>
|
|
)
|
|
}
|