Skip to content

feat: update earncontroller initialisation for bip-44#19160

Merged
ameliejyc merged 6 commits into
mainfrom
bump-earn-controller-package-for-bip-44
Sep 4, 2025
Merged

feat: update earncontroller initialisation for bip-44#19160
ameliejyc merged 6 commits into
mainfrom
bump-earn-controller-package-for-bip-44

Conversation

@ameliejyc

@ameliejyc ameliejyc commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Description

This PR integrates the EarnController core updates for BIP-44 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
Accompanies this PR

Manual testing steps

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

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

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.

@github-actions

github-actions Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

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.

@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
Updatednpm/​@​metamask/​account-tree-controller@​0.8.0 ⏵ 0.12.199 +310074 +198 +2100
Updatednpm/​@​metamask/​earn-controller@​5.0.0 ⏵ 7.0.098 +1010075 +199 +1100

View full report

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 3, 2025
@ameliejyc ameliejyc added No QA Needed Apply this label when your PR does not need any QA effort. No E2E Smoke Needed and removed INVALID-PR-TEMPLATE PR's body doesn't match template labels Sep 3, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 3, 2025
@ameliejyc ameliejyc force-pushed the bump-earn-controller-package-for-bip-44 branch from d9d2d8b to 631584b Compare September 3, 2025 11:31
@ameliejyc ameliejyc force-pushed the bump-earn-controller-package-for-bip-44 branch from 63c6220 to fdaaa0f Compare September 3, 2025 11:46
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.

Pre-approving, will approve again after core code is merged

ameliejyc added a commit to MetaMask/core that referenced this pull request Sep 3, 2025
## 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](#5555) (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

- [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
@github-actions github-actions Bot added size-S and removed size-XS labels Sep 3, 2025
@sonarqubecloud

sonarqubecloud Bot commented Sep 3, 2025

Copy link
Copy Markdown

@ameliejyc ameliejyc marked this pull request as ready for review September 3, 2025 20:06
@ameliejyc ameliejyc requested review from a team as code owners September 3, 2025 20:06
Comment thread package.json
"@ledgerhq/react-native-hw-transport-ble": "^6.34.1",
"@metamask/account-api": "^0.9.0",
"@metamask/account-tree-controller": "^0.8.0",
"@metamask/account-tree-controller": "^0.12.1",

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.

Note for other reviewers: Bumping to this dep normally require some other peer dep updates (like for the accounts-controller). We (the accounts team) will update those peer deps in a later PR.

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.

Thanks for bringing this up @ccharly , we need to make sure we do not ship with peer deps misaligned to prevent bug prone scenarios

@ameliejyc ameliejyc enabled auto-merge September 3, 2025 20:33
@ameliejyc ameliejyc removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 4, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 4, 2025
@ameliejyc ameliejyc removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 4, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 4, 2025

@tommasini tommasini 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.

@ameliejyc let's make sure this PR is not on the release with the peer dependencies misaligned please

@ameliejyc ameliejyc added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit a5f6e82 Sep 4, 2025
93 checks passed
@ameliejyc ameliejyc deleted the bump-earn-controller-package-for-bip-44 branch September 4, 2025 10:11
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2025
@metamaskbot metamaskbot added the release-7.56.0 Issue or pull request that will be included in release 7.56.0 label Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template No QA Needed Apply this label when your PR does not need any QA effort. release-7.56.0 Issue or pull request that will be included in release 7.56.0 size-S team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants