Skip to content

Commit

Permalink
make sure we only format number
Browse files Browse the repository at this point in the history
  • Loading branch information
atn4z7 committed Nov 15, 2024
1 parent df47d88 commit 9a5f68d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/core-mobile/app/AppHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const UniversalTokenSelector: FC<Props> = ({

const amountInCurrency = useMemo(() => {
if (!inputAmount || !selectedTokenDecimals) {
return ''
return undefined
}
const inputInTokenUnit = new TokenUnit(
inputAmount,
Expand All @@ -90,7 +90,7 @@ const UniversalTokenSelector: FC<Props> = ({
return selectedToken?.priceInCurrency
? inputInTokenUnit
.mul(selectedToken.priceInCurrency)
.toDisplay({ fixedDp: 2 })
.toDisplay({ fixedDp: 2, asNumber: true })
: undefined
}, [inputAmount, selectedToken, selectedTokenDecimals])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Row style={{ justifyContent: 'space-between' }}>
Expand All @@ -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 (
<View
Expand Down
6 changes: 3 additions & 3 deletions packages/core-mobile/app/screens/earn/StakeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const StakeDetails = (): JSX.Element | null => {
const estimatedRewardInCurrency = estimatedRewardInAvax?.mul(avaxPrice)
const estimatedRewardInCurrencyDisplay = estimatedRewardInCurrency
? tokenInCurrencyFormatter(
estimatedRewardInCurrency.toDisplay({ fixedDp: 2 })
estimatedRewardInCurrency.toDisplay({ fixedDp: 2, asNumber: true })
)
: UNKNOWN_AMOUNT

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions packages/core-mobile/app/screens/earn/components/StakeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9a5f68d

Please sign in to comment.