From 1b12c1aa7c9834821963a325278635effe1c74b9 Mon Sep 17 00:00:00 2001 From: noah Date: Thu, 30 Nov 2023 12:15:57 -0800 Subject: [PATCH] Fix tokenfactory metadata not finding the right decimals. (#1497) --- packages/state/recoil/selectors/token.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/state/recoil/selectors/token.ts b/packages/state/recoil/selectors/token.ts index 67010e046c..ba96a85843 100644 --- a/packages/state/recoil/selectors/token.ts +++ b/packages/state/recoil/selectors/token.ts @@ -402,7 +402,13 @@ export const nativeDenomMetadataInfoSelector = selectorFamily< const { base, denomUnits, symbol, display } = metadata + // If display is equal to the base, use the symbol denom unit if + // available. This fixes the case where display was not updated even + // though a nonzero exponent was created. + const searchDenom = display === base ? symbol : display + const displayDenom = + denomUnits.find(({ denom }) => denom === searchDenom) ?? denomUnits.find(({ denom }) => denom === display) ?? denomUnits.find(({ exponent }) => exponent > 0) ?? denomUnits[0] @@ -412,7 +418,7 @@ export const nativeDenomMetadataInfoSelector = selectorFamily< } return { - symbol: symbol || display || base, + symbol: displayDenom.denom, decimals: displayDenom.exponent, } },