@metamask/multichain-account-service 10.0.2 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/dist/MultichainAccountGroup.cjs +15 -0
  3. package/dist/MultichainAccountGroup.cjs.map +1 -1
  4. package/dist/MultichainAccountGroup.d.cts +10 -0
  5. package/dist/MultichainAccountGroup.d.cts.map +1 -1
  6. package/dist/MultichainAccountGroup.d.mts +10 -0
  7. package/dist/MultichainAccountGroup.d.mts.map +1 -1
  8. package/dist/MultichainAccountGroup.mjs +15 -0
  9. package/dist/MultichainAccountGroup.mjs.map +1 -1
  10. package/dist/MultichainAccountService-method-action-types.cjs.map +1 -1
  11. package/dist/MultichainAccountService-method-action-types.d.cts +10 -6
  12. package/dist/MultichainAccountService-method-action-types.d.cts.map +1 -1
  13. package/dist/MultichainAccountService-method-action-types.d.mts +10 -6
  14. package/dist/MultichainAccountService-method-action-types.d.mts.map +1 -1
  15. package/dist/MultichainAccountService-method-action-types.mjs.map +1 -1
  16. package/dist/MultichainAccountService.cjs +67 -8
  17. package/dist/MultichainAccountService.cjs.map +1 -1
  18. package/dist/MultichainAccountService.d.cts +31 -7
  19. package/dist/MultichainAccountService.d.cts.map +1 -1
  20. package/dist/MultichainAccountService.d.mts +31 -7
  21. package/dist/MultichainAccountService.d.mts.map +1 -1
  22. package/dist/MultichainAccountService.mjs +67 -8
  23. package/dist/MultichainAccountService.mjs.map +1 -1
  24. package/dist/MultichainAccountWallet.cjs +20 -0
  25. package/dist/MultichainAccountWallet.cjs.map +1 -1
  26. package/dist/MultichainAccountWallet.d.cts +10 -0
  27. package/dist/MultichainAccountWallet.d.cts.map +1 -1
  28. package/dist/MultichainAccountWallet.d.mts +10 -0
  29. package/dist/MultichainAccountWallet.d.mts.map +1 -1
  30. package/dist/MultichainAccountWallet.mjs +20 -0
  31. package/dist/MultichainAccountWallet.mjs.map +1 -1
  32. package/dist/providers/AccountProviderWrapper.cjs +43 -0
  33. package/dist/providers/AccountProviderWrapper.cjs.map +1 -1
  34. package/dist/providers/AccountProviderWrapper.d.cts +37 -0
  35. package/dist/providers/AccountProviderWrapper.d.cts.map +1 -1
  36. package/dist/providers/AccountProviderWrapper.d.mts +37 -0
  37. package/dist/providers/AccountProviderWrapper.d.mts.map +1 -1
  38. package/dist/providers/AccountProviderWrapper.mjs +43 -0
  39. package/dist/providers/AccountProviderWrapper.mjs.map +1 -1
  40. package/dist/providers/BaseBip44AccountProvider.cjs +3 -18
  41. package/dist/providers/BaseBip44AccountProvider.cjs.map +1 -1
  42. package/dist/providers/BaseBip44AccountProvider.d.cts +36 -16
  43. package/dist/providers/BaseBip44AccountProvider.d.cts.map +1 -1
  44. package/dist/providers/BaseBip44AccountProvider.d.mts +36 -16
  45. package/dist/providers/BaseBip44AccountProvider.d.mts.map +1 -1
  46. package/dist/providers/BaseBip44AccountProvider.mjs +3 -18
  47. package/dist/providers/BaseBip44AccountProvider.mjs.map +1 -1
  48. package/dist/providers/EvmAccountProvider.cjs +19 -0
  49. package/dist/providers/EvmAccountProvider.cjs.map +1 -1
  50. package/dist/providers/EvmAccountProvider.d.cts +12 -0
  51. package/dist/providers/EvmAccountProvider.d.cts.map +1 -1
  52. package/dist/providers/EvmAccountProvider.d.mts +12 -0
  53. package/dist/providers/EvmAccountProvider.d.mts.map +1 -1
  54. package/dist/providers/EvmAccountProvider.mjs +19 -0
  55. package/dist/providers/EvmAccountProvider.mjs.map +1 -1
  56. package/dist/providers/SnapAccountProvider.cjs +28 -11
  57. package/dist/providers/SnapAccountProvider.cjs.map +1 -1
  58. package/dist/providers/SnapAccountProvider.d.cts +16 -4
  59. package/dist/providers/SnapAccountProvider.d.cts.map +1 -1
  60. package/dist/providers/SnapAccountProvider.d.mts +16 -4
  61. package/dist/providers/SnapAccountProvider.d.mts.map +1 -1
  62. package/dist/providers/SnapAccountProvider.mjs +28 -11
  63. package/dist/providers/SnapAccountProvider.mjs.map +1 -1
  64. package/dist/tests/providers.cjs +4 -0
  65. package/dist/tests/providers.cjs.map +1 -1
  66. package/dist/tests/providers.d.cts +2 -0
  67. package/dist/tests/providers.d.cts.map +1 -1
  68. package/dist/tests/providers.d.mts +2 -0
  69. package/dist/tests/providers.d.mts.map +1 -1
  70. package/dist/tests/providers.mjs +4 -0
  71. package/dist/tests/providers.mjs.map +1 -1
  72. package/dist/utils.cjs.map +1 -1
  73. package/dist/utils.d.cts +14 -1
  74. package/dist/utils.d.cts.map +1 -1
  75. package/dist/utils.d.mts +14 -1
  76. package/dist/utils.d.mts.map +1 -1
  77. package/dist/utils.mjs.map +1 -1
  78. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [11.0.0]
11
+
12
+ ### Added
13
+
14
+ - Added `Bip44AccountProvider.deleteAccount(id)` method ([#8960](https://github.com/MetaMask/core/pull/8960))
15
+ - The `KeyringController` will automatically prunes the non-primary empty keyrings when the last EVM account is getting removed.
16
+ - `AccountProviderWrapper.deleteAccount(id)` always removes the account, even if disabled.
17
+ - Added `AccountProviderWrapper.unwrap` method ([#8960](https://github.com/MetaMask/core/pull/8960))
18
+ - Use this if you need to access the inner (wrapped) keyring.
19
+ - Add `isAligned` ([#9039](https://github.com/MetaMask/core/pull/9039))
20
+ - This allows callers to cheaply check whether alignment has already occurred before triggering an explicit alignment operation.
21
+
22
+ ### Changed
23
+
24
+ - **BREAKING:** Replace `KeyringController:withKeyring` with `KeyringController:withKeyringV2` for the Snap account providers ([#8732](https://github.com/MetaMask/core/pull/8732))
25
+ - Bump `@metamask/eth-snap-keyring` from `^22.0.1` to `^22.3.0` ([#8732](https://github.com/MetaMask/core/pull/8732))
26
+ - **BREAKING:** `MultichainAccountService.removeMultichainAccountWallet` (and messenger action) now takes a single `entropySource` argument ([#8960](https://github.com/MetaMask/core/pull/8960))
27
+ - The previous `accountAddress` parameter has been removed.
28
+ - All accounts are now unconditionally removed from the wallet and providers (even for disabled `AccountProviderWrapper`).
29
+ - Per-account deletions are best-effort: a single account's failure does not abort cleanup of the remaining accounts.
30
+ - Errors are aggregated and reported in case of failure.
31
+ - Bump `@metamask/utils` from `^11.9.0` to `^11.11.0` ([#9074](https://github.com/MetaMask/core/pull/9074))
32
+ - Bump `@metamask/controller-utils` from `^12.1.1` to `^12.2.0` ([#9083](https://github.com/MetaMask/core/pull/9083))
33
+ - Bump `@metamask/keyring-controller` from `^27.0.0` to `^27.1.0` ([#9129](https://github.com/MetaMask/core/pull/9129))
34
+ - Bump `@metamask/accounts-controller` from `^39.0.1` to `^39.0.3` ([#9218](https://github.com/MetaMask/core/pull/9218), [#9231](https://github.com/MetaMask/core/pull/9231))
35
+ - Bump `@metamask/snap-account-service` from `^0.3.1` to `^1.0.0` ([#9231](https://github.com/MetaMask/core/pull/9231))
36
+
37
+ ## [10.0.3]
38
+
39
+ ### Changed
40
+
41
+ - Bump `@metamask/accounts-controller` from `^39.0.0` to `^39.0.1` ([#9058](https://github.com/MetaMask/core/pull/9058))
42
+ - Bump `@metamask/keyring-controller` from `^26.0.0` to `^27.0.0` ([#9058](https://github.com/MetaMask/core/pull/9058))
43
+ - Bump `@metamask/snap-account-service` from `^0.3.0` to `^0.3.1` ([#9058](https://github.com/MetaMask/core/pull/9058))
44
+
10
45
  ## [10.0.2]
11
46
 
12
47
  ### Changed
@@ -27,7 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
62
  ### Changed
28
63
 
29
64
  - **BREAKING:** The service messenger now requires the `SnapAccountService:ensureReady` action to be declared ([#8715](https://github.com/MetaMask/core/pull/8715))
30
- - **BREAKING:** Delegate Snap platform readiness to `@metamask/snap-account-service` ([#8715](https://github.com/MetaMask/core/pull/8715)), ([#8752](https://github.com/MetaMask/core/pull/8752))
65
+ - **BREAKING:** Delegate Snap platform readiness to `@metamask/snap-account-service` ([#8715](https://github.com/MetaMask/core/pull/8715), [#8752](https://github.com/MetaMask/core/pull/8752))
31
66
  - Removed `MultichainAccountService.ensureCanUseSnapPlatform()` method and the corresponding `MultichainAccountService:ensureCanUseSnapPlatform` messenger action.
32
67
  - Removed the `MultichainAccountServiceEnsureCanUseSnapPlatformAction` type export.
33
68
  - Removed `MultichainAccountServiceOptions.ensureOnboardingComplete`. Configure it via `SnapAccountService`'s `config.snapPlatformWatcher.ensureOnboardingComplete` instead.
@@ -500,7 +535,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
500
535
  - Add `MultichainAccountService` ([#6141](https://github.com/MetaMask/core/pull/6141), [#6165](https://github.com/MetaMask/core/pull/6165))
501
536
  - This service manages multichain accounts/wallets.
502
537
 
503
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@10.0.2...HEAD
538
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@11.0.0...HEAD
539
+ [11.0.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@10.0.3...@metamask/multichain-account-service@11.0.0
540
+ [10.0.3]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@10.0.2...@metamask/multichain-account-service@10.0.3
504
541
  [10.0.2]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@10.0.1...@metamask/multichain-account-service@10.0.2
505
542
  [10.0.1]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@10.0.0...@metamask/multichain-account-service@10.0.1
506
543
  [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/multichain-account-service@9.0.0...@metamask/multichain-account-service@10.0.0
@@ -167,6 +167,21 @@ class MultichainAccountGroup {
167
167
  select(selector) {
168
168
  return (0, account_api_1.select)(this.getAccounts(), selector);
169
169
  }
170
+ /**
171
+ * Check whether every provider has an aligned account in this group.
172
+ *
173
+ * A group is aligned when every registered provider reports that the
174
+ * account IDs it contributed to this group are non-empty and owned by it.
175
+ * Disabled {@link AccountProviderWrapper} instances always report `true`.
176
+ *
177
+ * @returns `true` when all providers are aligned for this group.
178
+ */
179
+ isAligned() {
180
+ return __classPrivateFieldGet(this, _MultichainAccountGroup_providers, "f").every((provider) => provider.isAligned({
181
+ entropySource: __classPrivateFieldGet(this, _MultichainAccountGroup_wallet, "f").entropySource,
182
+ groupIndex: __classPrivateFieldGet(this, _MultichainAccountGroup_groupIndex, "f"),
183
+ }, __classPrivateFieldGet(this, _MultichainAccountGroup_providerToAccounts, "f").get(provider) ?? []));
184
+ }
170
185
  }
171
186
  exports.MultichainAccountGroup = MultichainAccountGroup;
172
187
  _MultichainAccountGroup_id = new WeakMap(), _MultichainAccountGroup_wallet = new WeakMap(), _MultichainAccountGroup_groupIndex = new WeakMap(), _MultichainAccountGroup_providers = new WeakMap(), _MultichainAccountGroup_providerToAccounts = new WeakMap(), _MultichainAccountGroup_accountToProvider = new WeakMap(), _MultichainAccountGroup_messenger = new WeakMap(), _MultichainAccountGroup_log = new WeakMap(), _MultichainAccountGroup_initialized = new WeakMap(), _MultichainAccountGroup_instances = new WeakSet(), _MultichainAccountGroup_clearAccountToProviderState = function _MultichainAccountGroup_clearAccountToProviderState(provider) {
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountGroup.cjs","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA4E;AAC5E,uDAAmE;AAUnE,yCAAoE;AASpE;;GAEG;AACH,MAAa,sBAAsB;IA2BjC,YAAY,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GAMV;;QAlCQ,6CAA8B;QAE9B,iDAA0C;QAE1C,qDAAoB;QAEpB,oDAA4C;QAE5C,6DAGP;QAEO,4DAGP;QAEO,oDAA8C;QAE9C,8CAAa;QAEtB,8CAAe,KAAK,EAAC;QAanB,uBAAA,IAAI,8BAAO,IAAA,wCAA0B,EAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,MA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AG,CAAC,QAAkC;QACpC,OAAO,IAAA,uBAAS,EAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAkC;QACvC,OAAO,IAAA,oBAAM,EAAC,IAAI,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF;AAtOD,wDAsOC;qnBAhL8B,QAAuC;IAClE,uBAAA,IAAI,iDAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE;QACtD,IAAI,eAAe,KAAK,QAAQ,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,+EAOS,UAAsB;IAC9B,KAAK,MAAM,QAAQ,IAAI,uBAAA,IAAI,yCAAW,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,8FAA6B,MAAjC,IAAI,EAA8B,QAAQ,CAAC,CAAC;YAC5C,uBAAA,IAAI,kDAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAEnD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,uBAAA,IAAI,iDAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { AccountGroupType, select, selectOne } from '@metamask/account-api';\nimport { toMultichainAccountGroupId } from '@metamask/account-api';\nimport type {\n MultichainAccountGroupId,\n MultichainAccountGroup as MultichainAccountGroupDefinition,\n} from '@metamask/account-api';\nimport type { Bip44Account } from '@metamask/account-api';\nimport type { AccountSelector } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Logger } from './logger';\nimport { projectLogger as log, createModuleLogger } from './logger';\nimport type { ServiceState, StateKeys } from './MultichainAccountService';\nimport type { MultichainAccountWallet } from './MultichainAccountWallet';\nimport type { Bip44AccountProvider } from './providers';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport type GroupState =\n ServiceState[StateKeys['entropySource']][StateKeys['groupIndex']];\n\n/**\n * A multichain account group that holds multiple accounts.\n */\nexport class MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountGroupDefinition<Account> {\n readonly #id: MultichainAccountGroupId;\n\n readonly #wallet: MultichainAccountWallet<Account>;\n\n readonly #groupIndex: number;\n\n readonly #providers: Bip44AccountProvider<Account>[];\n\n readonly #providerToAccounts: Map<\n Bip44AccountProvider<Account>,\n Account['id'][]\n >;\n\n readonly #accountToProvider: Map<\n Account['id'],\n Bip44AccountProvider<Account>\n >;\n\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #log: Logger;\n\n #initialized = false;\n\n constructor({\n groupIndex,\n wallet,\n providers,\n messenger,\n }: {\n groupIndex: number;\n wallet: MultichainAccountWallet<Account>;\n providers: Bip44AccountProvider<Account>[];\n messenger: MultichainAccountServiceMessenger;\n }) {\n this.#id = toMultichainAccountGroupId(wallet.id, groupIndex);\n this.#groupIndex = groupIndex;\n this.#wallet = wallet;\n this.#providers = providers;\n this.#messenger = messenger;\n this.#providerToAccounts = new Map();\n this.#accountToProvider = new Map();\n\n this.#log = createModuleLogger(log, `[${this.#id}]`);\n }\n\n /**\n * Clear the account to provider state for a given provider.\n *\n * @param provider - The provider to clear the account to provider state for.\n */\n #clearAccountToProviderState(provider: Bip44AccountProvider<Account>): void {\n this.#accountToProvider.forEach((accountProvider, id) => {\n if (accountProvider === provider) {\n this.#accountToProvider.delete(id);\n }\n });\n }\n\n /**\n * Update the internal representation of accounts with the given group state.\n *\n * @param groupState - The group state.\n */\n #setState(groupState: GroupState): void {\n for (const provider of this.#providers) {\n const accountIds = groupState[provider.getName()];\n\n if (accountIds) {\n this.#clearAccountToProviderState(provider);\n this.#providerToAccounts.set(provider, accountIds);\n\n for (const accountId of accountIds) {\n this.#accountToProvider.set(accountId, provider);\n }\n }\n }\n }\n\n /**\n * Initialize the multichain account group and construct the internal representation of accounts.\n *\n * @param groupState - The group state.\n */\n init(groupState: GroupState): void {\n this.#log('Initializing group state...');\n this.#setState(groupState);\n this.#log('Finished initializing group state...');\n\n this.#initialized = true;\n }\n\n /**\n * Update the group state.\n *\n * @param groupState - The group state.\n */\n update(groupState: GroupState): void {\n this.#log('Updating group state...');\n this.#setState(groupState);\n this.#log('Finished updating group state...');\n\n if (this.#initialized) {\n this.#messenger.publish(\n 'MultichainAccountService:multichainAccountGroupUpdated',\n this,\n );\n }\n }\n\n /**\n * Gets the multichain account group ID.\n *\n * @returns The multichain account group ID.\n */\n get id(): MultichainAccountGroupId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account group type.\n *\n * @returns The multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount {\n return AccountGroupType.MultichainAccount;\n }\n\n /**\n * Gets the multichain account's wallet reference (parent).\n *\n * @returns The multichain account's wallet.\n */\n get wallet(): MultichainAccountWallet<Account> {\n return this.#wallet;\n }\n\n /**\n * Gets the multichain account group index.\n *\n * @returns The multichain account group index.\n */\n get groupIndex(): number {\n return this.#groupIndex;\n }\n\n /**\n * Checks if there's any underlying accounts for this multichain accounts.\n *\n * @returns True if there's any underlying accounts, false otherwise.\n */\n hasAccounts(): boolean {\n // If there's anything in the reverse-map, it means we have some accounts.\n return this.#accountToProvider.size > 0;\n }\n\n /**\n * Gets the accounts for this multichain account.\n *\n * @returns The accounts.\n */\n getAccounts(): Account[] {\n const allAccounts: Account[] = [];\n\n for (const [provider, accounts] of this.#providerToAccounts.entries()) {\n for (const id of accounts) {\n const account = provider.getAccount(id);\n\n if (account) {\n // If for some reason we cannot get this account from the provider, it\n // might means it has been deleted or something, so we just filter it\n // out.\n allAccounts.push(account);\n }\n }\n }\n\n return allAccounts;\n }\n\n /**\n * Gets the account IDs for this multichain account.\n *\n * @returns The account IDs.\n */\n getAccountIds(): Account['id'][] {\n return [...this.#accountToProvider.keys()];\n }\n\n /**\n * Gets the account for a given account ID.\n *\n * @param id - Account ID.\n * @returns The account or undefined if not found.\n */\n getAccount(id: Account['id']): Account | undefined {\n const provider = this.#accountToProvider.get(id);\n\n // If there's nothing in the map, it means we tried to get an account\n // that does not belong to this multichain account.\n if (!provider) {\n return undefined;\n }\n\n return provider.getAccount(id);\n }\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined {\n return selectOne(this.getAccounts(), selector);\n }\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[] {\n return select(this.getAccounts(), selector);\n }\n}\n"]}
1
+ {"version":3,"file":"MultichainAccountGroup.cjs","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAA4E;AAC5E,uDAAmE;AAUnE,yCAAoE;AASpE;;GAEG;AACH,MAAa,sBAAsB;IA2BjC,YAAY,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GAMV;;QAlCQ,6CAA8B;QAE9B,iDAA0C;QAE1C,qDAAoB;QAEpB,oDAA4C;QAE5C,6DAGP;QAEO,4DAGP;QAEO,oDAA8C;QAE9C,8CAAa;QAEtB,8CAAe,KAAK,EAAC;QAanB,uBAAA,IAAI,8BAAO,IAAA,wCAA0B,EAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,MAAA,CAAC;QAC7D,uBAAA,IAAI,sCAAe,UAAU,MAAA,CAAC;QAC9B,uBAAA,IAAI,kCAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,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sourcesContent":["import { AccountGroupType, select, selectOne } from '@metamask/account-api';\nimport { toMultichainAccountGroupId } from '@metamask/account-api';\nimport type {\n MultichainAccountGroupId,\n MultichainAccountGroup as MultichainAccountGroupDefinition,\n} from '@metamask/account-api';\nimport type { Bip44Account } from '@metamask/account-api';\nimport type { AccountSelector } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Logger } from './logger';\nimport { projectLogger as log, createModuleLogger } from './logger';\nimport type { ServiceState, StateKeys } from './MultichainAccountService';\nimport type { MultichainAccountWallet } from './MultichainAccountWallet';\nimport type { Bip44AccountProvider } from './providers';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport type GroupState =\n ServiceState[StateKeys['entropySource']][StateKeys['groupIndex']];\n\n/**\n * A multichain account group that holds multiple accounts.\n */\nexport class MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountGroupDefinition<Account> {\n readonly #id: MultichainAccountGroupId;\n\n readonly #wallet: MultichainAccountWallet<Account>;\n\n readonly #groupIndex: number;\n\n readonly #providers: Bip44AccountProvider<Account>[];\n\n readonly #providerToAccounts: Map<\n Bip44AccountProvider<Account>,\n Account['id'][]\n >;\n\n readonly #accountToProvider: Map<\n Account['id'],\n Bip44AccountProvider<Account>\n >;\n\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #log: Logger;\n\n #initialized = false;\n\n constructor({\n groupIndex,\n wallet,\n providers,\n messenger,\n }: {\n groupIndex: number;\n wallet: MultichainAccountWallet<Account>;\n providers: Bip44AccountProvider<Account>[];\n messenger: MultichainAccountServiceMessenger;\n }) {\n this.#id = toMultichainAccountGroupId(wallet.id, groupIndex);\n this.#groupIndex = groupIndex;\n this.#wallet = wallet;\n this.#providers = providers;\n this.#messenger = messenger;\n this.#providerToAccounts = new Map();\n this.#accountToProvider = new Map();\n\n this.#log = createModuleLogger(log, `[${this.#id}]`);\n }\n\n /**\n * Clear the account to provider state for a given provider.\n *\n * @param provider - The provider to clear the account to provider state for.\n */\n #clearAccountToProviderState(provider: Bip44AccountProvider<Account>): void {\n this.#accountToProvider.forEach((accountProvider, id) => {\n if (accountProvider === provider) {\n this.#accountToProvider.delete(id);\n }\n });\n }\n\n /**\n * Update the internal representation of accounts with the given group state.\n *\n * @param groupState - The group state.\n */\n #setState(groupState: GroupState): void {\n for (const provider of this.#providers) {\n const accountIds = groupState[provider.getName()];\n\n if (accountIds) {\n this.#clearAccountToProviderState(provider);\n this.#providerToAccounts.set(provider, accountIds);\n\n for (const accountId of accountIds) {\n this.#accountToProvider.set(accountId, provider);\n }\n }\n }\n }\n\n /**\n * Initialize the multichain account group and construct the internal representation of accounts.\n *\n * @param groupState - The group state.\n */\n init(groupState: GroupState): void {\n this.#log('Initializing group state...');\n this.#setState(groupState);\n this.#log('Finished initializing group state...');\n\n this.#initialized = true;\n }\n\n /**\n * Update the group state.\n *\n * @param groupState - The group state.\n */\n update(groupState: GroupState): void {\n this.#log('Updating group state...');\n this.#setState(groupState);\n this.#log('Finished updating group state...');\n\n if (this.#initialized) {\n this.#messenger.publish(\n 'MultichainAccountService:multichainAccountGroupUpdated',\n this,\n );\n }\n }\n\n /**\n * Gets the multichain account group ID.\n *\n * @returns The multichain account group ID.\n */\n get id(): MultichainAccountGroupId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account group type.\n *\n * @returns The multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount {\n return AccountGroupType.MultichainAccount;\n }\n\n /**\n * Gets the multichain account's wallet reference (parent).\n *\n * @returns The multichain account's wallet.\n */\n get wallet(): MultichainAccountWallet<Account> {\n return this.#wallet;\n }\n\n /**\n * Gets the multichain account group index.\n *\n * @returns The multichain account group index.\n */\n get groupIndex(): number {\n return this.#groupIndex;\n }\n\n /**\n * Checks if there's any underlying accounts for this multichain accounts.\n *\n * @returns True if there's any underlying accounts, false otherwise.\n */\n hasAccounts(): boolean {\n // If there's anything in the reverse-map, it means we have some accounts.\n return this.#accountToProvider.size > 0;\n }\n\n /**\n * Gets the accounts for this multichain account.\n *\n * @returns The accounts.\n */\n getAccounts(): Account[] {\n const allAccounts: Account[] = [];\n\n for (const [provider, accounts] of this.#providerToAccounts.entries()) {\n for (const id of accounts) {\n const account = provider.getAccount(id);\n\n if (account) {\n // If for some reason we cannot get this account from the provider, it\n // might means it has been deleted or something, so we just filter it\n // out.\n allAccounts.push(account);\n }\n }\n }\n\n return allAccounts;\n }\n\n /**\n * Gets the account IDs for this multichain account.\n *\n * @returns The account IDs.\n */\n getAccountIds(): Account['id'][] {\n return [...this.#accountToProvider.keys()];\n }\n\n /**\n * Gets the account for a given account ID.\n *\n * @param id - Account ID.\n * @returns The account or undefined if not found.\n */\n getAccount(id: Account['id']): Account | undefined {\n const provider = this.#accountToProvider.get(id);\n\n // If there's nothing in the map, it means we tried to get an account\n // that does not belong to this multichain account.\n if (!provider) {\n return undefined;\n }\n\n return provider.getAccount(id);\n }\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined {\n return selectOne(this.getAccounts(), selector);\n }\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[] {\n return select(this.getAccounts(), selector);\n }\n\n /**\n * Check whether every provider has an aligned account in this group.\n *\n * A group is aligned when every registered provider reports that the\n * account IDs it contributed to this group are non-empty and owned by it.\n * Disabled {@link AccountProviderWrapper} instances always report `true`.\n *\n * @returns `true` when all providers are aligned for this group.\n */\n isAligned(): boolean {\n return this.#providers.every((provider) =>\n provider.isAligned(\n {\n entropySource: this.#wallet.entropySource,\n groupIndex: this.#groupIndex,\n },\n this.#providerToAccounts.get(provider) ?? [],\n ),\n );\n }\n}\n"]}
@@ -95,5 +95,15 @@ export declare class MultichainAccountGroup<Account extends Bip44Account<Keyring
95
95
  * @returns The accounts matching the selector.
96
96
  */
97
97
  select(selector: AccountSelector<Account>): Account[];
98
+ /**
99
+ * Check whether every provider has an aligned account in this group.
100
+ *
101
+ * A group is aligned when every registered provider reports that the
102
+ * account IDs it contributed to this group are non-empty and owned by it.
103
+ * Disabled {@link AccountProviderWrapper} instances always report `true`.
104
+ *
105
+ * @returns `true` when all providers are aligned for this group.
106
+ */
107
+ isAligned(): boolean;
98
108
  }
99
109
  //# sourceMappingURL=MultichainAccountGroup.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountGroup.d.cts","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqB,8BAA8B;AAE5E,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,IAAI,gCAAgC,EAC3D,8BAA8B;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAI5D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,uCAAmC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAkC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAAoB;AACxD,OAAO,KAAK,EAAE,iCAAiC,EAAE,oBAAgB;AAEjE,MAAM,MAAM,UAAU,GACpB,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAEpE;;GAEG;AACH,qBAAa,sBAAsB,CACjC,OAAO,SAAS,YAAY,CAAC,cAAc,CAAC,CAC5C,YAAW,gCAAgC,CAAC,OAAO,CAAC;;gBAyBxC,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GACV,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACzC,SAAS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AC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,SAAS;IAYlD;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS;IAI5D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIrD;;;;;;;;OAQG;IACH,SAAS,IAAI,OAAO;CAWrB"}
@@ -95,5 +95,15 @@ export declare class MultichainAccountGroup<Account extends Bip44Account<Keyring
95
95
  * @returns The accounts matching the selector.
96
96
  */
97
97
  select(selector: AccountSelector<Account>): Account[];
98
+ /**
99
+ * Check whether every provider has an aligned account in this group.
100
+ *
101
+ * A group is aligned when every registered provider reports that the
102
+ * account IDs it contributed to this group are non-empty and owned by it.
103
+ * Disabled {@link AccountProviderWrapper} instances always report `true`.
104
+ *
105
+ * @returns `true` when all providers are aligned for this group.
106
+ */
107
+ isAligned(): boolean;
98
108
  }
99
109
  //# sourceMappingURL=MultichainAccountGroup.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountGroup.d.mts","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqB,8BAA8B;AAE5E,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,IAAI,gCAAgC,EAC3D,8BAA8B;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,8BAA8B;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,8BAA8B;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,8BAA8B;AAI5D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,uCAAmC;AAC1E,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAkC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAAoB;AACxD,OAAO,KAAK,EAAE,iCAAiC,EAAE,oBAAg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IAAI,wBAAwB,CAEjC;IAED;;;;OAIG;IACH,IAAI,IAAI,IAAI,gBAAgB,CAAC,iBAAiB,CAE7C;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAE7C;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAKtB;;;;OAIG;IACH,WAAW,IAAI,OAAO,EAAE;IAmBxB;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;IAIhC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,SAAS;IAYlD;;;;;;OAMG;IACH,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,SAAS;IAI5D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,EAAE;IAIrD;;;;;;;;OAQG;IACH,SAAS,IAAI,OAAO;CAWrB"}
@@ -164,6 +164,21 @@ export class MultichainAccountGroup {
164
164
  select(selector) {
165
165
  return select(this.getAccounts(), selector);
166
166
  }
167
+ /**
168
+ * Check whether every provider has an aligned account in this group.
169
+ *
170
+ * A group is aligned when every registered provider reports that the
171
+ * account IDs it contributed to this group are non-empty and owned by it.
172
+ * Disabled {@link AccountProviderWrapper} instances always report `true`.
173
+ *
174
+ * @returns `true` when all providers are aligned for this group.
175
+ */
176
+ isAligned() {
177
+ return __classPrivateFieldGet(this, _MultichainAccountGroup_providers, "f").every((provider) => provider.isAligned({
178
+ entropySource: __classPrivateFieldGet(this, _MultichainAccountGroup_wallet, "f").entropySource,
179
+ groupIndex: __classPrivateFieldGet(this, _MultichainAccountGroup_groupIndex, "f"),
180
+ }, __classPrivateFieldGet(this, _MultichainAccountGroup_providerToAccounts, "f").get(provider) ?? []));
181
+ }
167
182
  }
168
183
  _MultichainAccountGroup_id = new WeakMap(), _MultichainAccountGroup_wallet = new WeakMap(), _MultichainAccountGroup_groupIndex = new WeakMap(), _MultichainAccountGroup_providers = new WeakMap(), _MultichainAccountGroup_providerToAccounts = new WeakMap(), _MultichainAccountGroup_accountToProvider = new WeakMap(), _MultichainAccountGroup_messenger = new WeakMap(), _MultichainAccountGroup_log = new WeakMap(), _MultichainAccountGroup_initialized = new WeakMap(), _MultichainAccountGroup_instances = new WeakSet(), _MultichainAccountGroup_clearAccountToProviderState = function _MultichainAccountGroup_clearAccountToProviderState(provider) {
169
184
  __classPrivateFieldGet(this, _MultichainAccountGroup_accountToProvider, "f").forEach((accountProvider, id) => {
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountGroup.mjs","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,8BAA8B;AAC5E,OAAO,EAAE,0BAA0B,EAAE,8BAA8B;AAUnE,OAAO,EAAE,aAAa,IAAI,GAAG,EAAE,kBAAkB,EAAE,qBAAiB;AASpE;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA2BjC,YAAY,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GAMV;;QAlCQ,6CAA8B;QAE9B,iDAA0C;QAE1C,qDAAoB;QAEpB,oDAA4C;QAE5C,6DAGP;QAEO,4DAGP;QAEO,oDAA8C;QAE9C,8CAAa;QAEtB,8CAAe,KAAK,EAAC;QAanB,uBAAA,IAAI,8BAAO,0BAA0B,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,MAAA,CAAC;QAC7D,uBAAA,IAAI,sCAAe,UAAU,MAAA,CAAC;QAC9B,uBAAA,IAAI,kCAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,qCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,qCAAc,SAAS,MAAA,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AE,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF;qnBAhL8B,QAAuC;IAClE,uBAAA,IAAI,iDAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE;QACtD,IAAI,eAAe,KAAK,QAAQ,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,+EAOS,UAAsB;IAC9B,KAAK,MAAM,QAAQ,IAAI,uBAAA,IAAI,yCAAW,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,8FAA6B,MAAjC,IAAI,EAA8B,QAAQ,CAAC,CAAC;YAC5C,uBAAA,IAAI,kDAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAEnD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,uBAAA,IAAI,iDAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { AccountGroupType, select, selectOne } from '@metamask/account-api';\nimport { toMultichainAccountGroupId } from '@metamask/account-api';\nimport type {\n MultichainAccountGroupId,\n MultichainAccountGroup as MultichainAccountGroupDefinition,\n} from '@metamask/account-api';\nimport type { Bip44Account } from '@metamask/account-api';\nimport type { AccountSelector } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Logger } from './logger';\nimport { projectLogger as log, createModuleLogger } from './logger';\nimport type { ServiceState, StateKeys } from './MultichainAccountService';\nimport type { MultichainAccountWallet } from './MultichainAccountWallet';\nimport type { Bip44AccountProvider } from './providers';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport type GroupState =\n ServiceState[StateKeys['entropySource']][StateKeys['groupIndex']];\n\n/**\n * A multichain account group that holds multiple accounts.\n */\nexport class MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountGroupDefinition<Account> {\n readonly #id: MultichainAccountGroupId;\n\n readonly #wallet: MultichainAccountWallet<Account>;\n\n readonly #groupIndex: number;\n\n readonly #providers: Bip44AccountProvider<Account>[];\n\n readonly #providerToAccounts: Map<\n Bip44AccountProvider<Account>,\n Account['id'][]\n >;\n\n readonly #accountToProvider: Map<\n Account['id'],\n Bip44AccountProvider<Account>\n >;\n\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #log: Logger;\n\n #initialized = false;\n\n constructor({\n groupIndex,\n wallet,\n providers,\n messenger,\n }: {\n groupIndex: number;\n wallet: MultichainAccountWallet<Account>;\n providers: Bip44AccountProvider<Account>[];\n messenger: MultichainAccountServiceMessenger;\n }) {\n this.#id = toMultichainAccountGroupId(wallet.id, groupIndex);\n this.#groupIndex = groupIndex;\n this.#wallet = wallet;\n this.#providers = providers;\n this.#messenger = messenger;\n this.#providerToAccounts = new Map();\n this.#accountToProvider = new Map();\n\n this.#log = createModuleLogger(log, `[${this.#id}]`);\n }\n\n /**\n * Clear the account to provider state for a given provider.\n *\n * @param provider - The provider to clear the account to provider state for.\n */\n #clearAccountToProviderState(provider: Bip44AccountProvider<Account>): void {\n this.#accountToProvider.forEach((accountProvider, id) => {\n if (accountProvider === provider) {\n this.#accountToProvider.delete(id);\n }\n });\n }\n\n /**\n * Update the internal representation of accounts with the given group state.\n *\n * @param groupState - The group state.\n */\n #setState(groupState: GroupState): void {\n for (const provider of this.#providers) {\n const accountIds = groupState[provider.getName()];\n\n if (accountIds) {\n this.#clearAccountToProviderState(provider);\n this.#providerToAccounts.set(provider, accountIds);\n\n for (const accountId of accountIds) {\n this.#accountToProvider.set(accountId, provider);\n }\n }\n }\n }\n\n /**\n * Initialize the multichain account group and construct the internal representation of accounts.\n *\n * @param groupState - The group state.\n */\n init(groupState: GroupState): void {\n this.#log('Initializing group state...');\n this.#setState(groupState);\n this.#log('Finished initializing group state...');\n\n this.#initialized = true;\n }\n\n /**\n * Update the group state.\n *\n * @param groupState - The group state.\n */\n update(groupState: GroupState): void {\n this.#log('Updating group state...');\n this.#setState(groupState);\n this.#log('Finished updating group state...');\n\n if (this.#initialized) {\n this.#messenger.publish(\n 'MultichainAccountService:multichainAccountGroupUpdated',\n this,\n );\n }\n }\n\n /**\n * Gets the multichain account group ID.\n *\n * @returns The multichain account group ID.\n */\n get id(): MultichainAccountGroupId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account group type.\n *\n * @returns The multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount {\n return AccountGroupType.MultichainAccount;\n }\n\n /**\n * Gets the multichain account's wallet reference (parent).\n *\n * @returns The multichain account's wallet.\n */\n get wallet(): MultichainAccountWallet<Account> {\n return this.#wallet;\n }\n\n /**\n * Gets the multichain account group index.\n *\n * @returns The multichain account group index.\n */\n get groupIndex(): number {\n return this.#groupIndex;\n }\n\n /**\n * Checks if there's any underlying accounts for this multichain accounts.\n *\n * @returns True if there's any underlying accounts, false otherwise.\n */\n hasAccounts(): boolean {\n // If there's anything in the reverse-map, it means we have some accounts.\n return this.#accountToProvider.size > 0;\n }\n\n /**\n * Gets the accounts for this multichain account.\n *\n * @returns The accounts.\n */\n getAccounts(): Account[] {\n const allAccounts: Account[] = [];\n\n for (const [provider, accounts] of this.#providerToAccounts.entries()) {\n for (const id of accounts) {\n const account = provider.getAccount(id);\n\n if (account) {\n // If for some reason we cannot get this account from the provider, it\n // might means it has been deleted or something, so we just filter it\n // out.\n allAccounts.push(account);\n }\n }\n }\n\n return allAccounts;\n }\n\n /**\n * Gets the account IDs for this multichain account.\n *\n * @returns The account IDs.\n */\n getAccountIds(): Account['id'][] {\n return [...this.#accountToProvider.keys()];\n }\n\n /**\n * Gets the account for a given account ID.\n *\n * @param id - Account ID.\n * @returns The account or undefined if not found.\n */\n getAccount(id: Account['id']): Account | undefined {\n const provider = this.#accountToProvider.get(id);\n\n // If there's nothing in the map, it means we tried to get an account\n // that does not belong to this multichain account.\n if (!provider) {\n return undefined;\n }\n\n return provider.getAccount(id);\n }\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined {\n return selectOne(this.getAccounts(), selector);\n }\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[] {\n return select(this.getAccounts(), selector);\n }\n}\n"]}
1
+ {"version":3,"file":"MultichainAccountGroup.mjs","sourceRoot":"","sources":["../src/MultichainAccountGroup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,8BAA8B;AAC5E,OAAO,EAAE,0BAA0B,EAAE,8BAA8B;AAUnE,OAAO,EAAE,aAAa,IAAI,GAAG,EAAE,kBAAkB,EAAE,qBAAiB;AASpE;;GAEG;AACH,MAAM,OAAO,sBAAsB;IA2BjC,YAAY,EACV,UAAU,EACV,MAAM,EACN,SAAS,EACT,SAAS,GAMV;;QAlCQ,6CAA8B;QAE9B,iDAA0C;QAE1C,qDAAoB;QAEpB,oDAA4C;QAE5C,6DAGP;QAEO,4DAGP;QAEO,oDAA8C;QAE9C,8CAAa;QAEtB,8CAAe,KAAK,EAAC;QAanB,uBAAA,IAAI,8BAAO,0BAA0B,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,MAAA,CAAC;QAC7D,uBAAA,IAAI,sCAAe,UAAU,MAAA,CAAC;QAC9B,uBAAA,IAAI,kCAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,qCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,qCAAc,SAAS,MAAA,CAAC;QAC5B,uBAAA,IAAI,8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C,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS;QACP,OAAO,uBAAA,IAAI,yCAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,CACxC,QAAQ,CAAC,SAAS,CAChB;YACE,aAAa,EAAE,uBAAA,IAAI,sCAAQ,CAAC,aAAa;YACzC,UAAU,EAAE,uBAAA,IAAI,0CAAY;SAC7B,EACD,uBAAA,IAAI,kDAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAC7C,CACF,CAAC;IACJ,CAAC;CACF;qnBArM8B,QAAuC;IAClE,uBAAA,IAAI,iDAAmB,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE;QACtD,IAAI,eAAe,KAAK,QAAQ,EAAE,CAAC;YACjC,uBAAA,IAAI,iDAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,+EAOS,UAAsB;IAC9B,KAAK,MAAM,QAAQ,IAAI,uBAAA,IAAI,yCAAW,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACf,uBAAA,IAAI,8FAA6B,MAAjC,IAAI,EAA8B,QAAQ,CAAC,CAAC;YAC5C,uBAAA,IAAI,kDAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAEnD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,uBAAA,IAAI,iDAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { AccountGroupType, select, selectOne } from '@metamask/account-api';\nimport { toMultichainAccountGroupId } from '@metamask/account-api';\nimport type {\n MultichainAccountGroupId,\n MultichainAccountGroup as MultichainAccountGroupDefinition,\n} from '@metamask/account-api';\nimport type { Bip44Account } from '@metamask/account-api';\nimport type { AccountSelector } from '@metamask/account-api';\nimport type { KeyringAccount } from '@metamask/keyring-api';\n\nimport type { Logger } from './logger';\nimport { projectLogger as log, createModuleLogger } from './logger';\nimport type { ServiceState, StateKeys } from './MultichainAccountService';\nimport type { MultichainAccountWallet } from './MultichainAccountWallet';\nimport type { Bip44AccountProvider } from './providers';\nimport type { MultichainAccountServiceMessenger } from './types';\n\nexport type GroupState =\n ServiceState[StateKeys['entropySource']][StateKeys['groupIndex']];\n\n/**\n * A multichain account group that holds multiple accounts.\n */\nexport class MultichainAccountGroup<\n Account extends Bip44Account<KeyringAccount>,\n> implements MultichainAccountGroupDefinition<Account> {\n readonly #id: MultichainAccountGroupId;\n\n readonly #wallet: MultichainAccountWallet<Account>;\n\n readonly #groupIndex: number;\n\n readonly #providers: Bip44AccountProvider<Account>[];\n\n readonly #providerToAccounts: Map<\n Bip44AccountProvider<Account>,\n Account['id'][]\n >;\n\n readonly #accountToProvider: Map<\n Account['id'],\n Bip44AccountProvider<Account>\n >;\n\n readonly #messenger: MultichainAccountServiceMessenger;\n\n readonly #log: Logger;\n\n #initialized = false;\n\n constructor({\n groupIndex,\n wallet,\n providers,\n messenger,\n }: {\n groupIndex: number;\n wallet: MultichainAccountWallet<Account>;\n providers: Bip44AccountProvider<Account>[];\n messenger: MultichainAccountServiceMessenger;\n }) {\n this.#id = toMultichainAccountGroupId(wallet.id, groupIndex);\n this.#groupIndex = groupIndex;\n this.#wallet = wallet;\n this.#providers = providers;\n this.#messenger = messenger;\n this.#providerToAccounts = new Map();\n this.#accountToProvider = new Map();\n\n this.#log = createModuleLogger(log, `[${this.#id}]`);\n }\n\n /**\n * Clear the account to provider state for a given provider.\n *\n * @param provider - The provider to clear the account to provider state for.\n */\n #clearAccountToProviderState(provider: Bip44AccountProvider<Account>): void {\n this.#accountToProvider.forEach((accountProvider, id) => {\n if (accountProvider === provider) {\n this.#accountToProvider.delete(id);\n }\n });\n }\n\n /**\n * Update the internal representation of accounts with the given group state.\n *\n * @param groupState - The group state.\n */\n #setState(groupState: GroupState): void {\n for (const provider of this.#providers) {\n const accountIds = groupState[provider.getName()];\n\n if (accountIds) {\n this.#clearAccountToProviderState(provider);\n this.#providerToAccounts.set(provider, accountIds);\n\n for (const accountId of accountIds) {\n this.#accountToProvider.set(accountId, provider);\n }\n }\n }\n }\n\n /**\n * Initialize the multichain account group and construct the internal representation of accounts.\n *\n * @param groupState - The group state.\n */\n init(groupState: GroupState): void {\n this.#log('Initializing group state...');\n this.#setState(groupState);\n this.#log('Finished initializing group state...');\n\n this.#initialized = true;\n }\n\n /**\n * Update the group state.\n *\n * @param groupState - The group state.\n */\n update(groupState: GroupState): void {\n this.#log('Updating group state...');\n this.#setState(groupState);\n this.#log('Finished updating group state...');\n\n if (this.#initialized) {\n this.#messenger.publish(\n 'MultichainAccountService:multichainAccountGroupUpdated',\n this,\n );\n }\n }\n\n /**\n * Gets the multichain account group ID.\n *\n * @returns The multichain account group ID.\n */\n get id(): MultichainAccountGroupId {\n return this.#id;\n }\n\n /**\n * Gets the multichain account group type.\n *\n * @returns The multichain account type.\n */\n get type(): AccountGroupType.MultichainAccount {\n return AccountGroupType.MultichainAccount;\n }\n\n /**\n * Gets the multichain account's wallet reference (parent).\n *\n * @returns The multichain account's wallet.\n */\n get wallet(): MultichainAccountWallet<Account> {\n return this.#wallet;\n }\n\n /**\n * Gets the multichain account group index.\n *\n * @returns The multichain account group index.\n */\n get groupIndex(): number {\n return this.#groupIndex;\n }\n\n /**\n * Checks if there's any underlying accounts for this multichain accounts.\n *\n * @returns True if there's any underlying accounts, false otherwise.\n */\n hasAccounts(): boolean {\n // If there's anything in the reverse-map, it means we have some accounts.\n return this.#accountToProvider.size > 0;\n }\n\n /**\n * Gets the accounts for this multichain account.\n *\n * @returns The accounts.\n */\n getAccounts(): Account[] {\n const allAccounts: Account[] = [];\n\n for (const [provider, accounts] of this.#providerToAccounts.entries()) {\n for (const id of accounts) {\n const account = provider.getAccount(id);\n\n if (account) {\n // If for some reason we cannot get this account from the provider, it\n // might means it has been deleted or something, so we just filter it\n // out.\n allAccounts.push(account);\n }\n }\n }\n\n return allAccounts;\n }\n\n /**\n * Gets the account IDs for this multichain account.\n *\n * @returns The account IDs.\n */\n getAccountIds(): Account['id'][] {\n return [...this.#accountToProvider.keys()];\n }\n\n /**\n * Gets the account for a given account ID.\n *\n * @param id - Account ID.\n * @returns The account or undefined if not found.\n */\n getAccount(id: Account['id']): Account | undefined {\n const provider = this.#accountToProvider.get(id);\n\n // If there's nothing in the map, it means we tried to get an account\n // that does not belong to this multichain account.\n if (!provider) {\n return undefined;\n }\n\n return provider.getAccount(id);\n }\n\n /**\n * Query an account matching the selector.\n *\n * @param selector - Query selector.\n * @returns The account matching the selector or undefined if not matching.\n * @throws If multiple accounts match the selector.\n */\n get(selector: AccountSelector<Account>): Account | undefined {\n return selectOne(this.getAccounts(), selector);\n }\n\n /**\n * Query accounts matching the selector.\n *\n * @param selector - Query selector.\n * @returns The accounts matching the selector.\n */\n select(selector: AccountSelector<Account>): Account[] {\n return select(this.getAccounts(), selector);\n }\n\n /**\n * Check whether every provider has an aligned account in this group.\n *\n * A group is aligned when every registered provider reports that the\n * account IDs it contributed to this group are non-empty and owned by it.\n * Disabled {@link AccountProviderWrapper} instances always report `true`.\n *\n * @returns `true` when all providers are aligned for this group.\n */\n isAligned(): boolean {\n return this.#providers.every((provider) =>\n provider.isAligned(\n {\n entropySource: this.#wallet.entropySource,\n groupIndex: this.#groupIndex,\n },\n this.#providerToAccounts.get(provider) ?? [],\n ),\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountService-method-action-types.cjs","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MultichainAccountService } from './MultichainAccountService';\n\n/**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\nexport type MultichainAccountServiceInitAction = {\n type: `MultichainAccountService:init`;\n handler: MultichainAccountService['init'];\n};\n\n/**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n *\n * READ THIS CAREFULLY (State inconsistency bugs/de-sync)\n * We've seen some problems were keyring accounts on some Snaps were not synchronized\n * with the accounts on MM side. This causes problems where we cannot interact with\n * those accounts because the Snap does know about them.\n * To \"workaround\" this de-sync problem for now, we make sure that both parties are\n * in-sync when the service boots up.\n * ----------------------------------------------------------------------------------\n */\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `MultichainAccountService:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\n/**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `MultichainAccountService:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\n/**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `MultichainAccountService:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\n/**\n * Creates a new multichain account wallet by either importing an existing mnemonic,\n * creating a new vault and keychain, or restoring a vault and keyring.\n *\n * NOTE: This method should only be called in client code where a mutex lock is acquired.\n * `discoverAccounts` should be called after this method to discover and create accounts.\n *\n * @param params - The parameters to use to create the new wallet.\n * @param params.mnemonic - The mnemonic to use to create the new wallet.\n * @param params.password - The password to encrypt the vault with.\n * @param params.type - The flow type to use to create the new wallet.\n * @throws If the mnemonic has already been imported.\n * @returns The new multichain account wallet.\n */\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `MultichainAccountService:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\n/**\n * Removes a multichain account wallet.\n *\n * NOTE: This method should only be called in client code as a revert mechanism.\n * At the point that this code is called, discovery shouldn't have been triggered.\n * This is meant to be used in the scenario where a seed phrase backup is not successful.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n * @param accountAddress - The address of the account to remove.\n * @returns The removed multichain account wallet.\n */\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `MultichainAccountService:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\n/**\n * Gets a reference to the multichain account group matching this entropy source\n * and a group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `MultichainAccountService:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\n/**\n * Gets all multichain account groups for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `MultichainAccountService:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\n/**\n * Creates the next multichain account group.\n *\n * @param options - Options.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The next multichain account group.\n */\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `MultichainAccountService:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\n/**\n * Creates a multichain account group.\n *\n * @param options - Options.\n * @param options.groupIndex - The group index to use.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The multichain account group for this group index.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `MultichainAccountService:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\n/**\n * Creates multiple multichain account groups up to maxGroupIndex.\n *\n * @param params - Parameters for creating account groups.\n * @param params.fromGroupIndex - Starting group index to create (inclusive) (defaults to 0).\n * @param params.toGroupIndex - Maximum group index to create (inclusive).\n * @param params.entropySource - The entropy source ID.\n * @returns Array of created multichain account groups.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupsAction = {\n type: `MultichainAccountService:createMultichainAccountGroups`;\n handler: MultichainAccountService['createMultichainAccountGroups'];\n};\n\n/**\n * Set basic functionality state and trigger alignment if enabled.\n * When basic functionality is disabled, snap-based providers are disabled.\n * When enabled, all snap providers are enabled and wallet alignment is triggered.\n * EVM providers are never disabled as they're required for basic wallet functionality.\n *\n * @param enabled - Whether basic functionality is enabled.\n */\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `MultichainAccountService:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\n/**\n * Align all multichain account wallets.\n */\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `MultichainAccountService:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\n/**\n * Align a specific multichain account wallet.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `MultichainAccountService:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\n/**\n * Union of all MultichainAccountService action types.\n */\nexport type MultichainAccountServiceMethodActions =\n | MultichainAccountServiceInitAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupsAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceAlignWalletAction;\n"]}
1
+ {"version":3,"file":"MultichainAccountService-method-action-types.cjs","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MultichainAccountService } from './MultichainAccountService';\n\n/**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\nexport type MultichainAccountServiceInitAction = {\n type: `MultichainAccountService:init`;\n handler: MultichainAccountService['init'];\n};\n\n/**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n *\n * READ THIS CAREFULLY (State inconsistency bugs/de-sync)\n * We've seen some problems were keyring accounts on some Snaps were not synchronized\n * with the accounts on MM side. This causes problems where we cannot interact with\n * those accounts because the Snap does know about them.\n * To \"workaround\" this de-sync problem for now, we make sure that both parties are\n * in-sync when the service boots up.\n * ----------------------------------------------------------------------------------\n */\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `MultichainAccountService:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\n/**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `MultichainAccountService:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\n/**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `MultichainAccountService:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\n/**\n * Creates a new multichain account wallet by either importing an existing mnemonic,\n * creating a new vault and keychain, or restoring a vault and keyring.\n *\n * NOTE: This method should only be called in client code where a mutex lock is acquired.\n * `discoverAccounts` should be called after this method to discover and create accounts.\n *\n * @param params - The parameters to use to create the new wallet.\n * @param params.mnemonic - The mnemonic to use to create the new wallet.\n * @param params.password - The password to encrypt the vault with.\n * @param params.type - The flow type to use to create the new wallet.\n * @throws If the mnemonic has already been imported.\n * @returns The new multichain account wallet.\n */\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `MultichainAccountService:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\n/**\n * Removes a multichain account wallet, deleting all of its accounts across\n * every registered provider (EVM and snap-based).\n *\n * The deletion iterates providers (the source of truth for their own\n * account lists) and filters each provider's accounts to those matching\n * the wallet's entropy source. Cleanup is best-effort end-to-end: neither\n * a single account deletion failure nor a failure to enumerate a given\n * provider's accounts aborts cleanup of the remaining providers. If one or\n * more operations fail, a single aggregated error is reported via\n * `reportError` with all per-failure details in its context. The wallet is\n * always removed from the service's internal map at the end.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `MultichainAccountService:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\n/**\n * Gets a reference to the multichain account group matching this entropy source\n * and a group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `MultichainAccountService:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\n/**\n * Gets all multichain account groups for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `MultichainAccountService:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\n/**\n * Creates the next multichain account group.\n *\n * @param options - Options.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The next multichain account group.\n */\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `MultichainAccountService:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\n/**\n * Creates a multichain account group.\n *\n * @param options - Options.\n * @param options.groupIndex - The group index to use.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The multichain account group for this group index.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `MultichainAccountService:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\n/**\n * Creates multiple multichain account groups up to maxGroupIndex.\n *\n * @param params - Parameters for creating account groups.\n * @param params.fromGroupIndex - Starting group index to create (inclusive) (defaults to 0).\n * @param params.toGroupIndex - Maximum group index to create (inclusive).\n * @param params.entropySource - The entropy source ID.\n * @returns Array of created multichain account groups.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupsAction = {\n type: `MultichainAccountService:createMultichainAccountGroups`;\n handler: MultichainAccountService['createMultichainAccountGroups'];\n};\n\n/**\n * Set basic functionality state and trigger alignment if enabled.\n * When basic functionality is disabled, snap-based providers are disabled.\n * When enabled, all snap providers are enabled and wallet alignment is triggered.\n * EVM providers are never disabled as they're required for basic wallet functionality.\n *\n * @param enabled - Whether basic functionality is enabled.\n */\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `MultichainAccountService:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\n/**\n * Align all multichain account wallets.\n */\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `MultichainAccountService:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\n/**\n * Align a specific multichain account wallet.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `MultichainAccountService:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\n/**\n * Union of all MultichainAccountService action types.\n */\nexport type MultichainAccountServiceMethodActions =\n | MultichainAccountServiceInitAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupsAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceAlignWalletAction;\n"]}
@@ -70,15 +70,19 @@ export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
70
70
  handler: MultichainAccountService['createMultichainAccountWallet'];
71
71
  };
72
72
  /**
73
- * Removes a multichain account wallet.
73
+ * Removes a multichain account wallet, deleting all of its accounts across
74
+ * every registered provider (EVM and snap-based).
74
75
  *
75
- * NOTE: This method should only be called in client code as a revert mechanism.
76
- * At the point that this code is called, discovery shouldn't have been triggered.
77
- * This is meant to be used in the scenario where a seed phrase backup is not successful.
76
+ * The deletion iterates providers (the source of truth for their own
77
+ * account lists) and filters each provider's accounts to those matching
78
+ * the wallet's entropy source. Cleanup is best-effort end-to-end: neither
79
+ * a single account deletion failure nor a failure to enumerate a given
80
+ * provider's accounts aborts cleanup of the remaining providers. If one or
81
+ * more operations fail, a single aggregated error is reported via
82
+ * `reportError` with all per-failure details in its context. The wallet is
83
+ * always removed from the service's internal map at the end.
78
84
  *
79
85
  * @param entropySource - The entropy source of the multichain account wallet.
80
- * @param accountAddress - The address of the account to remove.
81
- * @returns The removed multichain account wallet.
82
86
  */
83
87
  export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
84
88
  type: `MultichainAccountService:removeMultichainAccountWallet`;
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountService-method-action-types.d.cts","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,qDAAqD,CAAC;IAC5D,OAAO,EAAE,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;CACjE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,wBAAwB,CAAC,6BAA6B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,wBAAwB,CAAC,+BAA+B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,2DAA2D,G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,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,kCAAkC,GAClC,4CAA4C,GAC5C,wDAAwD,GACxD,yDAAyD,GACzD,2DAA2D,GAC3D,2DAA2D,GAC3D,uDAAuD,GACvD,wDAAwD,GACxD,8DAA8D,GAC9D,0DAA0D,GAC1D,2DAA2D,GAC3D,mDAAmD,GACnD,0CAA0C,GAC1C,yCAAyC,CAAC"}
1
+ {"version":3,"file":"MultichainAccountService-method-action-types.d.cts","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;;GAGG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wDAAwD,GAAG;IACrE,IAAI,EAAE,qDAAqD,CAAC;IAC5D,OAAO,EAAE,wBAAwB,CAAC,4BAA4B,CAAC,CAAC;CACjE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,wBAAwB,CAAC,6BAA6B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,wBAAwB,CAAC,+BAA+B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;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tD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,kCAAkC,GAClC,4CAA4C,GAC5C,wDAAwD,GACxD,yDAAyD,GACzD,2DAA2D,GAC3D,2DAA2D,GAC3D,uDAAuD,GACvD,wDAAwD,GACxD,8DAA8D,GAC9D,0DAA0D,GAC1D,2DAA2D,GAC3D,mDAAmD,GACnD,0CAA0C,GAC1C,yCAAyC,CAAC"}
@@ -70,15 +70,19 @@ export type MultichainAccountServiceCreateMultichainAccountWalletAction = {
70
70
  handler: MultichainAccountService['createMultichainAccountWallet'];
71
71
  };
72
72
  /**
73
- * Removes a multichain account wallet.
73
+ * Removes a multichain account wallet, deleting all of its accounts across
74
+ * every registered provider (EVM and snap-based).
74
75
  *
75
- * NOTE: This method should only be called in client code as a revert mechanism.
76
- * At the point that this code is called, discovery shouldn't have been triggered.
77
- * This is meant to be used in the scenario where a seed phrase backup is not successful.
76
+ * The deletion iterates providers (the source of truth for their own
77
+ * account lists) and filters each provider's accounts to those matching
78
+ * the wallet's entropy source. Cleanup is best-effort end-to-end: neither
79
+ * a single account deletion failure nor a failure to enumerate a given
80
+ * provider's accounts aborts cleanup of the remaining providers. If one or
81
+ * more operations fail, a single aggregated error is reported via
82
+ * `reportError` with all per-failure details in its context. The wallet is
83
+ * always removed from the service's internal map at the end.
78
84
  *
79
85
  * @param entropySource - The entropy source of the multichain account wallet.
80
- * @param accountAddress - The address of the account to remove.
81
- * @returns The removed multichain account wallet.
82
86
  */
83
87
  export type MultichainAccountServiceRemoveMultichainAccountWalletAction = {
84
88
  type: `MultichainAccountService:removeMultichainAccountWallet`;
@@ -1 +1 @@
1
- {"version":3,"file":"MultichainAccountService-method-action-types.d.mts","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,E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AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,wBAAwB,CAAC,kCAAkC,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,0DAA0D,GAAG;IACvE,IAAI,EAAE,uDAAuD,CAAC;IAC9D,OAAO,EAAE,wBAAwB,CAAC,8BAA8B,CAAC,CAAC;CACnE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,wBAAwB,CAAC,+BAA+B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,wBAAwB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC;CACnD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,kCAAkC,GAClC,4CAA4C,GAC5C,wDAAwD,GACxD,yDAAyD,GACzD,2DAA2D,GAC3D,2DAA2D,GAC3D,uDAAuD,GACvD,wDAAwD,GACxD,8DAA8D,GAC9D,0DAA0D,GAC1D,2DAA2D,GAC3D,mDAAmD,GACnD,0CAA0C,GAC1C,yCAAyC,CAAC"}
1
+ {"version":3,"file":"MultichainAccountService-method-action-types.d.mts","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mapp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s","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MultichainAccountService } from './MultichainAccountService';\n\n/**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\nexport type MultichainAccountServiceInitAction = {\n type: `MultichainAccountService:init`;\n handler: MultichainAccountService['init'];\n};\n\n/**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n *\n * READ THIS CAREFULLY (State inconsistency bugs/de-sync)\n * We've seen some problems were keyring accounts on some Snaps were not synchronized\n * with the accounts on MM side. This causes problems where we cannot interact with\n * those accounts because the Snap does know about them.\n * To \"workaround\" this de-sync problem for now, we make sure that both parties are\n * in-sync when the service boots up.\n * ----------------------------------------------------------------------------------\n */\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `MultichainAccountService:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\n/**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `MultichainAccountService:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\n/**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `MultichainAccountService:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\n/**\n * Creates a new multichain account wallet by either importing an existing mnemonic,\n * creating a new vault and keychain, or restoring a vault and keyring.\n *\n * NOTE: This method should only be called in client code where a mutex lock is acquired.\n * `discoverAccounts` should be called after this method to discover and create accounts.\n *\n * @param params - The parameters to use to create the new wallet.\n * @param params.mnemonic - The mnemonic to use to create the new wallet.\n * @param params.password - The password to encrypt the vault with.\n * @param params.type - The flow type to use to create the new wallet.\n * @throws If the mnemonic has already been imported.\n * @returns The new multichain account wallet.\n */\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `MultichainAccountService:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\n/**\n * Removes a multichain account wallet.\n *\n * NOTE: This method should only be called in client code as a revert mechanism.\n * At the point that this code is called, discovery shouldn't have been triggered.\n * This is meant to be used in the scenario where a seed phrase backup is not successful.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n * @param accountAddress - The address of the account to remove.\n * @returns The removed multichain account wallet.\n */\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `MultichainAccountService:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\n/**\n * Gets a reference to the multichain account group matching this entropy source\n * and a group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `MultichainAccountService:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\n/**\n * Gets all multichain account groups for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `MultichainAccountService:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\n/**\n * Creates the next multichain account group.\n *\n * @param options - Options.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The next multichain account group.\n */\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `MultichainAccountService:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\n/**\n * Creates a multichain account group.\n *\n * @param options - Options.\n * @param options.groupIndex - The group index to use.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The multichain account group for this group index.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `MultichainAccountService:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\n/**\n * Creates multiple multichain account groups up to maxGroupIndex.\n *\n * @param params - Parameters for creating account groups.\n * @param params.fromGroupIndex - Starting group index to create (inclusive) (defaults to 0).\n * @param params.toGroupIndex - Maximum group index to create (inclusive).\n * @param params.entropySource - The entropy source ID.\n * @returns Array of created multichain account groups.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupsAction = {\n type: `MultichainAccountService:createMultichainAccountGroups`;\n handler: MultichainAccountService['createMultichainAccountGroups'];\n};\n\n/**\n * Set basic functionality state and trigger alignment if enabled.\n * When basic functionality is disabled, snap-based providers are disabled.\n * When enabled, all snap providers are enabled and wallet alignment is triggered.\n * EVM providers are never disabled as they're required for basic wallet functionality.\n *\n * @param enabled - Whether basic functionality is enabled.\n */\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `MultichainAccountService:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\n/**\n * Align all multichain account wallets.\n */\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `MultichainAccountService:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\n/**\n * Align a specific multichain account wallet.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `MultichainAccountService:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\n/**\n * Union of all MultichainAccountService action types.\n */\nexport type MultichainAccountServiceMethodActions =\n | MultichainAccountServiceInitAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupsAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceAlignWalletAction;\n"]}
1
+ {"version":3,"file":"MultichainAccountService-method-action-types.mjs","sourceRoot":"","sources":["../src/MultichainAccountService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { MultichainAccountService } from './MultichainAccountService';\n\n/**\n * Initialize the service and constructs the internal reprensentation of\n * multichain accounts and wallets.\n */\nexport type MultichainAccountServiceInitAction = {\n type: `MultichainAccountService:init`;\n handler: MultichainAccountService['init'];\n};\n\n/**\n * Re-synchronize MetaMask accounts and the providers accounts if needed.\n *\n * NOTE: This is mostly required if one of the providers (keyrings or Snaps)\n * have different sets of accounts. This method would ensure that both are\n * in-sync and use the same accounts (and same IDs).\n *\n * READ THIS CAREFULLY (State inconsistency bugs/de-sync)\n * We've seen some problems were keyring accounts on some Snaps were not synchronized\n * with the accounts on MM side. This causes problems where we cannot interact with\n * those accounts because the Snap does know about them.\n * To \"workaround\" this de-sync problem for now, we make sure that both parties are\n * in-sync when the service boots up.\n * ----------------------------------------------------------------------------------\n */\nexport type MultichainAccountServiceResyncAccountsAction = {\n type: `MultichainAccountService:resyncAccounts`;\n handler: MultichainAccountService['resyncAccounts'];\n};\n\n/**\n * Gets a reference to the multichain account wallet matching this entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @throws If none multichain account match this entropy.\n * @returns A reference to the multichain account wallet.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletAction = {\n type: `MultichainAccountService:getMultichainAccountWallet`;\n handler: MultichainAccountService['getMultichainAccountWallet'];\n};\n\n/**\n * Gets an array of all multichain account wallets.\n *\n * @returns An array of all multichain account wallets.\n */\nexport type MultichainAccountServiceGetMultichainAccountWalletsAction = {\n type: `MultichainAccountService:getMultichainAccountWallets`;\n handler: MultichainAccountService['getMultichainAccountWallets'];\n};\n\n/**\n * Creates a new multichain account wallet by either importing an existing mnemonic,\n * creating a new vault and keychain, or restoring a vault and keyring.\n *\n * NOTE: This method should only be called in client code where a mutex lock is acquired.\n * `discoverAccounts` should be called after this method to discover and create accounts.\n *\n * @param params - The parameters to use to create the new wallet.\n * @param params.mnemonic - The mnemonic to use to create the new wallet.\n * @param params.password - The password to encrypt the vault with.\n * @param params.type - The flow type to use to create the new wallet.\n * @throws If the mnemonic has already been imported.\n * @returns The new multichain account wallet.\n */\nexport type MultichainAccountServiceCreateMultichainAccountWalletAction = {\n type: `MultichainAccountService:createMultichainAccountWallet`;\n handler: MultichainAccountService['createMultichainAccountWallet'];\n};\n\n/**\n * Removes a multichain account wallet, deleting all of its accounts across\n * every registered provider (EVM and snap-based).\n *\n * The deletion iterates providers (the source of truth for their own\n * account lists) and filters each provider's accounts to those matching\n * the wallet's entropy source. Cleanup is best-effort end-to-end: neither\n * a single account deletion failure nor a failure to enumerate a given\n * provider's accounts aborts cleanup of the remaining providers. If one or\n * more operations fail, a single aggregated error is reported via\n * `reportError` with all per-failure details in its context. The wallet is\n * always removed from the service's internal map at the end.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceRemoveMultichainAccountWalletAction = {\n type: `MultichainAccountService:removeMultichainAccountWallet`;\n handler: MultichainAccountService['removeMultichainAccountWallet'];\n};\n\n/**\n * Gets a reference to the multichain account group matching this entropy source\n * and a group index.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source of the multichain account.\n * @param options.groupIndex - The group index of the multichain account.\n * @throws If none multichain account match this entropy source and group index.\n * @returns A reference to the multichain account.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupAction = {\n type: `MultichainAccountService:getMultichainAccountGroup`;\n handler: MultichainAccountService['getMultichainAccountGroup'];\n};\n\n/**\n * Gets all multichain account groups for a given entropy source.\n *\n * @param options - Options.\n * @param options.entropySource - The entropy source to query.\n * @throws If no multichain accounts match this entropy source.\n * @returns A list of all multichain accounts.\n */\nexport type MultichainAccountServiceGetMultichainAccountGroupsAction = {\n type: `MultichainAccountService:getMultichainAccountGroups`;\n handler: MultichainAccountService['getMultichainAccountGroups'];\n};\n\n/**\n * Creates the next multichain account group.\n *\n * @param options - Options.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The next multichain account group.\n */\nexport type MultichainAccountServiceCreateNextMultichainAccountGroupAction = {\n type: `MultichainAccountService:createNextMultichainAccountGroup`;\n handler: MultichainAccountService['createNextMultichainAccountGroup'];\n};\n\n/**\n * Creates a multichain account group.\n *\n * @param options - Options.\n * @param options.groupIndex - The group index to use.\n * @param options.entropySource - The wallet's entropy source.\n * @returns The multichain account group for this group index.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupAction = {\n type: `MultichainAccountService:createMultichainAccountGroup`;\n handler: MultichainAccountService['createMultichainAccountGroup'];\n};\n\n/**\n * Creates multiple multichain account groups up to maxGroupIndex.\n *\n * @param params - Parameters for creating account groups.\n * @param params.fromGroupIndex - Starting group index to create (inclusive) (defaults to 0).\n * @param params.toGroupIndex - Maximum group index to create (inclusive).\n * @param params.entropySource - The entropy source ID.\n * @returns Array of created multichain account groups.\n */\nexport type MultichainAccountServiceCreateMultichainAccountGroupsAction = {\n type: `MultichainAccountService:createMultichainAccountGroups`;\n handler: MultichainAccountService['createMultichainAccountGroups'];\n};\n\n/**\n * Set basic functionality state and trigger alignment if enabled.\n * When basic functionality is disabled, snap-based providers are disabled.\n * When enabled, all snap providers are enabled and wallet alignment is triggered.\n * EVM providers are never disabled as they're required for basic wallet functionality.\n *\n * @param enabled - Whether basic functionality is enabled.\n */\nexport type MultichainAccountServiceSetBasicFunctionalityAction = {\n type: `MultichainAccountService:setBasicFunctionality`;\n handler: MultichainAccountService['setBasicFunctionality'];\n};\n\n/**\n * Align all multichain account wallets.\n */\nexport type MultichainAccountServiceAlignWalletsAction = {\n type: `MultichainAccountService:alignWallets`;\n handler: MultichainAccountService['alignWallets'];\n};\n\n/**\n * Align a specific multichain account wallet.\n *\n * @param entropySource - The entropy source of the multichain account wallet.\n */\nexport type MultichainAccountServiceAlignWalletAction = {\n type: `MultichainAccountService:alignWallet`;\n handler: MultichainAccountService['alignWallet'];\n};\n\n/**\n * Union of all MultichainAccountService action types.\n */\nexport type MultichainAccountServiceMethodActions =\n | MultichainAccountServiceInitAction\n | MultichainAccountServiceResyncAccountsAction\n | MultichainAccountServiceGetMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountWalletsAction\n | MultichainAccountServiceCreateMultichainAccountWalletAction\n | MultichainAccountServiceRemoveMultichainAccountWalletAction\n | MultichainAccountServiceGetMultichainAccountGroupAction\n | MultichainAccountServiceGetMultichainAccountGroupsAction\n | MultichainAccountServiceCreateNextMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupAction\n | MultichainAccountServiceCreateMultichainAccountGroupsAction\n | MultichainAccountServiceSetBasicFunctionalityAction\n | MultichainAccountServiceAlignWalletsAction\n | MultichainAccountServiceAlignWalletAction;\n"]}
@@ -26,6 +26,7 @@ const AccountProviderWrapper_1 = require("./providers/AccountProviderWrapper.cjs
26
26
  const EvmAccountProvider_1 = require("./providers/EvmAccountProvider.cjs");
27
27
  const SolAccountProvider_1 = require("./providers/SolAccountProvider.cjs");
28
28
  const SolAccountProvider_2 = require("./providers/SolAccountProvider.cjs");
29
+ const utils_2 = require("./utils.cjs");
29
30
  exports.serviceName = 'MultichainAccountService';
30
31
  const MESSENGER_EXPOSED_METHODS = [
31
32
  'getMultichainAccountGroup',
@@ -208,19 +209,77 @@ class MultichainAccountService {
208
209
  return wallet;
209
210
  }
210
211
  /**
211
- * Removes a multichain account wallet.
212
+ * Removes a multichain account wallet, deleting all of its accounts across
213
+ * every registered provider (EVM and snap-based).
212
214
  *
213
- * NOTE: This method should only be called in client code as a revert mechanism.
214
- * At the point that this code is called, discovery shouldn't have been triggered.
215
- * This is meant to be used in the scenario where a seed phrase backup is not successful.
215
+ * The deletion iterates providers (the source of truth for their own
216
+ * account lists) and filters each provider's accounts to those matching
217
+ * the wallet's entropy source. Cleanup is best-effort end-to-end: neither
218
+ * a single account deletion failure nor a failure to enumerate a given
219
+ * provider's accounts aborts cleanup of the remaining providers. If one or
220
+ * more operations fail, a single aggregated error is reported via
221
+ * `reportError` with all per-failure details in its context. The wallet is
222
+ * always removed from the service's internal map at the end.
216
223
  *
217
224
  * @param entropySource - The entropy source of the multichain account wallet.
218
- * @param accountAddress - The address of the account to remove.
219
- * @returns The removed multichain account wallet.
220
225
  */
221
- async removeMultichainAccountWallet(entropySource, accountAddress) {
226
+ async removeMultichainAccountWallet(entropySource) {
222
227
  const wallet = __classPrivateFieldGet(this, _MultichainAccountService_instances, "m", _MultichainAccountService_getWallet).call(this, entropySource);
223
- await __classPrivateFieldGet(this, _MultichainAccountService_messenger, "f").call('KeyringController:removeAccount', accountAddress);
228
+ const failures = [];
229
+ for (const provider of __classPrivateFieldGet(this, _MultichainAccountService_providers, "f")) {
230
+ // Enumerating a provider's owned accounts can itself throw (e.g.
231
+ // `unwrap()`, `getAccounts()`, or reading account options). Catch it as
232
+ // a provider-level failure and move on so one bad provider does not
233
+ // abort cleanup of the others or skip the always-remove step below.
234
+ let owned;
235
+ try {
236
+ // For wrapped providers, enumerate via the underlying provider so we
237
+ // also see accounts when the wrapper has been disabled (i.e. basic
238
+ // functionality is off). The wrapper's `deleteAccount` itself forwards
239
+ // unconditionally, but its `getAccounts()` returns `[]` when disabled,
240
+ // which would otherwise leave snap-backed accounts orphaned in their
241
+ // underlying keyrings.
242
+ const source = (0, AccountProviderWrapper_1.isAccountProviderWrapper)(provider)
243
+ ? provider.unwrap()
244
+ : provider;
245
+ owned = source
246
+ .getAccounts()
247
+ .filter((account) => account.options.entropy.id === entropySource);
248
+ }
249
+ catch (error) {
250
+ failures.push({
251
+ provider: provider.getName(),
252
+ error,
253
+ });
254
+ continue;
255
+ }
256
+ for (const account of owned) {
257
+ try {
258
+ await provider.deleteAccount(account.id);
259
+ }
260
+ catch (error) {
261
+ failures.push({
262
+ provider: provider.getName(),
263
+ accountId: account.id,
264
+ error,
265
+ });
266
+ }
267
+ }
268
+ }
269
+ if (failures.length > 0) {
270
+ // One aggregated report per wallet-removal action: keeps the Sentry
271
+ // message stable for grouping while still surfacing every per-account
272
+ // failure in `context`. The shape is pinned by
273
+ // `RemoveMultichainAccountWalletFailureContext`.
274
+ const context = {
275
+ failures: failures.map(({ provider, accountId, error }) => ({
276
+ provider,
277
+ accountId,
278
+ error: (0, utils_2.toErrorMessage)(error),
279
+ })),
280
+ };
281
+ (0, errors_1.reportError)(__classPrivateFieldGet(this, _MultichainAccountService_messenger, "f"), `Failed to delete one or more accounts during wallet removal`, new Error('Wallet removal partially failed'), context);
282
+ }
224
283
  __classPrivateFieldGet(this, _MultichainAccountService_wallets, "f").delete(wallet.id);
225
284
  }
226
285
  /**