- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 252
 
change: set defi controller to refresh only one account #6944
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. | 
    
| 
           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. | 
    
| 
           @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. | 
    
        
          
                packages/assets-controllers/src/DeFiPositionsController/fetch-positions.ts
          
            Show resolved
            Hide resolved
        
      4f7407c    to
    a3456b1      
    Compare
  
    e30122d    to
    4076d85      
    Compare
  
    052c435    to
    26f7172      
    Compare
  
    Merge commits are not allowed on this repository
<!-- 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 -->
Explanation
KeyringController:unlockedeventDraft PR for extension: MetaMask/metamask-extension#37215
Draft PR for mobile: MetaMask/metamask-mobile#21657
References
Related to https://consensyssoftware.atlassian.net/browse/ASSETS-1238
Checklist
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.
_executePoll,#updateAccountPositions).AccountTreeController:getAccountsFromSelectedAccountGroupto derive selected EVM address.KeyringController:lock(unchanged).KeyringController:unlockandAccountsController:accountAddedlisteners.AccountTreeController:selectedAccountGroupChangeto refresh selected address.TransactionController:transactionConfirmednow updates only if it matches the selected address.fetch-positions: wraps API call withtimeoutWithRetry(8s timeout, 1 retry).utils/timeout-with-retrywith unit tests.Written by Cursor Bugbot for commit fe03293. This will update automatically on new commits. Configure here.