feat: merge api (#658)
This commit is contained in:
@@ -6,7 +6,7 @@ import { Context as BeeContext } from '../providers/Bee'
|
||||
import { Context as SettingsContext } from '../providers/Settings'
|
||||
|
||||
export default function DepositModal(): ReactElement {
|
||||
const { beeDebugApi } = useContext(SettingsContext)
|
||||
const { beeApi } = useContext(SettingsContext)
|
||||
const { refresh } = useContext(BeeContext)
|
||||
|
||||
return (
|
||||
@@ -18,9 +18,11 @@ export default function DepositModal(): ReactElement {
|
||||
icon={<Download size="1rem" />}
|
||||
min={new BigNumber(0)}
|
||||
action={async (amount: bigint) => {
|
||||
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid')
|
||||
if (!beeApi) {
|
||||
throw new Error('Bee URL is not valid')
|
||||
}
|
||||
|
||||
const transactionHash = await beeDebugApi.depositTokens(amount.toString())
|
||||
const transactionHash = await beeApi.depositTokens(amount.toString())
|
||||
refresh()
|
||||
|
||||
return transactionHash
|
||||
|
||||
@@ -11,7 +11,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function StakeModal({ onStarted, onFinished }: Props): ReactElement {
|
||||
const { beeDebugApi } = useContext(SettingsContext)
|
||||
const { beeApi } = useContext(SettingsContext)
|
||||
const { refresh } = useContext(BeeContext)
|
||||
|
||||
return (
|
||||
@@ -23,12 +23,14 @@ export default function StakeModal({ onStarted, onFinished }: Props): ReactEleme
|
||||
icon={<Download size="1rem" />}
|
||||
min={new BigNumber(0)}
|
||||
action={async (amount: bigint) => {
|
||||
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid')
|
||||
if (!beeApi) {
|
||||
throw new Error('Bee URL is not valid')
|
||||
}
|
||||
|
||||
onStarted()
|
||||
|
||||
try {
|
||||
await beeDebugApi.depositStake(amount.toString())
|
||||
await beeApi.depositStake(amount.toString())
|
||||
} finally {
|
||||
refresh()
|
||||
onFinished()
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Context as BeeContext } from '../providers/Bee'
|
||||
import { Context as SettingsContext } from '../providers/Settings'
|
||||
|
||||
export default function WithdrawModal(): ReactElement {
|
||||
const { beeDebugApi } = useContext(SettingsContext)
|
||||
const { beeApi } = useContext(SettingsContext)
|
||||
const { refresh } = useContext(BeeContext)
|
||||
|
||||
return (
|
||||
@@ -18,9 +18,11 @@ export default function WithdrawModal(): ReactElement {
|
||||
icon={<Upload size="1rem" />}
|
||||
min={new BigNumber(0)}
|
||||
action={async (amount: bigint) => {
|
||||
if (!beeDebugApi) throw new Error('Bee Debug URL is not valid')
|
||||
if (!beeApi) {
|
||||
throw new Error('Bee URL is not valid')
|
||||
}
|
||||
|
||||
const transactionHash = await beeDebugApi.withdrawTokens(amount.toString())
|
||||
const transactionHash = await beeApi.withdrawTokens(amount.toString())
|
||||
refresh()
|
||||
|
||||
return transactionHash
|
||||
|
||||
Reference in New Issue
Block a user