Skip to content

Commit

Permalink
Support token detection on Base and zkSync (#3584)
Browse files Browse the repository at this point in the history
## Explanation

Adds support for token detection on Base and zkSync. After these chains,
we'll support token detection on MetaMask's top 10 most popular
networks.

Token lists are available for both chains:
- https://token-api.metaswap.codefi.network/tokens/8453
- https://token-api.metaswap.codefi.network/tokens/324

I deployed and verified the [ERC20 balance
checker](https://github.com/wbobeirne/eth-balance-checker) on both
chains, since I didn't find existing ones documented:
-
https://basescan.org/address/0x6aa75276052d96696134252587894ef5ffa520af#code
-
https://explorer.zksync.io/address/0x458fEd3144680a5b8bcfaa0F9594aa19B4Ea2D34#contract

Related PR to extension (depends on this PR):
MetaMask/metamask-extension#21841

Tested successfully through the extension. It autodetected my ERC20
tokens on both chains.

## References

Related issues:
- MetaMask/metamask-extension#17697
- MetaMask/metamask-extension#16496

## Changelog

### `@metamask/assets-controllers`

- **ADDED**: Token detection support for Base and zkSync

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
  • Loading branch information
bergeron authored Dec 6, 2023
1 parent 1b60d47 commit 3fc1059
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/assets-controllers/src/AssetsContractController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export const SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID: Record<Hex, string> = {
'0x151E24A486D7258dd7C33Fb67E4bB01919B7B32c',
[SupportedTokenDetectionNetworks.optimism]:
'0xB1c568e9C3E6bdaf755A60c7418C269eb11524FC',
[SupportedTokenDetectionNetworks.base]:
'0x6AA75276052D96696134252587894ef5FFA520af',
[SupportedTokenDetectionNetworks.zksync]:
'0x458fEd3144680a5b8bcfaa0F9594aa19B4Ea2D34',
};

export const MISSING_PROVIDER_ERROR =
Expand Down
2 changes: 2 additions & 0 deletions packages/assets-controllers/src/assetsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export enum SupportedTokenDetectionNetworks {
linea_mainnet = '0xe708', // decimal: 59144
arbitrum = '0xa4b1', // decimal: 42161
optimism = '0xa', // decimal: 10
base = '0x2105', // decimal: 8453
zksync = '0x144', // decimal: 324
}

/**
Expand Down

0 comments on commit 3fc1059

Please sign in to comment.