diff --git a/src/views/forms/AccountManagementForms/WithdrawForm.tsx b/src/views/forms/AccountManagementForms/WithdrawForm.tsx index 7716e59..0a4d4f1 100644 --- a/src/views/forms/AccountManagementForms/WithdrawForm.tsx +++ b/src/views/forms/AccountManagementForms/WithdrawForm.tsx @@ -57,15 +57,11 @@ export const WithdrawForm = () => { const { requestPayload, token, - chain, + chain: chainIdStr, address: toAddress, resources, } = useSelector(getTransferInputs) || {}; - const toChain = useMemo( - () => (chain ? resources?.chainResources?.get(chain) : undefined), - [chain, resources] - ); const toToken = useMemo( () => (token ? resources?.tokenResources?.get(token) : undefined), [token, resources] @@ -145,7 +141,7 @@ export const WithdrawForm = () => { abacusStateManager.setTransferStatus({ hash, fromChainId: TESTNET_CHAIN_ID, - toChainId: toChain?.chainId?.toString(), + toChainId: chainIdStr || undefined, }); abacusStateManager.clearTransferInputValues(); setWithdrawAmount(''); @@ -156,7 +152,7 @@ export const WithdrawForm = () => { setIsLoading(false); } }, - [setTransactionHash, requestPayload, debouncedAmountBN, toChain] + [setTransactionHash, requestPayload, debouncedAmountBN, chainIdStr] ); const onChangeAddress = useCallback((e: ChangeEvent) => { @@ -189,12 +185,12 @@ export const WithdrawForm = () => { setWithdrawAmount(freeCollateralBN.toString()); }, [freeCollateral?.current, setWithdrawAmount]); - const onSelectChain = useCallback((chain: TransferInputChainResource) => { + const onSelectChain = useCallback((chain: string) => { if (chain) { abacusStateManager.clearTransferInputValues(); abacusStateManager.setTransferValue({ field: TransferInputField.chain, - value: chain.chainId, + value: chain, }); setWithdrawAmount(''); } @@ -247,7 +243,7 @@ export const WithdrawForm = () => { if (!toAddress) return stringGetter({ key: STRING_KEYS.WITHDRAW_MUST_SPECIFY_ADDRESS }); if (debouncedAmountBN) { - if (!toChain) { + if (!chainIdStr) { return stringGetter({ key: STRING_KEYS.WITHDRAW_MUST_SPECIFY_CHAIN }); } else if (!toToken) { return stringGetter({ key: STRING_KEYS.WITHDRAW_MUST_SPECIFY_ASSET }); @@ -259,12 +255,12 @@ export const WithdrawForm = () => { } return undefined; - }, [error, freeCollateralBN, toChain, debouncedAmountBN, toToken]); + }, [error, freeCollateralBN, chainIdStr, debouncedAmountBN, toToken]); const isDisabled = !!errorMessage || !toToken || - !toChain || + !chainIdStr || !toAddress || debouncedAmountBN.isNaN() || debouncedAmountBN.isZero(); @@ -281,7 +277,7 @@ export const WithdrawForm = () => { /> @@ -320,7 +316,7 @@ export const WithdrawForm = () => { isLoading={isLoading} setSlippage={onSetSlippage} slippage={slippage} - withdrawChain={toChain || undefined} + withdrawChain={chainIdStr || undefined} withdrawToken={toToken || undefined} /> diff --git a/src/views/forms/AccountManagementForms/WithdrawForm/WithdrawButtonAndReceipt.tsx b/src/views/forms/AccountManagementForms/WithdrawForm/WithdrawButtonAndReceipt.tsx index ff254ce..4ceb962 100644 --- a/src/views/forms/AccountManagementForms/WithdrawForm/WithdrawButtonAndReceipt.tsx +++ b/src/views/forms/AccountManagementForms/WithdrawForm/WithdrawButtonAndReceipt.tsx @@ -30,12 +30,13 @@ import { SlippageEditor } from '../SlippageEditor'; import { getSubaccount } from '@/state/accountSelectors'; import { getTransferInputs } from '@/state/inputsSelectors'; +import { w } from 'vitest/dist/types-2b1c412e'; type ElementProps = { setSlippage: (slippage: number) => void; slippage: number; - withdrawChain?: TransferInputChainResource; + withdrawChain?: string; withdrawToken?: TransferInputTokenResource; isDisabled?: boolean; @@ -59,9 +60,8 @@ export const WithdrawButtonAndReceipt = ({ const { balance, queryStatus } = useAccountBalance({ addressOrDenom: withdrawToken?.address || undefined, assetSymbol: withdrawToken?.symbol || undefined, - chainId: withdrawChain?.chainId || undefined, + chainId: withdrawChain ? parseInt(withdrawChain) : undefined, decimals: withdrawToken?.decimals || undefined, - rpc: withdrawChain?.rpc || undefined, isCosmosChain: false, });