Skip to content

Commit

Permalink
code review observations
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Aug 14, 2023
1 parent bcc16d0 commit 8a1b7e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/components/Transfer/Source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<StepDescription>
Expand Down
19 changes: 13 additions & 6 deletions src/hooks/useMinimumAmountGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 8a1b7e7

Please sign in to comment.