Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchErc20Decimals should not use getTokenStandardAndDetails #24374

Open
dbrans opened this issue May 3, 2024 · 0 comments
Open

fetchErc20Decimals should not use getTokenStandardAndDetails #24374

dbrans opened this issue May 3, 2024 · 0 comments
Labels
INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. team-confirmations Push issues to confirmations team

Comments

@dbrans
Copy link
Contributor

dbrans commented May 3, 2024

Brian Bergeron wrote:
I do suspect getTokenStandardAndDetails is used in some places it shouldn't. It should only be used when we have an address and no idea what kind of token it is. Because it has to cycle through all the standards. For example this code just wants ERC20 decimals:

async function fetchErc20Decimals(address: Hex): Promise<number> {
  try {
    const { decimals } = await getTokenStandardAndDetails(address);
    return decimals ? parseInt(decimals, 10) : ERC20_DEFAULT_DECIMALS;
  } catch {
    return ERC20_DEFAULT_DECIMALS;
  }
}

Which should be 1 RPC request since we already 'know' its an ERC20, but that could do up to 4 RPC requests (checking for NFTs and returning other ERC20 details other than decimals)

@dbrans dbrans added the team-confirmations Push issues to confirmations team label May 3, 2024
@metamaskbot metamaskbot added the INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-ISSUE-TEMPLATE Issue's body doesn't match any issue template. team-confirmations Push issues to confirmations team
Projects
None yet
Development

No branches or pull requests

2 participants