From 1e896cd2a6ad54a0ea14bc08c909b113a2b98596 Mon Sep 17 00:00:00 2001 From: woody <125113430+woodenfurniture@users.noreply.github.com> Date: Sat, 25 Jan 2025 00:30:58 +1100 Subject: [PATCH 1/2] fix: sell amount briefly appearing as NaNaNaN due to division by zero (#8659) --- .../components/TradeInput/components/SellAssetInput.tsx | 9 ++++++++- .../common/tradeInputBase/createTradeInputBaseSlice.ts | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/MultiHopTrade/components/TradeInput/components/SellAssetInput.tsx b/src/components/MultiHopTrade/components/TradeInput/components/SellAssetInput.tsx index ccaba296aa8..bb5ee845ec0 100644 --- a/src/components/MultiHopTrade/components/TradeInput/components/SellAssetInput.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/components/SellAssetInput.tsx @@ -69,12 +69,19 @@ export const SellAssetInput = memo( const handleSellAssetInputChange = useCallback( (value: string, isFiat: boolean | undefined) => { + const isRateZero = bnOrZero(sellAssetUserCurrencyRate).isZero() + + // Avoid division by zero const sellAmountCryptoPrecision = isFiat - ? bnOrZero(value).div(sellAssetUserCurrencyRate).toFixed() + ? isRateZero + ? '0' + : bnOrZero(value).div(sellAssetUserCurrencyRate).toFixed() : value + const sellAmountUserCurrency = !isFiat ? bnOrZero(value).times(sellAssetUserCurrencyRate).toFixed() : value + setRawSellAmountCryptoPrecision(sellAmountCryptoPrecision) setRawSellAmountUserCurrency(sellAmountUserCurrency) }, diff --git a/src/state/slices/common/tradeInputBase/createTradeInputBaseSlice.ts b/src/state/slices/common/tradeInputBase/createTradeInputBaseSlice.ts index 09dea71847c..6e0adea182d 100644 --- a/src/state/slices/common/tradeInputBase/createTradeInputBaseSlice.ts +++ b/src/state/slices/common/tradeInputBase/createTradeInputBaseSlice.ts @@ -71,7 +71,10 @@ const getBaseReducers = (initialState: T) => ({ const { sellAssetUsdRate, buyAssetUsdRate } = action.payload const sellAmountUsd = bnOrZero(state.sellAmountCryptoPrecision).times(sellAssetUsdRate ?? '0') - state.sellAmountCryptoPrecision = sellAmountUsd.div(buyAssetUsdRate ?? '0').toFixed() + // Avoid division by zero + state.sellAmountCryptoPrecision = bnOrZero(buyAssetUsdRate).isZero() + ? '0' + : sellAmountUsd.div(buyAssetUsdRate!).toFixed() const buyAsset = state.sellAsset state.sellAsset = state.buyAsset From b3ef25a6c95b6bd86f817a55733fb23771822ad5 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Fri, 24 Jan 2025 16:39:31 +0100 Subject: [PATCH 2/2] feat: new wallet flow go live (#8655) --- .env.base | 2 +- .env.dev | 1 - .env.develop | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.env.base b/.env.base index 5dd0fc994f7..a80cceaf52c 100644 --- a/.env.base +++ b/.env.base @@ -51,7 +51,7 @@ REACT_APP_FEATURE_PHANTOM_WALLET=true REACT_APP_FEATURE_THOR_FREE_FEES=true REACT_APP_FEATURE_LIMIT_ORDERS=true REACT_APP_FEATURE_NEW_TRADE_FLOW=true -REACT_APP_FEATURE_NEW_WALLET_FLOW=false +REACT_APP_FEATURE_NEW_WALLET_FLOW=true REACT_APP_FEATURE_FOX_PAGE_FOX_WIF_HAT_SECTION=false # absolute URL prefix diff --git a/.env.dev b/.env.dev index 7e53bf7fb12..e9df090dc2a 100644 --- a/.env.dev +++ b/.env.dev @@ -8,7 +8,6 @@ REACT_APP_FEATURE_FOX_PAGE_FOX_WIF_HAT_SECTION=true # feature flags REACT_APP_FEATURE_RFOX_LP=true -REACT_APP_FEATURE_NEW_WALLET_FLOW=true # logging REACT_APP_REDUX_WINDOW=false diff --git a/.env.develop b/.env.develop index 79a49445cc2..e8b601c3196 100644 --- a/.env.develop +++ b/.env.develop @@ -8,7 +8,6 @@ REACT_APP_FEATURE_FOX_PAGE_FOX_WIF_HAT_SECTION=true # feature flags REACT_APP_FEATURE_RFOX_LP=true -REACT_APP_FEATURE_NEW_WALLET_FLOW=true # mixpanel REACT_APP_MIXPANEL_TOKEN=1c1369f6ea23a6404bac41b42817cc4b