Skip to content

fix: account tracker controller with useMultiPolling #28277

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

Merged

Conversation

sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Nov 4, 2024

Description

Adds Multi chain polling for the token account tracker controller.

We will have a separate PR to add the following e2e:
1- polling doesn't start with the wallet locked
2- once we unlock the wallet, polling starts with the wallet networks: we should check that the mocked requests for polling are happening
3- once we add a new account, polling is updated: we should check new requests including the new address happen

Open in GitHub Codespaces

Related issues

Fixes:
Related: #28402

Manual testing steps

This should not result in any new visual changes/new errors

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

@sahar-fehri sahar-fehri requested a review from a team as a code owner November 4, 2024 17:56
Copy link
Contributor

github-actions bot commented Nov 4, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@sahar-fehri sahar-fehri added the needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. label Nov 4, 2024
@sahar-fehri sahar-fehri marked this pull request as draft November 4, 2024 18:56
@sahar-fehri sahar-fehri force-pushed the feat/multi-chain-for-account-tracker-controller-v2 branch from a59f0d7 to 3068288 Compare November 4, 2024 19:18
@sahar-fehri sahar-fehri marked this pull request as ready for review November 4, 2024 19:19
@sahar-fehri sahar-fehri requested a review from a team as a code owner November 4, 2024 19:52
@@ -29,6 +29,8 @@
"github.com",
"goerli.infura.io",
"lattice.gridplus.io",
"linea-mainnet.infura.io",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we have additional RPC requests that we should be mocking in e2e tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these still needed after mocks have been added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point actually i dnt think they are needed anymore; pushing now

github-merge-queue bot pushed a commit that referenced this pull request Nov 13, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
There is a race condition in our testing setup, which causes that the
expected fixtures state, not being there when we start the test. This
has been surfaced in [this
branch](#28277),
where the account tracker multi polling is being added.
The problem is that if we don't have the AccountTracker in state when
the `resetState` function is called (at the beginning of wallet loading)
the balance will remain loading until we refresh the wallet.

Edit: performing the load state early in the test setup fixes the issue.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28421?quickstart=1)

## **Related issues**

Fixes: MetaMask/MetaMask-planning#3627

## **Manual testing steps**

1. Check all tests continue to pass
2. Check this changes fix this branch ENS test
https://github.com/MetaMask/metamask-extension/pull/28402/files#diff-1acb7898d60977530c97169551d22dbe477a4e3aeb74f1f14bf2eea0b4d75d35
. Alternatively, see videos below with before and after behaviours

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**




https://github.com/user-attachments/assets/8f50ec04-cf96-478e-9c3c-dce54254a628



### **After**


https://github.com/user-attachments/assets/0f109b1a-9289-48d9-b337-d51890c9d448




## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
gambinish pushed a commit that referenced this pull request Nov 13, 2024
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
There is a race condition in our testing setup, which causes that the
expected fixtures state, not being there when we start the test. This
has been surfaced in [this
branch](#28277),
where the account tracker multi polling is being added.
The problem is that if we don't have the AccountTracker in state when
the `resetState` function is called (at the beginning of wallet loading)
the balance will remain loading until we refresh the wallet.

Edit: performing the load state early in the test setup fixes the issue.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28421?quickstart=1)

## **Related issues**

Fixes: MetaMask/MetaMask-planning#3627

## **Manual testing steps**

1. Check all tests continue to pass
2. Check this changes fix this branch ENS test
https://github.com/MetaMask/metamask-extension/pull/28402/files#diff-1acb7898d60977530c97169551d22dbe477a4e3aeb74f1f14bf2eea0b4d75d35
. Alternatively, see videos below with before and after behaviours

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**




https://github.com/user-attachments/assets/8f50ec04-cf96-478e-9c3c-dce54254a628



### **After**


https://github.com/user-attachments/assets/0f109b1a-9289-48d9-b337-d51890c9d448




## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.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.
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
List of failing tests:

- Malicious Confirmation Signature - Bad Domain @no-mmi displays alert
for domain binding and confirms
- Malicious Confirmation Signature - Bad Domain @no-mmi initiates and
rejects from confirmation screen
- Malicious Confirmation Signature - Bad Domain @no-mmi initiates and
rejects from alert friction modal
- Malicious Confirmation Signature - Bad Domain @no-mmi displays alert
for domain binding and confirms
- Malicious Confirmation Signature - Bad Domain @no-mmi initiates and
rejects from confirmation screen
- Malicious Confirmation Signature - Bad Domain @no-mmi initiates and
rejects from alert friction modal
- smart transactions @no-mmi Completes a Swap
- Simple Send Security Alert - Blockaid @no-mmi should not show security
alerts for benign requests
- Simple Send Security Alert - Blockaid @no-mmi should show security
alerts for malicious requests
- MultiRpc: should select rpc from modal
- MetaMask onboarding @no-mmi doesn't make any network requests to
infura before create new wallet onboarding is completed
- MetaMask onboarding @no-mmi doesn't make any network requests to
infura before onboarding by import is completed
- MetaMask onboarding @no-mmi doesn't make any network requests to
infura before create new wallet onboarding is completed
- MetaMask onboarding @no-mmi doesn't make any network requests to
infura before onboarding by import is completed
- 

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28402?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

Swaps


https://github.com/user-attachments/assets/656ba20a-bc48-4f57-84d4-8b11e62a25cf


ENS


https://github.com/user-attachments/assets/aa23bb34-aeb0-48e9-af17-c98a82367437



## **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/develop/.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/develop/.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: sahar-fehri <[email protected]>
@sahar-fehri sahar-fehri requested a review from seaona November 13, 2024 19:10
@metamaskbot
Copy link
Collaborator

Builds ready [9aff235]
Page Load Metrics (2320 ± 145 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34028932215525252
domContentLoaded180028472288300144
load181128602320303145
domInteractive31168552914
backgroundConnect9133322814
firstReactRender8551217510751
getState477272512
initialActions00000
loadScripts132122071718244117
setupStore67015178
uiStartup202933922718340163
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 142 Bytes (0.00%)
  • ui: 1.35 KiB (0.02%)
  • common: 305 Bytes (0.00%)

seaona
seaona previously approved these changes Nov 15, 2024
Copy link
Contributor

@seaona seaona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good from the e2e and testing side 🔥 awesome work!!

@bergeron
Copy link
Contributor

resolved merge conflicts

@metamaskbot
Copy link
Collaborator

Builds ready [78d0a6b]
Page Load Metrics (1939 ± 62 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint32222151858373179
domContentLoaded17162135191111555
load17522219193912962
domInteractive27102442110
backgroundConnect1083332512
firstReactRender48204874019
getState44197903015
initialActions01000
loadScripts1288166014359847
setupStore679172211
uiStartup19942635226515977
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 142 Bytes (0.00%)
  • ui: 1.46 KiB (0.02%)
  • common: 305 Bytes (0.00%)

gambinish
gambinish previously approved these changes Nov 18, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [22b383a]
Page Load Metrics (1764 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16562272176913967
domContentLoaded16002218173512962
load16572271176413565
domInteractive256733105
backgroundConnect107732189
firstReactRender462891197134
getState40205935225
initialActions01000
loadScripts11581700130411053
setupStore612721
uiStartup18872604211220196
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 142 Bytes (0.00%)
  • ui: 1.46 KiB (0.02%)
  • common: 305 Bytes (0.00%)

bergeron
bergeron previously approved these changes Nov 19, 2024
Copy link
Contributor

@bergeron bergeron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. tested with and without PORTFOLIO_VIEW

@metamaskbot
Copy link
Collaborator

Builds ready [acd5a74]
Page Load Metrics (2181 ± 119 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint34326601875627301
domContentLoaded188728632151239115
load190329062181247119
domInteractive31218775727
backgroundConnect87632209
firstReactRender563751216732
getState2185532211
initialActions01000
loadScripts139722251626210101
setupStore65819199
uiStartup214935812505328157
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 142 Bytes (0.00%)
  • ui: 1.46 KiB (0.02%)
  • common: 305 Bytes (0.00%)

@sahar-fehri sahar-fehri dismissed stale reviews from bergeron and gambinish via 67ad764 November 19, 2024 20:53
@bergeron bergeron removed the request for review from a team November 19, 2024 21:03
@sahar-fehri sahar-fehri added this pull request to the merge queue Nov 19, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [67ad764]
Page Load Metrics (2106 ± 161 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint165030242114333160
domContentLoaded163929972075331159
load164930212106336161
domInteractive15121482612
backgroundConnect980342411
firstReactRender702971155727
getState452821014924
initialActions01000
loadScripts119724661598314151
setupStore683182311
uiStartup192034192498379182
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 142 Bytes (0.00%)
  • ui: 1.46 KiB (0.02%)
  • common: 305 Bytes (0.00%)

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2024
@sahar-fehri sahar-fehri added this pull request to the merge queue Nov 19, 2024
Merged via the queue into develop with commit 7ac581c Nov 19, 2024
77 checks passed
@sahar-fehri sahar-fehri deleted the feat/multi-chain-for-account-tracker-controller-v2 branch November 19, 2024 22:09
@github-actions github-actions bot locked and limited conversation to collaborators Nov 19, 2024
@metamaskbot metamaskbot added the release-12.9.0 Issue or pull request that will be included in release 12.9.0 label Nov 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-assets-ux-review A shared label between the Assets and UX team to flag PRs ready for consolidated team review. release-12.9.0 Issue or pull request that will be included in release 12.9.0 team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants