-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: DeFiPositionsController package changes #37215
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
|
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [6512549]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [379f01e]
UI Startup Metrics (1199 ± 98 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> - Updates DeFiPositionsController to only update the selected EVM account - Adds timeout & retry mechanism - Fixes issue with DeFi polling starting before onboarding due to subscription to `KeyringController:unlocked` event Draft PR for extension: MetaMask/metamask-extension#37215 Draft PR for mobile: MetaMask/metamask-mobile#21657 ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Related to https://consensyssoftware.atlassian.net/browse/ASSETS-1238 ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates DeFi positions to only refresh the selected EVM address, gates updates on relevant events, and adds an 8s timeout with a single retry to the API fetch. > > - **DeFiPositionsController** > - Refreshes DeFi positions for only the selected EVM account (`_executePoll`, `#updateAccountPositions`). > - Replaces AccountsController dependencies with `AccountTreeController:getAccountsFromSelectedAccountGroup` to derive selected EVM address. > - Event changes: > - Stops polling on `KeyringController:lock` (unchanged). > - Removes `KeyringController:unlock` and `AccountsController:accountAdded` listeners. > - Adds `AccountTreeController:selectedAccountGroupChange` to refresh selected address. > - `TransactionController:transactionConfirmed` now updates only if it matches the selected address. > - **Fetch behavior** > - `fetch-positions`: wraps API call with `timeoutWithRetry` (8s timeout, 1 retry). > - Adds `utils/timeout-with-retry` with unit tests. > - **Tests** > - Update unit tests to new selected-account-only behavior and new events. > - **Changelog** > - Documents breaking changes to events/behavior and new timeout+retry. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit fe03293. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
<!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> - Updates DeFiPositionsController to only update the selected EVM account - Adds timeout & retry mechanism - Fixes issue with DeFi polling starting before onboarding due to subscription to `KeyringController:unlocked` event Draft PR for extension: MetaMask/metamask-extension#37215 Draft PR for mobile: MetaMask/metamask-mobile#21657 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Related to https://consensyssoftware.atlassian.net/browse/ASSETS-1238 - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Updates DeFi positions to only refresh the selected EVM address, gates updates on relevant events, and adds an 8s timeout with a single retry to the API fetch. > > - **DeFiPositionsController** > - Refreshes DeFi positions for only the selected EVM account (`_executePoll`, `#updateAccountPositions`). > - Replaces AccountsController dependencies with `AccountTreeController:getAccountsFromSelectedAccountGroup` to derive selected EVM address. > - Event changes: > - Stops polling on `KeyringController:lock` (unchanged). > - Removes `KeyringController:unlock` and `AccountsController:accountAdded` listeners. > - Adds `AccountTreeController:selectedAccountGroupChange` to refresh selected address. > - `TransactionController:transactionConfirmed` now updates only if it matches the selected address. > - **Fetch behavior** > - `fetch-positions`: wraps API call with `timeoutWithRetry` (8s timeout, 1 retry). > - Adds `utils/timeout-with-retry` with unit tests. > - **Tests** > - Update unit tests to new selected-account-only behavior and new events. > - **Changelog** > - Documents breaking changes to events/behavior and new timeout+retry. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit fe03293. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Builds ready [1d6a0d5]
UI Startup Metrics (1251 ± 88 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3a3149f]
UI Startup Metrics (1205 ± 97 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
3a3149f to
b06a791
Compare
✨ Files requiring CODEOWNER review ✨💎 @MetaMask/metamask-assets (1 files, +1 -0)
|
Builds ready [e493f21]
UI Startup Metrics (1223 ± 98 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| marketValue: formatCurrencyWithMinThreshold(marketValue, 'USD'), | ||
| chainId: chainId as Hex, | ||
| iconGroup, | ||
| tokenFiatAmount: marketValue, |
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.
The sorting by value wasn't working, since it relied on this field to be present.
| ); | ||
|
|
||
| return useExternalServices && featureFlagForDeFi; | ||
| return completedOnboarding && useExternalServices && featureFlagForDeFi; |
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.
Now that it does not start polling on keyring unlock (which occurs before onboarding is finished), this is technically speaking not necessary.
Still, better to have it just in case, since we should never poll defi until onboarding is completed (this state does not exist in mobile though).
Builds ready [fd46bbe]
UI Startup Metrics (1209 ± 79 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [55af115]
UI Startup Metrics (1205 ± 84 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3c6ffc8]
UI Startup Metrics (1246 ± 90 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Update assets-controllers with a set of changes for DeFi position fetching:
Changelog
CHANGELOG entry: Changed how DeFi positions are fetch in the client to reduce amount of calls
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1295
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Require completed onboarding to enable DeFi positions, migrate controller messenger to account-tree APIs, add raw fiat amount to DeFi list items, and upgrade assets-controllers to v87.
DeFiPositionsControllerInitnow requirescompletedOnboardingalong withuseExternalServicesand theassetsDefiPositionsEnabledflag.AccountTreeController:getAccountsFromSelectedAccountGroup.AccountTreeController:selectedAccountGroupChange; removeKeyringController:unlockand accounts events.app/scripts/controller-init/messengers/defi-positions/index.ts, includinggetDeFiPositionsControllerInitMessenger.ui/components/app/assets/defi-list/defi-list.tsx: include rawtokenFiatAmount(unformattedaggregatedMarketValue) in protocol cell data.@metamask/assets-controllersto^87.0.0(lockfile updated).Written by Cursor Bugbot for commit 3c6ffc8. This will update automatically on new commits. Configure here.