Skip to content

Commit

Permalink
Merge pull request #517 from provenance-io/bug/ibc-page-implosion
Browse files Browse the repository at this point in the history
Gracefully handle denoms that aren't in the denom metadata
  • Loading branch information
webbushka committed Nov 1, 2023
2 parents 3df7984 + 2a2cdb2 commit 1cbcc4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const AccountAssets = () => {
const tableData = accountAssets.map((a) => ({
...a,
displayDenom: assetMetadata.find((md) => md.base === a.denom)?.display,
exponent: assetMetadata.find((md) => md.base === a.denom)?.denomUnits[1].exponent,
exponent: assetMetadata.find((md) => md.base === a.denom)?.denomUnits?.[1].exponent,
}));

// Table header values in order
Expand Down
8 changes: 5 additions & 3 deletions src/utils/number/currencyFormat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export const currencyFormat = (value = 0, initialDenom: string, toBase = false)
);

// If the value isn't a number,
// the initial and final denoms don't match a known conversion or
// the initial and final denoms are the same string,
// the initial and final denoms don't match a known conversion,
// the initial and final denoms are the same string or
// the denom units don't exist
// just return the value
if (isNaN(value) || !denomInfo) return { amount: value, denom: initialDenom };
if (isNaN(value) || !denomInfo || !denomInfo?.denomUnits)
return { amount: value, denom: initialDenom };

// pull the needed denom info
const { base, display, denomUnits } = denomInfo;
Expand Down

0 comments on commit 1cbcc4b

Please sign in to comment.