Skip to content

feat: BIP-44 support for EarnController#6402

Merged
ameliejyc merged 20 commits into
mainfrom
TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences
Sep 3, 2025
Merged

feat: BIP-44 support for EarnController#6402
ameliejyc merged 20 commits into
mainfrom
TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences

Conversation

@ameliejyc

@ameliejyc ameliejyc commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

Explanation

To remove our dependency on AccountsController and use the new BIP-44 enabled AccountTreeController, this PR contains two main changes:

  • Swaps out the listener AccountsController:selectedAccountChange for AccountTreeController:selectedAccountGroupChange
  • Swaps out the action AccountsController:getSelectedAccount for AccountTreeController:getAccountsFromSelectedAccountGroup from which we derive the EVM-compatible account

This relies on the latest 0.12.1 release of the account-tree-controller package.

Small things of note:

  • The account listener no longer needs the account payload to update the account address as the race condition of concern has been fixed (this is relevant to mention still because despite using the new AccountTreeController event, it still uses AccountsController under the hood)
  • In the new getSelectedEvmAccount() function I initially handled the case of no account being found (which shouldn't be possible) by failing early with a 'No EVM-compatible account address found' error. But on seeing how this case is handled by consuming functions (sometimes returning early, sometimes returning empty objects, sometimes throwing error) I opted to keep it consistent with the current code

References

Fixes the core side of this issue: https://consensyssoftware.atlassian.net/browse/TAT-1315?atlOrigin=eyJpIjoiMmQ2MDY1ZjQ4MDU5NDdiYmJhMjRhYzNiMThhMjEwYzIiLCJwIjoiaiJ9

And should be tested alongside the accompanying mobile repo update: MetaMask/metamask-mobile#19160

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch 2 times, most recently from aa8c429 to 8facad0 Compare August 28, 2025 15:35
@MetaMask MetaMask deleted a comment from github-actions Bot Aug 28, 2025
@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch from 8facad0 to e821953 Compare August 28, 2025 16:04
@MetaMask MetaMask deleted a comment from github-actions Bot Aug 28, 2025
@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch from 50f93e3 to e821953 Compare August 29, 2025 09:02
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 1, 2025
@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch from ac78790 to 839f91f Compare September 1, 2025 15:15
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 1, 2025
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 1, 2025
@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch from 839f91f to a0f3b9c Compare September 2, 2025 08:25
@ameliejyc ameliejyc force-pushed the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch from 747c1cb to f06fad2 Compare September 3, 2025 09:47
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 3, 2025
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 3, 2025
@MetaMask MetaMask deleted a comment from github-actions Bot Sep 3, 2025
@ameliejyc

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "0.12.1-preview-f06fad2b",
  "@metamask-previews/accounts-controller": "33.0.0-preview-f06fad2b",
  "@metamask-previews/address-book-controller": "6.1.1-preview-f06fad2b",
  "@metamask-previews/announcement-controller": "7.0.3-preview-f06fad2b",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-f06fad2b",
  "@metamask-previews/approval-controller": "7.1.3-preview-f06fad2b",
  "@metamask-previews/assets-controllers": "74.3.2-preview-f06fad2b",
  "@metamask-previews/base-controller": "8.2.0-preview-f06fad2b",
  "@metamask-previews/bridge-controller": "41.4.0-preview-f06fad2b",
  "@metamask-previews/bridge-status-controller": "41.0.0-preview-f06fad2b",
  "@metamask-previews/build-utils": "3.0.3-preview-f06fad2b",
  "@metamask-previews/chain-agnostic-permission": "1.1.1-preview-f06fad2b",
  "@metamask-previews/composable-controller": "11.0.0-preview-f06fad2b",
  "@metamask-previews/controller-utils": "11.12.0-preview-f06fad2b",
  "@metamask-previews/delegation-controller": "0.7.0-preview-f06fad2b",
  "@metamask-previews/earn-controller": "6.0.0-preview-f06fad2b",
  "@metamask-previews/eip1193-permission-middleware": "1.0.0-preview-f06fad2b",
  "@metamask-previews/ens-controller": "17.0.1-preview-f06fad2b",
  "@metamask-previews/error-reporting-service": "2.0.0-preview-f06fad2b",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-f06fad2b",
  "@metamask-previews/foundryup": "1.0.1-preview-f06fad2b",
  "@metamask-previews/gas-fee-controller": "24.0.0-preview-f06fad2b",
  "@metamask-previews/gator-permissions-controller": "0.0.0-preview-f06fad2b",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-f06fad2b",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-f06fad2b",
  "@metamask-previews/keyring-controller": "23.0.0-preview-f06fad2b",
  "@metamask-previews/logging-controller": "6.0.4-preview-f06fad2b",
  "@metamask-previews/message-manager": "12.0.2-preview-f06fad2b",
  "@metamask-previews/messenger": "0.1.0-preview-f06fad2b",
  "@metamask-previews/multichain-account-service": "0.6.0-preview-f06fad2b",
  "@metamask-previews/multichain-api-middleware": "1.0.0-preview-f06fad2b",
  "@metamask-previews/multichain-network-controller": "0.12.0-preview-f06fad2b",
  "@metamask-previews/multichain-transactions-controller": "5.0.0-preview-f06fad2b",
  "@metamask-previews/name-controller": "8.0.3-preview-f06fad2b",
  "@metamask-previews/network-controller": "24.1.0-preview-f06fad2b",
  "@metamask-previews/network-enablement-controller": "0.4.0-preview-f06fad2b",
  "@metamask-previews/notification-services-controller": "17.0.0-preview-f06fad2b",
  "@metamask-previews/permission-controller": "11.0.6-preview-f06fad2b",
  "@metamask-previews/permission-log-controller": "4.0.0-preview-f06fad2b",
  "@metamask-previews/phishing-controller": "13.1.0-preview-f06fad2b",
  "@metamask-previews/polling-controller": "14.0.0-preview-f06fad2b",
  "@metamask-previews/preferences-controller": "19.0.0-preview-f06fad2b",
  "@metamask-previews/profile-sync-controller": "24.0.0-preview-f06fad2b",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-f06fad2b",
  "@metamask-previews/remote-feature-flag-controller": "1.7.0-preview-f06fad2b",
  "@metamask-previews/sample-controllers": "1.0.0-preview-f06fad2b",
  "@metamask-previews/seedless-onboarding-controller": "3.0.0-preview-f06fad2b",
  "@metamask-previews/selected-network-controller": "23.0.0-preview-f06fad2b",
  "@metamask-previews/shield-controller": "0.1.2-preview-f06fad2b",
  "@metamask-previews/signature-controller": "33.0.0-preview-f06fad2b",
  "@metamask-previews/subscription-controller": "0.0.0-preview-f06fad2b",
  "@metamask-previews/token-search-discovery-controller": "3.3.0-preview-f06fad2b",
  "@metamask-previews/transaction-controller": "60.1.0-preview-f06fad2b",
  "@metamask-previews/user-operation-controller": "39.0.0-preview-f06fad2b"
}

@ameliejyc ameliejyc marked this pull request as ready for review September 3, 2025 10:59
@ameliejyc ameliejyc requested review from a team as code owners September 3, 2025 10:59
nickewansmith
nickewansmith previously approved these changes Sep 3, 2025

@nickewansmith nickewansmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM on mobile side

@ameliejyc ameliejyc enabled auto-merge (squash) September 3, 2025 14:27
Comment thread packages/earn-controller/package.json Outdated
@socket-security

socket-security Bot commented Sep 3, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​account-tree-controller@​0.12.1991007498100

View full report

cursor[bot]

This comment was marked as outdated.

Comment thread packages/earn-controller/package.json
Comment thread packages/earn-controller/package.json
Comment thread packages/earn-controller/package.json
Comment thread packages/earn-controller/CHANGELOG.md Outdated
Comment thread packages/earn-controller/src/EarnController.ts
Comment thread packages/earn-controller/src/EarnController.test.ts
Comment thread packages/earn-controller/package.json
Comment thread packages/earn-controller/CHANGELOG.md Outdated
@ameliejyc ameliejyc merged commit 38f4887 into main Sep 3, 2025
239 checks passed
@ameliejyc ameliejyc deleted the TAT-1315-migrate-to-multichain-accounts-controller-for-earn-experiences branch September 3, 2025 16:48
github-merge-queue Bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Sep 4, 2025
## **Description**

This PR integrates the [EarnController core updates for
BIP-44](MetaMask/core#6402) in version 7.0.0.

It also bumps the account-tree-controller package to the latest patch we
need 0.12.1 - the accounts team is fine for us to go ahead with this and
will do a full alignment on their side later in the week.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: the mobile repo side of
[this](https://consensyssoftware.atlassian.net/browse/TAT-1315)
Accompanies [this](MetaMask/core#6402) PR

## **Manual testing steps**

Test the following scenarios that ensure that eligibility, pooled
stakes, lending positions, and earn transactions work as expected.

```gherkin
Feature: EarnController BIP-44 updates

  Scenario: user sees Earn feature on fresh app install
    Given a user downloads the MM app for the first time
    When user lands on the homescreen
    Then they see an Earn button next to Ethereum that takes them to the Earn feature

  Scenario: user sees Earn feature on account import with existing positions
    Given a user is on the MM app
    When user imports an account with existing positions
    Then they see Earn buttons next to all relevant stablecoins or ETH
     And they see earn data when they click on the token
  
  Scenario: user can conduct Earn transactions using the correct selected account
    Given a user has selected an account and pressed Earn on a lendable token
    When user makes a deposit or withdrawal
    Then the transaction successfully completes and the metadata shows the same selected account


```
## Screenshots/Recordings 
N/A

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] 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
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants