-
-
Notifications
You must be signed in to change notification settings - Fork 230
fix: detectTokens on tx confirmed #5859
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
Conversation
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
ef2405f
to
fae4bd9
Compare
…untRemoved" This reverts commit fae4bd9.
…sController:accountRemoved
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
## **Description** This PR integrates [tokenBalances](MetaMask/core#5726) controller state update optimizations to extension. Also integrates changes to triggered detectTokens as soon as a tx is confirmed MetaMask/core#5859 TokenBalancesController used to make state updates even though none of the token balances has changed. When a user removes an account both TokensController and TokenBalancesController state would still have the tokens and balances related to that account; hence triggering api calls to still fetch the token balances and save to state even though the user has already removes that account. The migration in this PR checks if there are any tokenBalances or tokens in both tokensController state and TokenBalancesController state that belong to accounts that do not exist anymore and cleans them up. No functional changes are expected in this PR [](https://codespaces.new/MetaMask/metamask-extension/pull/32467?quickstart=1) ## **Related issues** Fixes: #31029 ## **Manual testing steps** Test migration: 1. Import new account (on main branch) 2. You should still be able to see balances correctly 3. Import new tokens and you should still be able to see balances correctly 4. Remove an account 5. Build on this branch 6. Download state logs and make sure the removed account no longer appears in tokensController or tokenBalancesController state Test: 1. Import new account 2. import new tokens for the account 3. You should be able to see token balances correctly Test: 1- Start a swap to a token that is not already imported in state ( you can use uniswap) 2- submit transaction 3- Notice that as soon as the tx if confirmed you are able to see your new token in the main token list with balance ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
## **Description** This PR integrates [tokenBalances](MetaMask/core#5726) controller state update optimizations to extension. Also integrates changes to triggered detectTokens as soon as a tx is confirmed MetaMask/core#5859 TokenBalancesController used to make state updates even though none of the token balances has changed. When a user removes an account both TokensController and TokenBalancesController state would still have the tokens and balances related to that account; hence triggering api calls to still fetch the token balances and save to state even though the user has already removes that account. The migration in this PR checks if there are any tokenBalances or tokens in both tokensController state and TokenBalancesController state that belong to accounts that do not exist anymore and cleans them up. No functional changes are expected in this PR [](https://codespaces.new/MetaMask/metamask-extension/pull/32467?quickstart=1) ## **Related issues** Fixes: #31029 ## **Manual testing steps** Test migration: 1. Import new account (on main branch) 2. You should still be able to see balances correctly 3. Import new tokens and you should still be able to see balances correctly 4. Remove an account 5. Build on this branch 6. Download state logs and make sure the removed account no longer appears in tokensController or tokenBalancesController state Test: 1. Import new account 2. import new tokens for the account 3. You should be able to see token balances correctly Test: 1- Start a swap to a token that is not already imported in state ( you can use uniswap) 2- submit transaction 3- Notice that as soon as the tx if confirmed you are able to see your new token in the main token list with balance ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
## **Description** This PR integrates [tokenBalances](MetaMask/core#5726) controller state update optimizations to extension. Also integrates changes to triggered detectTokens as soon as a tx is confirmed MetaMask/core#5859 TokenBalancesController used to make state updates even though none of the token balances has changed. When a user removes an account both TokensController and TokenBalancesController state would still have the tokens and balances related to that account; hence triggering api calls to still fetch the token balances and save to state even though the user has already removes that account. The migration in this PR checks if there are any tokenBalances or tokens in both tokensController state and TokenBalancesController state that belong to accounts that do not exist anymore and cleans them up. No functional changes are expected in this PR [](https://codespaces.new/MetaMask/metamask-extension/pull/32467?quickstart=1) ## **Related issues** Fixes: #31029 ## **Manual testing steps** Test migration: 1. Import new account (on main branch) 2. You should still be able to see balances correctly 3. Import new tokens and you should still be able to see balances correctly 4. Remove an account 5. Build on this branch 6. Download state logs and make sure the removed account no longer appears in tokensController or tokenBalancesController state Test: 1. Import new account 2. import new tokens for the account 3. You should be able to see token balances correctly Test: 1- Start a swap to a token that is not already imported in state ( you can use uniswap) 2- submit transaction 3- Notice that as soon as the tx if confirmed you are able to see your new token in the main token list with balance ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
## **Description** This PR integrates [tokenBalances](MetaMask/core#5726) controller state update optimizations to extension. Also integrates changes to triggered detectTokens as soon as a tx is confirmed MetaMask/core#5859 TokenBalancesController used to make state updates even though none of the token balances has changed. When a user removes an account both TokensController and TokenBalancesController state would still have the tokens and balances related to that account; hence triggering api calls to still fetch the token balances and save to state even though the user has already removes that account. The migration in this PR checks if there are any tokenBalances or tokens in both tokensController state and TokenBalancesController state that belong to accounts that do not exist anymore and cleans them up. No functional changes are expected in this PR [](https://codespaces.new/MetaMask/metamask-extension/pull/32467?quickstart=1) ## **Related issues** Fixes: #31029 ## **Manual testing steps** Test migration: 1. Import new account (on main branch) 2. You should still be able to see balances correctly 3. Import new tokens and you should still be able to see balances correctly 4. Remove an account 5. Build on this branch 6. Download state logs and make sure the removed account no longer appears in tokensController or tokenBalancesController state Test: 1. Import new account 2. import new tokens for the account 3. You should be able to see token balances correctly Test: 1- Start a swap to a token that is not already imported in state ( you can use uniswap) 2- submit transaction 3- Notice that as soon as the tx if confirmed you are able to see your new token in the main token list with balance ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot <[email protected]>
Explanation
This PR
Adds subscription to
TransactionController:transactionConfirmed
event intokenDetectionController
to attempt to detect new tokens and update tokenList as soon as a transaction is confirmed as opposed to waiting for 3mins before updating state.Adds account address along with accountId to payload when publishing
AccountsController:accountRemoved
eventReferences
Changelog
Checklist