diff --git a/nym-wallet/src/pages/unbond/UnbondGateway.tsx b/nym-wallet/src/pages/unbond/UnbondGateway.tsx index 36b61db377..e80080f1bc 100644 --- a/nym-wallet/src/pages/unbond/UnbondGateway.tsx +++ b/nym-wallet/src/pages/unbond/UnbondGateway.tsx @@ -1,19 +1,18 @@ import React from 'react'; import { Box, Button } from '@mui/material'; +import { FeeDetails } from '@nymproject/types'; import { useGetFee } from 'src/hooks/useGetFee'; -import { simulateUnbondGateway, simulateVestingUnbondGateway, unbondGateway, vestingUnbondGateway } from 'src/requests'; -import { EnumNodeType } from 'src/types'; -import { Console } from 'src/utils/console'; -import { ConfirmationModal } from './ConfirmationModal'; +import { simulateUnbondGateway, simulateVestingUnbondGateway } from 'src/requests'; +import { ConfirmTx } from 'src/components/ConfirmTX'; export const UnbondGateway = ({ isWithVestingTokens, + onConfirm, onError, - onSuccess, }: { isWithVestingTokens: boolean; - onError: () => void; - onSuccess: () => void; + onConfirm: (isWithVestingTokens: boolean, fee: FeeDetails) => Promise; + onError: (err?: string) => void; }) => { const { fee, getFee, resetFeeState } = useGetFee(); @@ -22,26 +21,24 @@ export const UnbondGateway = ({ if (isWithVestingTokens) await getFee(simulateVestingUnbondGateway, {}); if (!isWithVestingTokens) await getFee(simulateUnbondGateway, {}); } catch (e) { - Console.error(e); - onError(); - } - }; - - const handleConfirm = async () => { - try { - if (isWithVestingTokens) await vestingUnbondGateway(fee?.fee); - if (!isWithVestingTokens) await unbondGateway(fee?.fee); - onSuccess(); - } catch (e) { - Console.error(e); - onError(); + onError(e as string); } }; return ( {fee && ( - + { + onConfirm(isWithVestingTokens, fee); + resetFeeState(); + }} + /> )}