Skip to content

Commit

Permalink
Merge pull request #936 from telosnetwork/935-token-section-for-a-par…
Browse files Browse the repository at this point in the history
…ticular-address-is-loading-for-ever

#935 | Fixing broken token balances section for address page
  • Loading branch information
pmjanus authored Jan 20, 2025
2 parents 86ef8c8 + 5482c96 commit 338c136
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
31 changes: 20 additions & 11 deletions src/components/Token/TokenList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,26 @@ export default {
tokensOfficial.push(token);
return token;
} else if(result.contract !== '___NATIVE_CURRENCY___'){
let contract = await contractManager.getContract(result.contract);
result.address = contract.address;
result.name = contract.name;
result.symbol = contract.properties?.symbol;
result.decimals = contract.properties?.decimals;
result.price = contract.properties?.price || 0;
result.contract = contract;
result.logoURI = DEFAULT_TOKEN_LOGO;
result.fullBalance = `${formatWei(result.balance, result.contract.properties?.decimals)}`;
result.balance = `${formatWei(result.balance, result.contract.properties?.decimals, 4)}`;
tokens.push(result);
try {
let contract = await contractManager.getContract(result.contract);
result.address = contract.address;
result.name = contract.name;
result.symbol = contract.properties?.symbol;
result.decimals = contract.properties?.decimals;
result.price = contract.properties?.price || 0;
result.contract = contract;
result.logoURI = DEFAULT_TOKEN_LOGO;
result.fullBalance = `${formatWei(result.balance, result.contract.properties?.decimals)}`;
result.balance = `${formatWei(result.balance, result.contract.properties?.decimals, 4)}`;
tokens.push(result);
} catch (e) {
console.error('Error loading token', {
error: e,
contract: result.contract,
token: result,
});
return result;
}
return result;
}
}));
Expand Down
6 changes: 5 additions & 1 deletion src/lib/contract/ContractManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ export default class ContractManager {
addContractsToCache(contracts){
for(const index in contracts){
// skipping non-real contracts
if (contracts[index].creator) {
if (
contracts[index].creator ||
contracts[index].name ||
contracts[index].calldata
) {
this.addContractToCache(index, contracts[index]);
}
}
Expand Down

0 comments on commit 338c136

Please sign in to comment.