From 8a1b7e7201e9e874b60669a5bb1316442144ef99 Mon Sep 17 00:00:00 2001 From: Sebastian Scatularo Date: Mon, 14 Aug 2023 16:34:22 -0300 Subject: [PATCH] code review observations --- src/components/Transfer/Source.tsx | 3 ++- src/hooks/useMinimumAmountGuard.ts | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/Transfer/Source.tsx b/src/components/Transfer/Source.tsx index 033096af0..74eb92ac7 100644 --- a/src/components/Transfer/Source.tsx +++ b/src/components/Transfer/Source.tsx @@ -170,7 +170,8 @@ function Source() { isPandle ); /* End pandle token check */ - const isBelowMinimum = useMinimumAmountGuard(); + const { decimals = 0, isNativeAsset = false } = parsedTokenAccount || {}; + const isBelowMinimum = useMinimumAmountGuard({ amount, sourceChain, decimals, isNativeAsset }); return ( <> diff --git a/src/hooks/useMinimumAmountGuard.ts b/src/hooks/useMinimumAmountGuard.ts index 5afbe0b1d..615183bd7 100644 --- a/src/hooks/useMinimumAmountGuard.ts +++ b/src/hooks/useMinimumAmountGuard.ts @@ -25,12 +25,19 @@ function getAdjustedDecimals( : decimals; } -export default function useMinimumAmountGuard() { - const { - amount, - sourceChain, - sourceParsedTokenAccount: { decimals = 0, isNativeAsset = false } = {}, - } = useSelector((state: RootState) => state.transfer); +export type MinimumAmountGuardArgs = { + amount: string; + sourceChain: ChainId; + decimals: number; + isNativeAsset: boolean; +} + +export default function useMinimumAmountGuard({ + amount, + sourceChain, + decimals = 0, + isNativeAsset = false, +}: MinimumAmountGuardArgs) { const isBelowMinimum = useMemo( () => checkIfIsBelowMinimum(