From 1137ade3741104ec1f7841820a744e5c32a15868 Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Mon, 19 Jan 2026 10:39:47 +0100 Subject: [PATCH 1/4] add mpc keyring type --- packages/keyring-controller/src/KeyringController.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 1c9e8ac5cd7..1ec6e773d9f 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -61,6 +61,7 @@ export enum KeyringTypes { ledger = 'Ledger Hardware', lattice = 'Lattice Hardware', snap = 'Snap Keyring', + mpc = 'MPC Keyring', /* eslint-enable @typescript-eslint/naming-convention */ } From 91e0d8c43593bbf649f44a0b1e88b2ec9fe55f50 Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Tue, 27 Jan 2026 23:00:45 +0100 Subject: [PATCH 2/4] accounts: keyringTypeToName: add mpc --- packages/accounts-controller/src/utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/accounts-controller/src/utils.ts b/packages/accounts-controller/src/utils.ts index e2bbcc93fbd..7dcf26e7985 100644 --- a/packages/accounts-controller/src/utils.ts +++ b/packages/accounts-controller/src/utils.ts @@ -40,6 +40,9 @@ export function keyringTypeToName(keyringType: string): string { case KeyringTypes.snap: { return 'Snap Account'; } + case KeyringTypes.mpc: { + return 'MPC'; + } default: { throw new Error(`Unknown keyring ${keyringType}`); } From 7aec4bf1bc72b9d9781c0bd5aa44337b86e005c6 Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Fri, 13 Feb 2026 11:20:55 +0100 Subject: [PATCH 3/4] account-tree: handle mpc keyring type naming --- packages/account-tree-controller/src/rules/keyring.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/account-tree-controller/src/rules/keyring.ts b/packages/account-tree-controller/src/rules/keyring.ts index 881e8d86d74..d994a37875c 100644 --- a/packages/account-tree-controller/src/rules/keyring.ts +++ b/packages/account-tree-controller/src/rules/keyring.ts @@ -43,6 +43,9 @@ export function getAccountWalletNameFromKeyringType(type: KeyringTypes) { case KeyringTypes.snap: { return 'Snap Wallet'; } + case KeyringTypes.mpc: { + return 'MPC Wallet'; + } // ------------------------------------------------------------------------ default: { return 'Unknown'; @@ -84,6 +87,9 @@ export function getAccountGroupPrefixFromKeyringType(type: KeyringTypes) { case KeyringTypes.snap: { return 'Snap Account'; } + case KeyringTypes.mpc: { + return 'MPC Account'; + } // ------------------------------------------------------------------------ default: { return 'Unknown Account'; @@ -93,8 +99,7 @@ export function getAccountGroupPrefixFromKeyringType(type: KeyringTypes) { export class KeyringRule extends BaseRule - implements Rule -{ + implements Rule { readonly walletType = AccountWalletType.Keyring; readonly groupType = AccountGroupType.SingleAccount; From d9c1249746a277f9231bafce20f579935a7c222c Mon Sep 17 00:00:00 2001 From: Matthias Geihs Date: Fri, 13 Feb 2026 15:19:30 +0100 Subject: [PATCH 4/4] have each mpc keyring have its own wallet group --- .../src/rules/keyring.ts | 40 ++++++++++++++++++- .../account-tree-controller/src/wallet.ts | 2 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/account-tree-controller/src/rules/keyring.ts b/packages/account-tree-controller/src/rules/keyring.ts index d994a37875c..4d83d44934e 100644 --- a/packages/account-tree-controller/src/rules/keyring.ts +++ b/packages/account-tree-controller/src/rules/keyring.ts @@ -99,11 +99,28 @@ export function getAccountGroupPrefixFromKeyringType(type: KeyringTypes) { export class KeyringRule extends BaseRule - implements Rule { + implements Rule +{ readonly walletType = AccountWalletType.Keyring; readonly groupType = AccountGroupType.SingleAccount; + #findKeyringIdForAccount( + keyringType: string, + address: string, + ): string | undefined { + const { keyrings } = this.messenger.call('KeyringController:getState'); + const matchingKeyrings = keyrings.filter((k) => k.type === keyringType); + for (const keyring of matchingKeyrings) { + if ( + keyring.accounts.some((a) => a.toLowerCase() === address.toLowerCase()) + ) { + return keyring.metadata?.id; + } + } + return undefined; + } + match( account: InternalAccount, // No `| undefined` return type for this rule, as it cannot fail. @@ -111,7 +128,14 @@ export class KeyringRule // We assume that `type` is really a `KeyringTypes`. const keyringType = account.metadata.keyring.type as KeyringTypes; - const walletId = toAccountWalletId(this.walletType, keyringType); + // For MPC keyrings, we store the keyring ID in metadata and create a separate wallet per keyring instance + const keyringId = + keyringType === KeyringTypes.mpc + ? this.#findKeyringIdForAccount(keyringType, account.address) + : undefined; + + const walletSubId = keyringId ? `${keyringType}/${keyringId}` : keyringType; + const walletId = toAccountWalletId(this.walletType, walletSubId); const groupId = toAccountGroupId(walletId, account.address); return { @@ -121,6 +145,7 @@ export class KeyringRule metadata: { keyring: { type: keyringType, + ...(keyringId && { id: keyringId }), }, }, }, @@ -139,6 +164,17 @@ export class KeyringRule getDefaultAccountWalletName( wallet: AccountWalletObjectOf, ): string { + if ( + wallet.metadata.keyring.type === KeyringTypes.mpc && + wallet.metadata.keyring.id + ) { + const { keyrings } = this.messenger.call('KeyringController:getState'); + const mpcKeyrings = keyrings.filter((k) => k.type === KeyringTypes.mpc); + const index = mpcKeyrings.findIndex( + (k) => k.metadata?.id === wallet.metadata.keyring.id, + ); + return `MPC Wallet ${index === -1 ? '' : index + 1}`.trim(); + } return getAccountWalletNameFromKeyringType(wallet.metadata.keyring.type); } diff --git a/packages/account-tree-controller/src/wallet.ts b/packages/account-tree-controller/src/wallet.ts index fdfc46270f5..b1b8658c3d7 100644 --- a/packages/account-tree-controller/src/wallet.ts +++ b/packages/account-tree-controller/src/wallet.ts @@ -100,6 +100,8 @@ export type AccountWalletKeyringObject = { metadata: AccountTreeWalletMetadata & { keyring: { type: KeyringTypes; + /** Keyring instance ID, used for keyrings that can have multiple instances (e.g., MPC) */ + id?: string; }; }; };