Skip to content
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

feat(accounts-controller): re-publish Snap keyring events #5190

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

ccharly
Copy link
Contributor

@ccharly ccharly commented Jan 23, 2025

Explanation

The SnapKeyring now forward some keyring events coming from a Snap. To avoid having controllers to depend the SnapKeyring for those new events, we subscribe to them from the AccountsController and re-publish them from it. This way, the AccountsController is the sole dependency for those events (and is already a dependency of many controllers anyway).

References

Changelog

@metamask/accounts-controller

  • ADDED: Re-publish Snap keyring events

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 highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@ccharly
Copy link
Contributor Author

ccharly commented Jan 23, 2025

@metamaskbot publish-preview

Copy link
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/accounts-controller": "21.0.2-preview-b1518d1",
  "@metamask-previews/address-book-controller": "6.0.2-preview-b1518d1",
  "@metamask-previews/announcement-controller": "7.0.2-preview-b1518d1",
  "@metamask-previews/approval-controller": "7.1.2-preview-b1518d1",
  "@metamask-previews/assets-controllers": "46.0.1-preview-b1518d1",
  "@metamask-previews/base-controller": "7.1.1-preview-b1518d1",
  "@metamask-previews/build-utils": "3.0.2-preview-b1518d1",
  "@metamask-previews/composable-controller": "10.0.0-preview-b1518d1",
  "@metamask-previews/controller-utils": "11.4.5-preview-b1518d1",
  "@metamask-previews/ens-controller": "15.0.1-preview-b1518d1",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-b1518d1",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-b1518d1",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-b1518d1",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-b1518d1",
  "@metamask-previews/keyring-controller": "19.0.4-preview-b1518d1",
  "@metamask-previews/logging-controller": "6.0.3-preview-b1518d1",
  "@metamask-previews/message-manager": "12.0.0-preview-b1518d1",
  "@metamask-previews/multichain": "2.1.0-preview-b1518d1",
  "@metamask-previews/multichain-transactions-controller": "0.0.1-preview-b1518d1",
  "@metamask-previews/name-controller": "8.0.2-preview-b1518d1",
  "@metamask-previews/network-controller": "22.1.1-preview-b1518d1",
  "@metamask-previews/notification-services-controller": "0.16.0-preview-b1518d1",
  "@metamask-previews/permission-controller": "11.0.5-preview-b1518d1",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-b1518d1",
  "@metamask-previews/phishing-controller": "12.3.1-preview-b1518d1",
  "@metamask-previews/polling-controller": "12.0.2-preview-b1518d1",
  "@metamask-previews/preferences-controller": "15.0.1-preview-b1518d1",
  "@metamask-previews/profile-sync-controller": "4.1.1-preview-b1518d1",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-b1518d1",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-b1518d1",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-b1518d1",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-b1518d1",
  "@metamask-previews/signature-controller": "23.2.0-preview-b1518d1",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-b1518d1",
  "@metamask-previews/transaction-controller": "43.0.0-preview-b1518d1",
  "@metamask-previews/user-operation-controller": "22.0.0-preview-b1518d1"
}

@ccharly ccharly force-pushed the feat/forward-keyring-events branch from b1518d1 to 37da015 Compare January 24, 2025 21:35
Copy link

socket-security bot commented Jan 24, 2025

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/eth-snap-keyring@9.0.0 None +21 4.65 MB metamaskbot
npm/@metamask/keyring-internal-api@3.0.0 None +3 936 kB metamaskbot

View full report↗︎

@ccharly ccharly marked this pull request as ready for review January 24, 2025 21:45
@ccharly ccharly requested review from a team as code owners January 24, 2025 21:45
@ccharly
Copy link
Contributor Author

ccharly commented Jan 27, 2025

@metamaskbot publish-preview

Copy link
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/accounts-controller": "21.0.2-preview-37da015",
  "@metamask-previews/address-book-controller": "6.0.2-preview-37da015",
  "@metamask-previews/announcement-controller": "7.0.2-preview-37da015",
  "@metamask-previews/approval-controller": "7.1.2-preview-37da015",
  "@metamask-previews/assets-controllers": "46.0.1-preview-37da015",
  "@metamask-previews/base-controller": "7.1.1-preview-37da015",
  "@metamask-previews/build-utils": "3.0.2-preview-37da015",
  "@metamask-previews/composable-controller": "10.0.0-preview-37da015",
  "@metamask-previews/controller-utils": "11.4.5-preview-37da015",
  "@metamask-previews/ens-controller": "15.0.1-preview-37da015",
  "@metamask-previews/eth-json-rpc-provider": "4.1.7-preview-37da015",
  "@metamask-previews/gas-fee-controller": "22.0.2-preview-37da015",
  "@metamask-previews/json-rpc-engine": "10.0.2-preview-37da015",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.6-preview-37da015",
  "@metamask-previews/keyring-controller": "19.0.4-preview-37da015",
  "@metamask-previews/logging-controller": "6.0.3-preview-37da015",
  "@metamask-previews/message-manager": "12.0.0-preview-37da015",
  "@metamask-previews/multichain": "2.1.0-preview-37da015",
  "@metamask-previews/multichain-transactions-controller": "0.0.1-preview-37da015",
  "@metamask-previews/name-controller": "8.0.2-preview-37da015",
  "@metamask-previews/network-controller": "22.1.1-preview-37da015",
  "@metamask-previews/notification-services-controller": "0.16.0-preview-37da015",
  "@metamask-previews/permission-controller": "11.0.5-preview-37da015",
  "@metamask-previews/permission-log-controller": "3.0.2-preview-37da015",
  "@metamask-previews/phishing-controller": "12.3.1-preview-37da015",
  "@metamask-previews/polling-controller": "12.0.2-preview-37da015",
  "@metamask-previews/preferences-controller": "15.0.1-preview-37da015",
  "@metamask-previews/profile-sync-controller": "4.1.1-preview-37da015",
  "@metamask-previews/queued-request-controller": "9.0.0-preview-37da015",
  "@metamask-previews/rate-limit-controller": "6.0.2-preview-37da015",
  "@metamask-previews/remote-feature-flag-controller": "1.3.0-preview-37da015",
  "@metamask-previews/selected-network-controller": "21.0.0-preview-37da015",
  "@metamask-previews/signature-controller": "23.2.0-preview-37da015",
  "@metamask-previews/token-search-discovery-controller": "1.0.0-preview-37da015",
  "@metamask-previews/transaction-controller": "43.0.0-preview-37da015",
  "@metamask-previews/user-operation-controller": "22.0.0-preview-37da015"
}

Copy link
Contributor

@salimtb salimtb left a comment

Choose a reason for hiding this comment

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

Assets changes LGTM

@ccharly ccharly enabled auto-merge (squash) January 27, 2025 14:34
@ccharly ccharly merged commit 9791790 into main Jan 27, 2025
359 checks passed
@ccharly ccharly deleted the feat/forward-keyring-events branch January 27, 2025 14:39
github-merge-queue bot pushed a commit to MetaMask/metamask-extension that referenced this pull request Jan 31, 2025
## **Description**

Use the new Snap keyring version that no longer rely on a
`SnapController` reference. Instead it uses the messaging system.

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

> [!NOTE]
> This PR is blocking other features for the moment, so not every peer
deps (related to the `AccountsController`) have been updated here. This
will be done in a separate PR:
> - #30011

## **Related issues**

- MetaMask/core#5190

## **Manual testing steps**

N/A

## **Screenshots/Recordings**

### **Before**

### **After**

## **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/main/.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/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.

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Feb 13, 2025
…ction controller etc) (#13436)

<!--
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**

This PR updates the
[AccountsController](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
and the
[TransactionController](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510).
These are the two major updates however there are a few smaller peer dep
updates as well. Here is a description of the changes...

### "@metamask/accounts-controller": "^21.0.0" -> 23.1.0"
-
[changelog](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
- Breaking changes:
- BREAKING: Now requires
SnapKeyring:account{AssetList,Balances,Transactions}Updated events to be
registered on the messenger (MetaMask/core#5190)
- BREAKING: Bump @metamask/snaps-controllers peer dependency from ^9.7.0
to ^9.19.0 (MetaMask/core#5265)
    - Bump @metamask/base-controller from ^7.1.1 to ^8.0.0
- Non breaking changes:
- Bump @metamask/keyring-api" from ^16.1.0 to ^17.0.0
(MetaMask/core#5280)
- Bump @metamask/eth-snap-keyring from ^9.1.1 to ^10.0.0
(MetaMask/core#5280)
- Bump @metamask/snaps-sdk from ^6.7.0 to ^6.17.1
(MetaMask/core#5220),
(MetaMask/core#5265)
- Bump @metamask/snaps-utils from ^8.9.0 to ^8.10.0
(MetaMask/core#5265)

### "@metamask/transaction-controller": "^43.0.0" -> 45.1.0
-
[changelog](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510)
- Breaking changes:
- BREAKING: Bump @metamask/accounts-controller peer dependency from
^22.0.0 to ^23.0.0

### "@metamask/keyring-api": "^13.0.0" -> 17.0.0
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-api/CHANGELOG.md#1700)
- Breaking changes:
- BREAKING: Make CaipAssetType type more restritive
(MetaMask/accounts#150) It used to be a string
but it has been restricted with a template literal type that matches
CAIP-19 asset type.
- BREAKING: Make specific *AccountStruct.scopes more strict
(MetaMask/accounts#159)
- BREAKING: Remove CAIP redefinitions
(MetaMask/accounts#167) We now rely on CAIP
definitions coming @metamask/utils.
- BREAKING: Enforce that scopes contains CAIP-2 chain IDs
(MetaMask/accounts#165) Initially scopes
accepted CAIP-2 namespaces as well to address the EVM EOA accounts that
supports all EVM chains. This has been dropped in favor of eip155:0
scope.
- BREAKING: Rename *Scopes enums to *Scope
(MetaMask/accounts#165)
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186) This was missing from
SIP-26, but we expect this address to be CAIP-10 compliant.

### "@metamask/keyring-internal-api": "^2.0.0" -> 4.0.2
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-internal-api/CHANGELOG.md#402)
- Breaking changes
- BREAKING: Bump @metamask/keyring-api from ^14.0.0 to ^15.0.0
(MetaMask/accounts#160) The scopes from each
*AccountStruct types is now more strict which impact all
Internal*AccountStruct types.
- BREAKING: Bump @metamask/keyring-api from ^15.0.0 to ^16.0.0
(MetaMask/accounts#172)
The scopes from each *AccountStruct types is now more strict (remove
support of CAIP-2 namespaces) which impact all Internal*AccountStruct
types.
- Bump @metamask/keyring-api from ^16.1.0 to ^17.0.0
(MetaMask/accounts#192)

### "@metamask/eth-snap-keyring": "^7.1.0" -> 10.0.0
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-snap-bridge/CHANGELOG.md)
- Breaking changes:
- BREAKING: Bump @metamask/keyring-api from ^12.0.0 to ^13.0.0
(MetaMask/accounts#101)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount and InternalAccount have a new required field (scopes)
and are part of the public API.
- BREAKING: Bump @metamask/keyring-internal-api from ^1.0.0 to ^2.0.0
(MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
InternalAccount extends KeyringAccount which has a new required field
(scopes) and is part of the public API.
- BREAKING: Bump @metamask/keyring-snap-internal-client from ^1.0.0 to
^2.0.0 (MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount has a new required field (scopes) and is part of the
public API.
- BREAKING: Use Messenger instead of SnapsController
(MetaMask/accounts#152)
This allows to break the runtime dependency we had with some snaps-*
pacakges.
- BREAKING: Make scopes more strict
(MetaMask/accounts#159)
We now use specific *AccountStucts when checking created/updated
accounts to make the scopes sent by the Snap are valid regarding their
account type definition.
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186)
This was missing from SIP-26, but we expect this address to be CAIP-10
compliant.

### "@metamask/snaps-sdk": "^6.13.0" -> 6.17.1
-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-sdk/CHANGELOG.md#6171)
- no breaking changes

### "@metamask/snaps-utils": "^8.6.1" -> ^8.10.0
-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-utils/CHANGELOG.md#8100)
- no breaking changes

## **Related issues**

Fixes: #13374
Fixes: #13377

## **Manual testing steps**

#### Testing snap accounts
1. ensure you are building metamask flask by setting the value of
`METAMASK_BUILD_TYPE` to `flask` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios
5. create/import a wallet
6. click on the selected account at the top of the home page
7. click on the Add account button
8. then click the Add Solana account (Beta) button
9. a popup with a suggested name should appeaer
10. click OK, the account should now be added to your account list. if
you have a balance on this address then it should show in the portfolio
view.
11. repeat the above steps with the Bitcoin and Bitcoin testnet account

#### Testing transactions
1. ensure you are NOT building flask by setting the value of
`METAMASK_BUILD_TYPE` to `main` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios 
5. import an account that has funds
6. click on the selected account at the top of the screen and the
account list should open
7. then click on the add account button, then click add account
8. a new eth account should appear in your wallet
9. click on main bottom tab navigator icon which should open a list of
actions, select Send.
10. the Send flow should open.
11. set your from account to the account that has funds and the to
account to your newly created account.
12. type in a valid amount then go through the rest of the send flow
13. in the end the transaction should go through.
14. the account balances on the home page should be updated

## **Screenshots/Recordings**

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

### **Before**

<!-- [screenshots/recordings] -->

### **After**

On-boarding and Account Creation Flow


https://github.com/user-attachments/assets/2ccd8fb4-4857-4a99-ab52-cdb071bd0447

Send flow


https://github.com/user-attachments/assets/da81d49c-b472-49a7-83c4-1d1046521072


## **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
- [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-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.
christopherferreira9 pushed a commit to MetaMask/metamask-mobile that referenced this pull request Feb 14, 2025
…ction controller etc) (#13436)

<!--
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**

This PR updates the
[AccountsController](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
and the
[TransactionController](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510).
These are the two major updates however there are a few smaller peer dep
updates as well. Here is a description of the changes...

### "@metamask/accounts-controller": "^21.0.0" -> 23.1.0"
-
[changelog](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
- Breaking changes:
- BREAKING: Now requires
SnapKeyring:account{AssetList,Balances,Transactions}Updated events to be
registered on the messenger (MetaMask/core#5190)
- BREAKING: Bump @metamask/snaps-controllers peer dependency from ^9.7.0
to ^9.19.0 (MetaMask/core#5265)
    - Bump @metamask/base-controller from ^7.1.1 to ^8.0.0
- Non breaking changes:
- Bump @metamask/keyring-api" from ^16.1.0 to ^17.0.0
(MetaMask/core#5280)
- Bump @metamask/eth-snap-keyring from ^9.1.1 to ^10.0.0
(MetaMask/core#5280)
- Bump @metamask/snaps-sdk from ^6.7.0 to ^6.17.1
(MetaMask/core#5220),
(MetaMask/core#5265)
- Bump @metamask/snaps-utils from ^8.9.0 to ^8.10.0
(MetaMask/core#5265)

### "@metamask/transaction-controller": "^43.0.0" -> 45.1.0
-
[changelog](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510)
- Breaking changes:
- BREAKING: Bump @metamask/accounts-controller peer dependency from
^22.0.0 to ^23.0.0

### "@metamask/keyring-api": "^13.0.0" -> 17.0.0
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-api/CHANGELOG.md#1700)
- Breaking changes:
- BREAKING: Make CaipAssetType type more restritive
(MetaMask/accounts#150) It used to be a string
but it has been restricted with a template literal type that matches
CAIP-19 asset type.
- BREAKING: Make specific *AccountStruct.scopes more strict
(MetaMask/accounts#159)
- BREAKING: Remove CAIP redefinitions
(MetaMask/accounts#167) We now rely on CAIP
definitions coming @metamask/utils.
- BREAKING: Enforce that scopes contains CAIP-2 chain IDs
(MetaMask/accounts#165) Initially scopes
accepted CAIP-2 namespaces as well to address the EVM EOA accounts that
supports all EVM chains. This has been dropped in favor of eip155:0
scope.
- BREAKING: Rename *Scopes enums to *Scope
(MetaMask/accounts#165)
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186) This was missing from
SIP-26, but we expect this address to be CAIP-10 compliant.

### "@metamask/keyring-internal-api": "^2.0.0" -> 4.0.2
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-internal-api/CHANGELOG.md#402)
- Breaking changes
- BREAKING: Bump @metamask/keyring-api from ^14.0.0 to ^15.0.0
(MetaMask/accounts#160) The scopes from each
*AccountStruct types is now more strict which impact all
Internal*AccountStruct types.
- BREAKING: Bump @metamask/keyring-api from ^15.0.0 to ^16.0.0
(MetaMask/accounts#172)
The scopes from each *AccountStruct types is now more strict (remove
support of CAIP-2 namespaces) which impact all Internal*AccountStruct
types.
- Bump @metamask/keyring-api from ^16.1.0 to ^17.0.0
(MetaMask/accounts#192)

### "@metamask/eth-snap-keyring": "^7.1.0" -> 10.0.0
-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-snap-bridge/CHANGELOG.md)
- Breaking changes:
- BREAKING: Bump @metamask/keyring-api from ^12.0.0 to ^13.0.0
(MetaMask/accounts#101)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount and InternalAccount have a new required field (scopes)
and are part of the public API.
- BREAKING: Bump @metamask/keyring-internal-api from ^1.0.0 to ^2.0.0
(MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
InternalAccount extends KeyringAccount which has a new required field
(scopes) and is part of the public API.
- BREAKING: Bump @metamask/keyring-snap-internal-client from ^1.0.0 to
^2.0.0 (MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount has a new required field (scopes) and is part of the
public API.
- BREAKING: Use Messenger instead of SnapsController
(MetaMask/accounts#152)
This allows to break the runtime dependency we had with some snaps-*
pacakges.
- BREAKING: Make scopes more strict
(MetaMask/accounts#159)
We now use specific *AccountStucts when checking created/updated
accounts to make the scopes sent by the Snap are valid regarding their
account type definition.
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186)
This was missing from SIP-26, but we expect this address to be CAIP-10
compliant.

### "@metamask/snaps-sdk": "^6.13.0" -> 6.17.1
-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-sdk/CHANGELOG.md#6171)
- no breaking changes

### "@metamask/snaps-utils": "^8.6.1" -> ^8.10.0
-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-utils/CHANGELOG.md#8100)
- no breaking changes

## **Related issues**

Fixes: #13374
Fixes: #13377

## **Manual testing steps**

#### Testing snap accounts
1. ensure you are building metamask flask by setting the value of
`METAMASK_BUILD_TYPE` to `flask` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios
5. create/import a wallet
6. click on the selected account at the top of the home page
7. click on the Add account button
8. then click the Add Solana account (Beta) button
9. a popup with a suggested name should appeaer
10. click OK, the account should now be added to your account list. if
you have a balance on this address then it should show in the portfolio
view.
11. repeat the above steps with the Bitcoin and Bitcoin testnet account

#### Testing transactions
1. ensure you are NOT building flask by setting the value of
`METAMASK_BUILD_TYPE` to `main` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios 
5. import an account that has funds
6. click on the selected account at the top of the screen and the
account list should open
7. then click on the add account button, then click add account
8. a new eth account should appear in your wallet
9. click on main bottom tab navigator icon which should open a list of
actions, select Send.
10. the Send flow should open.
11. set your from account to the account that has funds and the to
account to your newly created account.
12. type in a valid amount then go through the rest of the send flow
13. in the end the transaction should go through.
14. the account balances on the home page should be updated

## **Screenshots/Recordings**

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

### **Before**

<!-- [screenshots/recordings] -->

### **After**

On-boarding and Account Creation Flow


https://github.com/user-attachments/assets/2ccd8fb4-4857-4a99-ab52-cdb071bd0447

Send flow


https://github.com/user-attachments/assets/da81d49c-b472-49a7-83c4-1d1046521072


## **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
- [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-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.
MarioAslau pushed a commit to MetaMask/metamask-mobile that referenced this pull request Feb 14, 2025
…ction controller etc) (#13436)

<!--
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.
-->

This PR updates the
[AccountsController](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
and the
[TransactionController](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510).
These are the two major updates however there are a few smaller peer dep
updates as well. Here is a description of the changes...

-
[changelog](https://github.com/MetaMask/core/blob/main/packages/accounts-controller/CHANGELOG.md#2310)
- Breaking changes:
- BREAKING: Now requires
SnapKeyring:account{AssetList,Balances,Transactions}Updated events to be
registered on the messenger (MetaMask/core#5190)
- BREAKING: Bump @metamask/snaps-controllers peer dependency from ^9.7.0
to ^9.19.0 (MetaMask/core#5265)
    - Bump @metamask/base-controller from ^7.1.1 to ^8.0.0
- Non breaking changes:
- Bump @metamask/keyring-api" from ^16.1.0 to ^17.0.0
(MetaMask/core#5280)
- Bump @metamask/eth-snap-keyring from ^9.1.1 to ^10.0.0
(MetaMask/core#5280)
- Bump @metamask/snaps-sdk from ^6.7.0 to ^6.17.1
(MetaMask/core#5220),
(MetaMask/core#5265)
- Bump @metamask/snaps-utils from ^8.9.0 to ^8.10.0
(MetaMask/core#5265)

-
[changelog](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#4510)
- Breaking changes:
- BREAKING: Bump @metamask/accounts-controller peer dependency from
^22.0.0 to ^23.0.0

-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-api/CHANGELOG.md#1700)
- Breaking changes:
- BREAKING: Make CaipAssetType type more restritive
(MetaMask/accounts#150) It used to be a string
but it has been restricted with a template literal type that matches
CAIP-19 asset type.
- BREAKING: Make specific *AccountStruct.scopes more strict
(MetaMask/accounts#159)
- BREAKING: Remove CAIP redefinitions
(MetaMask/accounts#167) We now rely on CAIP
definitions coming @metamask/utils.
- BREAKING: Enforce that scopes contains CAIP-2 chain IDs
(MetaMask/accounts#165) Initially scopes
accepted CAIP-2 namespaces as well to address the EVM EOA accounts that
supports all EVM chains. This has been dropped in favor of eip155:0
scope.
- BREAKING: Rename *Scopes enums to *Scope
(MetaMask/accounts#165)
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186) This was missing from
SIP-26, but we expect this address to be CAIP-10 compliant.

-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-internal-api/CHANGELOG.md#402)
- Breaking changes
- BREAKING: Bump @metamask/keyring-api from ^14.0.0 to ^15.0.0
(MetaMask/accounts#160) The scopes from each
*AccountStruct types is now more strict which impact all
Internal*AccountStruct types.
- BREAKING: Bump @metamask/keyring-api from ^15.0.0 to ^16.0.0
(MetaMask/accounts#172)
The scopes from each *AccountStruct types is now more strict (remove
support of CAIP-2 namespaces) which impact all Internal*AccountStruct
types.
- Bump @metamask/keyring-api from ^16.1.0 to ^17.0.0
(MetaMask/accounts#192)

-
[changelog](https://github.com/MetaMask/accounts/blob/main/packages/keyring-snap-bridge/CHANGELOG.md)
- Breaking changes:
- BREAKING: Bump @metamask/keyring-api from ^12.0.0 to ^13.0.0
(MetaMask/accounts#101)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount and InternalAccount have a new required field (scopes)
and are part of the public API.
- BREAKING: Bump @metamask/keyring-internal-api from ^1.0.0 to ^2.0.0
(MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
InternalAccount extends KeyringAccount which has a new required field
(scopes) and is part of the public API.
- BREAKING: Bump @metamask/keyring-snap-internal-client from ^1.0.0 to
^2.0.0 (MetaMask/accounts#135)
This change was not properly reported as breaking on the 7.1.0.
KeyringAccount has a new required field (scopes) and is part of the
public API.
- BREAKING: Use Messenger instead of SnapsController
(MetaMask/accounts#152)
This allows to break the runtime dependency we had with some snaps-*
pacakges.
- BREAKING: Make scopes more strict
(MetaMask/accounts#159)
We now use specific *AccountStucts when checking created/updated
accounts to make the scopes sent by the Snap are valid regarding their
account type definition.
- BREAKING: Use CaipAccountId for ResolvedAccountAddress.address
(MetaMask/accounts#186)
This was missing from SIP-26, but we expect this address to be CAIP-10
compliant.

-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-sdk/CHANGELOG.md#6171)
- no breaking changes

-
[changelog](https://github.com/MetaMask/snaps/blob/main/packages/snaps-utils/CHANGELOG.md#8100)
- no breaking changes

Fixes: #13374
Fixes: #13377

1. ensure you are building metamask flask by setting the value of
`METAMASK_BUILD_TYPE` to `flask` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios
5. create/import a wallet
6. click on the selected account at the top of the home page
7. click on the Add account button
8. then click the Add Solana account (Beta) button
9. a popup with a suggested name should appeaer
10. click OK, the account should now be added to your account list. if
you have a balance on this address then it should show in the portfolio
view.
11. repeat the above steps with the Bitcoin and Bitcoin testnet account

1. ensure you are NOT building flask by setting the value of
`METAMASK_BUILD_TYPE` to `main` in your `.js.env`
2. source .js.env
3. yarn setup
4. yarn start:ios
5. import an account that has funds
6. click on the selected account at the top of the screen and the
account list should open
7. then click on the add account button, then click add account
8. a new eth account should appear in your wallet
9. click on main bottom tab navigator icon which should open a list of
actions, select Send.
10. the Send flow should open.
11. set your from account to the account that has funds and the to
account to your newly created account.
12. type in a valid amount then go through the rest of the send flow
13. in the end the transaction should go through.
14. the account balances on the home page should be updated

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

<!-- [screenshots/recordings] -->

On-boarding and Account Creation Flow

https://github.com/user-attachments/assets/2ccd8fb4-4857-4a99-ab52-cdb071bd0447

Send flow

https://github.com/user-attachments/assets/da81d49c-b472-49a7-83c4-1d1046521072

- [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
- [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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

- [ ] 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
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants