From 88fa4e26e4d7f3e37ae8cad1416c27bb4631b5ad Mon Sep 17 00:00:00 2001 From: jaredvu Date: Tue, 20 Feb 2024 10:10:42 -0800 Subject: [PATCH] TransferType prop --- src/hooks/useWithdrawalInfo.ts | 8 ++++++-- src/views/dialogs/WithdrawalGateDialog.tsx | 11 ++++++----- .../forms/AccountManagementForms/WithdrawForm.tsx | 2 +- src/views/forms/TransferForm.tsx | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/hooks/useWithdrawalInfo.ts b/src/hooks/useWithdrawalInfo.ts index a2395f2..db53b12 100644 --- a/src/hooks/useWithdrawalInfo.ts +++ b/src/hooks/useWithdrawalInfo.ts @@ -20,7 +20,11 @@ import { useTokenConfigs } from './useTokenConfigs'; const BLOCK_TIME = isMainnet ? 1_000 : 1_500; -export const useWithdrawalInfo = ({ isTransfer }: { isTransfer?: boolean }) => { +export const useWithdrawalInfo = ({ + transferType, +}: { + transferType: 'withdrawal' | 'transfer'; +}) => { const { getWithdrawalAndTransferGatingStatus, getWithdrawalCapacityByDenom } = useDydxClient(); const { usdcDenom, usdcDecimals } = useTokenConfigs(); const apiState = useSelector(getApiState, shallowEqual); @@ -95,7 +99,7 @@ export const useWithdrawalInfo = ({ isTransfer }: { isTransfer?: boolean }) => { openDialog({ type: DialogTypes.WithdrawalGated, dialogProps: { - isTransfer, + transferType, estimatedUnblockTime: withdrawalAndTransferGatingStatusValue.estimatedUnblockTime, }, }) diff --git a/src/views/dialogs/WithdrawalGateDialog.tsx b/src/views/dialogs/WithdrawalGateDialog.tsx index 5edf22e..3d6f01f 100644 --- a/src/views/dialogs/WithdrawalGateDialog.tsx +++ b/src/views/dialogs/WithdrawalGateDialog.tsx @@ -12,14 +12,14 @@ import { Icon, IconName } from '@/components/Icon'; type ElementProps = { setIsOpen: (open: boolean) => void; - isTransfer?: boolean; + transferType: 'withdrawal' | 'transfer'; estimatedUnblockTime?: string | null; }; export const WithdrawalGateDialog = ({ setIsOpen, - isTransfer, estimatedUnblockTime, + transferType, }: ElementProps) => { const stringGetter = useStringGetter(); const { withdrawalGateLearnMore } = useURLConfigs(); @@ -30,9 +30,10 @@ export const WithdrawalGateDialog = ({ stacked setIsOpen={setIsOpen} title={ - isTransfer - ? stringGetter({ key: STRING_KEYS.TRANSFERS_PAUSED }) - : stringGetter({ key: STRING_KEYS.WITHDRAWALS_PAUSED }) + { + withdrawal: stringGetter({ key: STRING_KEYS.WITHDRAWALS_PAUSED }), + transfer: stringGetter({ key: STRING_KEYS.TRANSFERS_PAUSED }), + }[transferType] } slotIcon={ diff --git a/src/views/forms/AccountManagementForms/WithdrawForm.tsx b/src/views/forms/AccountManagementForms/WithdrawForm.tsx index 0f267c1..0f8bbe0 100644 --- a/src/views/forms/AccountManagementForms/WithdrawForm.tsx +++ b/src/views/forms/AccountManagementForms/WithdrawForm.tsx @@ -89,7 +89,7 @@ export const WithdrawForm = () => { const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 0.1% slippage const debouncedAmount = useDebounce(withdrawAmount, 500); const { usdcLabel } = useTokenConfigs(); - const { usdcWithdawalCapacity } = useWithdrawalInfo({ isTransfer: false }); + const { usdcWithdawalCapacity } = useWithdrawalInfo({ transferType: 'withdrawal' }); const isValidAddress = toAddress && isAddress(toAddress); diff --git a/src/views/forms/TransferForm.tsx b/src/views/forms/TransferForm.tsx index e715173..5410040 100644 --- a/src/views/forms/TransferForm.tsx +++ b/src/views/forms/TransferForm.tsx @@ -65,7 +65,7 @@ export const TransferForm = ({ const { nativeTokenBalance, usdcBalance } = useAccountBalance(); const selectedDydxChainId = useSelector(getSelectedDydxChainId); const { tokensConfigs, usdcLabel, chainTokenLabel } = useTokenConfigs(); - useWithdrawalInfo({ isTransfer: true }); + useWithdrawalInfo({ transferType: 'transfer' }); const { address: recipientAddress,