Skip to content

feat: add multichain-account-controller #6070

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

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
411d7b2
fix(create-package): remove unneeded ts-expect-error directives
ccharly Jun 23, 2025
7b670bb
feat: add multichain-account-controller implementation
ccharly Jul 3, 2025
20bff89
build: fix build
ccharly Jul 3, 2025
0f72c59
fix: fix exports
ccharly Jul 3, 2025
6a859e5
chore: lint imports
ccharly Jul 3, 2025
eb404f9
fix: fix circular dep
ccharly Jul 4, 2025
8ff77b1
fix: fix deps
ccharly Jul 4, 2025
a3f523c
chore: lint
ccharly Jul 4, 2025
78bcbb1
build: fix entrypoints
ccharly Jul 4, 2025
a59fc20
build: add missing yarn commands + add description
ccharly Jul 4, 2025
6929010
build: add missing peer deps
ccharly Jul 4, 2025
de2564b
chore: yarn.lock
ccharly Jul 4, 2025
9a8ee1a
test: move common test data into src/test
ccharly Jul 4, 2025
59b4f86
fix: fix EvmAccountProvider
ccharly Jul 4, 2025
072d2e0
fix: fix SolAccountProvider + use SnapKeyring.createAccount
ccharly Jul 4, 2025
0e45527
fix: fix SolAccountProvider + re-create fake InternalAccount temporarily
ccharly Jul 4, 2025
81161a1
fix: do not auto-select Solana account when creating
ccharly Jul 4, 2025
a8f6536
feat(accounts-controller): add account.options.index for native EVM a…
ccharly Jul 4, 2025
8672b54
refactor: use types.ts
ccharly Jul 4, 2025
dccbb1e
refactor: add init method
ccharly Jul 4, 2025
ac06731
fix: fix EvmAccountProvider account creation
ccharly Jul 4, 2025
b9f3367
chore: cosmetic
ccharly Jul 4, 2025
3c8bcc8
refactor: use new api
ccharly Jul 4, 2025
cf2a0ee
test: fix tests
ccharly Jul 8, 2025
02a9d7e
refactor: add BaseAccountProvider + use it for {Evm,Sol}AccountProvider
ccharly Jul 8, 2025
ee7d525
test: add withAddressSuffix
ccharly Jul 8, 2025
e269f01
test: add test for EvmAccountProvider
ccharly Jul 8, 2025
d8ac097
test: add test for BaseAccountProvider
ccharly Jul 8, 2025
afe03fb
refactor: use generic error message
ccharly Jul 8, 2025
821d6e4
test: add test for SolAccountProvider
ccharly Jul 8, 2025
a39f6b5
refactor: do not use default value for #getAccounts filter
ccharly Jul 8, 2025
4839289
test: remove uncovered branches
ccharly Jul 9, 2025
0d7196b
test: rewrite tests to use AccountProvider mocks + cover discoverCrea…
ccharly Jul 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Each package in this repository has its own README where you can find installati
- [`@metamask/keyring-controller`](packages/keyring-controller)
- [`@metamask/logging-controller`](packages/logging-controller)
- [`@metamask/message-manager`](packages/message-manager)
- [`@metamask/multichain-account-controller`](packages/multichain-account-controller)
- [`@metamask/multichain-api-middleware`](packages/multichain-api-middleware)
- [`@metamask/multichain-network-controller`](packages/multichain-network-controller)
- [`@metamask/multichain-transactions-controller`](packages/multichain-transactions-controller)
Expand Down Expand Up @@ -104,6 +105,7 @@ linkStyle default opacity:0.5
keyring_controller(["@metamask/keyring-controller"]);
logging_controller(["@metamask/logging-controller"]);
message_manager(["@metamask/message-manager"]);
multichain_account_controller(["@metamask/multichain-account-controller"]);
multichain_api_middleware(["@metamask/multichain-api-middleware"]);
multichain_network_controller(["@metamask/multichain-network-controller"]);
multichain_transactions_controller(["@metamask/multichain-transactions-controller"]);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"resolutions": {
"elliptic@6.5.4": "^6.5.7",
"fast-xml-parser@^4.3.4": "^4.4.1",
"ws@7.4.6": "^7.5.10"
"ws@7.4.6": "^7.5.10",
"@metamask/multichain-account-api@^0.0.0": "npm:@metamask-previews/multichain-account-api@0.0.0-5ab4699"
},
"devDependencies": {
"@babel/core": "^7.23.5",
Expand Down
2 changes: 2 additions & 0 deletions packages/accounts-controller/src/AccountsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ export class AccountsController extends BaseController<
// getting the keyring instance here feels a bit overkill.
// This will be naturally fixed once every keyring start using `KeyringAccount` and implement the keyring API.
derivationPath: getDerivationPathForIndex(accountIndex),
// Required now for multichain accounts.
index: accountIndex, // TODO: Rename those to `groupIndex` maybe?
};
}

Expand Down
10 changes: 10 additions & 0 deletions packages/multichain-account-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

[Unreleased]: https://github.com/MetaMask/core/
20 changes: 20 additions & 0 deletions packages/multichain-account-controller/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2025 MetaMask

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 changes: 15 additions & 0 deletions packages/multichain-account-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@metamask/multichain-account-controller`

example

## Installation

`yarn add @metamask/multichain-account-controller`

or

`npm install @metamask/multichain-account-controller`

## Contributing

This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
26 changes: 26 additions & 0 deletions packages/multichain-account-controller/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/

const merge = require('deepmerge');
const path = require('path');

const baseConfig = require('../../jest.config.packages');

const displayName = path.basename(__dirname);

module.exports = merge(baseConfig, {
// The display name when running multiple projects
displayName,

// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
});
92 changes: 92 additions & 0 deletions packages/multichain-account-controller/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "@metamask/multichain-account-controller",
"version": "0.0.0",
"description": "Controller to manage multichain accounts",
"keywords": [
"MetaMask",
"Ethereum"
],
"homepage": "https://github.com/MetaMask/core/tree/main/packages/multichain-account-controller#readme",
"bugs": {
"url": "https://github.com/MetaMask/core/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/core.git"
},
"license": "MIT",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.cts",
"files": [
"dist/"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
"build:docs": "typedoc",
"changelog:update": "../../scripts/update-changelog.sh @metamask/multichain-account-controller",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/multichain-account-controller",
"publish:preview": "yarn npm publish --tag preview",
"since-latest-release": "../../scripts/since-latest-release.sh",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^8.0.1",
"@metamask/keyring-api": "^18.0.0",
"@metamask/keyring-controller": "^19.0.0",
"@metamask/keyring-internal-api": "^6.2.0",
"@metamask/keyring-snap-client": "^5.0.0",
"@metamask/multichain-account-api": "^0.0.0",
"@metamask/snaps-sdk": "^7.1.0",
"@metamask/snaps-utils": "^9.4.0"
},
"devDependencies": {
"@metamask/accounts-controller": "^31.0.0",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/eth-snap-keyring": "^13.0.0",
"@metamask/keyring-controller": "^22.0.2",
"@metamask/providers": "^22.1.0",
"@metamask/snaps-controllers": "^12.3.1",
"@types/jest": "^27.4.1",
"@types/uuid": "^8.3.0",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typedoc": "^0.24.8",
"typedoc-plugin-missing-exports": "^2.0.0",
"typescript": "~5.2.2",
"uuid": "^8.3.2",
"webextension-polyfill": "^0.12.0"
},
"peerDependencies": {
"@metamask/accounts-controller": "^31.0.0",
"@metamask/keyring-controller": "^22.0.0",
"@metamask/multichain-account-api": "^0.0.0",
"@metamask/providers": "^22.0.0",
"@metamask/snaps-controllers": "^12.0.0",
"webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0"
},
"engines": {
"node": "^18.18 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
Loading
Loading