From dc2dc18a9f31b6c44a48a93a70d5900f2e5e3698 Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 12:34:12 -0400 Subject: [PATCH 1/6] show all tokens --- src/storage/account.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/storage/account.ts b/src/storage/account.ts index 0038561..67a865c 100644 --- a/src/storage/account.ts +++ b/src/storage/account.ts @@ -263,14 +263,13 @@ export async function queryTokensByAddress(address: string, detail = false): Pro const accountExist = await queryAccountByAccountId( contractAddress.slice(2).toLowerCase() + '0'.repeat(24) //Search by Shardus address ) - if (accountExist && accountExist.contractType) { - filterTokens.push({ - contractAddress: contractAddress, - contractInfo: accountExist.contractInfo, - contractType: accountExist.contractType, - balance: tokenValue, - }) - } + // Include all tokens, but provide contract info when available + filterTokens.push({ + contractAddress: contractAddress, + contractInfo: accountExist?.contractInfo || null, + contractType: accountExist?.contractType || null, + balance: tokenValue, + }) } } if (config.verbose) console.log('Tokens of an address', tokens) From 94d3491f215dee20055fae48ddb432f974088d0d Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 12:36:29 -0400 Subject: [PATCH 2/6] null access fix --- src/frontend/account/TokenDropdown/TokenDropdown.tsx | 2 +- .../transaction/TransactionDetail/Overview/Ovewview.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/account/TokenDropdown/TokenDropdown.tsx b/src/frontend/account/TokenDropdown/TokenDropdown.tsx index f74c60a..0aebc0e 100644 --- a/src/frontend/account/TokenDropdown/TokenDropdown.tsx +++ b/src/frontend/account/TokenDropdown/TokenDropdown.tsx @@ -60,7 +60,7 @@ export const TokenDropdown: React.FC = (props) => { { tokens && tokens.length > 0 ? ( tokens?.map((row, index) => ( - + )) ) : (
No Tokens Found!
diff --git a/src/frontend/transaction/TransactionDetail/Overview/Ovewview.tsx b/src/frontend/transaction/TransactionDetail/Overview/Ovewview.tsx index 6662e54..c759f61 100644 --- a/src/frontend/transaction/TransactionDetail/Overview/Ovewview.tsx +++ b/src/frontend/transaction/TransactionDetail/Overview/Ovewview.tsx @@ -65,7 +65,7 @@ export const Ovewview: React.FC = ({ transaction }) => { For
{calculateTokenValue(item, item.tokenType, undefined, true)} 
- {item.tokenType === TokenType.EVM_Internal ? 'SHM' : item.contractInfo.name || item.contractAddress} + {item.tokenType === TokenType.EVM_Internal ? 'SHM' : item.contractInfo?.name || item.contractAddress} ))} From 7c996a78d48e03a484ffd9649998ad202f272128 Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 12:41:54 -0400 Subject: [PATCH 3/6] fix count of erc-20 tokens --- src/frontend/account/TokenDropdown/TokenDropdown.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/account/TokenDropdown/TokenDropdown.tsx b/src/frontend/account/TokenDropdown/TokenDropdown.tsx index 0aebc0e..3e2e39b 100644 --- a/src/frontend/account/TokenDropdown/TokenDropdown.tsx +++ b/src/frontend/account/TokenDropdown/TokenDropdown.tsx @@ -53,14 +53,19 @@ export const TokenDropdown: React.FC = (props) => {
- ERC-20 Tokens (1) + ERC-20 Tokens ({tokens.length})
setIsSortUp(!isSortUp)} />
{ tokens && tokens.length > 0 ? ( tokens?.map((row, index) => ( - + )) ) : (
No Tokens Found!
From 87f320c5669cf1e36624c24400297d622cb9baf4 Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 12:48:34 -0400 Subject: [PATCH 4/6] revert show all tokens change --- src/storage/account.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/storage/account.ts b/src/storage/account.ts index 67a865c..3a8a14c 100644 --- a/src/storage/account.ts +++ b/src/storage/account.ts @@ -263,13 +263,14 @@ export async function queryTokensByAddress(address: string, detail = false): Pro const accountExist = await queryAccountByAccountId( contractAddress.slice(2).toLowerCase() + '0'.repeat(24) //Search by Shardus address ) - // Include all tokens, but provide contract info when available - filterTokens.push({ - contractAddress: contractAddress, - contractInfo: accountExist?.contractInfo || null, - contractType: accountExist?.contractType || null, - balance: tokenValue, - }) + if (accountExist && accountExist.contractType) { + filterTokens.push({ + contractAddress: contractAddress, + contractInfo: accountExist?.contractInfo || null, + contractType: accountExist?.contractType || null, + balance: tokenValue, + }) + } } } if (config.verbose) console.log('Tokens of an address', tokens) From dc35d46cc6a1b6edb6edddb91c2fb3772fc6db67 Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 13:29:16 -0400 Subject: [PATCH 5/6] fix errors in conversion --- src/frontend/account/AccountDetail/useAccountDetailHook.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/account/AccountDetail/useAccountDetailHook.ts b/src/frontend/account/AccountDetail/useAccountDetailHook.ts index b062d3b..0370663 100644 --- a/src/frontend/account/AccountDetail/useAccountDetailHook.ts +++ b/src/frontend/account/AccountDetail/useAccountDetailHook.ts @@ -83,11 +83,11 @@ export const useAccountDetailHook = ({ id, txType }: detailProps): AccountDetail (accounts && accounts.length > 0 && accounts[0].accountId) ) { const { tokens } = await getToken() - if (tokens.length > 0) { + if (tokens && tokens.length > 0) { tokens.forEach( - (item: { contractType: ContractType; contractInfo: { decimals: string }; balance: BigNumberish }) => { + (item: { contractType: ContractType; contractInfo: { decimals: string } | null; balance: BigNumberish }) => { if (item.contractType === ContractType.ERC_20) { - const decimalsValue = item.contractInfo.decimals ? parseInt(item.contractInfo.decimals) : 18 + const decimalsValue = item.contractInfo?.decimals ? parseInt(item.contractInfo.decimals) : 18 item.balance = utils.formatUnits(item.balance, decimalsValue) } } From a009d552efb3cad005bf60be2ab621604f069b7d Mon Sep 17 00:00:00 2001 From: Sam Sweet Date: Wed, 27 Aug 2025 13:32:56 -0400 Subject: [PATCH 6/6] fix all ethers versioning issues --- .../account/AccountDetail/useAccountDetailHook.ts | 4 ++-- src/frontend/token/Token.tsx | 14 +++++--------- src/frontend/utils/calculateValue.ts | 8 ++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/frontend/account/AccountDetail/useAccountDetailHook.ts b/src/frontend/account/AccountDetail/useAccountDetailHook.ts index 0370663..861a32f 100644 --- a/src/frontend/account/AccountDetail/useAccountDetailHook.ts +++ b/src/frontend/account/AccountDetail/useAccountDetailHook.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useState } from 'react' import { api, PATHS } from '../../api' import { Account, AccountType, ContractType, Token, Transaction, TransactionSearchType } from '../../../types' -import { BigNumberish, utils } from 'ethers' +import { BigNumberish, formatUnits } from 'ethers' interface detailProps { id: string @@ -88,7 +88,7 @@ export const useAccountDetailHook = ({ id, txType }: detailProps): AccountDetail (item: { contractType: ContractType; contractInfo: { decimals: string } | null; balance: BigNumberish }) => { if (item.contractType === ContractType.ERC_20) { const decimalsValue = item.contractInfo?.decimals ? parseInt(item.contractInfo.decimals) : 18 - item.balance = utils.formatUnits(item.balance, decimalsValue) + item.balance = formatUnits(item.balance, decimalsValue) } } ) diff --git a/src/frontend/token/Token.tsx b/src/frontend/token/Token.tsx index 1b181d7..0d9f371 100644 --- a/src/frontend/token/Token.tsx +++ b/src/frontend/token/Token.tsx @@ -1,6 +1,6 @@ import React from 'react' import { useRouter } from 'next/router' -import { utils } from 'ethers' +import { formatUnits } from 'ethers' import { AnchorLink, Button, ContentLayout, CopyButton, Spacer, Tab, Table, Pagination } from '../components' import { DetailCard } from '../account/DetailCard' @@ -59,8 +59,7 @@ export const Token: React.FC = () => { {val ? transactionType === TransactionSearchType.ERC_721 ? val - : utils - .formatUnits( + : formatUnits( val as number, account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18 ) @@ -157,8 +156,7 @@ export const Token: React.FC = () => { { key: 'Max Total Supply :', value: account?.contractInfo?.totalSupply - ? utils - .formatUnits( + ? formatUnits( account?.contractInfo?.totalSupply, account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18 ) @@ -178,8 +176,7 @@ export const Token: React.FC = () => { { key: 'Max Total Supply :', value: account?.contractInfo?.totalSupply - ? utils - .formatUnits( + ? formatUnits( account?.contractInfo?.totalSupply, account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18 ) @@ -220,8 +217,7 @@ export const Token: React.FC = () => { {tokenBalance ? transactionType === TransactionSearchType.ERC_721 ? tokenBalance - : utils - .formatUnits( + : formatUnits( tokenBalance, account?.contractInfo?.decimals ? parseInt(account?.contractInfo?.decimals) : 18 ) diff --git a/src/frontend/utils/calculateValue.ts b/src/frontend/utils/calculateValue.ts index 257d090..6546c69 100644 --- a/src/frontend/utils/calculateValue.ts +++ b/src/frontend/utils/calculateValue.ts @@ -1,5 +1,5 @@ import web3 from 'web3' -import { utils } from 'ethers' +import { formatUnits } from 'ethers' import { TokenTx, TokenType, TransactionType } from '../../types' import BN from 'bn.js' import { fromWeiNoTrailingComma } from './fromWeiNoTrailingComma' @@ -28,13 +28,13 @@ export const calculateTokenValue = ( ): string => { try { if (txType === TokenType.ERC_20 || txType === TokenType.EVM_Internal) { - const decimalsValue = tokenTx.contractInfo.decimals ? parseInt(tokenTx.contractInfo.decimals) : 18 + const decimalsValue = tokenTx.contractInfo?.decimals ? parseInt(tokenTx.contractInfo.decimals) : 18 return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ? 'unlimited' : fullValue - ? utils.formatUnits(tokenTx.tokenValue, decimalsValue) - : roundTokenValue(utils.formatUnits(tokenTx.tokenValue, decimalsValue)) + ? formatUnits(tokenTx.tokenValue, decimalsValue) + : roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue)) // : round(web3.utils.fromWei(tokenTx.tokenValue, "ether")); } else if (txType === TokenType.ERC_721) {