diff --git a/.changelog/1372.bugfix.md b/.changelog/1372.bugfix.md new file mode 100644 index 000000000..2b4ca90e8 --- /dev/null +++ b/.changelog/1372.bugfix.md @@ -0,0 +1 @@ +Fix isAccountEmpty to handle accounts with balances = 0 diff --git a/src/oasis-nexus/api.ts b/src/oasis-nexus/api.ts index c5e616564..a6e7ed5f1 100644 --- a/src/oasis-nexus/api.ts +++ b/src/oasis-nexus/api.ts @@ -113,9 +113,9 @@ declare module './generated/api' { export const isAccountEmpty = (account: RuntimeAccount) => { const { balances, evm_balances, stats } = account const { total_received, total_sent, num_txns } = stats - const result = - !balances?.length && !evm_balances?.length && total_received === '0' && total_sent === '0' && !num_txns - return result + const hasNoBalances = [...balances, ...evm_balances].every(b => b.balance === '0' || b.balance === '0.0') + const hasNoTransactions = total_received === '0' && total_sent === '0' && num_txns === 0 + return hasNoBalances && hasNoTransactions } export const isAccountNonEmpty = (account: RuntimeAccount) => !isAccountEmpty(account)