TransferType prop

This commit is contained in:
jaredvu 2024-02-20 10:10:42 -08:00
parent daf862aa40
commit 88fa4e26e4
No known key found for this signature in database
GPG Key ID: B9FE2F3F0A5D523C
4 changed files with 14 additions and 9 deletions

View File

@ -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,
},
})

View File

@ -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={
<Styled.IconContainer>

View File

@ -89,7 +89,7 @@ export const WithdrawForm = () => {
const [slippage, setSlippage] = useState(isCctp ? 0 : 0.01); // 0.1% slippage
const debouncedAmount = useDebounce<string>(withdrawAmount, 500);
const { usdcLabel } = useTokenConfigs();
const { usdcWithdawalCapacity } = useWithdrawalInfo({ isTransfer: false });
const { usdcWithdawalCapacity } = useWithdrawalInfo({ transferType: 'withdrawal' });
const isValidAddress = toAddress && isAddress(toAddress);

View File

@ -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,