From 9a5f68d0e287e075cbb922ffc7e9960dca0085df Mon Sep 17 00:00:00 2001 From: An Nguyen Date: Fri, 15 Nov 2024 12:33:50 -0600 Subject: [PATCH] make sure we only format number --- packages/core-mobile/app/AppHook.ts | 2 +- .../app/components/UniversalTokenSelector.tsx | 4 ++-- .../app/screens/earn/Confirmation/Confirmation.tsx | 4 ++-- packages/core-mobile/app/screens/earn/StakeDetails.tsx | 6 +++--- .../app/screens/earn/components/StakeCard.tsx | 10 ++++++---- .../app/screens/watchlist/components/WatchList.tsx | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/core-mobile/app/AppHook.ts b/packages/core-mobile/app/AppHook.ts index 3bf60c693b..b87c36e603 100644 --- a/packages/core-mobile/app/AppHook.ts +++ b/packages/core-mobile/app/AppHook.ts @@ -19,7 +19,7 @@ export type AppHook = { deleteWallet: () => void signOut: () => void currencyFormatter(num: number | string, notation?: NotationTypes): string - tokenInCurrencyFormatter(num: number | string): string + tokenInCurrencyFormatter(num: number): string } export function useApp(): AppHook { diff --git a/packages/core-mobile/app/components/UniversalTokenSelector.tsx b/packages/core-mobile/app/components/UniversalTokenSelector.tsx index 6aad9b7ff2..c9eebe3f00 100644 --- a/packages/core-mobile/app/components/UniversalTokenSelector.tsx +++ b/packages/core-mobile/app/components/UniversalTokenSelector.tsx @@ -80,7 +80,7 @@ const UniversalTokenSelector: FC = ({ const amountInCurrency = useMemo(() => { if (!inputAmount || !selectedTokenDecimals) { - return '' + return undefined } const inputInTokenUnit = new TokenUnit( inputAmount, @@ -90,7 +90,7 @@ const UniversalTokenSelector: FC = ({ return selectedToken?.priceInCurrency ? inputInTokenUnit .mul(selectedToken.priceInCurrency) - .toDisplay({ fixedDp: 2 }) + .toDisplay({ fixedDp: 2, asNumber: true }) : undefined }, [inputAmount, selectedToken, selectedTokenDecimals]) diff --git a/packages/core-mobile/app/screens/earn/Confirmation/Confirmation.tsx b/packages/core-mobile/app/screens/earn/Confirmation/Confirmation.tsx index 3eb9eafafb..d5f11b97eb 100644 --- a/packages/core-mobile/app/screens/earn/Confirmation/Confirmation.tsx +++ b/packages/core-mobile/app/screens/earn/Confirmation/Confirmation.tsx @@ -236,7 +236,7 @@ export const Confirmation = (): JSX.Element | null => { const stakingAmountInAvax = deductedStakingAmount.toDisplay() const stakingAmountInCurrency = deductedStakingAmount .mul(avaxPrice) - .toDisplay({ fixedDp: 2 }) + .toDisplay({ fixedDp: 2, asNumber: true }) return ( @@ -263,7 +263,7 @@ export const Confirmation = (): JSX.Element | null => { const estimatedRewardInAvax = data.estimatedTokenReward.toDisplay() const estimatedRewardInCurrency = data.estimatedTokenReward .mul(avaxPrice) - .toDisplay({ fixedDp: 2 }) + .toDisplay({ fixedDp: 2, asNumber: true }) return ( { const estimatedRewardInCurrency = estimatedRewardInAvax?.mul(avaxPrice) const estimatedRewardInCurrencyDisplay = estimatedRewardInCurrency ? tokenInCurrencyFormatter( - estimatedRewardInCurrency.toDisplay({ fixedDp: 2 }) + estimatedRewardInCurrency.toDisplay({ fixedDp: 2, asNumber: true }) ) : UNKNOWN_AMOUNT @@ -166,7 +166,7 @@ const StakeDetails = (): JSX.Element | null => { const rewardAmountInCurrencyDisplay = rewardAmountInCurrency ? tokenInCurrencyFormatter( - rewardAmountInCurrency.toDisplay({ fixedDp: 2 }) + rewardAmountInCurrency.toDisplay({ fixedDp: 2, asNumber: true }) ) : UNKNOWN_AMOUNT @@ -229,7 +229,7 @@ const StakeDetails = (): JSX.Element | null => { const stakeAmountInCurrencyDisplay = stakeAmountInCurrency ? tokenInCurrencyFormatter( - stakeAmountInCurrency.toDisplay({ fixedDp: 2 }) + stakeAmountInCurrency.toDisplay({ fixedDp: 2, asNumber: true }) ) : UNKNOWN_AMOUNT diff --git a/packages/core-mobile/app/screens/earn/components/StakeCard.tsx b/packages/core-mobile/app/screens/earn/components/StakeCard.tsx index 7d2b137b9f..7a63adc098 100644 --- a/packages/core-mobile/app/screens/earn/components/StakeCard.tsx +++ b/packages/core-mobile/app/screens/earn/components/StakeCard.tsx @@ -107,10 +107,9 @@ export const StakeCard = (props: Props): JSX.Element => { stakeAmountInAvax?.toDisplay() ?? UNKNOWN_AMOUNT const stakeAmountInCurrency = stakeAmountInAvax?.mul(avaxPrice) - const stakeAmountInCurrencyDisplay = stakeAmountInCurrency ? tokenInCurrencyFormatter( - stakeAmountInCurrency.toDisplay({ fixedDp: 2 }) + stakeAmountInCurrency.toDisplay({ fixedDp: 2, asNumber: true }) ) : UNKNOWN_AMOUNT @@ -131,7 +130,10 @@ export const StakeCard = (props: Props): JSX.Element => { const estimatedRewardInCurrencyDisplay = estimatedRewardInCurrency ? tokenInCurrencyFormatter( - estimatedRewardInCurrency.toDisplay({ fixedDp: 2 }) + estimatedRewardInCurrency.toDisplay({ + fixedDp: 2, + asNumber: true + }) ) : UNKNOWN_AMOUNT @@ -197,7 +199,7 @@ export const StakeCard = (props: Props): JSX.Element => { const rewardAmountInCurrencyDisplay = rewardAmountInCurrency ? tokenInCurrencyFormatter( - rewardAmountInCurrency.toDisplay({ fixedDp: 2 }) + rewardAmountInCurrency.toDisplay({ fixedDp: 2, asNumber: true }) ) : UNKNOWN_AMOUNT diff --git a/packages/core-mobile/app/screens/watchlist/components/WatchList.tsx b/packages/core-mobile/app/screens/watchlist/components/WatchList.tsx index 04318b24db..1b7432e458 100644 --- a/packages/core-mobile/app/screens/watchlist/components/WatchList.tsx +++ b/packages/core-mobile/app/screens/watchlist/components/WatchList.tsx @@ -26,7 +26,7 @@ import { WatchlistFilter } from '../types' const getDisplayValue = ( price: PriceData, - currencyFormatter: (num: number | string) => string + currencyFormatter: (num: number) => string ): string => { const priceInCurrency = price.priceInCurrency return currencyFormatter(priceInCurrency)