Skip to content

Commit

Permalink
fix(linea): enable token detection for Linea mainnet and testnet (#20698
Browse files Browse the repository at this point in the history
)

## Explanation

Token detection was never enabled in the extension code although the
APIs we rely on for token detection do support Linea Mainnet and Linea
Goerli.

Work needed:
- Add Linea Mainnet and Linea Goerli to the list of supported networks
for autodetection (several enums to update in Extension code base).
- Deploy a smart contract on Linea Mainnet and Linea Goerli. This
contract is then used to fetch token balances in batch. Its address
needs to be hardcoded in the Extension code base. See
assetsContractController.js in the "Core" code base.

## Screenshots/Screencaps

### Before

<img width="853" alt="Screenshot 2023-09-01 at 08 28 59"
src="https://github.com/MetaMask/metamask-extension/assets/7071180/f5c2fc05-e293-41d4-bc40-4b51928fe615">

### After

`TBD`

## Manual Testing Steps

1. Install Extension and initialise it with an account that already owns
some well-known ERC20 tokens (Ex: USDC) on both Linea Mainnet and Linea
Goerli.
2. Go to "Extension Settings > Security & privacy > Token autodetection"
and enable "Autodetect tokens" toggle.
3. Select "Linea Mainnet" => **Acceptance criteria: You shall see your
USDC listed on the tokens list screen.**
4. Got to "Import tokens > Custom token" screen => **Acceptance
criteria: You shall not see the following banner: "Token detection is
not available on this network yet."**
5. Import token with address
`0x176211869cA2b568f2A7D4EE941E073a821EE1ff` and symbol `USDC ` =>
Acceptance criteria: Successful import.
6. Select "Linea Goerli" => **Acceptance criteria: You shall see your
USDC listed on the tokens list screen.**
7. Got to "Import tokens > Custom token" screen => **Acceptance
criteria: You shall not see the following banner: "Token detection is
not available on this network yet."**
8. Import token with address `0xb4257f31750961c8e536f5cfcbb3079437700416
` and symbol `USDC ` => Acceptance criteria: Successful import.

## Pre-merge author checklist

- [x] I've clearly explained:
  - [x] What problem this PR is solving
  - [x] How this problem was solved
  - [x] How reviewers can test my changes
- [ ] Sufficient automated test coverage has been added

## Pre-merge reviewer checklist

- [ ] Manual testing (e.g. pull and build branch, run in browser, test
code being changed)
- [ ] PR is linked to the appropriate GitHub issue
- [ ] **IF** this PR fixes a bug in the release milestone, add this PR
to the release milestone

If further QA is required (e.g. new feature, complex testing steps,
large refactor), add the `Extension QA Board` label.

In this case, a QA Engineer approval will be be required.
  • Loading branch information
gauthierpetetin authored Oct 20, 2023
1 parent 61a66df commit b9f75cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions shared/modules/network.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function isTokenDetectionEnabledForNetwork(chainId: string | undefined) {
case CHAIN_IDS.BSC:
case CHAIN_IDS.POLYGON:
case CHAIN_IDS.AVALANCHE:
case CHAIN_IDS.LINEA_GOERLI:
case CHAIN_IDS.LINEA_MAINNET:
case CHAIN_IDS.AURORA:
return true;
default:
Expand Down
8 changes: 7 additions & 1 deletion ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,10 @@ export const getTokenDetectionSupportNetworkByChainId = (state) => {
return POLYGON_DISPLAY_NAME;
case CHAIN_IDS.AVALANCHE:
return AVALANCHE_DISPLAY_NAME;
case CHAIN_IDS.LINEA_GOERLI:
return LINEA_GOERLI_DISPLAY_NAME;
case CHAIN_IDS.LINEA_MAINNET:
return LINEA_MAINNET_DISPLAY_NAME;
case CHAIN_IDS.AURORA:
return AURORA_DISPLAY_NAME;
default:
Expand All @@ -1435,7 +1439,7 @@ export const getTokenDetectionSupportNetworkByChainId = (state) => {
};
/**
* To check if the chainId supports token detection,
* currently it returns true for Ethereum Mainnet, Polygon, BSC, Avalanche and Aurora
* currently it returns true for Ethereum Mainnet, BSC, Polygon, Avalanche, Linea and Aurora
*
* @param {*} state
* @returns Boolean
Expand All @@ -1447,6 +1451,8 @@ export function getIsDynamicTokenListAvailable(state) {
CHAIN_IDS.BSC,
CHAIN_IDS.POLYGON,
CHAIN_IDS.AVALANCHE,
CHAIN_IDS.LINEA_GOERLI,
CHAIN_IDS.LINEA_MAINNET,
CHAIN_IDS.AURORA,
].includes(chainId);
}
Expand Down

0 comments on commit b9f75cf

Please sign in to comment.