@metamask/accounts-controller 37.0.0 → 37.1.1
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.
- package/CHANGELOG.md +30 -1
- package/dist/AccountsController-method-action-types.cjs +1 -1
- package/dist/AccountsController-method-action-types.cjs.map +1 -1
- package/dist/AccountsController-method-action-types.d.cts +1 -1
- package/dist/AccountsController-method-action-types.d.mts +1 -1
- package/dist/AccountsController-method-action-types.mjs +1 -1
- package/dist/AccountsController-method-action-types.mjs.map +1 -1
- package/dist/AccountsController.cjs +8 -2
- package/dist/AccountsController.cjs.map +1 -1
- package/dist/AccountsController.d.cts +11 -3
- package/dist/AccountsController.d.cts.map +1 -1
- package/dist/AccountsController.d.mts +11 -3
- package/dist/AccountsController.d.mts.map +1 -1
- package/dist/AccountsController.mjs +8 -2
- package/dist/AccountsController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.mts +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [37.1.1]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/snaps-controllers` from `^17.2.0` to `^19.0.0` ([#8319](https://github.com/MetaMask/core/pull/8319))
|
|
15
|
+
- Bump `@metamask/snaps-sdk` from `^10.3.0` to `^11.0.0` ([#8319](https://github.com/MetaMask/core/pull/8319))
|
|
16
|
+
- Bump `@metamask/snaps-utils` from `^11.7.0` to `^12.1.2` ([#8319](https://github.com/MetaMask/core/pull/8319))
|
|
17
|
+
|
|
18
|
+
## [37.1.0]
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Add `:accounts{Added,Removed}` batch events ([#8151](https://github.com/MetaMask/core/pull/8151))
|
|
23
|
+
- Those new events can be used instead of single `:accountAdded` and `:accountRemoved` events to reduce the number of events emitted during batch operations (e.g. `KeyringController` state re-synchronization).
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Bump `@metamask/base-controller` from `^9.0.0` to `^9.0.1` ([#8317](https://github.com/MetaMask/core/pull/8317))
|
|
28
|
+
- Bump `@metamask/keyring-controller` from `^25.1.0` to `^25.1.1` ([#8317](https://github.com/MetaMask/core/pull/8317))
|
|
29
|
+
- Bump `@metamask/messenger` from `^0.3.0` to `^1.0.0` ([#8317](https://github.com/MetaMask/core/pull/8317))
|
|
30
|
+
- Bump `@metamask/network-controller` from `^30.0.0` to `^30.0.1` ([#8317](https://github.com/MetaMask/core/pull/8317))
|
|
31
|
+
- Bump `@metamask/keyring-api` from `^21.5.0` to `^21.6.0` ([#8259](https://github.com/MetaMask/core/pull/8259))
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Prevent `getSelectedAccount` and `getSelectedMultichainAccount` from throwing when `selectedAccount` is `undefined` ([#8231](https://github.com/MetaMask/core/pull/8231))
|
|
36
|
+
|
|
10
37
|
## [37.0.0]
|
|
11
38
|
|
|
12
39
|
### Added
|
|
@@ -721,7 +748,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
721
748
|
|
|
722
749
|
- Initial release ([#1637](https://github.com/MetaMask/core/pull/1637))
|
|
723
750
|
|
|
724
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@37.
|
|
751
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@37.1.1...HEAD
|
|
752
|
+
[37.1.1]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@37.1.0...@metamask/accounts-controller@37.1.1
|
|
753
|
+
[37.1.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@37.0.0...@metamask/accounts-controller@37.1.0
|
|
725
754
|
[37.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@36.0.1...@metamask/accounts-controller@37.0.0
|
|
726
755
|
[36.0.1]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@36.0.0...@metamask/accounts-controller@36.0.1
|
|
727
756
|
[36.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@35.0.2...@metamask/accounts-controller@36.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController-method-action-types.cjs","sourceRoot":"","sources":["../src/AccountsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated
|
|
1
|
+
{"version":3,"file":"AccountsController-method-action-types.cjs","sourceRoot":"","sources":["../src/AccountsController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AccountsController } from './AccountsController';\n\n/**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\nexport type AccountsControllerGetAccountAction = {\n type: `AccountsController:getAccount`;\n handler: AccountsController['getAccount'];\n};\n\n/**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\nexport type AccountsControllerGetAccountsAction = {\n type: `AccountsController:getAccounts`;\n handler: AccountsController['getAccounts'];\n};\n\n/**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\nexport type AccountsControllerListAccountsAction = {\n type: `AccountsController:listAccounts`;\n handler: AccountsController['listAccounts'];\n};\n\n/**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\nexport type AccountsControllerListMultichainAccountsAction = {\n type: `AccountsController:listMultichainAccounts`;\n handler: AccountsController['listMultichainAccounts'];\n};\n\n/**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\nexport type AccountsControllerGetSelectedAccountAction = {\n type: `AccountsController:getSelectedAccount`;\n handler: AccountsController['getSelectedAccount'];\n};\n\n/**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\nexport type AccountsControllerGetSelectedMultichainAccountAction = {\n type: `AccountsController:getSelectedMultichainAccount`;\n handler: AccountsController['getSelectedMultichainAccount'];\n};\n\n/**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\nexport type AccountsControllerGetAccountByAddressAction = {\n type: `AccountsController:getAccountByAddress`;\n handler: AccountsController['getAccountByAddress'];\n};\n\n/**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\nexport type AccountsControllerSetSelectedAccountAction = {\n type: `AccountsController:setSelectedAccount`;\n handler: AccountsController['setSelectedAccount'];\n};\n\n/**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\nexport type AccountsControllerSetAccountNameAction = {\n type: `AccountsController:setAccountName`;\n handler: AccountsController['setAccountName'];\n};\n\n/**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\nexport type AccountsControllerSetAccountNameAndSelectAccountAction = {\n type: `AccountsController:setAccountNameAndSelectAccount`;\n handler: AccountsController['setAccountNameAndSelectAccount'];\n};\n\n/**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\nexport type AccountsControllerUpdateAccountMetadataAction = {\n type: `AccountsController:updateAccountMetadata`;\n handler: AccountsController['updateAccountMetadata'];\n};\n\n/**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\nexport type AccountsControllerUpdateAccountsAction = {\n type: `AccountsController:updateAccounts`;\n handler: AccountsController['updateAccounts'];\n};\n\n/**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\nexport type AccountsControllerLoadBackupAction = {\n type: `AccountsController:loadBackup`;\n handler: AccountsController['loadBackup'];\n};\n\n/**\n * Union of all AccountsController action types.\n */\nexport type AccountsControllerMethodActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountsAction\n | AccountsControllerListAccountsAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerGetSelectedMultichainAccountAction\n | AccountsControllerGetAccountByAddressAction\n | AccountsControllerSetSelectedAccountAction\n | AccountsControllerSetAccountNameAction\n | AccountsControllerSetAccountNameAndSelectAccountAction\n | AccountsControllerUpdateAccountMetadataAction\n | AccountsControllerUpdateAccountsAction\n | AccountsControllerLoadBackupAction;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController-method-action-types.mjs","sourceRoot":"","sources":["../src/AccountsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated
|
|
1
|
+
{"version":3,"file":"AccountsController-method-action-types.mjs","sourceRoot":"","sources":["../src/AccountsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AccountsController } from './AccountsController';\n\n/**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\nexport type AccountsControllerGetAccountAction = {\n type: `AccountsController:getAccount`;\n handler: AccountsController['getAccount'];\n};\n\n/**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\nexport type AccountsControllerGetAccountsAction = {\n type: `AccountsController:getAccounts`;\n handler: AccountsController['getAccounts'];\n};\n\n/**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\nexport type AccountsControllerListAccountsAction = {\n type: `AccountsController:listAccounts`;\n handler: AccountsController['listAccounts'];\n};\n\n/**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\nexport type AccountsControllerListMultichainAccountsAction = {\n type: `AccountsController:listMultichainAccounts`;\n handler: AccountsController['listMultichainAccounts'];\n};\n\n/**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\nexport type AccountsControllerGetSelectedAccountAction = {\n type: `AccountsController:getSelectedAccount`;\n handler: AccountsController['getSelectedAccount'];\n};\n\n/**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\nexport type AccountsControllerGetSelectedMultichainAccountAction = {\n type: `AccountsController:getSelectedMultichainAccount`;\n handler: AccountsController['getSelectedMultichainAccount'];\n};\n\n/**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\nexport type AccountsControllerGetAccountByAddressAction = {\n type: `AccountsController:getAccountByAddress`;\n handler: AccountsController['getAccountByAddress'];\n};\n\n/**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\nexport type AccountsControllerSetSelectedAccountAction = {\n type: `AccountsController:setSelectedAccount`;\n handler: AccountsController['setSelectedAccount'];\n};\n\n/**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\nexport type AccountsControllerSetAccountNameAction = {\n type: `AccountsController:setAccountName`;\n handler: AccountsController['setAccountName'];\n};\n\n/**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\nexport type AccountsControllerSetAccountNameAndSelectAccountAction = {\n type: `AccountsController:setAccountNameAndSelectAccount`;\n handler: AccountsController['setAccountNameAndSelectAccount'];\n};\n\n/**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\nexport type AccountsControllerUpdateAccountMetadataAction = {\n type: `AccountsController:updateAccountMetadata`;\n handler: AccountsController['updateAccountMetadata'];\n};\n\n/**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\nexport type AccountsControllerUpdateAccountsAction = {\n type: `AccountsController:updateAccounts`;\n handler: AccountsController['updateAccounts'];\n};\n\n/**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\nexport type AccountsControllerLoadBackupAction = {\n type: `AccountsController:loadBackup`;\n handler: AccountsController['loadBackup'];\n};\n\n/**\n * Union of all AccountsController action types.\n */\nexport type AccountsControllerMethodActions =\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountsAction\n | AccountsControllerListAccountsAction\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetSelectedAccountAction\n | AccountsControllerGetSelectedMultichainAccountAction\n | AccountsControllerGetAccountByAddressAction\n | AccountsControllerSetSelectedAccountAction\n | AccountsControllerSetAccountNameAction\n | AccountsControllerSetAccountNameAndSelectAccountAction\n | AccountsControllerUpdateAccountMetadataAction\n | AccountsControllerUpdateAccountsAction\n | AccountsControllerLoadBackupAction;\n"]}
|
|
@@ -167,7 +167,7 @@ class AccountsController extends base_controller_1.BaseController {
|
|
|
167
167
|
const { internalAccounts: { selectedAccount }, } = this.state;
|
|
168
168
|
// Edge case where the extension is setup but the srp is not yet created
|
|
169
169
|
// certain ui elements will query the selected address before any accounts are created.
|
|
170
|
-
if (selectedAccount
|
|
170
|
+
if (!selectedAccount) {
|
|
171
171
|
return exports.EMPTY_ACCOUNT;
|
|
172
172
|
}
|
|
173
173
|
const account = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getAccountExpect).call(this, selectedAccount);
|
|
@@ -197,7 +197,7 @@ class AccountsController extends base_controller_1.BaseController {
|
|
|
197
197
|
const { internalAccounts: { selectedAccount }, } = this.state;
|
|
198
198
|
// Edge case where the extension is setup but the srp is not yet created
|
|
199
199
|
// certain ui elements will query the selected address before any accounts are created.
|
|
200
|
-
if (selectedAccount
|
|
200
|
+
if (!selectedAccount) {
|
|
201
201
|
return exports.EMPTY_ACCOUNT;
|
|
202
202
|
}
|
|
203
203
|
if (!chainId) {
|
|
@@ -581,9 +581,15 @@ _AccountsController_instances = new WeakSet(), _AccountsController_getAccountExp
|
|
|
581
581
|
for (const id of diff.removed) {
|
|
582
582
|
this.messenger.publish('AccountsController:accountRemoved', id);
|
|
583
583
|
}
|
|
584
|
+
if (diff.removed.length > 0) {
|
|
585
|
+
this.messenger.publish('AccountsController:accountsRemoved', diff.removed);
|
|
586
|
+
}
|
|
584
587
|
for (const account of diff.added) {
|
|
585
588
|
this.messenger.publish('AccountsController:accountAdded', account);
|
|
586
589
|
}
|
|
590
|
+
if (diff.added.length > 0) {
|
|
591
|
+
this.messenger.publish('AccountsController:accountsAdded', diff.added);
|
|
592
|
+
}
|
|
587
593
|
});
|
|
588
594
|
(0, logger_1.projectLogger)('Accounts synchronized (through :stateChange)!');
|
|
589
595
|
// NOTE: Since we also track "updated" accounts with our patches, we could fire a new event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController.cjs","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA2D;AAK3D,iEAAyD;AAOzD,uDAM+B;AAS/B,2DAA4D;AAQ5D,2CAAgD;AAGhD,mCAAmC;AAGnC,yCAAgD;AAIhD,uCASiB;AAEjB,MAAM,cAAc,GAAG,oBAAoB,CAAC;AA6B5C,MAAM,yBAAyB,GAAG;IAChC,oBAAoB;IACpB,gBAAgB;IAChB,gCAAgC;IAChC,cAAc;IACd,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,8BAA8B;IAC9B,qBAAqB;IACrB,YAAY;IACZ,aAAa;IACb,uBAAuB;IACv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CAAC,YAAY,EAAE,EAAE,CACzE,uBAAA,IAAI,qFAA4B,MAAhC,IAAI,EAA6B,YAAY,CAAC,CAC/C,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,qCAAqC,EACrC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,4CAA4C,EAC5C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,oCAAoC,EACpC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,2CAA2C,EAC3C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,wCAAwC,EACxC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,+CAA+C,EAC/C,gBAAgB,CACjB,CACJ,CAAC;IAEF,2DAA2D;IAC3D,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,8CAA8C,EAC9C,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,6FAAoC,MAAxC,IAAI,EAAqC,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type {\n SnapKeyringAccountAssetListUpdatedEvent,\n SnapKeyringAccountBalancesUpdatedEvent,\n SnapKeyringAccountTransactionsUpdatedEvent,\n} from '@metamask/eth-snap-keyring';\nimport type { KeyringAccountEntropyOptions } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n isEvmAccountType,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerGetStateAction,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { isScopeEqualToAny } from '@metamask/keyring-utils';\nimport type { Messenger, ExtractEventPayload } from '@metamask/messenger';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type {\n SnapControllerState,\n SnapStateChange,\n} from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { isCaipChainId } from '@metamask/utils';\nimport type { CaipChainId } from '@metamask/utils';\nimport type { WritableDraft } from 'immer/dist/internal.js';\nimport { cloneDeep } from 'lodash';\n\nimport { AccountsControllerMethodActions } from './AccountsController-method-action-types';\nimport { projectLogger as log } from './logger';\nimport type { MultichainNetworkControllerNetworkDidChangeEvent } from './types';\nimport type { AccountsControllerStrictState } from './typing';\nimport type { HdSnapKeyringAccount } from './utils';\nimport {\n constructAccountIdByAddress,\n getEvmDerivationPathForIndex,\n getEvmGroupIndexFromAddressIndex,\n getUUIDFromAddressOfNormalAccount,\n isHdKeyringType,\n isHdSnapKeyringAccount,\n isSnapKeyringType,\n keyringTypeToName,\n} from './utils';\n\nconst controllerName = 'AccountsController';\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountId = string;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerState = {\n internalAccounts: {\n accounts: Record<AccountId, InternalAccount>;\n selectedAccount: string; // id of the selected account\n };\n accountIdByAddress: Record<InternalAccount['address'], AccountId>;\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountsControllerState\n>;\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'setSelectedAccount',\n 'setAccountName',\n 'setAccountNameAndSelectAccount',\n 'listAccounts',\n 'listMultichainAccounts',\n 'updateAccounts',\n 'getSelectedAccount',\n 'getSelectedMultichainAccount',\n 'getAccountByAddress',\n 'getAccount',\n 'getAccounts',\n 'updateAccountMetadata',\n 'loadBackup',\n] as const;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedActions =\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetStateAction;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerActions =\n | AccountsControllerGetStateAction\n | AccountsControllerMethodActions;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountsControllerState\n>;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedAccountChangeEvent = {\n type: `${typeof controllerName}:selectedAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedEvmAccountChangeEvent = {\n type: `${typeof controllerName}:selectedEvmAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAddedEvent = {\n type: `${typeof controllerName}:accountAdded`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRemovedEvent = {\n type: `${typeof controllerName}:accountRemoved`;\n payload: [AccountId];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRenamedEvent = {\n type: `${typeof controllerName}:accountRenamed`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountBalancesUpdatesEvent = {\n type: `${typeof controllerName}:accountBalancesUpdated`;\n payload: SnapKeyringAccountBalancesUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountTransactionsUpdatedEvent = {\n type: `${typeof controllerName}:accountTransactionsUpdated`;\n payload: SnapKeyringAccountTransactionsUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAssetListUpdatedEvent = {\n type: `${typeof controllerName}:accountAssetListUpdated`;\n payload: SnapKeyringAccountAssetListUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedEvents =\n | SnapStateChange\n | KeyringControllerStateChangeEvent\n | SnapKeyringAccountAssetListUpdatedEvent\n | SnapKeyringAccountBalancesUpdatedEvent\n | SnapKeyringAccountTransactionsUpdatedEvent\n | MultichainNetworkControllerNetworkDidChangeEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerEvents =\n | AccountsControllerChangeEvent\n | AccountsControllerSelectedAccountChangeEvent\n | AccountsControllerSelectedEvmAccountChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerAccountRenamedEvent\n | AccountsControllerAccountBalancesUpdatesEvent\n | AccountsControllerAccountTransactionsUpdatedEvent\n | AccountsControllerAccountAssetListUpdatedEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerMessenger = Messenger<\n typeof controllerName,\n AccountsControllerActions | AllowedActions,\n AccountsControllerEvents | AllowedEvents\n>;\n\nconst accountsControllerMetadata = {\n internalAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n accountIdByAddress: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst defaultState: AccountsControllerState = {\n internalAccounts: {\n accounts: {},\n selectedAccount: '',\n },\n accountIdByAddress: {},\n};\n\n/**\n * @deprecated This constant is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport const EMPTY_ACCOUNT = {\n id: '',\n address: '',\n options: {},\n methods: [],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: '',\n keyring: {\n type: '',\n },\n importTime: 0,\n },\n};\n\n/**\n * A patch representing a keyring state change.\n */\ntype StatePatch = {\n previous: Record<string, InternalAccount>;\n added: {\n address: string;\n keyring: KeyringObject;\n }[];\n updated: InternalAccount[];\n removed: InternalAccount[];\n};\n\n/**\n * Controller that manages internal accounts.\n * The accounts controller is responsible for creating and managing internal accounts.\n * It also provides convenience methods for accessing and updating the internal accounts.\n * The accounts controller also listens for keyring state changes and updates the internal accounts accordingly.\n * The accounts controller also listens for snap state changes and updates the internal accounts accordingly.\n *\n * @deprecated This class is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport class AccountsController extends BaseController<\n typeof controllerName,\n AccountsControllerState,\n AccountsControllerMessenger\n> {\n /**\n * Constructor for AccountsController.\n *\n * @param options - The controller options.\n * @param options.messenger - The messenger object.\n * @param options.state - Initial state to set on this controller\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: AccountsControllerMessenger;\n state: AccountsControllerState;\n }) {\n const accountIdByAddress = constructAccountIdByAddress(\n state?.internalAccounts?.accounts ?? {},\n );\n super({\n messenger,\n name: controllerName,\n metadata: accountsControllerMetadata,\n state: {\n ...defaultState,\n ...state,\n accountIdByAddress,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#subscribeToMessageEvents();\n }\n\n /**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\n getAccount(accountId: string): InternalAccount | undefined {\n return this.state.internalAccounts.accounts[accountId];\n }\n\n /**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\n getAccounts(accountIds: string[]): (InternalAccount | undefined)[] {\n return accountIds.map((accountId) => this.getAccount(accountId));\n }\n\n /**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\n listAccounts(): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n return accounts.filter((account) => isEvmAccountType(account.type));\n }\n\n /**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\n listMultichainAccounts(chainId?: CaipChainId): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n if (!chainId) {\n return accounts;\n }\n\n if (!isCaipChainId(chainId)) {\n throw new Error(`Invalid CAIP-2 chain ID: ${String(chainId)}`);\n }\n\n return accounts.filter((account) =>\n isScopeEqualToAny(chainId, account.scopes),\n );\n }\n\n /**\n * Returns the internal account object for the given account ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object.\n * @throws An error if the account ID is not found.\n */\n #getAccountExpect(accountId: string): InternalAccount {\n const account = this.getAccount(accountId);\n if (account === undefined) {\n throw new Error(`Account Id \"${accountId}\" not found`);\n }\n return account;\n }\n\n /**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\n getSelectedAccount(): InternalAccount {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (selectedAccount === '') {\n return EMPTY_ACCOUNT;\n }\n\n const account = this.#getAccountExpect(selectedAccount);\n if (isEvmAccountType(account.type)) {\n return account;\n }\n\n const accounts = this.listAccounts();\n if (!accounts.length) {\n // ! Should never reach this.\n throw new Error('No EVM accounts');\n }\n\n // This will never be undefined because we have already checked if accounts.length is > 0\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.#getLastSelectedAccount(accounts)!;\n }\n\n /**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\n getSelectedMultichainAccount(\n chainId?: CaipChainId,\n ): InternalAccount | undefined {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (selectedAccount === '') {\n return EMPTY_ACCOUNT;\n }\n\n if (!chainId) {\n return this.#getAccountExpect(selectedAccount);\n }\n\n const accounts = this.listMultichainAccounts(chainId);\n return this.#getLastSelectedAccount(accounts);\n }\n\n /**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\n getAccountByAddress(address: string): InternalAccount | undefined {\n // We need to have a fallback as a cache miss might be attributed to a checksummed address being passed.\n let accountId = this.state.accountIdByAddress[address];\n if (!accountId) {\n // FIXME: We should not need lower-cased addresses, but some consumers might\n // still be using non-normalized addresses. For now we keep it\n // for convenience, but we will need to remove this fallback\n // at some point.\n // NOTE: We should only hit that branch for EVM accounts only.\n const lowercasedAddress = address.toLowerCase();\n accountId = this.state.accountIdByAddress[lowercasedAddress];\n if (accountId) {\n log(\n `Cache missed for account ID: ${accountId}, received address: \"${address}\", matched address: \"${lowercasedAddress}\"`,\n );\n }\n }\n return accountId ? this.getAccount(accountId) : undefined;\n }\n\n /**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\n setSelectedAccount(accountId: string): void {\n const account = this.#getAccountExpect(accountId);\n\n if (this.state.internalAccounts.selectedAccount === account.id) {\n return;\n }\n\n this.#update((state) => {\n const { internalAccounts } = state;\n\n internalAccounts.accounts[account.id].metadata.lastSelected = Date.now();\n internalAccounts.selectedAccount = account.id;\n });\n }\n\n /**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountName(accountId: string, accountName: string): void {\n // This will check for name uniqueness and fire the `accountRenamed` event\n // if the account has been renamed.\n this.updateAccountMetadata(accountId, {\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n });\n }\n\n /**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountNameAndSelectAccount(accountId: string, accountName: string): void {\n const account = this.#getAccountExpect(accountId);\n\n this.#assertAccountCanBeRenamed(account, accountName);\n\n const internalAccount = {\n ...account,\n metadata: {\n ...account.metadata,\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n lastSelected: this.#getLastSelectedIndex(),\n },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[account.id] = internalAccount;\n state.internalAccounts.selectedAccount = account.id;\n });\n\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n\n #assertAccountCanBeRenamed(\n account: InternalAccount,\n accountName: string,\n ): void {\n if (\n this.listMultichainAccounts().find(\n (internalAccount) =>\n internalAccount.metadata.name === accountName &&\n internalAccount.id !== account.id,\n )\n ) {\n throw new Error('Account name already exists');\n }\n }\n\n /**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\n updateAccountMetadata(\n accountId: string,\n metadata: Partial<InternalAccount['metadata']>,\n ): void {\n const account = this.#getAccountExpect(accountId);\n\n if (metadata.name) {\n this.#assertAccountCanBeRenamed(account, metadata.name);\n }\n\n const internalAccount = {\n ...account,\n metadata: { ...account.metadata, ...metadata },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[accountId] = internalAccount;\n });\n\n if (metadata.name) {\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n }\n\n /**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\n async updateAccounts(): Promise<void> {\n log('Synchronizing accounts with keyrings...');\n\n const keyringAccountIndexes = new Map<string, number>();\n\n const existingInternalAccounts = this.state.internalAccounts.accounts;\n const internalAccounts: AccountsControllerState['internalAccounts']['accounts'] =\n {};\n\n const { keyrings } = this.messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n const keyringTypeName = keyringTypeToName(keyring.type);\n\n for (const address of keyring.accounts) {\n const internalAccount = this.#getInternalAccountFromAddressAndType(\n address,\n keyring,\n );\n\n // This should never really happen, but if for some reason we're not\n // able to get the Snap keyring reference, this would return an\n // undefined account.\n // So we just skip it, even though, this should not really happen.\n if (!internalAccount) {\n continue;\n }\n\n // Get current index for this keyring (we use human indexing, so start at 1).\n const keyringAccountIndex =\n keyringAccountIndexes.get(keyringTypeName) ?? 1;\n\n const existingAccount = existingInternalAccounts[internalAccount.id];\n internalAccounts[internalAccount.id] = {\n ...internalAccount,\n\n metadata: {\n ...internalAccount.metadata,\n\n // Re-use existing metadata if any.\n name:\n existingAccount?.metadata.name ??\n `${keyringTypeName} ${keyringAccountIndex}`,\n importTime: existingAccount?.metadata.importTime ?? Date.now(),\n lastSelected: existingAccount?.metadata.lastSelected ?? 0,\n },\n };\n\n // Increment the account index for this keyring.\n keyringAccountIndexes.set(keyringTypeName, keyringAccountIndex + 1);\n }\n }\n\n this.#update((state) => {\n state.internalAccounts.accounts = internalAccounts;\n state.accountIdByAddress = constructAccountIdByAddress(internalAccounts);\n });\n\n log('Accounts synchronized!');\n }\n\n /**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\n loadBackup(backup: AccountsControllerState): void {\n if (backup.internalAccounts) {\n const accountIdByAddress = constructAccountIdByAddress(\n backup.internalAccounts.accounts,\n );\n this.update(\n (currentState: WritableDraft<AccountsControllerStrictState>) => {\n currentState.internalAccounts = backup.internalAccounts;\n currentState.accountIdByAddress = accountIdByAddress;\n },\n );\n }\n }\n\n /**\n * Gets an internal account representation for a non-Snap account.\n *\n * @param address - The address of the account.\n * @param keyring - The keyring object of the account.\n * @returns The generated internal account.\n */\n #getInternalAccountForNonSnapAccount(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount {\n const id = getUUIDFromAddressOfNormalAccount(address);\n\n // We might have an account for this ID already, so we'll just re-use\n // the same metadata\n const account = this.getAccount(id);\n const metadata: InternalAccount['metadata'] = {\n name: account?.metadata.name ?? '',\n ...(account?.metadata.nameLastUpdatedAt\n ? {\n nameLastUpdatedAt: account?.metadata.nameLastUpdatedAt,\n }\n : {}),\n importTime: account?.metadata.importTime ?? Date.now(),\n lastSelected: account?.metadata.lastSelected ?? 0,\n keyring: {\n type: keyring.type,\n },\n };\n\n let options: InternalAccount['options'] = {};\n if (isHdKeyringType(keyring.type)) {\n // We need to find the account index from its HD keyring.\n const groupIndex = getEvmGroupIndexFromAddressIndex(keyring, address);\n\n // If for some reason, we cannot find this address, then the caller made a mistake\n // and it did not use the proper keyring object. For now, we do not fail and just\n // consider this account as \"simple account\".\n if (groupIndex !== undefined) {\n // NOTE: We are not using the `hdPath` from the associated keyring here and\n // getting the keyring instance here feels a bit overkill.\n // This will be naturally fixed once every keyring start using `KeyringAccount` and implement the keyring API.\n const derivationPath = getEvmDerivationPathForIndex(groupIndex);\n\n // Those are \"legacy options\" and they were used before `KeyringAccount` added\n // support for type options. We keep those temporarily until we update everything\n // to use the new typed options.\n const legacyOptions = {\n entropySource: keyring.metadata.id,\n derivationPath,\n groupIndex,\n };\n\n // New typed entropy options. This is required for multichain accounts.\n const entropyOptions: { entropy: KeyringAccountEntropyOptions } = {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: keyring.metadata.id,\n derivationPath,\n groupIndex,\n },\n };\n\n options = {\n ...legacyOptions,\n ...entropyOptions,\n };\n }\n }\n\n return {\n id,\n address,\n options,\n methods: [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n ],\n scopes: [EthScope.Eoa],\n type: EthAccountType.Eoa,\n metadata,\n };\n }\n\n /**\n * Get Snap keyring from the keyring controller.\n *\n * @returns The Snap keyring if available.\n */\n #getSnapKeyring(): SnapKeyring | undefined {\n const [snapKeyring] = this.messenger.call(\n 'KeyringController:getKeyringsByType',\n SnapKeyring.type,\n );\n\n // Snap keyring is not available until the first account is created in the keyring\n // controller, so this might be undefined.\n return snapKeyring as SnapKeyring | undefined;\n }\n\n /**\n * Re-publish an account event.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param payload - The event payload. The type of the parameters for each event handler must\n * match the type of this payload.\n * @template EventType - A Snap keyring event type.\n */\n #handleOnSnapKeyringAccountEvent<\n EventType extends AccountsControllerEvents['type'],\n >(\n event: EventType,\n ...payload: ExtractEventPayload<AccountsControllerEvents, EventType>\n ): void {\n this.messenger.publish(event, ...payload);\n }\n\n /**\n * Handles changes in the keyring state, specifically when new accounts are added or removed.\n *\n * @param keyringState - The new state of the keyring controller.\n * @param keyringState.isUnlocked - True if the keyrings are unlocked, false otherwise.\n * @param keyringState.keyrings - List of all keyrings.\n */\n #handleOnKeyringStateChange({\n isUnlocked,\n keyrings,\n }: KeyringControllerState): void {\n // TODO: Change when accountAdded event is added to the keyring controller.\n\n // We check for keyrings length to be greater than 0 because the extension client may try execute\n // submit password twice and clear the keyring state.\n // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910\n if (!isUnlocked || keyrings.length === 0) {\n return;\n }\n\n log('Synchronizing accounts with keyrings (through :stateChange)...');\n\n // State patches.\n const generatePatch = (): StatePatch => {\n return {\n previous: {},\n added: [],\n updated: [],\n removed: [],\n };\n };\n const patches = {\n snap: generatePatch(),\n normal: generatePatch(),\n };\n\n // Gets the patch object based on the keyring type (since Snap accounts and other accounts\n // are handled differently).\n const patchOf = (type: string): StatePatch => {\n if (isSnapKeyringType(type)) {\n return patches.snap;\n }\n return patches.normal;\n };\n\n // Create a map (with lower-cased addresses) of all existing accounts.\n for (const account of this.listMultichainAccounts()) {\n const address = account.address.toLowerCase();\n const patch = patchOf(account.metadata.keyring.type);\n\n patch.previous[address] = account;\n }\n\n // Go over all keyring changes and create patches out of it.\n const addresses = new Set<string>();\n for (const keyring of keyrings) {\n const patch = patchOf(keyring.type);\n\n for (const accountAddress of keyring.accounts) {\n // Lower-case address to use it in the `previous` map.\n const address = accountAddress.toLowerCase();\n const account = patch.previous[address];\n\n if (account) {\n // If the account exists before, this might be an update.\n patch.updated.push(account);\n } else {\n // Otherwise, that's a new account.\n patch.added.push({\n address,\n keyring,\n });\n }\n\n // Keep track of those address to check for removed accounts later.\n addresses.add(address);\n }\n }\n\n // We might have accounts associated with removed keyrings, so we iterate\n // over all previous known accounts and check against the keyring addresses.\n for (const patch of [patches.snap, patches.normal]) {\n for (const [address, account] of Object.entries(patch.previous)) {\n // If a previous address is not part of the new addesses, then it got removed.\n if (!addresses.has(address)) {\n patch.removed.push(account);\n }\n }\n }\n\n // Diff that we will use to publish events afterward.\n const diff: { removed: string[]; added: InternalAccount[] } = {\n removed: [],\n added: [],\n };\n\n this.#update(\n (state) => {\n const { internalAccounts, accountIdByAddress } = state;\n\n for (const patch of [patches.snap, patches.normal]) {\n for (const account of patch.removed) {\n delete internalAccounts.accounts[account.id];\n delete accountIdByAddress[account.address];\n\n diff.removed.push(account.id);\n }\n\n for (const added of patch.added) {\n const account = this.#getInternalAccountFromAddressAndType(\n added.address,\n added.keyring,\n );\n\n if (account) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // If it's the first account, we need to select it.\n const lastSelected =\n accounts.length === 0 ? this.#getLastSelectedIndex() : 0;\n\n internalAccounts.accounts[account.id] = {\n ...account,\n metadata: {\n ...account.metadata,\n importTime: Date.now(),\n lastSelected,\n },\n };\n\n accountIdByAddress[account.address] = account.id;\n\n diff.added.push(internalAccounts.accounts[account.id]);\n }\n }\n }\n },\n // Will get executed after the update, but before re-selecting an account in case\n // the current one is not valid anymore.\n () => {\n // Now publish events\n for (const id of diff.removed) {\n this.messenger.publish('AccountsController:accountRemoved', id);\n }\n\n for (const account of diff.added) {\n this.messenger.publish('AccountsController:accountAdded', account);\n }\n },\n );\n\n log('Accounts synchronized (through :stateChange)!');\n\n // NOTE: Since we also track \"updated\" accounts with our patches, we could fire a new event\n // like `accountUpdated` (we would still need to check if anything really changed on the account).\n }\n\n /**\n * Update the state and fixup the currently selected account.\n *\n * @param callback - Callback for updating state, passed a draft state object.\n * @param beforeAutoSelectAccount - Callback to be executed before auto-selecting an account\n * if the current one is no longer available.\n */\n #update(\n callback: (state: WritableDraft<AccountsControllerStrictState>) => void,\n beforeAutoSelectAccount?: () => void,\n ): void {\n // The currently selected account might get deleted during the update, so keep track\n // of it before doing any change.\n const previouslySelectedAccount =\n this.state.internalAccounts.selectedAccount;\n\n this.update((state: WritableDraft<AccountsControllerStrictState>) => {\n callback(state);\n\n // If the account no longer exists (or none is selected), we need to re-select another one.\n const { internalAccounts } = state;\n if (!internalAccounts.accounts[previouslySelectedAccount]) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // Get the lastly selected account (according to the current accounts).\n const lastSelectedAccount = this.#getLastSelectedAccount(accounts);\n if (lastSelectedAccount) {\n internalAccounts.selectedAccount = lastSelectedAccount.id;\n internalAccounts.accounts[\n lastSelectedAccount.id\n ].metadata.lastSelected = this.#getLastSelectedIndex();\n } else {\n // It will be undefined if there are no accounts.\n internalAccounts.selectedAccount = '';\n }\n }\n });\n\n // We might want to do some pre-work before selecting a new account.\n beforeAutoSelectAccount?.();\n\n // Now, we compare the newly selected account, and we send event if different.\n const { selectedAccount } = this.state.internalAccounts;\n if (selectedAccount && selectedAccount !== previouslySelectedAccount) {\n const account = this.getSelectedMultichainAccount();\n\n // The account should always be defined at this point, since we have already checked for\n // `selectedAccount` to be non-empty.\n if (account) {\n if (isEvmAccountType(account.type)) {\n this.messenger.publish(\n 'AccountsController:selectedEvmAccountChange',\n account,\n );\n }\n this.messenger.publish(\n 'AccountsController:selectedAccountChange',\n account,\n );\n }\n }\n }\n\n /**\n * Handles the change in SnapControllerState by updating the metadata of accounts that have a snap enabled.\n *\n * @param snapState - The new SnapControllerState.\n */\n #handleOnSnapStateChange(snapState: SnapControllerState): void {\n // Only check if Snaps changed in status.\n const { snaps } = snapState;\n\n const accounts: { id: string; enabled: boolean }[] = [];\n for (const account of this.listMultichainAccounts()) {\n if (account.metadata.snap) {\n const snap = snaps[account.metadata.snap.id as SnapId];\n\n if (snap) {\n const enabled = snap.enabled && !snap.blocked;\n const metadata = account.metadata.snap;\n\n if (metadata.enabled !== enabled) {\n accounts.push({ id: account.id, enabled });\n }\n } else {\n // If Snap could not be found on the state, we consider it disabled.\n accounts.push({ id: account.id, enabled: false });\n }\n }\n }\n\n if (accounts.length > 0) {\n this.update((state) => {\n for (const { id, enabled } of accounts) {\n const account = state.internalAccounts.accounts[id];\n\n if (account.metadata.snap) {\n account.metadata.snap.enabled = enabled;\n }\n }\n });\n }\n }\n\n /**\n * Returns the last selected account from the given array of accounts.\n *\n * @param accounts - An array of InternalAccount objects.\n * @returns The InternalAccount object that was last selected, or undefined if the array is empty.\n */\n #getLastSelectedAccount(\n accounts: InternalAccount[],\n ): InternalAccount | undefined {\n const [accountToSelect] = accounts.sort((accountA, accountB) => {\n // sort by lastSelected descending\n return (\n (accountB.metadata.lastSelected ?? 0) -\n (accountA.metadata.lastSelected ?? 0)\n );\n });\n\n return accountToSelect;\n }\n\n /**\n * Retrieves the index value for `metadata.lastSelected`.\n *\n * @returns The index value.\n */\n #getLastSelectedIndex(): number {\n // NOTE: For now we use the current date, since we know this value\n // will always be higher than any already selected account index.\n return Date.now();\n }\n\n /**\n * Get an internal account given an address and a keyring type.\n *\n * If the account is not a Snap Keyring account, generates an internal account for it and adds it to the controller.\n * If the account is a Snap Keyring account, retrieves the account from the keyring and adds it to the controller.\n *\n * @param address - The address of the new account.\n * @param keyring - The keyring object of that new account.\n * @returns The newly generated/retrieved internal account.\n */\n #getInternalAccountFromAddressAndType(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount | undefined {\n if (isSnapKeyringType(keyring.type)) {\n const snapKeyring = this.#getSnapKeyring();\n\n // We need the Snap keyring to retrieve the account from its address.\n if (!snapKeyring) {\n return undefined;\n }\n\n // This might be undefined if the Snap deleted the account before\n // reaching that point.\n let account = snapKeyring.getAccountByAddress(address);\n if (account) {\n // We force the copy here, to avoid mutating the reference returned by the Snap keyring.\n account = cloneDeep(account);\n\n // MIGRATION: To avoid any existing Snap account migration, we are\n // just \"adding\" the new typed options that we need for multichain\n // accounts. Ultimately, we would need a real Snap account migrations\n // (being handled by each Snaps).\n if (isHdSnapKeyringAccount(account)) {\n const options: HdSnapKeyringAccount['options'] = {\n ...account.options,\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: account.options.entropySource,\n groupIndex: account.options.index,\n derivationPath: account.options.derivationPath,\n },\n };\n // Inject the new typed options to the internal account copy.\n account.options = options;\n }\n }\n\n return account;\n }\n\n return this.#getInternalAccountForNonSnapAccount(address, keyring);\n }\n\n /**\n * Handles the change in multichain network by updating the selected account.\n *\n * @param id - The EVM client ID or non-EVM chain ID that changed.\n */\n #handleOnMultichainNetworkDidChange(id: NetworkClientId | CaipChainId): void {\n let accountId: string;\n\n // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin\n // MultichainNetworkController will handle throwing an error if the Caip chain ID is not supported\n if (isCaipChainId(id)) {\n // Update selected account to non evm account\n const lastSelectedNonEvmAccount = this.getSelectedMultichainAccount(id);\n // @ts-expect-error - This should never be undefined, otherwise it's a bug that should be handled\n accountId = lastSelectedNonEvmAccount.id;\n } else {\n // Update selected account to evm account\n const lastSelectedEvmAccount = this.getSelectedAccount();\n accountId = lastSelectedEvmAccount.id;\n }\n\n if (this.state.internalAccounts.selectedAccount === accountId) {\n return;\n }\n\n this.update((currentState) => {\n currentState.internalAccounts.accounts[accountId].metadata.lastSelected =\n Date.now();\n currentState.internalAccounts.selectedAccount = accountId;\n });\n\n // DO NOT publish AccountsController:setSelectedAccount to prevent circular listener loops\n }\n\n /**\n * Subscribes to message events.\n */\n #subscribeToMessageEvents(): void {\n this.messenger.subscribe('SnapController:stateChange', (snapStateState) =>\n this.#handleOnSnapStateChange(snapStateState),\n );\n\n this.messenger.subscribe('KeyringController:stateChange', (keyringState) =>\n this.#handleOnKeyringStateChange(keyringState),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountAssetListUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountAssetListUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountBalancesUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountBalancesUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountTransactionsUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountTransactionsUpdated',\n snapAccountEvent,\n ),\n );\n\n // Handle account change when multichain network is changed\n this.messenger.subscribe(\n 'MultichainNetworkController:networkDidChange',\n (id) => this.#handleOnMultichainNetworkDidChange(id),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AccountsController.cjs","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA2D;AAK3D,iEAAyD;AAOzD,uDAM+B;AAS/B,2DAA4D;AAQ5D,2CAAgD;AAGhD,mCAAmC;AAGnC,yCAAgD;AAIhD,uCASiB;AAEjB,MAAM,cAAc,GAAG,oBAAoB,CAAC;AA6B5C,MAAM,yBAAyB,GAAG;IAChC,oBAAoB;IACpB,gBAAgB;IAChB,gCAAgC;IAChC,cAAc;IACd,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,8BAA8B;IAC9B,qBAAqB;IACrB,YAAY;IACZ,aAAa;IACb,uBAAuB;IACvB,YAAY;CACJ,CAAC;AAoJX,MAAM,0BAA0B,GAAG;IACjC,gBAAgB,EAAE;QAChB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,KAAK;QACzB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,MAAM,YAAY,GAA4B;IAC5C,gBAAgB,EAAE;QAChB,QAAQ,EAAE,EAAE;QACZ,eAAe,EAAE,EAAE;KACpB;IACD,kBAAkB,EAAE,EAAE;CACvB,CAAC;AAEF;;;GAGG;AACU,QAAA,aAAa,GAAG;IAC3B,EAAE,EAAE,EAAE;IACN,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OA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,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,oCAAoC,EACpC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,2CAA2C,EAC3C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,wCAAwC,EACxC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,+CAA+C,EAC/C,gBAAgB,CACjB,CACJ,CAAC;IAEF,2DAA2D;IAC3D,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,8CAA8C,EAC9C,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,6FAAoC,MAAxC,IAAI,EAAqC,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type {\n SnapKeyringAccountAssetListUpdatedEvent,\n SnapKeyringAccountBalancesUpdatedEvent,\n SnapKeyringAccountTransactionsUpdatedEvent,\n} from '@metamask/eth-snap-keyring';\nimport type { KeyringAccountEntropyOptions } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n isEvmAccountType,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerGetStateAction,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { isScopeEqualToAny } from '@metamask/keyring-utils';\nimport type { Messenger, ExtractEventPayload } from '@metamask/messenger';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type {\n SnapControllerState,\n SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { isCaipChainId } from '@metamask/utils';\nimport type { CaipChainId } from '@metamask/utils';\nimport type { WritableDraft } from 'immer/dist/internal.js';\nimport { cloneDeep } from 'lodash';\n\nimport { AccountsControllerMethodActions } from './AccountsController-method-action-types';\nimport { projectLogger as log } from './logger';\nimport type { MultichainNetworkControllerNetworkDidChangeEvent } from './types';\nimport type { AccountsControllerStrictState } from './typing';\nimport type { HdSnapKeyringAccount } from './utils';\nimport {\n constructAccountIdByAddress,\n getEvmDerivationPathForIndex,\n getEvmGroupIndexFromAddressIndex,\n getUUIDFromAddressOfNormalAccount,\n isHdKeyringType,\n isHdSnapKeyringAccount,\n isSnapKeyringType,\n keyringTypeToName,\n} from './utils';\n\nconst controllerName = 'AccountsController';\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountId = string;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerState = {\n internalAccounts: {\n accounts: Record<AccountId, InternalAccount>;\n selectedAccount: string; // id of the selected account\n };\n accountIdByAddress: Record<InternalAccount['address'], AccountId>;\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountsControllerState\n>;\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'setSelectedAccount',\n 'setAccountName',\n 'setAccountNameAndSelectAccount',\n 'listAccounts',\n 'listMultichainAccounts',\n 'updateAccounts',\n 'getSelectedAccount',\n 'getSelectedMultichainAccount',\n 'getAccountByAddress',\n 'getAccount',\n 'getAccounts',\n 'updateAccountMetadata',\n 'loadBackup',\n] as const;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedActions =\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetStateAction;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerActions =\n | AccountsControllerGetStateAction\n | AccountsControllerMethodActions;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountsControllerState\n>;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedAccountChangeEvent = {\n type: `${typeof controllerName}:selectedAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedEvmAccountChangeEvent = {\n type: `${typeof controllerName}:selectedEvmAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAddedEvent = {\n type: `${typeof controllerName}:accountAdded`;\n payload: [InternalAccount];\n};\n\nexport type AccountsControllerAccountsAddedEvent = {\n type: `${typeof controllerName}:accountsAdded`;\n payload: [InternalAccount[]];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRemovedEvent = {\n type: `${typeof controllerName}:accountRemoved`;\n payload: [AccountId];\n};\n\nexport type AccountsControllerAccountsRemovedEvent = {\n type: `${typeof controllerName}:accountsRemoved`;\n payload: [AccountId[]];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRenamedEvent = {\n type: `${typeof controllerName}:accountRenamed`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountBalancesUpdatesEvent = {\n type: `${typeof controllerName}:accountBalancesUpdated`;\n payload: SnapKeyringAccountBalancesUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountTransactionsUpdatedEvent = {\n type: `${typeof controllerName}:accountTransactionsUpdated`;\n payload: SnapKeyringAccountTransactionsUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAssetListUpdatedEvent = {\n type: `${typeof controllerName}:accountAssetListUpdated`;\n payload: SnapKeyringAccountAssetListUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedEvents =\n | KeyringControllerStateChangeEvent\n | SnapControllerStateChangeEvent\n | SnapKeyringAccountAssetListUpdatedEvent\n | SnapKeyringAccountBalancesUpdatedEvent\n | SnapKeyringAccountTransactionsUpdatedEvent\n | MultichainNetworkControllerNetworkDidChangeEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerEvents =\n | AccountsControllerChangeEvent\n | AccountsControllerSelectedAccountChangeEvent\n | AccountsControllerSelectedEvmAccountChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountsAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerAccountsRemovedEvent\n | AccountsControllerAccountRenamedEvent\n | AccountsControllerAccountBalancesUpdatesEvent\n | AccountsControllerAccountTransactionsUpdatedEvent\n | AccountsControllerAccountAssetListUpdatedEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerMessenger = Messenger<\n typeof controllerName,\n AccountsControllerActions | AllowedActions,\n AccountsControllerEvents | AllowedEvents\n>;\n\nconst accountsControllerMetadata = {\n internalAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n accountIdByAddress: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst defaultState: AccountsControllerState = {\n internalAccounts: {\n accounts: {},\n selectedAccount: '',\n },\n accountIdByAddress: {},\n};\n\n/**\n * @deprecated This constant is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport const EMPTY_ACCOUNT = {\n id: '',\n address: '',\n options: {},\n methods: [],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: '',\n keyring: {\n type: '',\n },\n importTime: 0,\n },\n};\n\n/**\n * A patch representing a keyring state change.\n */\ntype StatePatch = {\n previous: Record<string, InternalAccount>;\n added: {\n address: string;\n keyring: KeyringObject;\n }[];\n updated: InternalAccount[];\n removed: InternalAccount[];\n};\n\n/**\n * Controller that manages internal accounts.\n * The accounts controller is responsible for creating and managing internal accounts.\n * It also provides convenience methods for accessing and updating the internal accounts.\n * The accounts controller also listens for keyring state changes and updates the internal accounts accordingly.\n * The accounts controller also listens for snap state changes and updates the internal accounts accordingly.\n *\n * @deprecated This class is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport class AccountsController extends BaseController<\n typeof controllerName,\n AccountsControllerState,\n AccountsControllerMessenger\n> {\n /**\n * Constructor for AccountsController.\n *\n * @param options - The controller options.\n * @param options.messenger - The messenger object.\n * @param options.state - Initial state to set on this controller\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: AccountsControllerMessenger;\n state: AccountsControllerState;\n }) {\n const accountIdByAddress = constructAccountIdByAddress(\n state?.internalAccounts?.accounts ?? {},\n );\n super({\n messenger,\n name: controllerName,\n metadata: accountsControllerMetadata,\n state: {\n ...defaultState,\n ...state,\n accountIdByAddress,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#subscribeToMessageEvents();\n }\n\n /**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\n getAccount(accountId: string): InternalAccount | undefined {\n return this.state.internalAccounts.accounts[accountId];\n }\n\n /**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\n getAccounts(accountIds: string[]): (InternalAccount | undefined)[] {\n return accountIds.map((accountId) => this.getAccount(accountId));\n }\n\n /**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\n listAccounts(): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n return accounts.filter((account) => isEvmAccountType(account.type));\n }\n\n /**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\n listMultichainAccounts(chainId?: CaipChainId): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n if (!chainId) {\n return accounts;\n }\n\n if (!isCaipChainId(chainId)) {\n throw new Error(`Invalid CAIP-2 chain ID: ${String(chainId)}`);\n }\n\n return accounts.filter((account) =>\n isScopeEqualToAny(chainId, account.scopes),\n );\n }\n\n /**\n * Returns the internal account object for the given account ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object.\n * @throws An error if the account ID is not found.\n */\n #getAccountExpect(accountId: string): InternalAccount {\n const account = this.getAccount(accountId);\n if (account === undefined) {\n throw new Error(`Account Id \"${accountId}\" not found`);\n }\n return account;\n }\n\n /**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\n getSelectedAccount(): InternalAccount {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (!selectedAccount) {\n return EMPTY_ACCOUNT;\n }\n\n const account = this.#getAccountExpect(selectedAccount);\n if (isEvmAccountType(account.type)) {\n return account;\n }\n\n const accounts = this.listAccounts();\n if (!accounts.length) {\n // ! Should never reach this.\n throw new Error('No EVM accounts');\n }\n\n // This will never be undefined because we have already checked if accounts.length is > 0\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.#getLastSelectedAccount(accounts)!;\n }\n\n /**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\n getSelectedMultichainAccount(\n chainId?: CaipChainId,\n ): InternalAccount | undefined {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (!selectedAccount) {\n return EMPTY_ACCOUNT;\n }\n\n if (!chainId) {\n return this.#getAccountExpect(selectedAccount);\n }\n\n const accounts = this.listMultichainAccounts(chainId);\n return this.#getLastSelectedAccount(accounts);\n }\n\n /**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\n getAccountByAddress(address: string): InternalAccount | undefined {\n // We need to have a fallback as a cache miss might be attributed to a checksummed address being passed.\n let accountId = this.state.accountIdByAddress[address];\n if (!accountId) {\n // FIXME: We should not need lower-cased addresses, but some consumers might\n // still be using non-normalized addresses. For now we keep it\n // for convenience, but we will need to remove this fallback\n // at some point.\n // NOTE: We should only hit that branch for EVM accounts only.\n const lowercasedAddress = address.toLowerCase();\n accountId = this.state.accountIdByAddress[lowercasedAddress];\n if (accountId) {\n log(\n `Cache missed for account ID: ${accountId}, received address: \"${address}\", matched address: \"${lowercasedAddress}\"`,\n );\n }\n }\n return accountId ? this.getAccount(accountId) : undefined;\n }\n\n /**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\n setSelectedAccount(accountId: string): void {\n const account = this.#getAccountExpect(accountId);\n\n if (this.state.internalAccounts.selectedAccount === account.id) {\n return;\n }\n\n this.#update((state) => {\n const { internalAccounts } = state;\n\n internalAccounts.accounts[account.id].metadata.lastSelected = Date.now();\n internalAccounts.selectedAccount = account.id;\n });\n }\n\n /**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountName(accountId: string, accountName: string): void {\n // This will check for name uniqueness and fire the `accountRenamed` event\n // if the account has been renamed.\n this.updateAccountMetadata(accountId, {\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n });\n }\n\n /**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountNameAndSelectAccount(accountId: string, accountName: string): void {\n const account = this.#getAccountExpect(accountId);\n\n this.#assertAccountCanBeRenamed(account, accountName);\n\n const internalAccount = {\n ...account,\n metadata: {\n ...account.metadata,\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n lastSelected: this.#getLastSelectedIndex(),\n },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[account.id] = internalAccount;\n state.internalAccounts.selectedAccount = account.id;\n });\n\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n\n #assertAccountCanBeRenamed(\n account: InternalAccount,\n accountName: string,\n ): void {\n if (\n this.listMultichainAccounts().find(\n (internalAccount) =>\n internalAccount.metadata.name === accountName &&\n internalAccount.id !== account.id,\n )\n ) {\n throw new Error('Account name already exists');\n }\n }\n\n /**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\n updateAccountMetadata(\n accountId: string,\n metadata: Partial<InternalAccount['metadata']>,\n ): void {\n const account = this.#getAccountExpect(accountId);\n\n if (metadata.name) {\n this.#assertAccountCanBeRenamed(account, metadata.name);\n }\n\n const internalAccount = {\n ...account,\n metadata: { ...account.metadata, ...metadata },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[accountId] = internalAccount;\n });\n\n if (metadata.name) {\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n }\n\n /**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\n async updateAccounts(): Promise<void> {\n log('Synchronizing accounts with keyrings...');\n\n const keyringAccountIndexes = new Map<string, number>();\n\n const existingInternalAccounts = this.state.internalAccounts.accounts;\n const internalAccounts: AccountsControllerState['internalAccounts']['accounts'] =\n {};\n\n const { keyrings } = this.messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n const keyringTypeName = keyringTypeToName(keyring.type);\n\n for (const address of keyring.accounts) {\n const internalAccount = this.#getInternalAccountFromAddressAndType(\n address,\n keyring,\n );\n\n // This should never really happen, but if for some reason we're not\n // able to get the Snap keyring reference, this would return an\n // undefined account.\n // So we just skip it, even though, this should not really happen.\n if (!internalAccount) {\n continue;\n }\n\n // Get current index for this keyring (we use human indexing, so start at 1).\n const keyringAccountIndex =\n keyringAccountIndexes.get(keyringTypeName) ?? 1;\n\n const existingAccount = existingInternalAccounts[internalAccount.id];\n internalAccounts[internalAccount.id] = {\n ...internalAccount,\n\n metadata: {\n ...internalAccount.metadata,\n\n // Re-use existing metadata if any.\n name:\n existingAccount?.metadata.name ??\n `${keyringTypeName} ${keyringAccountIndex}`,\n importTime: existingAccount?.metadata.importTime ?? Date.now(),\n lastSelected: existingAccount?.metadata.lastSelected ?? 0,\n },\n };\n\n // Increment the account index for this keyring.\n keyringAccountIndexes.set(keyringTypeName, keyringAccountIndex + 1);\n }\n }\n\n this.#update((state) => {\n state.internalAccounts.accounts = internalAccounts;\n state.accountIdByAddress = constructAccountIdByAddress(internalAccounts);\n });\n\n log('Accounts synchronized!');\n }\n\n /**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\n loadBackup(backup: AccountsControllerState): void {\n if (backup.internalAccounts) {\n const accountIdByAddress = constructAccountIdByAddress(\n backup.internalAccounts.accounts,\n );\n this.update(\n (currentState: WritableDraft<AccountsControllerStrictState>) => {\n currentState.internalAccounts = backup.internalAccounts;\n currentState.accountIdByAddress = accountIdByAddress;\n },\n );\n }\n }\n\n /**\n * Gets an internal account representation for a non-Snap account.\n *\n * @param address - The address of the account.\n * @param keyring - The keyring object of the account.\n * @returns The generated internal account.\n */\n #getInternalAccountForNonSnapAccount(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount {\n const id = getUUIDFromAddressOfNormalAccount(address);\n\n // We might have an account for this ID already, so we'll just re-use\n // the same metadata\n const account = this.getAccount(id);\n const metadata: InternalAccount['metadata'] = {\n name: account?.metadata.name ?? '',\n ...(account?.metadata.nameLastUpdatedAt\n ? {\n nameLastUpdatedAt: account?.metadata.nameLastUpdatedAt,\n }\n : {}),\n importTime: account?.metadata.importTime ?? Date.now(),\n lastSelected: account?.metadata.lastSelected ?? 0,\n keyring: {\n type: keyring.type,\n },\n };\n\n let options: InternalAccount['options'] = {};\n if (isHdKeyringType(keyring.type)) {\n // We need to find the account index from its HD keyring.\n const groupIndex = getEvmGroupIndexFromAddressIndex(keyring, address);\n\n // If for some reason, we cannot find this address, then the caller made a mistake\n // and it did not use the proper keyring object. For now, we do not fail and just\n // consider this account as \"simple account\".\n if (groupIndex !== undefined) {\n // NOTE: We are not using the `hdPath` from the associated keyring here and\n // getting the keyring instance here feels a bit overkill.\n // This will be naturally fixed once every keyring start using `KeyringAccount` and implement the keyring API.\n const derivationPath = getEvmDerivationPathForIndex(groupIndex);\n\n // Those are \"legacy options\" and they were used before `KeyringAccount` added\n // support for type options. We keep those temporarily until we update everything\n // to use the new typed options.\n const legacyOptions = {\n entropySource: keyring.metadata.id,\n derivationPath,\n groupIndex,\n };\n\n // New typed entropy options. This is required for multichain accounts.\n const entropyOptions: { entropy: KeyringAccountEntropyOptions } = {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: keyring.metadata.id,\n derivationPath,\n groupIndex,\n },\n };\n\n options = {\n ...legacyOptions,\n ...entropyOptions,\n };\n }\n }\n\n return {\n id,\n address,\n options,\n methods: [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n ],\n scopes: [EthScope.Eoa],\n type: EthAccountType.Eoa,\n metadata,\n };\n }\n\n /**\n * Get Snap keyring from the keyring controller.\n *\n * @returns The Snap keyring if available.\n */\n #getSnapKeyring(): SnapKeyring | undefined {\n const [snapKeyring] = this.messenger.call(\n 'KeyringController:getKeyringsByType',\n SnapKeyring.type,\n );\n\n // Snap keyring is not available until the first account is created in the keyring\n // controller, so this might be undefined.\n return snapKeyring as SnapKeyring | undefined;\n }\n\n /**\n * Re-publish an account event.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param payload - The event payload. The type of the parameters for each event handler must\n * match the type of this payload.\n * @template EventType - A Snap keyring event type.\n */\n #handleOnSnapKeyringAccountEvent<\n EventType extends AccountsControllerEvents['type'],\n >(\n event: EventType,\n ...payload: ExtractEventPayload<AccountsControllerEvents, EventType>\n ): void {\n this.messenger.publish(event, ...payload);\n }\n\n /**\n * Handles changes in the keyring state, specifically when new accounts are added or removed.\n *\n * @param keyringState - The new state of the keyring controller.\n * @param keyringState.isUnlocked - True if the keyrings are unlocked, false otherwise.\n * @param keyringState.keyrings - List of all keyrings.\n */\n #handleOnKeyringStateChange({\n isUnlocked,\n keyrings,\n }: KeyringControllerState): void {\n // TODO: Change when accountAdded event is added to the keyring controller.\n\n // We check for keyrings length to be greater than 0 because the extension client may try execute\n // submit password twice and clear the keyring state.\n // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910\n if (!isUnlocked || keyrings.length === 0) {\n return;\n }\n\n log('Synchronizing accounts with keyrings (through :stateChange)...');\n\n // State patches.\n const generatePatch = (): StatePatch => {\n return {\n previous: {},\n added: [],\n updated: [],\n removed: [],\n };\n };\n const patches = {\n snap: generatePatch(),\n normal: generatePatch(),\n };\n\n // Gets the patch object based on the keyring type (since Snap accounts and other accounts\n // are handled differently).\n const patchOf = (type: string): StatePatch => {\n if (isSnapKeyringType(type)) {\n return patches.snap;\n }\n return patches.normal;\n };\n\n // Create a map (with lower-cased addresses) of all existing accounts.\n for (const account of this.listMultichainAccounts()) {\n const address = account.address.toLowerCase();\n const patch = patchOf(account.metadata.keyring.type);\n\n patch.previous[address] = account;\n }\n\n // Go over all keyring changes and create patches out of it.\n const addresses = new Set<string>();\n for (const keyring of keyrings) {\n const patch = patchOf(keyring.type);\n\n for (const accountAddress of keyring.accounts) {\n // Lower-case address to use it in the `previous` map.\n const address = accountAddress.toLowerCase();\n const account = patch.previous[address];\n\n if (account) {\n // If the account exists before, this might be an update.\n patch.updated.push(account);\n } else {\n // Otherwise, that's a new account.\n patch.added.push({\n address,\n keyring,\n });\n }\n\n // Keep track of those address to check for removed accounts later.\n addresses.add(address);\n }\n }\n\n // We might have accounts associated with removed keyrings, so we iterate\n // over all previous known accounts and check against the keyring addresses.\n for (const patch of [patches.snap, patches.normal]) {\n for (const [address, account] of Object.entries(patch.previous)) {\n // If a previous address is not part of the new addesses, then it got removed.\n if (!addresses.has(address)) {\n patch.removed.push(account);\n }\n }\n }\n\n // Diff that we will use to publish events afterward.\n const diff: { removed: string[]; added: InternalAccount[] } = {\n removed: [],\n added: [],\n };\n\n this.#update(\n (state) => {\n const { internalAccounts, accountIdByAddress } = state;\n\n for (const patch of [patches.snap, patches.normal]) {\n for (const account of patch.removed) {\n delete internalAccounts.accounts[account.id];\n delete accountIdByAddress[account.address];\n\n diff.removed.push(account.id);\n }\n\n for (const added of patch.added) {\n const account = this.#getInternalAccountFromAddressAndType(\n added.address,\n added.keyring,\n );\n\n if (account) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // If it's the first account, we need to select it.\n const lastSelected =\n accounts.length === 0 ? this.#getLastSelectedIndex() : 0;\n\n internalAccounts.accounts[account.id] = {\n ...account,\n metadata: {\n ...account.metadata,\n importTime: Date.now(),\n lastSelected,\n },\n };\n\n accountIdByAddress[account.address] = account.id;\n\n diff.added.push(internalAccounts.accounts[account.id]);\n }\n }\n }\n },\n // Will get executed after the update, but before re-selecting an account in case\n // the current one is not valid anymore.\n () => {\n // Now publish events\n for (const id of diff.removed) {\n this.messenger.publish('AccountsController:accountRemoved', id);\n }\n if (diff.removed.length > 0) {\n this.messenger.publish(\n 'AccountsController:accountsRemoved',\n diff.removed,\n );\n }\n\n for (const account of diff.added) {\n this.messenger.publish('AccountsController:accountAdded', account);\n }\n if (diff.added.length > 0) {\n this.messenger.publish(\n 'AccountsController:accountsAdded',\n diff.added,\n );\n }\n },\n );\n\n log('Accounts synchronized (through :stateChange)!');\n\n // NOTE: Since we also track \"updated\" accounts with our patches, we could fire a new event\n // like `accountUpdated` (we would still need to check if anything really changed on the account).\n }\n\n /**\n * Update the state and fixup the currently selected account.\n *\n * @param callback - Callback for updating state, passed a draft state object.\n * @param beforeAutoSelectAccount - Callback to be executed before auto-selecting an account\n * if the current one is no longer available.\n */\n #update(\n callback: (state: WritableDraft<AccountsControllerStrictState>) => void,\n beforeAutoSelectAccount?: () => void,\n ): void {\n // The currently selected account might get deleted during the update, so keep track\n // of it before doing any change.\n const previouslySelectedAccount =\n this.state.internalAccounts.selectedAccount;\n\n this.update((state: WritableDraft<AccountsControllerStrictState>) => {\n callback(state);\n\n // If the account no longer exists (or none is selected), we need to re-select another one.\n const { internalAccounts } = state;\n if (!internalAccounts.accounts[previouslySelectedAccount]) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // Get the lastly selected account (according to the current accounts).\n const lastSelectedAccount = this.#getLastSelectedAccount(accounts);\n if (lastSelectedAccount) {\n internalAccounts.selectedAccount = lastSelectedAccount.id;\n internalAccounts.accounts[\n lastSelectedAccount.id\n ].metadata.lastSelected = this.#getLastSelectedIndex();\n } else {\n // It will be undefined if there are no accounts.\n internalAccounts.selectedAccount = '';\n }\n }\n });\n\n // We might want to do some pre-work before selecting a new account.\n beforeAutoSelectAccount?.();\n\n // Now, we compare the newly selected account, and we send event if different.\n const { selectedAccount } = this.state.internalAccounts;\n if (selectedAccount && selectedAccount !== previouslySelectedAccount) {\n const account = this.getSelectedMultichainAccount();\n\n // The account should always be defined at this point, since we have already checked for\n // `selectedAccount` to be non-empty.\n if (account) {\n if (isEvmAccountType(account.type)) {\n this.messenger.publish(\n 'AccountsController:selectedEvmAccountChange',\n account,\n );\n }\n this.messenger.publish(\n 'AccountsController:selectedAccountChange',\n account,\n );\n }\n }\n }\n\n /**\n * Handles the change in SnapControllerState by updating the metadata of accounts that have a snap enabled.\n *\n * @param snapState - The new SnapControllerState.\n */\n #handleOnSnapStateChange(snapState: SnapControllerState): void {\n // Only check if Snaps changed in status.\n const { snaps } = snapState;\n\n const accounts: { id: string; enabled: boolean }[] = [];\n for (const account of this.listMultichainAccounts()) {\n if (account.metadata.snap) {\n const snap = snaps[account.metadata.snap.id as SnapId];\n\n if (snap) {\n const enabled = snap.enabled && !snap.blocked;\n const metadata = account.metadata.snap;\n\n if (metadata.enabled !== enabled) {\n accounts.push({ id: account.id, enabled });\n }\n } else {\n // If Snap could not be found on the state, we consider it disabled.\n accounts.push({ id: account.id, enabled: false });\n }\n }\n }\n\n if (accounts.length > 0) {\n this.update((state) => {\n for (const { id, enabled } of accounts) {\n const account = state.internalAccounts.accounts[id];\n\n if (account.metadata.snap) {\n account.metadata.snap.enabled = enabled;\n }\n }\n });\n }\n }\n\n /**\n * Returns the last selected account from the given array of accounts.\n *\n * @param accounts - An array of InternalAccount objects.\n * @returns The InternalAccount object that was last selected, or undefined if the array is empty.\n */\n #getLastSelectedAccount(\n accounts: InternalAccount[],\n ): InternalAccount | undefined {\n const [accountToSelect] = accounts.sort((accountA, accountB) => {\n // sort by lastSelected descending\n return (\n (accountB.metadata.lastSelected ?? 0) -\n (accountA.metadata.lastSelected ?? 0)\n );\n });\n\n return accountToSelect;\n }\n\n /**\n * Retrieves the index value for `metadata.lastSelected`.\n *\n * @returns The index value.\n */\n #getLastSelectedIndex(): number {\n // NOTE: For now we use the current date, since we know this value\n // will always be higher than any already selected account index.\n return Date.now();\n }\n\n /**\n * Get an internal account given an address and a keyring type.\n *\n * If the account is not a Snap Keyring account, generates an internal account for it and adds it to the controller.\n * If the account is a Snap Keyring account, retrieves the account from the keyring and adds it to the controller.\n *\n * @param address - The address of the new account.\n * @param keyring - The keyring object of that new account.\n * @returns The newly generated/retrieved internal account.\n */\n #getInternalAccountFromAddressAndType(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount | undefined {\n if (isSnapKeyringType(keyring.type)) {\n const snapKeyring = this.#getSnapKeyring();\n\n // We need the Snap keyring to retrieve the account from its address.\n if (!snapKeyring) {\n return undefined;\n }\n\n // This might be undefined if the Snap deleted the account before\n // reaching that point.\n let account = snapKeyring.getAccountByAddress(address);\n if (account) {\n // We force the copy here, to avoid mutating the reference returned by the Snap keyring.\n account = cloneDeep(account);\n\n // MIGRATION: To avoid any existing Snap account migration, we are\n // just \"adding\" the new typed options that we need for multichain\n // accounts. Ultimately, we would need a real Snap account migrations\n // (being handled by each Snaps).\n if (isHdSnapKeyringAccount(account)) {\n const options: HdSnapKeyringAccount['options'] = {\n ...account.options,\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: account.options.entropySource,\n groupIndex: account.options.index,\n derivationPath: account.options.derivationPath,\n },\n };\n // Inject the new typed options to the internal account copy.\n account.options = options;\n }\n }\n\n return account;\n }\n\n return this.#getInternalAccountForNonSnapAccount(address, keyring);\n }\n\n /**\n * Handles the change in multichain network by updating the selected account.\n *\n * @param id - The EVM client ID or non-EVM chain ID that changed.\n */\n #handleOnMultichainNetworkDidChange(id: NetworkClientId | CaipChainId): void {\n let accountId: string;\n\n // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin\n // MultichainNetworkController will handle throwing an error if the Caip chain ID is not supported\n if (isCaipChainId(id)) {\n // Update selected account to non evm account\n const lastSelectedNonEvmAccount = this.getSelectedMultichainAccount(id);\n // @ts-expect-error - This should never be undefined, otherwise it's a bug that should be handled\n accountId = lastSelectedNonEvmAccount.id;\n } else {\n // Update selected account to evm account\n const lastSelectedEvmAccount = this.getSelectedAccount();\n accountId = lastSelectedEvmAccount.id;\n }\n\n if (this.state.internalAccounts.selectedAccount === accountId) {\n return;\n }\n\n this.update((currentState) => {\n currentState.internalAccounts.accounts[accountId].metadata.lastSelected =\n Date.now();\n currentState.internalAccounts.selectedAccount = accountId;\n });\n\n // DO NOT publish AccountsController:setSelectedAccount to prevent circular listener loops\n }\n\n /**\n * Subscribes to message events.\n */\n #subscribeToMessageEvents(): void {\n this.messenger.subscribe('SnapController:stateChange', (snapStateState) =>\n this.#handleOnSnapStateChange(snapStateState),\n );\n\n this.messenger.subscribe('KeyringController:stateChange', (keyringState) =>\n this.#handleOnKeyringStateChange(keyringState),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountAssetListUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountAssetListUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountBalancesUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountBalancesUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountTransactionsUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountTransactionsUpdated',\n snapAccountEvent,\n ),\n );\n\n // Handle account change when multichain network is changed\n this.messenger.subscribe(\n 'MultichainNetworkController:networkDidChange',\n (id) => this.#handleOnMultichainNetworkDidChange(id),\n );\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { EthAccountType, EthScope } from "@metamask/keyring-api";
|
|
|
5
5
|
import type { KeyringControllerGetKeyringsByTypeAction, KeyringControllerStateChangeEvent, KeyringControllerGetStateAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
7
7
|
import type { Messenger } from "@metamask/messenger";
|
|
8
|
-
import type {
|
|
8
|
+
import type { SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
|
|
9
9
|
import type { CaipChainId } from "@metamask/utils";
|
|
10
10
|
import { AccountsControllerMethodActions } from "./AccountsController-method-action-types.cjs";
|
|
11
11
|
import type { MultichainNetworkControllerNetworkDidChangeEvent } from "./types.cjs";
|
|
@@ -70,6 +70,10 @@ export type AccountsControllerAccountAddedEvent = {
|
|
|
70
70
|
type: `${typeof controllerName}:accountAdded`;
|
|
71
71
|
payload: [InternalAccount];
|
|
72
72
|
};
|
|
73
|
+
export type AccountsControllerAccountsAddedEvent = {
|
|
74
|
+
type: `${typeof controllerName}:accountsAdded`;
|
|
75
|
+
payload: [InternalAccount[]];
|
|
76
|
+
};
|
|
73
77
|
/**
|
|
74
78
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
75
79
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -78,6 +82,10 @@ export type AccountsControllerAccountRemovedEvent = {
|
|
|
78
82
|
type: `${typeof controllerName}:accountRemoved`;
|
|
79
83
|
payload: [AccountId];
|
|
80
84
|
};
|
|
85
|
+
export type AccountsControllerAccountsRemovedEvent = {
|
|
86
|
+
type: `${typeof controllerName}:accountsRemoved`;
|
|
87
|
+
payload: [AccountId[]];
|
|
88
|
+
};
|
|
81
89
|
/**
|
|
82
90
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
83
91
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -114,12 +122,12 @@ export type AccountsControllerAccountAssetListUpdatedEvent = {
|
|
|
114
122
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
115
123
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
116
124
|
*/
|
|
117
|
-
export type AllowedEvents =
|
|
125
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent | SnapControllerStateChangeEvent | SnapKeyringAccountAssetListUpdatedEvent | SnapKeyringAccountBalancesUpdatedEvent | SnapKeyringAccountTransactionsUpdatedEvent | MultichainNetworkControllerNetworkDidChangeEvent;
|
|
118
126
|
/**
|
|
119
127
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
120
128
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
121
129
|
*/
|
|
122
|
-
export type AccountsControllerEvents = AccountsControllerChangeEvent | AccountsControllerSelectedAccountChangeEvent | AccountsControllerSelectedEvmAccountChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountRenamedEvent | AccountsControllerAccountBalancesUpdatesEvent | AccountsControllerAccountTransactionsUpdatedEvent | AccountsControllerAccountAssetListUpdatedEvent;
|
|
130
|
+
export type AccountsControllerEvents = AccountsControllerChangeEvent | AccountsControllerSelectedAccountChangeEvent | AccountsControllerSelectedEvmAccountChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountsAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountsRemovedEvent | AccountsControllerAccountRenamedEvent | AccountsControllerAccountBalancesUpdatesEvent | AccountsControllerAccountTransactionsUpdatedEvent | AccountsControllerAccountAssetListUpdatedEvent;
|
|
123
131
|
/**
|
|
124
132
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
125
133
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController.d.cts","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAEnC,OAAO,KAAK,EACV,uCAAuC,EACvC,sCAAsC,EACtC,0CAA0C,EAC3C,mCAAmC;AAEpC,OAAO,EACL,cAAc,EAEd,QAAQ,EAGT,8BAA8B;AAC/B,OAAO,KAAK,EAEV,wCAAwC,EACxC,iCAAiC,EACjC,+BAA+B,EAEhC,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAuB,4BAA4B;AAE1E,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"AccountsController.d.cts","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAEnC,OAAO,KAAK,EACV,uCAAuC,EACvC,sCAAsC,EACtC,0CAA0C,EAC3C,mCAAmC;AAEpC,OAAO,EACL,cAAc,EAEd,QAAQ,EAGT,8BAA8B;AAC/B,OAAO,KAAK,EAEV,wCAAwC,EACxC,iCAAiC,EACjC,+BAA+B,EAEhC,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAuB,4BAA4B;AAE1E,OAAO,KAAK,EAEV,8B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AG,SAAS;IAoBjE;;;;;;OAMG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAe3C;;;;;;;;OAQG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAS5D;;;;;;;;OAQG;IACH,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAyC5E;;;;;;;OAOG;IACH,qBAAqB,CACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,GAC7C,IAAI;IAwBP;;;;;;;OAOG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA4DrC;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;CAgkBlD"}
|
|
@@ -5,7 +5,7 @@ import { EthAccountType, EthScope } from "@metamask/keyring-api";
|
|
|
5
5
|
import type { KeyringControllerGetKeyringsByTypeAction, KeyringControllerStateChangeEvent, KeyringControllerGetStateAction } from "@metamask/keyring-controller";
|
|
6
6
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
7
7
|
import type { Messenger } from "@metamask/messenger";
|
|
8
|
-
import type {
|
|
8
|
+
import type { SnapControllerStateChangeEvent } from "@metamask/snaps-controllers";
|
|
9
9
|
import type { CaipChainId } from "@metamask/utils";
|
|
10
10
|
import { AccountsControllerMethodActions } from "./AccountsController-method-action-types.mjs";
|
|
11
11
|
import type { MultichainNetworkControllerNetworkDidChangeEvent } from "./types.mjs";
|
|
@@ -70,6 +70,10 @@ export type AccountsControllerAccountAddedEvent = {
|
|
|
70
70
|
type: `${typeof controllerName}:accountAdded`;
|
|
71
71
|
payload: [InternalAccount];
|
|
72
72
|
};
|
|
73
|
+
export type AccountsControllerAccountsAddedEvent = {
|
|
74
|
+
type: `${typeof controllerName}:accountsAdded`;
|
|
75
|
+
payload: [InternalAccount[]];
|
|
76
|
+
};
|
|
73
77
|
/**
|
|
74
78
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
75
79
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -78,6 +82,10 @@ export type AccountsControllerAccountRemovedEvent = {
|
|
|
78
82
|
type: `${typeof controllerName}:accountRemoved`;
|
|
79
83
|
payload: [AccountId];
|
|
80
84
|
};
|
|
85
|
+
export type AccountsControllerAccountsRemovedEvent = {
|
|
86
|
+
type: `${typeof controllerName}:accountsRemoved`;
|
|
87
|
+
payload: [AccountId[]];
|
|
88
|
+
};
|
|
81
89
|
/**
|
|
82
90
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
83
91
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -114,12 +122,12 @@ export type AccountsControllerAccountAssetListUpdatedEvent = {
|
|
|
114
122
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
115
123
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
116
124
|
*/
|
|
117
|
-
export type AllowedEvents =
|
|
125
|
+
export type AllowedEvents = KeyringControllerStateChangeEvent | SnapControllerStateChangeEvent | SnapKeyringAccountAssetListUpdatedEvent | SnapKeyringAccountBalancesUpdatedEvent | SnapKeyringAccountTransactionsUpdatedEvent | MultichainNetworkControllerNetworkDidChangeEvent;
|
|
118
126
|
/**
|
|
119
127
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
120
128
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
121
129
|
*/
|
|
122
|
-
export type AccountsControllerEvents = AccountsControllerChangeEvent | AccountsControllerSelectedAccountChangeEvent | AccountsControllerSelectedEvmAccountChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountRenamedEvent | AccountsControllerAccountBalancesUpdatesEvent | AccountsControllerAccountTransactionsUpdatedEvent | AccountsControllerAccountAssetListUpdatedEvent;
|
|
130
|
+
export type AccountsControllerEvents = AccountsControllerChangeEvent | AccountsControllerSelectedAccountChangeEvent | AccountsControllerSelectedEvmAccountChangeEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountsAddedEvent | AccountsControllerAccountRemovedEvent | AccountsControllerAccountsRemovedEvent | AccountsControllerAccountRenamedEvent | AccountsControllerAccountBalancesUpdatesEvent | AccountsControllerAccountTransactionsUpdatedEvent | AccountsControllerAccountAssetListUpdatedEvent;
|
|
123
131
|
/**
|
|
124
132
|
* @deprecated This type is deprecated and will be removed in a future version.
|
|
125
133
|
* Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController.d.mts","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAEnC,OAAO,KAAK,EACV,uCAAuC,EACvC,sCAAsC,EACtC,0CAA0C,EAC3C,mCAAmC;AAEpC,OAAO,EACL,cAAc,EAEd,QAAQ,EAGT,8BAA8B;AAC/B,OAAO,KAAK,EAEV,wCAAwC,EACxC,iCAAiC,EACjC,+BAA+B,EAEhC,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAuB,4BAA4B;AAE1E,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"AccountsController.d.mts","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAEnC,OAAO,KAAK,EACV,uCAAuC,EACvC,sCAAsC,EACtC,0CAA0C,EAC3C,mCAAmC;AAEpC,OAAO,EACL,cAA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AAG,eAAe,EAAE;IAgChE;;;;;;OAMG;IACH,kBAAkB,IAAI,eAAe;IA2BrC;;;;;;;;;OASG;IACH,4BAA4B,CAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,eAAe,GAAG,SAAS;IAmB9B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAoBjE;;;;;;OAMG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAe3C;;;;;;;;OAQG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAS5D;;;;;;;;OAQG;IACH,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAyC5E;;;;;;;OAOG;IACH,qBAAqB,CACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,GAC7C,IAAI;IAwBP;;;;;;;OAOG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA4DrC;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;CAgkBlD"}
|
|
@@ -165,7 +165,7 @@ export class AccountsController extends BaseController {
|
|
|
165
165
|
const { internalAccounts: { selectedAccount }, } = this.state;
|
|
166
166
|
// Edge case where the extension is setup but the srp is not yet created
|
|
167
167
|
// certain ui elements will query the selected address before any accounts are created.
|
|
168
|
-
if (selectedAccount
|
|
168
|
+
if (!selectedAccount) {
|
|
169
169
|
return EMPTY_ACCOUNT;
|
|
170
170
|
}
|
|
171
171
|
const account = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getAccountExpect).call(this, selectedAccount);
|
|
@@ -195,7 +195,7 @@ export class AccountsController extends BaseController {
|
|
|
195
195
|
const { internalAccounts: { selectedAccount }, } = this.state;
|
|
196
196
|
// Edge case where the extension is setup but the srp is not yet created
|
|
197
197
|
// certain ui elements will query the selected address before any accounts are created.
|
|
198
|
-
if (selectedAccount
|
|
198
|
+
if (!selectedAccount) {
|
|
199
199
|
return EMPTY_ACCOUNT;
|
|
200
200
|
}
|
|
201
201
|
if (!chainId) {
|
|
@@ -578,9 +578,15 @@ _AccountsController_instances = new WeakSet(), _AccountsController_getAccountExp
|
|
|
578
578
|
for (const id of diff.removed) {
|
|
579
579
|
this.messenger.publish('AccountsController:accountRemoved', id);
|
|
580
580
|
}
|
|
581
|
+
if (diff.removed.length > 0) {
|
|
582
|
+
this.messenger.publish('AccountsController:accountsRemoved', diff.removed);
|
|
583
|
+
}
|
|
581
584
|
for (const account of diff.added) {
|
|
582
585
|
this.messenger.publish('AccountsController:accountAdded', account);
|
|
583
586
|
}
|
|
587
|
+
if (diff.added.length > 0) {
|
|
588
|
+
this.messenger.publish('AccountsController:accountsAdded', diff.added);
|
|
589
|
+
}
|
|
584
590
|
});
|
|
585
591
|
log('Accounts synchronized (through :stateChange)!');
|
|
586
592
|
// NOTE: Since we also track "updated" accounts with our patches, we could fire a new event
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountsController.mjs","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAOzD,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,+BAA+B,EAChC,8BAA8B;AAS/B,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAQ5D,OAAO,EAAE,aAAa,EAAE,wBAAwB;;;AAMhD,OAAO,EAAE,aAAa,IAAI,GAAG,EAAE,qBAAiB;AAIhD,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,gCAAgC,EAChC,iCAAiC,EACjC,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EAClB,oBAAgB;AAEj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9C,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,+BAA+B,EAAE,CAAC,YAAY,EAAE,EAAE,CACzE,uBAAA,IAAI,qFAA4B,MAAhC,IAAI,EAA6B,YAAY,CAAC,CAC/C,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,qCAAqC,EACrC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,4CAA4C,EAC5C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,oCAAoC,EACpC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,2CAA2C,EAC3C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,wCAAwC,EACxC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,+CAA+C,EAC/C,gBAAgB,CACjB,CACJ,CAAC;IAEF,2DAA2D;IAC3D,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,8CAA8C,EAC9C,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,6FAAoC,MAAxC,IAAI,EAAqC,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type {\n SnapKeyringAccountAssetListUpdatedEvent,\n SnapKeyringAccountBalancesUpdatedEvent,\n SnapKeyringAccountTransactionsUpdatedEvent,\n} from '@metamask/eth-snap-keyring';\nimport type { KeyringAccountEntropyOptions } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n isEvmAccountType,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerGetStateAction,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { isScopeEqualToAny } from '@metamask/keyring-utils';\nimport type { Messenger, ExtractEventPayload } from '@metamask/messenger';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type {\n SnapControllerState,\n SnapStateChange,\n} from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { isCaipChainId } from '@metamask/utils';\nimport type { CaipChainId } from '@metamask/utils';\nimport type { WritableDraft } from 'immer/dist/internal.js';\nimport { cloneDeep } from 'lodash';\n\nimport { AccountsControllerMethodActions } from './AccountsController-method-action-types';\nimport { projectLogger as log } from './logger';\nimport type { MultichainNetworkControllerNetworkDidChangeEvent } from './types';\nimport type { AccountsControllerStrictState } from './typing';\nimport type { HdSnapKeyringAccount } from './utils';\nimport {\n constructAccountIdByAddress,\n getEvmDerivationPathForIndex,\n getEvmGroupIndexFromAddressIndex,\n getUUIDFromAddressOfNormalAccount,\n isHdKeyringType,\n isHdSnapKeyringAccount,\n isSnapKeyringType,\n keyringTypeToName,\n} from './utils';\n\nconst controllerName = 'AccountsController';\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountId = string;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerState = {\n internalAccounts: {\n accounts: Record<AccountId, InternalAccount>;\n selectedAccount: string; // id of the selected account\n };\n accountIdByAddress: Record<InternalAccount['address'], AccountId>;\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountsControllerState\n>;\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'setSelectedAccount',\n 'setAccountName',\n 'setAccountNameAndSelectAccount',\n 'listAccounts',\n 'listMultichainAccounts',\n 'updateAccounts',\n 'getSelectedAccount',\n 'getSelectedMultichainAccount',\n 'getAccountByAddress',\n 'getAccount',\n 'getAccounts',\n 'updateAccountMetadata',\n 'loadBackup',\n] as const;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedActions =\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetStateAction;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerActions =\n | AccountsControllerGetStateAction\n | AccountsControllerMethodActions;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountsControllerState\n>;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedAccountChangeEvent = {\n type: `${typeof controllerName}:selectedAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedEvmAccountChangeEvent = {\n type: `${typeof controllerName}:selectedEvmAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAddedEvent = {\n type: `${typeof controllerName}:accountAdded`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRemovedEvent = {\n type: `${typeof controllerName}:accountRemoved`;\n payload: [AccountId];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRenamedEvent = {\n type: `${typeof controllerName}:accountRenamed`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountBalancesUpdatesEvent = {\n type: `${typeof controllerName}:accountBalancesUpdated`;\n payload: SnapKeyringAccountBalancesUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountTransactionsUpdatedEvent = {\n type: `${typeof controllerName}:accountTransactionsUpdated`;\n payload: SnapKeyringAccountTransactionsUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAssetListUpdatedEvent = {\n type: `${typeof controllerName}:accountAssetListUpdated`;\n payload: SnapKeyringAccountAssetListUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedEvents =\n | SnapStateChange\n | KeyringControllerStateChangeEvent\n | SnapKeyringAccountAssetListUpdatedEvent\n | SnapKeyringAccountBalancesUpdatedEvent\n | SnapKeyringAccountTransactionsUpdatedEvent\n | MultichainNetworkControllerNetworkDidChangeEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerEvents =\n | AccountsControllerChangeEvent\n | AccountsControllerSelectedAccountChangeEvent\n | AccountsControllerSelectedEvmAccountChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerAccountRenamedEvent\n | AccountsControllerAccountBalancesUpdatesEvent\n | AccountsControllerAccountTransactionsUpdatedEvent\n | AccountsControllerAccountAssetListUpdatedEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerMessenger = Messenger<\n typeof controllerName,\n AccountsControllerActions | AllowedActions,\n AccountsControllerEvents | AllowedEvents\n>;\n\nconst accountsControllerMetadata = {\n internalAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n accountIdByAddress: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst defaultState: AccountsControllerState = {\n internalAccounts: {\n accounts: {},\n selectedAccount: '',\n },\n accountIdByAddress: {},\n};\n\n/**\n * @deprecated This constant is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport const EMPTY_ACCOUNT = {\n id: '',\n address: '',\n options: {},\n methods: [],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: '',\n keyring: {\n type: '',\n },\n importTime: 0,\n },\n};\n\n/**\n * A patch representing a keyring state change.\n */\ntype StatePatch = {\n previous: Record<string, InternalAccount>;\n added: {\n address: string;\n keyring: KeyringObject;\n }[];\n updated: InternalAccount[];\n removed: InternalAccount[];\n};\n\n/**\n * Controller that manages internal accounts.\n * The accounts controller is responsible for creating and managing internal accounts.\n * It also provides convenience methods for accessing and updating the internal accounts.\n * The accounts controller also listens for keyring state changes and updates the internal accounts accordingly.\n * The accounts controller also listens for snap state changes and updates the internal accounts accordingly.\n *\n * @deprecated This class is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport class AccountsController extends BaseController<\n typeof controllerName,\n AccountsControllerState,\n AccountsControllerMessenger\n> {\n /**\n * Constructor for AccountsController.\n *\n * @param options - The controller options.\n * @param options.messenger - The messenger object.\n * @param options.state - Initial state to set on this controller\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: AccountsControllerMessenger;\n state: AccountsControllerState;\n }) {\n const accountIdByAddress = constructAccountIdByAddress(\n state?.internalAccounts?.accounts ?? {},\n );\n super({\n messenger,\n name: controllerName,\n metadata: accountsControllerMetadata,\n state: {\n ...defaultState,\n ...state,\n accountIdByAddress,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#subscribeToMessageEvents();\n }\n\n /**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\n getAccount(accountId: string): InternalAccount | undefined {\n return this.state.internalAccounts.accounts[accountId];\n }\n\n /**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\n getAccounts(accountIds: string[]): (InternalAccount | undefined)[] {\n return accountIds.map((accountId) => this.getAccount(accountId));\n }\n\n /**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\n listAccounts(): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n return accounts.filter((account) => isEvmAccountType(account.type));\n }\n\n /**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\n listMultichainAccounts(chainId?: CaipChainId): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n if (!chainId) {\n return accounts;\n }\n\n if (!isCaipChainId(chainId)) {\n throw new Error(`Invalid CAIP-2 chain ID: ${String(chainId)}`);\n }\n\n return accounts.filter((account) =>\n isScopeEqualToAny(chainId, account.scopes),\n );\n }\n\n /**\n * Returns the internal account object for the given account ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object.\n * @throws An error if the account ID is not found.\n */\n #getAccountExpect(accountId: string): InternalAccount {\n const account = this.getAccount(accountId);\n if (account === undefined) {\n throw new Error(`Account Id \"${accountId}\" not found`);\n }\n return account;\n }\n\n /**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\n getSelectedAccount(): InternalAccount {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (selectedAccount === '') {\n return EMPTY_ACCOUNT;\n }\n\n const account = this.#getAccountExpect(selectedAccount);\n if (isEvmAccountType(account.type)) {\n return account;\n }\n\n const accounts = this.listAccounts();\n if (!accounts.length) {\n // ! Should never reach this.\n throw new Error('No EVM accounts');\n }\n\n // This will never be undefined because we have already checked if accounts.length is > 0\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.#getLastSelectedAccount(accounts)!;\n }\n\n /**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\n getSelectedMultichainAccount(\n chainId?: CaipChainId,\n ): InternalAccount | undefined {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (selectedAccount === '') {\n return EMPTY_ACCOUNT;\n }\n\n if (!chainId) {\n return this.#getAccountExpect(selectedAccount);\n }\n\n const accounts = this.listMultichainAccounts(chainId);\n return this.#getLastSelectedAccount(accounts);\n }\n\n /**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\n getAccountByAddress(address: string): InternalAccount | undefined {\n // We need to have a fallback as a cache miss might be attributed to a checksummed address being passed.\n let accountId = this.state.accountIdByAddress[address];\n if (!accountId) {\n // FIXME: We should not need lower-cased addresses, but some consumers might\n // still be using non-normalized addresses. For now we keep it\n // for convenience, but we will need to remove this fallback\n // at some point.\n // NOTE: We should only hit that branch for EVM accounts only.\n const lowercasedAddress = address.toLowerCase();\n accountId = this.state.accountIdByAddress[lowercasedAddress];\n if (accountId) {\n log(\n `Cache missed for account ID: ${accountId}, received address: \"${address}\", matched address: \"${lowercasedAddress}\"`,\n );\n }\n }\n return accountId ? this.getAccount(accountId) : undefined;\n }\n\n /**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\n setSelectedAccount(accountId: string): void {\n const account = this.#getAccountExpect(accountId);\n\n if (this.state.internalAccounts.selectedAccount === account.id) {\n return;\n }\n\n this.#update((state) => {\n const { internalAccounts } = state;\n\n internalAccounts.accounts[account.id].metadata.lastSelected = Date.now();\n internalAccounts.selectedAccount = account.id;\n });\n }\n\n /**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountName(accountId: string, accountName: string): void {\n // This will check for name uniqueness and fire the `accountRenamed` event\n // if the account has been renamed.\n this.updateAccountMetadata(accountId, {\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n });\n }\n\n /**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountNameAndSelectAccount(accountId: string, accountName: string): void {\n const account = this.#getAccountExpect(accountId);\n\n this.#assertAccountCanBeRenamed(account, accountName);\n\n const internalAccount = {\n ...account,\n metadata: {\n ...account.metadata,\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n lastSelected: this.#getLastSelectedIndex(),\n },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[account.id] = internalAccount;\n state.internalAccounts.selectedAccount = account.id;\n });\n\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n\n #assertAccountCanBeRenamed(\n account: InternalAccount,\n accountName: string,\n ): void {\n if (\n this.listMultichainAccounts().find(\n (internalAccount) =>\n internalAccount.metadata.name === accountName &&\n internalAccount.id !== account.id,\n )\n ) {\n throw new Error('Account name already exists');\n }\n }\n\n /**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\n updateAccountMetadata(\n accountId: string,\n metadata: Partial<InternalAccount['metadata']>,\n ): void {\n const account = this.#getAccountExpect(accountId);\n\n if (metadata.name) {\n this.#assertAccountCanBeRenamed(account, metadata.name);\n }\n\n const internalAccount = {\n ...account,\n metadata: { ...account.metadata, ...metadata },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[accountId] = internalAccount;\n });\n\n if (metadata.name) {\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n }\n\n /**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\n async updateAccounts(): Promise<void> {\n log('Synchronizing accounts with keyrings...');\n\n const keyringAccountIndexes = new Map<string, number>();\n\n const existingInternalAccounts = this.state.internalAccounts.accounts;\n const internalAccounts: AccountsControllerState['internalAccounts']['accounts'] =\n {};\n\n const { keyrings } = this.messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n const keyringTypeName = keyringTypeToName(keyring.type);\n\n for (const address of keyring.accounts) {\n const internalAccount = this.#getInternalAccountFromAddressAndType(\n address,\n keyring,\n );\n\n // This should never really happen, but if for some reason we're not\n // able to get the Snap keyring reference, this would return an\n // undefined account.\n // So we just skip it, even though, this should not really happen.\n if (!internalAccount) {\n continue;\n }\n\n // Get current index for this keyring (we use human indexing, so start at 1).\n const keyringAccountIndex =\n keyringAccountIndexes.get(keyringTypeName) ?? 1;\n\n const existingAccount = existingInternalAccounts[internalAccount.id];\n internalAccounts[internalAccount.id] = {\n ...internalAccount,\n\n metadata: {\n ...internalAccount.metadata,\n\n // Re-use existing metadata if any.\n name:\n existingAccount?.metadata.name ??\n `${keyringTypeName} ${keyringAccountIndex}`,\n importTime: existingAccount?.metadata.importTime ?? Date.now(),\n lastSelected: existingAccount?.metadata.lastSelected ?? 0,\n },\n };\n\n // Increment the account index for this keyring.\n keyringAccountIndexes.set(keyringTypeName, keyringAccountIndex + 1);\n }\n }\n\n this.#update((state) => {\n state.internalAccounts.accounts = internalAccounts;\n state.accountIdByAddress = constructAccountIdByAddress(internalAccounts);\n });\n\n log('Accounts synchronized!');\n }\n\n /**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\n loadBackup(backup: AccountsControllerState): void {\n if (backup.internalAccounts) {\n const accountIdByAddress = constructAccountIdByAddress(\n backup.internalAccounts.accounts,\n );\n this.update(\n (currentState: WritableDraft<AccountsControllerStrictState>) => {\n currentState.internalAccounts = backup.internalAccounts;\n currentState.accountIdByAddress = accountIdByAddress;\n },\n );\n }\n }\n\n /**\n * Gets an internal account representation for a non-Snap account.\n *\n * @param address - The address of the account.\n * @param keyring - The keyring object of the account.\n * @returns The generated internal account.\n */\n #getInternalAccountForNonSnapAccount(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount {\n const id = getUUIDFromAddressOfNormalAccount(address);\n\n // We might have an account for this ID already, so we'll just re-use\n // the same metadata\n const account = this.getAccount(id);\n const metadata: InternalAccount['metadata'] = {\n name: account?.metadata.name ?? '',\n ...(account?.metadata.nameLastUpdatedAt\n ? {\n nameLastUpdatedAt: account?.metadata.nameLastUpdatedAt,\n }\n : {}),\n importTime: account?.metadata.importTime ?? Date.now(),\n lastSelected: account?.metadata.lastSelected ?? 0,\n keyring: {\n type: keyring.type,\n },\n };\n\n let options: InternalAccount['options'] = {};\n if (isHdKeyringType(keyring.type)) {\n // We need to find the account index from its HD keyring.\n const groupIndex = getEvmGroupIndexFromAddressIndex(keyring, address);\n\n // If for some reason, we cannot find this address, then the caller made a mistake\n // and it did not use the proper keyring object. For now, we do not fail and just\n // consider this account as \"simple account\".\n if (groupIndex !== undefined) {\n // NOTE: We are not using the `hdPath` from the associated keyring here and\n // getting the keyring instance here feels a bit overkill.\n // This will be naturally fixed once every keyring start using `KeyringAccount` and implement the keyring API.\n const derivationPath = getEvmDerivationPathForIndex(groupIndex);\n\n // Those are \"legacy options\" and they were used before `KeyringAccount` added\n // support for type options. We keep those temporarily until we update everything\n // to use the new typed options.\n const legacyOptions = {\n entropySource: keyring.metadata.id,\n derivationPath,\n groupIndex,\n };\n\n // New typed entropy options. This is required for multichain accounts.\n const entropyOptions: { entropy: KeyringAccountEntropyOptions } = {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: keyring.metadata.id,\n derivationPath,\n groupIndex,\n },\n };\n\n options = {\n ...legacyOptions,\n ...entropyOptions,\n };\n }\n }\n\n return {\n id,\n address,\n options,\n methods: [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n ],\n scopes: [EthScope.Eoa],\n type: EthAccountType.Eoa,\n metadata,\n };\n }\n\n /**\n * Get Snap keyring from the keyring controller.\n *\n * @returns The Snap keyring if available.\n */\n #getSnapKeyring(): SnapKeyring | undefined {\n const [snapKeyring] = this.messenger.call(\n 'KeyringController:getKeyringsByType',\n SnapKeyring.type,\n );\n\n // Snap keyring is not available until the first account is created in the keyring\n // controller, so this might be undefined.\n return snapKeyring as SnapKeyring | undefined;\n }\n\n /**\n * Re-publish an account event.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param payload - The event payload. The type of the parameters for each event handler must\n * match the type of this payload.\n * @template EventType - A Snap keyring event type.\n */\n #handleOnSnapKeyringAccountEvent<\n EventType extends AccountsControllerEvents['type'],\n >(\n event: EventType,\n ...payload: ExtractEventPayload<AccountsControllerEvents, EventType>\n ): void {\n this.messenger.publish(event, ...payload);\n }\n\n /**\n * Handles changes in the keyring state, specifically when new accounts are added or removed.\n *\n * @param keyringState - The new state of the keyring controller.\n * @param keyringState.isUnlocked - True if the keyrings are unlocked, false otherwise.\n * @param keyringState.keyrings - List of all keyrings.\n */\n #handleOnKeyringStateChange({\n isUnlocked,\n keyrings,\n }: KeyringControllerState): void {\n // TODO: Change when accountAdded event is added to the keyring controller.\n\n // We check for keyrings length to be greater than 0 because the extension client may try execute\n // submit password twice and clear the keyring state.\n // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910\n if (!isUnlocked || keyrings.length === 0) {\n return;\n }\n\n log('Synchronizing accounts with keyrings (through :stateChange)...');\n\n // State patches.\n const generatePatch = (): StatePatch => {\n return {\n previous: {},\n added: [],\n updated: [],\n removed: [],\n };\n };\n const patches = {\n snap: generatePatch(),\n normal: generatePatch(),\n };\n\n // Gets the patch object based on the keyring type (since Snap accounts and other accounts\n // are handled differently).\n const patchOf = (type: string): StatePatch => {\n if (isSnapKeyringType(type)) {\n return patches.snap;\n }\n return patches.normal;\n };\n\n // Create a map (with lower-cased addresses) of all existing accounts.\n for (const account of this.listMultichainAccounts()) {\n const address = account.address.toLowerCase();\n const patch = patchOf(account.metadata.keyring.type);\n\n patch.previous[address] = account;\n }\n\n // Go over all keyring changes and create patches out of it.\n const addresses = new Set<string>();\n for (const keyring of keyrings) {\n const patch = patchOf(keyring.type);\n\n for (const accountAddress of keyring.accounts) {\n // Lower-case address to use it in the `previous` map.\n const address = accountAddress.toLowerCase();\n const account = patch.previous[address];\n\n if (account) {\n // If the account exists before, this might be an update.\n patch.updated.push(account);\n } else {\n // Otherwise, that's a new account.\n patch.added.push({\n address,\n keyring,\n });\n }\n\n // Keep track of those address to check for removed accounts later.\n addresses.add(address);\n }\n }\n\n // We might have accounts associated with removed keyrings, so we iterate\n // over all previous known accounts and check against the keyring addresses.\n for (const patch of [patches.snap, patches.normal]) {\n for (const [address, account] of Object.entries(patch.previous)) {\n // If a previous address is not part of the new addesses, then it got removed.\n if (!addresses.has(address)) {\n patch.removed.push(account);\n }\n }\n }\n\n // Diff that we will use to publish events afterward.\n const diff: { removed: string[]; added: InternalAccount[] } = {\n removed: [],\n added: [],\n };\n\n this.#update(\n (state) => {\n const { internalAccounts, accountIdByAddress } = state;\n\n for (const patch of [patches.snap, patches.normal]) {\n for (const account of patch.removed) {\n delete internalAccounts.accounts[account.id];\n delete accountIdByAddress[account.address];\n\n diff.removed.push(account.id);\n }\n\n for (const added of patch.added) {\n const account = this.#getInternalAccountFromAddressAndType(\n added.address,\n added.keyring,\n );\n\n if (account) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // If it's the first account, we need to select it.\n const lastSelected =\n accounts.length === 0 ? this.#getLastSelectedIndex() : 0;\n\n internalAccounts.accounts[account.id] = {\n ...account,\n metadata: {\n ...account.metadata,\n importTime: Date.now(),\n lastSelected,\n },\n };\n\n accountIdByAddress[account.address] = account.id;\n\n diff.added.push(internalAccounts.accounts[account.id]);\n }\n }\n }\n },\n // Will get executed after the update, but before re-selecting an account in case\n // the current one is not valid anymore.\n () => {\n // Now publish events\n for (const id of diff.removed) {\n this.messenger.publish('AccountsController:accountRemoved', id);\n }\n\n for (const account of diff.added) {\n this.messenger.publish('AccountsController:accountAdded', account);\n }\n },\n );\n\n log('Accounts synchronized (through :stateChange)!');\n\n // NOTE: Since we also track \"updated\" accounts with our patches, we could fire a new event\n // like `accountUpdated` (we would still need to check if anything really changed on the account).\n }\n\n /**\n * Update the state and fixup the currently selected account.\n *\n * @param callback - Callback for updating state, passed a draft state object.\n * @param beforeAutoSelectAccount - Callback to be executed before auto-selecting an account\n * if the current one is no longer available.\n */\n #update(\n callback: (state: WritableDraft<AccountsControllerStrictState>) => void,\n beforeAutoSelectAccount?: () => void,\n ): void {\n // The currently selected account might get deleted during the update, so keep track\n // of it before doing any change.\n const previouslySelectedAccount =\n this.state.internalAccounts.selectedAccount;\n\n this.update((state: WritableDraft<AccountsControllerStrictState>) => {\n callback(state);\n\n // If the account no longer exists (or none is selected), we need to re-select another one.\n const { internalAccounts } = state;\n if (!internalAccounts.accounts[previouslySelectedAccount]) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // Get the lastly selected account (according to the current accounts).\n const lastSelectedAccount = this.#getLastSelectedAccount(accounts);\n if (lastSelectedAccount) {\n internalAccounts.selectedAccount = lastSelectedAccount.id;\n internalAccounts.accounts[\n lastSelectedAccount.id\n ].metadata.lastSelected = this.#getLastSelectedIndex();\n } else {\n // It will be undefined if there are no accounts.\n internalAccounts.selectedAccount = '';\n }\n }\n });\n\n // We might want to do some pre-work before selecting a new account.\n beforeAutoSelectAccount?.();\n\n // Now, we compare the newly selected account, and we send event if different.\n const { selectedAccount } = this.state.internalAccounts;\n if (selectedAccount && selectedAccount !== previouslySelectedAccount) {\n const account = this.getSelectedMultichainAccount();\n\n // The account should always be defined at this point, since we have already checked for\n // `selectedAccount` to be non-empty.\n if (account) {\n if (isEvmAccountType(account.type)) {\n this.messenger.publish(\n 'AccountsController:selectedEvmAccountChange',\n account,\n );\n }\n this.messenger.publish(\n 'AccountsController:selectedAccountChange',\n account,\n );\n }\n }\n }\n\n /**\n * Handles the change in SnapControllerState by updating the metadata of accounts that have a snap enabled.\n *\n * @param snapState - The new SnapControllerState.\n */\n #handleOnSnapStateChange(snapState: SnapControllerState): void {\n // Only check if Snaps changed in status.\n const { snaps } = snapState;\n\n const accounts: { id: string; enabled: boolean }[] = [];\n for (const account of this.listMultichainAccounts()) {\n if (account.metadata.snap) {\n const snap = snaps[account.metadata.snap.id as SnapId];\n\n if (snap) {\n const enabled = snap.enabled && !snap.blocked;\n const metadata = account.metadata.snap;\n\n if (metadata.enabled !== enabled) {\n accounts.push({ id: account.id, enabled });\n }\n } else {\n // If Snap could not be found on the state, we consider it disabled.\n accounts.push({ id: account.id, enabled: false });\n }\n }\n }\n\n if (accounts.length > 0) {\n this.update((state) => {\n for (const { id, enabled } of accounts) {\n const account = state.internalAccounts.accounts[id];\n\n if (account.metadata.snap) {\n account.metadata.snap.enabled = enabled;\n }\n }\n });\n }\n }\n\n /**\n * Returns the last selected account from the given array of accounts.\n *\n * @param accounts - An array of InternalAccount objects.\n * @returns The InternalAccount object that was last selected, or undefined if the array is empty.\n */\n #getLastSelectedAccount(\n accounts: InternalAccount[],\n ): InternalAccount | undefined {\n const [accountToSelect] = accounts.sort((accountA, accountB) => {\n // sort by lastSelected descending\n return (\n (accountB.metadata.lastSelected ?? 0) -\n (accountA.metadata.lastSelected ?? 0)\n );\n });\n\n return accountToSelect;\n }\n\n /**\n * Retrieves the index value for `metadata.lastSelected`.\n *\n * @returns The index value.\n */\n #getLastSelectedIndex(): number {\n // NOTE: For now we use the current date, since we know this value\n // will always be higher than any already selected account index.\n return Date.now();\n }\n\n /**\n * Get an internal account given an address and a keyring type.\n *\n * If the account is not a Snap Keyring account, generates an internal account for it and adds it to the controller.\n * If the account is a Snap Keyring account, retrieves the account from the keyring and adds it to the controller.\n *\n * @param address - The address of the new account.\n * @param keyring - The keyring object of that new account.\n * @returns The newly generated/retrieved internal account.\n */\n #getInternalAccountFromAddressAndType(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount | undefined {\n if (isSnapKeyringType(keyring.type)) {\n const snapKeyring = this.#getSnapKeyring();\n\n // We need the Snap keyring to retrieve the account from its address.\n if (!snapKeyring) {\n return undefined;\n }\n\n // This might be undefined if the Snap deleted the account before\n // reaching that point.\n let account = snapKeyring.getAccountByAddress(address);\n if (account) {\n // We force the copy here, to avoid mutating the reference returned by the Snap keyring.\n account = cloneDeep(account);\n\n // MIGRATION: To avoid any existing Snap account migration, we are\n // just \"adding\" the new typed options that we need for multichain\n // accounts. Ultimately, we would need a real Snap account migrations\n // (being handled by each Snaps).\n if (isHdSnapKeyringAccount(account)) {\n const options: HdSnapKeyringAccount['options'] = {\n ...account.options,\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: account.options.entropySource,\n groupIndex: account.options.index,\n derivationPath: account.options.derivationPath,\n },\n };\n // Inject the new typed options to the internal account copy.\n account.options = options;\n }\n }\n\n return account;\n }\n\n return this.#getInternalAccountForNonSnapAccount(address, keyring);\n }\n\n /**\n * Handles the change in multichain network by updating the selected account.\n *\n * @param id - The EVM client ID or non-EVM chain ID that changed.\n */\n #handleOnMultichainNetworkDidChange(id: NetworkClientId | CaipChainId): void {\n let accountId: string;\n\n // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin\n // MultichainNetworkController will handle throwing an error if the Caip chain ID is not supported\n if (isCaipChainId(id)) {\n // Update selected account to non evm account\n const lastSelectedNonEvmAccount = this.getSelectedMultichainAccount(id);\n // @ts-expect-error - This should never be undefined, otherwise it's a bug that should be handled\n accountId = lastSelectedNonEvmAccount.id;\n } else {\n // Update selected account to evm account\n const lastSelectedEvmAccount = this.getSelectedAccount();\n accountId = lastSelectedEvmAccount.id;\n }\n\n if (this.state.internalAccounts.selectedAccount === accountId) {\n return;\n }\n\n this.update((currentState) => {\n currentState.internalAccounts.accounts[accountId].metadata.lastSelected =\n Date.now();\n currentState.internalAccounts.selectedAccount = accountId;\n });\n\n // DO NOT publish AccountsController:setSelectedAccount to prevent circular listener loops\n }\n\n /**\n * Subscribes to message events.\n */\n #subscribeToMessageEvents(): void {\n this.messenger.subscribe('SnapController:stateChange', (snapStateState) =>\n this.#handleOnSnapStateChange(snapStateState),\n );\n\n this.messenger.subscribe('KeyringController:stateChange', (keyringState) =>\n this.#handleOnKeyringStateChange(keyringState),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountAssetListUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountAssetListUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountBalancesUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountBalancesUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountTransactionsUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountTransactionsUpdated',\n snapAccountEvent,\n ),\n );\n\n // Handle account change when multichain network is changed\n this.messenger.subscribe(\n 'MultichainNetworkController:networkDidChange',\n (id) => this.#handleOnMultichainNetworkDidChange(id),\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AccountsController.mjs","sourceRoot":"","sources":["../src/AccountsController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EAAE,WAAW,EAAE,mCAAmC;AAOzD,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,+BAA+B,EAChC,8BAA8B;AAS/B,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAQ5D,OAAO,EAAE,aAAa,EAAE,wBAAwB;;;AAMhD,OAAO,EAAE,aAAa,IAAI,GAAG,EAAE,qBAAiB;AAIhD,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,gCAAgC,EAChC,iCAAiC,EACjC,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EAClB,oBAAgB;AAEjB,MAAM,cAAc,GAAG,oBAAoB,CAAC;AA6B5C,MAAM,yBAAyB,GAAG;IAChC,oBAAoB;IACpB,gBAAgB;IAChB,gCAAgC;IAChC,cAAc;IACd,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,8BAA8B;IAC9B,qBAAqB;IACrB,YAAY;IACZ,aAAa;IACb,uBAAuB;IACvB,YAAY;CACJ,CAAC;AAoJX,MAAM,0BAA0B,GAAG;IACjC,gBAAgB,EAAE;QAChB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,kBA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AI,qFAA4B,MAAhC,IAAI,EAA6B,YAAY,CAAC,CAC/C,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,qCAAqC,EACrC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,4CAA4C,EAC5C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,oCAAoC,EACpC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,2CAA2C,EAC3C,gBAAgB,CACjB,CACJ,CAAC;IAEF,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,wCAAwC,EACxC,CAAC,gBAAgB,EAAE,EAAE,CACnB,uBAAA,IAAI,0FAAiC,MAArC,IAAI,EACF,+CAA+C,EAC/C,gBAAgB,CACjB,CACJ,CAAC;IAEF,2DAA2D;IAC3D,IAAI,CAAC,SAAS,CAAC,SAAS,CACtB,8CAA8C,EAC9C,CAAC,EAAE,EAAE,EAAE,CAAC,uBAAA,IAAI,6FAAoC,MAAxC,IAAI,EAAqC,EAAE,CAAC,CACrD,CAAC;AACJ,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { SnapKeyring } from '@metamask/eth-snap-keyring';\nimport type {\n SnapKeyringAccountAssetListUpdatedEvent,\n SnapKeyringAccountBalancesUpdatedEvent,\n SnapKeyringAccountTransactionsUpdatedEvent,\n} from '@metamask/eth-snap-keyring';\nimport type { KeyringAccountEntropyOptions } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n isEvmAccountType,\n KeyringAccountEntropyTypeOption,\n} from '@metamask/keyring-api';\nimport type {\n KeyringControllerState,\n KeyringControllerGetKeyringsByTypeAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerGetStateAction,\n KeyringObject,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { isScopeEqualToAny } from '@metamask/keyring-utils';\nimport type { Messenger, ExtractEventPayload } from '@metamask/messenger';\nimport type { NetworkClientId } from '@metamask/network-controller';\nimport type {\n SnapControllerState,\n SnapControllerStateChangeEvent,\n} from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { isCaipChainId } from '@metamask/utils';\nimport type { CaipChainId } from '@metamask/utils';\nimport type { WritableDraft } from 'immer/dist/internal.js';\nimport { cloneDeep } from 'lodash';\n\nimport { AccountsControllerMethodActions } from './AccountsController-method-action-types';\nimport { projectLogger as log } from './logger';\nimport type { MultichainNetworkControllerNetworkDidChangeEvent } from './types';\nimport type { AccountsControllerStrictState } from './typing';\nimport type { HdSnapKeyringAccount } from './utils';\nimport {\n constructAccountIdByAddress,\n getEvmDerivationPathForIndex,\n getEvmGroupIndexFromAddressIndex,\n getUUIDFromAddressOfNormalAccount,\n isHdKeyringType,\n isHdSnapKeyringAccount,\n isSnapKeyringType,\n keyringTypeToName,\n} from './utils';\n\nconst controllerName = 'AccountsController';\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountId = string;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerState = {\n internalAccounts: {\n accounts: Record<AccountId, InternalAccount>;\n selectedAccount: string; // id of the selected account\n };\n accountIdByAddress: Record<InternalAccount['address'], AccountId>;\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n AccountsControllerState\n>;\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'setSelectedAccount',\n 'setAccountName',\n 'setAccountNameAndSelectAccount',\n 'listAccounts',\n 'listMultichainAccounts',\n 'updateAccounts',\n 'getSelectedAccount',\n 'getSelectedMultichainAccount',\n 'getAccountByAddress',\n 'getAccount',\n 'getAccounts',\n 'updateAccountMetadata',\n 'loadBackup',\n] as const;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedActions =\n | KeyringControllerGetKeyringsByTypeAction\n | KeyringControllerGetStateAction;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerActions =\n | AccountsControllerGetStateAction\n | AccountsControllerMethodActions;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n AccountsControllerState\n>;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedAccountChangeEvent = {\n type: `${typeof controllerName}:selectedAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerSelectedEvmAccountChangeEvent = {\n type: `${typeof controllerName}:selectedEvmAccountChange`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAddedEvent = {\n type: `${typeof controllerName}:accountAdded`;\n payload: [InternalAccount];\n};\n\nexport type AccountsControllerAccountsAddedEvent = {\n type: `${typeof controllerName}:accountsAdded`;\n payload: [InternalAccount[]];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRemovedEvent = {\n type: `${typeof controllerName}:accountRemoved`;\n payload: [AccountId];\n};\n\nexport type AccountsControllerAccountsRemovedEvent = {\n type: `${typeof controllerName}:accountsRemoved`;\n payload: [AccountId[]];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountRenamedEvent = {\n type: `${typeof controllerName}:accountRenamed`;\n payload: [InternalAccount];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountBalancesUpdatesEvent = {\n type: `${typeof controllerName}:accountBalancesUpdated`;\n payload: SnapKeyringAccountBalancesUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountTransactionsUpdatedEvent = {\n type: `${typeof controllerName}:accountTransactionsUpdated`;\n payload: SnapKeyringAccountTransactionsUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerAccountAssetListUpdatedEvent = {\n type: `${typeof controllerName}:accountAssetListUpdated`;\n payload: SnapKeyringAccountAssetListUpdatedEvent['payload'];\n};\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AllowedEvents =\n | KeyringControllerStateChangeEvent\n | SnapControllerStateChangeEvent\n | SnapKeyringAccountAssetListUpdatedEvent\n | SnapKeyringAccountBalancesUpdatedEvent\n | SnapKeyringAccountTransactionsUpdatedEvent\n | MultichainNetworkControllerNetworkDidChangeEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerEvents =\n | AccountsControllerChangeEvent\n | AccountsControllerSelectedAccountChangeEvent\n | AccountsControllerSelectedEvmAccountChangeEvent\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountsAddedEvent\n | AccountsControllerAccountRemovedEvent\n | AccountsControllerAccountsRemovedEvent\n | AccountsControllerAccountRenamedEvent\n | AccountsControllerAccountBalancesUpdatesEvent\n | AccountsControllerAccountTransactionsUpdatedEvent\n | AccountsControllerAccountAssetListUpdatedEvent;\n\n/**\n * @deprecated This type is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport type AccountsControllerMessenger = Messenger<\n typeof controllerName,\n AccountsControllerActions | AllowedActions,\n AccountsControllerEvents | AllowedEvents\n>;\n\nconst accountsControllerMetadata = {\n internalAccounts: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n accountIdByAddress: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\nconst defaultState: AccountsControllerState = {\n internalAccounts: {\n accounts: {},\n selectedAccount: '',\n },\n accountIdByAddress: {},\n};\n\n/**\n * @deprecated This constant is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport const EMPTY_ACCOUNT = {\n id: '',\n address: '',\n options: {},\n methods: [],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: '',\n keyring: {\n type: '',\n },\n importTime: 0,\n },\n};\n\n/**\n * A patch representing a keyring state change.\n */\ntype StatePatch = {\n previous: Record<string, InternalAccount>;\n added: {\n address: string;\n keyring: KeyringObject;\n }[];\n updated: InternalAccount[];\n removed: InternalAccount[];\n};\n\n/**\n * Controller that manages internal accounts.\n * The accounts controller is responsible for creating and managing internal accounts.\n * It also provides convenience methods for accessing and updating the internal accounts.\n * The accounts controller also listens for keyring state changes and updates the internal accounts accordingly.\n * The accounts controller also listens for snap state changes and updates the internal accounts accordingly.\n *\n * @deprecated This class is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n */\nexport class AccountsController extends BaseController<\n typeof controllerName,\n AccountsControllerState,\n AccountsControllerMessenger\n> {\n /**\n * Constructor for AccountsController.\n *\n * @param options - The controller options.\n * @param options.messenger - The messenger object.\n * @param options.state - Initial state to set on this controller\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: AccountsControllerMessenger;\n state: AccountsControllerState;\n }) {\n const accountIdByAddress = constructAccountIdByAddress(\n state?.internalAccounts?.accounts ?? {},\n );\n super({\n messenger,\n name: controllerName,\n metadata: accountsControllerMetadata,\n state: {\n ...defaultState,\n ...state,\n accountIdByAddress,\n },\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#subscribeToMessageEvents();\n }\n\n /**\n * Returns the internal account object for the given account ID, if it exists.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object, or undefined if the account does not exist.\n */\n getAccount(accountId: string): InternalAccount | undefined {\n return this.state.internalAccounts.accounts[accountId];\n }\n\n /**\n * Returns the internal account objects for the given account IDs, if they exist.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountIds - The IDs of the accounts to retrieve.\n * @returns The internal account objects, or undefined if the account(s) do not exist.\n */\n getAccounts(accountIds: string[]): (InternalAccount | undefined)[] {\n return accountIds.map((accountId) => this.getAccount(accountId));\n }\n\n /**\n * Returns an array of all evm internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns An array of InternalAccount objects.\n */\n listAccounts(): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n return accounts.filter((account) => isEvmAccountType(account.type));\n }\n\n /**\n * Returns an array of all internal accounts.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID.\n * @returns An array of InternalAccount objects.\n */\n listMultichainAccounts(chainId?: CaipChainId): InternalAccount[] {\n const accounts = Object.values(this.state.internalAccounts.accounts);\n if (!chainId) {\n return accounts;\n }\n\n if (!isCaipChainId(chainId)) {\n throw new Error(`Invalid CAIP-2 chain ID: ${String(chainId)}`);\n }\n\n return accounts.filter((account) =>\n isScopeEqualToAny(chainId, account.scopes),\n );\n }\n\n /**\n * Returns the internal account object for the given account ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to retrieve.\n * @returns The internal account object.\n * @throws An error if the account ID is not found.\n */\n #getAccountExpect(accountId: string): InternalAccount {\n const account = this.getAccount(accountId);\n if (account === undefined) {\n throw new Error(`Account Id \"${accountId}\" not found`);\n }\n return account;\n }\n\n /**\n * Returns the last selected EVM account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns The selected internal account.\n */\n getSelectedAccount(): InternalAccount {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (!selectedAccount) {\n return EMPTY_ACCOUNT;\n }\n\n const account = this.#getAccountExpect(selectedAccount);\n if (isEvmAccountType(account.type)) {\n return account;\n }\n\n const accounts = this.listAccounts();\n if (!accounts.length) {\n // ! Should never reach this.\n throw new Error('No EVM accounts');\n }\n\n // This will never be undefined because we have already checked if accounts.length is > 0\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.#getLastSelectedAccount(accounts)!;\n }\n\n /**\n * __WARNING The return value may be undefined if there isn't an account for that chain id.__\n *\n * Retrieves the last selected account by chain ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param chainId - The chain ID to filter the accounts.\n * @returns The last selected account compatible with the specified chain ID or undefined.\n */\n getSelectedMultichainAccount(\n chainId?: CaipChainId,\n ): InternalAccount | undefined {\n const {\n internalAccounts: { selectedAccount },\n } = this.state;\n\n // Edge case where the extension is setup but the srp is not yet created\n // certain ui elements will query the selected address before any accounts are created.\n if (!selectedAccount) {\n return EMPTY_ACCOUNT;\n }\n\n if (!chainId) {\n return this.#getAccountExpect(selectedAccount);\n }\n\n const accounts = this.listMultichainAccounts(chainId);\n return this.#getLastSelectedAccount(accounts);\n }\n\n /**\n * Returns the account with the specified address.\n * ! This method will only return the first account that matches the address\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param address - The address of the account to retrieve.\n * @returns The account with the specified address, or undefined if not found.\n */\n getAccountByAddress(address: string): InternalAccount | undefined {\n // We need to have a fallback as a cache miss might be attributed to a checksummed address being passed.\n let accountId = this.state.accountIdByAddress[address];\n if (!accountId) {\n // FIXME: We should not need lower-cased addresses, but some consumers might\n // still be using non-normalized addresses. For now we keep it\n // for convenience, but we will need to remove this fallback\n // at some point.\n // NOTE: We should only hit that branch for EVM accounts only.\n const lowercasedAddress = address.toLowerCase();\n accountId = this.state.accountIdByAddress[lowercasedAddress];\n if (accountId) {\n log(\n `Cache missed for account ID: ${accountId}, received address: \"${address}\", matched address: \"${lowercasedAddress}\"`,\n );\n }\n }\n return accountId ? this.getAccount(accountId) : undefined;\n }\n\n /**\n * Sets the selected account by its ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to be selected.\n */\n setSelectedAccount(accountId: string): void {\n const account = this.#getAccountExpect(accountId);\n\n if (this.state.internalAccounts.selectedAccount === account.id) {\n return;\n }\n\n this.#update((state) => {\n const { internalAccounts } = state;\n\n internalAccounts.accounts[account.id].metadata.lastSelected = Date.now();\n internalAccounts.selectedAccount = account.id;\n });\n }\n\n /**\n * Sets the name of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountName(accountId: string, accountName: string): void {\n // This will check for name uniqueness and fire the `accountRenamed` event\n // if the account has been renamed.\n this.updateAccountMetadata(accountId, {\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n });\n }\n\n /**\n * Sets the name of the account with the given ID and select it.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account to set the name for and select.\n * @param accountName - The new name for the account.\n * @throws An error if an account with the same name already exists.\n */\n setAccountNameAndSelectAccount(accountId: string, accountName: string): void {\n const account = this.#getAccountExpect(accountId);\n\n this.#assertAccountCanBeRenamed(account, accountName);\n\n const internalAccount = {\n ...account,\n metadata: {\n ...account.metadata,\n name: accountName,\n nameLastUpdatedAt: Date.now(),\n lastSelected: this.#getLastSelectedIndex(),\n },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[account.id] = internalAccount;\n state.internalAccounts.selectedAccount = account.id;\n });\n\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n\n #assertAccountCanBeRenamed(\n account: InternalAccount,\n accountName: string,\n ): void {\n if (\n this.listMultichainAccounts().find(\n (internalAccount) =>\n internalAccount.metadata.name === accountName &&\n internalAccount.id !== account.id,\n )\n ) {\n throw new Error('Account name already exists');\n }\n }\n\n /**\n * Updates the metadata of the account with the given ID.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param accountId - The ID of the account for which the metadata will be updated.\n * @param metadata - The new metadata for the account.\n */\n updateAccountMetadata(\n accountId: string,\n metadata: Partial<InternalAccount['metadata']>,\n ): void {\n const account = this.#getAccountExpect(accountId);\n\n if (metadata.name) {\n this.#assertAccountCanBeRenamed(account, metadata.name);\n }\n\n const internalAccount = {\n ...account,\n metadata: { ...account.metadata, ...metadata },\n };\n\n this.#update((state) => {\n state.internalAccounts.accounts[accountId] = internalAccount;\n });\n\n if (metadata.name) {\n this.messenger.publish(\n 'AccountsController:accountRenamed',\n internalAccount,\n );\n }\n }\n\n /**\n * Updates the internal accounts list by retrieving normal and snap accounts,\n * removing duplicates, and updating the metadata of each account.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @returns A Promise that resolves when the accounts have been updated.\n */\n async updateAccounts(): Promise<void> {\n log('Synchronizing accounts with keyrings...');\n\n const keyringAccountIndexes = new Map<string, number>();\n\n const existingInternalAccounts = this.state.internalAccounts.accounts;\n const internalAccounts: AccountsControllerState['internalAccounts']['accounts'] =\n {};\n\n const { keyrings } = this.messenger.call('KeyringController:getState');\n for (const keyring of keyrings) {\n const keyringTypeName = keyringTypeToName(keyring.type);\n\n for (const address of keyring.accounts) {\n const internalAccount = this.#getInternalAccountFromAddressAndType(\n address,\n keyring,\n );\n\n // This should never really happen, but if for some reason we're not\n // able to get the Snap keyring reference, this would return an\n // undefined account.\n // So we just skip it, even though, this should not really happen.\n if (!internalAccount) {\n continue;\n }\n\n // Get current index for this keyring (we use human indexing, so start at 1).\n const keyringAccountIndex =\n keyringAccountIndexes.get(keyringTypeName) ?? 1;\n\n const existingAccount = existingInternalAccounts[internalAccount.id];\n internalAccounts[internalAccount.id] = {\n ...internalAccount,\n\n metadata: {\n ...internalAccount.metadata,\n\n // Re-use existing metadata if any.\n name:\n existingAccount?.metadata.name ??\n `${keyringTypeName} ${keyringAccountIndex}`,\n importTime: existingAccount?.metadata.importTime ?? Date.now(),\n lastSelected: existingAccount?.metadata.lastSelected ?? 0,\n },\n };\n\n // Increment the account index for this keyring.\n keyringAccountIndexes.set(keyringTypeName, keyringAccountIndex + 1);\n }\n }\n\n this.#update((state) => {\n state.internalAccounts.accounts = internalAccounts;\n state.accountIdByAddress = constructAccountIdByAddress(internalAccounts);\n });\n\n log('Accounts synchronized!');\n }\n\n /**\n * Loads the backup state of the accounts controller.\n *\n * @deprecated This method is deprecated and will be removed in a future version.\n * Use `AccountTreeController`, `MultichainAccountService`, or the Keyring API v2 instead.\n * @param backup - The backup state to load.\n */\n loadBackup(backup: AccountsControllerState): void {\n if (backup.internalAccounts) {\n const accountIdByAddress = constructAccountIdByAddress(\n backup.internalAccounts.accounts,\n );\n this.update(\n (currentState: WritableDraft<AccountsControllerStrictState>) => {\n currentState.internalAccounts = backup.internalAccounts;\n currentState.accountIdByAddress = accountIdByAddress;\n },\n );\n }\n }\n\n /**\n * Gets an internal account representation for a non-Snap account.\n *\n * @param address - The address of the account.\n * @param keyring - The keyring object of the account.\n * @returns The generated internal account.\n */\n #getInternalAccountForNonSnapAccount(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount {\n const id = getUUIDFromAddressOfNormalAccount(address);\n\n // We might have an account for this ID already, so we'll just re-use\n // the same metadata\n const account = this.getAccount(id);\n const metadata: InternalAccount['metadata'] = {\n name: account?.metadata.name ?? '',\n ...(account?.metadata.nameLastUpdatedAt\n ? {\n nameLastUpdatedAt: account?.metadata.nameLastUpdatedAt,\n }\n : {}),\n importTime: account?.metadata.importTime ?? Date.now(),\n lastSelected: account?.metadata.lastSelected ?? 0,\n keyring: {\n type: keyring.type,\n },\n };\n\n let options: InternalAccount['options'] = {};\n if (isHdKeyringType(keyring.type)) {\n // We need to find the account index from its HD keyring.\n const groupIndex = getEvmGroupIndexFromAddressIndex(keyring, address);\n\n // If for some reason, we cannot find this address, then the caller made a mistake\n // and it did not use the proper keyring object. For now, we do not fail and just\n // consider this account as \"simple account\".\n if (groupIndex !== undefined) {\n // NOTE: We are not using the `hdPath` from the associated keyring here and\n // getting the keyring instance here feels a bit overkill.\n // This will be naturally fixed once every keyring start using `KeyringAccount` and implement the keyring API.\n const derivationPath = getEvmDerivationPathForIndex(groupIndex);\n\n // Those are \"legacy options\" and they were used before `KeyringAccount` added\n // support for type options. We keep those temporarily until we update everything\n // to use the new typed options.\n const legacyOptions = {\n entropySource: keyring.metadata.id,\n derivationPath,\n groupIndex,\n };\n\n // New typed entropy options. This is required for multichain accounts.\n const entropyOptions: { entropy: KeyringAccountEntropyOptions } = {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: keyring.metadata.id,\n derivationPath,\n groupIndex,\n },\n };\n\n options = {\n ...legacyOptions,\n ...entropyOptions,\n };\n }\n }\n\n return {\n id,\n address,\n options,\n methods: [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n ],\n scopes: [EthScope.Eoa],\n type: EthAccountType.Eoa,\n metadata,\n };\n }\n\n /**\n * Get Snap keyring from the keyring controller.\n *\n * @returns The Snap keyring if available.\n */\n #getSnapKeyring(): SnapKeyring | undefined {\n const [snapKeyring] = this.messenger.call(\n 'KeyringController:getKeyringsByType',\n SnapKeyring.type,\n );\n\n // Snap keyring is not available until the first account is created in the keyring\n // controller, so this might be undefined.\n return snapKeyring as SnapKeyring | undefined;\n }\n\n /**\n * Re-publish an account event.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param payload - The event payload. The type of the parameters for each event handler must\n * match the type of this payload.\n * @template EventType - A Snap keyring event type.\n */\n #handleOnSnapKeyringAccountEvent<\n EventType extends AccountsControllerEvents['type'],\n >(\n event: EventType,\n ...payload: ExtractEventPayload<AccountsControllerEvents, EventType>\n ): void {\n this.messenger.publish(event, ...payload);\n }\n\n /**\n * Handles changes in the keyring state, specifically when new accounts are added or removed.\n *\n * @param keyringState - The new state of the keyring controller.\n * @param keyringState.isUnlocked - True if the keyrings are unlocked, false otherwise.\n * @param keyringState.keyrings - List of all keyrings.\n */\n #handleOnKeyringStateChange({\n isUnlocked,\n keyrings,\n }: KeyringControllerState): void {\n // TODO: Change when accountAdded event is added to the keyring controller.\n\n // We check for keyrings length to be greater than 0 because the extension client may try execute\n // submit password twice and clear the keyring state.\n // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910\n if (!isUnlocked || keyrings.length === 0) {\n return;\n }\n\n log('Synchronizing accounts with keyrings (through :stateChange)...');\n\n // State patches.\n const generatePatch = (): StatePatch => {\n return {\n previous: {},\n added: [],\n updated: [],\n removed: [],\n };\n };\n const patches = {\n snap: generatePatch(),\n normal: generatePatch(),\n };\n\n // Gets the patch object based on the keyring type (since Snap accounts and other accounts\n // are handled differently).\n const patchOf = (type: string): StatePatch => {\n if (isSnapKeyringType(type)) {\n return patches.snap;\n }\n return patches.normal;\n };\n\n // Create a map (with lower-cased addresses) of all existing accounts.\n for (const account of this.listMultichainAccounts()) {\n const address = account.address.toLowerCase();\n const patch = patchOf(account.metadata.keyring.type);\n\n patch.previous[address] = account;\n }\n\n // Go over all keyring changes and create patches out of it.\n const addresses = new Set<string>();\n for (const keyring of keyrings) {\n const patch = patchOf(keyring.type);\n\n for (const accountAddress of keyring.accounts) {\n // Lower-case address to use it in the `previous` map.\n const address = accountAddress.toLowerCase();\n const account = patch.previous[address];\n\n if (account) {\n // If the account exists before, this might be an update.\n patch.updated.push(account);\n } else {\n // Otherwise, that's a new account.\n patch.added.push({\n address,\n keyring,\n });\n }\n\n // Keep track of those address to check for removed accounts later.\n addresses.add(address);\n }\n }\n\n // We might have accounts associated with removed keyrings, so we iterate\n // over all previous known accounts and check against the keyring addresses.\n for (const patch of [patches.snap, patches.normal]) {\n for (const [address, account] of Object.entries(patch.previous)) {\n // If a previous address is not part of the new addesses, then it got removed.\n if (!addresses.has(address)) {\n patch.removed.push(account);\n }\n }\n }\n\n // Diff that we will use to publish events afterward.\n const diff: { removed: string[]; added: InternalAccount[] } = {\n removed: [],\n added: [],\n };\n\n this.#update(\n (state) => {\n const { internalAccounts, accountIdByAddress } = state;\n\n for (const patch of [patches.snap, patches.normal]) {\n for (const account of patch.removed) {\n delete internalAccounts.accounts[account.id];\n delete accountIdByAddress[account.address];\n\n diff.removed.push(account.id);\n }\n\n for (const added of patch.added) {\n const account = this.#getInternalAccountFromAddressAndType(\n added.address,\n added.keyring,\n );\n\n if (account) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // If it's the first account, we need to select it.\n const lastSelected =\n accounts.length === 0 ? this.#getLastSelectedIndex() : 0;\n\n internalAccounts.accounts[account.id] = {\n ...account,\n metadata: {\n ...account.metadata,\n importTime: Date.now(),\n lastSelected,\n },\n };\n\n accountIdByAddress[account.address] = account.id;\n\n diff.added.push(internalAccounts.accounts[account.id]);\n }\n }\n }\n },\n // Will get executed after the update, but before re-selecting an account in case\n // the current one is not valid anymore.\n () => {\n // Now publish events\n for (const id of diff.removed) {\n this.messenger.publish('AccountsController:accountRemoved', id);\n }\n if (diff.removed.length > 0) {\n this.messenger.publish(\n 'AccountsController:accountsRemoved',\n diff.removed,\n );\n }\n\n for (const account of diff.added) {\n this.messenger.publish('AccountsController:accountAdded', account);\n }\n if (diff.added.length > 0) {\n this.messenger.publish(\n 'AccountsController:accountsAdded',\n diff.added,\n );\n }\n },\n );\n\n log('Accounts synchronized (through :stateChange)!');\n\n // NOTE: Since we also track \"updated\" accounts with our patches, we could fire a new event\n // like `accountUpdated` (we would still need to check if anything really changed on the account).\n }\n\n /**\n * Update the state and fixup the currently selected account.\n *\n * @param callback - Callback for updating state, passed a draft state object.\n * @param beforeAutoSelectAccount - Callback to be executed before auto-selecting an account\n * if the current one is no longer available.\n */\n #update(\n callback: (state: WritableDraft<AccountsControllerStrictState>) => void,\n beforeAutoSelectAccount?: () => void,\n ): void {\n // The currently selected account might get deleted during the update, so keep track\n // of it before doing any change.\n const previouslySelectedAccount =\n this.state.internalAccounts.selectedAccount;\n\n this.update((state: WritableDraft<AccountsControllerStrictState>) => {\n callback(state);\n\n // If the account no longer exists (or none is selected), we need to re-select another one.\n const { internalAccounts } = state;\n if (!internalAccounts.accounts[previouslySelectedAccount]) {\n const accounts = Object.values(\n internalAccounts.accounts,\n ) as InternalAccount[];\n\n // Get the lastly selected account (according to the current accounts).\n const lastSelectedAccount = this.#getLastSelectedAccount(accounts);\n if (lastSelectedAccount) {\n internalAccounts.selectedAccount = lastSelectedAccount.id;\n internalAccounts.accounts[\n lastSelectedAccount.id\n ].metadata.lastSelected = this.#getLastSelectedIndex();\n } else {\n // It will be undefined if there are no accounts.\n internalAccounts.selectedAccount = '';\n }\n }\n });\n\n // We might want to do some pre-work before selecting a new account.\n beforeAutoSelectAccount?.();\n\n // Now, we compare the newly selected account, and we send event if different.\n const { selectedAccount } = this.state.internalAccounts;\n if (selectedAccount && selectedAccount !== previouslySelectedAccount) {\n const account = this.getSelectedMultichainAccount();\n\n // The account should always be defined at this point, since we have already checked for\n // `selectedAccount` to be non-empty.\n if (account) {\n if (isEvmAccountType(account.type)) {\n this.messenger.publish(\n 'AccountsController:selectedEvmAccountChange',\n account,\n );\n }\n this.messenger.publish(\n 'AccountsController:selectedAccountChange',\n account,\n );\n }\n }\n }\n\n /**\n * Handles the change in SnapControllerState by updating the metadata of accounts that have a snap enabled.\n *\n * @param snapState - The new SnapControllerState.\n */\n #handleOnSnapStateChange(snapState: SnapControllerState): void {\n // Only check if Snaps changed in status.\n const { snaps } = snapState;\n\n const accounts: { id: string; enabled: boolean }[] = [];\n for (const account of this.listMultichainAccounts()) {\n if (account.metadata.snap) {\n const snap = snaps[account.metadata.snap.id as SnapId];\n\n if (snap) {\n const enabled = snap.enabled && !snap.blocked;\n const metadata = account.metadata.snap;\n\n if (metadata.enabled !== enabled) {\n accounts.push({ id: account.id, enabled });\n }\n } else {\n // If Snap could not be found on the state, we consider it disabled.\n accounts.push({ id: account.id, enabled: false });\n }\n }\n }\n\n if (accounts.length > 0) {\n this.update((state) => {\n for (const { id, enabled } of accounts) {\n const account = state.internalAccounts.accounts[id];\n\n if (account.metadata.snap) {\n account.metadata.snap.enabled = enabled;\n }\n }\n });\n }\n }\n\n /**\n * Returns the last selected account from the given array of accounts.\n *\n * @param accounts - An array of InternalAccount objects.\n * @returns The InternalAccount object that was last selected, or undefined if the array is empty.\n */\n #getLastSelectedAccount(\n accounts: InternalAccount[],\n ): InternalAccount | undefined {\n const [accountToSelect] = accounts.sort((accountA, accountB) => {\n // sort by lastSelected descending\n return (\n (accountB.metadata.lastSelected ?? 0) -\n (accountA.metadata.lastSelected ?? 0)\n );\n });\n\n return accountToSelect;\n }\n\n /**\n * Retrieves the index value for `metadata.lastSelected`.\n *\n * @returns The index value.\n */\n #getLastSelectedIndex(): number {\n // NOTE: For now we use the current date, since we know this value\n // will always be higher than any already selected account index.\n return Date.now();\n }\n\n /**\n * Get an internal account given an address and a keyring type.\n *\n * If the account is not a Snap Keyring account, generates an internal account for it and adds it to the controller.\n * If the account is a Snap Keyring account, retrieves the account from the keyring and adds it to the controller.\n *\n * @param address - The address of the new account.\n * @param keyring - The keyring object of that new account.\n * @returns The newly generated/retrieved internal account.\n */\n #getInternalAccountFromAddressAndType(\n address: string,\n keyring: KeyringObject,\n ): InternalAccount | undefined {\n if (isSnapKeyringType(keyring.type)) {\n const snapKeyring = this.#getSnapKeyring();\n\n // We need the Snap keyring to retrieve the account from its address.\n if (!snapKeyring) {\n return undefined;\n }\n\n // This might be undefined if the Snap deleted the account before\n // reaching that point.\n let account = snapKeyring.getAccountByAddress(address);\n if (account) {\n // We force the copy here, to avoid mutating the reference returned by the Snap keyring.\n account = cloneDeep(account);\n\n // MIGRATION: To avoid any existing Snap account migration, we are\n // just \"adding\" the new typed options that we need for multichain\n // accounts. Ultimately, we would need a real Snap account migrations\n // (being handled by each Snaps).\n if (isHdSnapKeyringAccount(account)) {\n const options: HdSnapKeyringAccount['options'] = {\n ...account.options,\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: account.options.entropySource,\n groupIndex: account.options.index,\n derivationPath: account.options.derivationPath,\n },\n };\n // Inject the new typed options to the internal account copy.\n account.options = options;\n }\n }\n\n return account;\n }\n\n return this.#getInternalAccountForNonSnapAccount(address, keyring);\n }\n\n /**\n * Handles the change in multichain network by updating the selected account.\n *\n * @param id - The EVM client ID or non-EVM chain ID that changed.\n */\n #handleOnMultichainNetworkDidChange(id: NetworkClientId | CaipChainId): void {\n let accountId: string;\n\n // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin\n // MultichainNetworkController will handle throwing an error if the Caip chain ID is not supported\n if (isCaipChainId(id)) {\n // Update selected account to non evm account\n const lastSelectedNonEvmAccount = this.getSelectedMultichainAccount(id);\n // @ts-expect-error - This should never be undefined, otherwise it's a bug that should be handled\n accountId = lastSelectedNonEvmAccount.id;\n } else {\n // Update selected account to evm account\n const lastSelectedEvmAccount = this.getSelectedAccount();\n accountId = lastSelectedEvmAccount.id;\n }\n\n if (this.state.internalAccounts.selectedAccount === accountId) {\n return;\n }\n\n this.update((currentState) => {\n currentState.internalAccounts.accounts[accountId].metadata.lastSelected =\n Date.now();\n currentState.internalAccounts.selectedAccount = accountId;\n });\n\n // DO NOT publish AccountsController:setSelectedAccount to prevent circular listener loops\n }\n\n /**\n * Subscribes to message events.\n */\n #subscribeToMessageEvents(): void {\n this.messenger.subscribe('SnapController:stateChange', (snapStateState) =>\n this.#handleOnSnapStateChange(snapStateState),\n );\n\n this.messenger.subscribe('KeyringController:stateChange', (keyringState) =>\n this.#handleOnKeyringStateChange(keyringState),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountAssetListUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountAssetListUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountBalancesUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountBalancesUpdated',\n snapAccountEvent,\n ),\n );\n\n this.messenger.subscribe(\n 'SnapKeyring:accountTransactionsUpdated',\n (snapAccountEvent) =>\n this.#handleOnSnapKeyringAccountEvent(\n 'AccountsController:accountTransactionsUpdated',\n snapAccountEvent,\n ),\n );\n\n // Handle account change when multichain network is changed\n this.messenger.subscribe(\n 'MultichainNetworkController:networkDidChange',\n (id) => this.#handleOnMultichainNetworkDidChange(id),\n );\n }\n}\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAoCA,+DAAyE;AAAhE,mHAAA,aAAa,OAAA;AAAE,wHAAA,kBAAkB,OAAA;AAC1C,qCAKiB;AAJf,0GAAA,iBAAiB,OAAA;AACjB,iIAAA,wCAAwC,OAAA;AACxC,0HAAA,iCAAiC,OAAA;AACjC,4GAAA,mBAAmB,OAAA","sourcesContent":["export type {\n AccountId,\n AccountsControllerState,\n AccountsControllerGetStateAction,\n AllowedActions,\n AccountsControllerActions,\n AccountsControllerChangeEvent,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSelectedEvmAccountChangeEvent,\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountsAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerAccountsRemovedEvent,\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountBalancesUpdatesEvent,\n AccountsControllerAccountTransactionsUpdatedEvent,\n AccountsControllerAccountAssetListUpdatedEvent,\n AllowedEvents,\n AccountsControllerEvents,\n AccountsControllerMessenger,\n} from './AccountsController';\nexport type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountsAction,\n AccountsControllerListAccountsAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetSelectedMultichainAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerSetSelectedAccountAction,\n AccountsControllerSetAccountNameAction,\n AccountsControllerSetAccountNameAndSelectAccountAction,\n AccountsControllerUpdateAccountMetadataAction,\n AccountsControllerUpdateAccountsAction,\n AccountsControllerLoadBackupAction,\n} from './AccountsController-method-action-types';\nexport { EMPTY_ACCOUNT, AccountsController } from './AccountsController';\nexport {\n keyringTypeToName,\n getUUIDOptionsFromAddressOfNormalAccount,\n getUUIDFromAddressOfNormalAccount,\n isNormalKeyringType,\n} from './utils';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AccountId, AccountsControllerState, AccountsControllerGetStateAction, AllowedActions, AccountsControllerActions, AccountsControllerChangeEvent, AccountsControllerSelectedAccountChangeEvent, AccountsControllerSelectedEvmAccountChangeEvent, AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerAccountRenamedEvent, AccountsControllerAccountBalancesUpdatesEvent, AccountsControllerAccountTransactionsUpdatedEvent, AccountsControllerAccountAssetListUpdatedEvent, AllowedEvents, AccountsControllerEvents, AccountsControllerMessenger, } from "./AccountsController.cjs";
|
|
1
|
+
export type { AccountId, AccountsControllerState, AccountsControllerGetStateAction, AllowedActions, AccountsControllerActions, AccountsControllerChangeEvent, AccountsControllerSelectedAccountChangeEvent, AccountsControllerSelectedEvmAccountChangeEvent, AccountsControllerAccountAddedEvent, AccountsControllerAccountsAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerAccountsRemovedEvent, AccountsControllerAccountRenamedEvent, AccountsControllerAccountBalancesUpdatesEvent, AccountsControllerAccountTransactionsUpdatedEvent, AccountsControllerAccountAssetListUpdatedEvent, AllowedEvents, AccountsControllerEvents, AccountsControllerMessenger, } from "./AccountsController.cjs";
|
|
2
2
|
export type { AccountsControllerGetAccountAction, AccountsControllerGetAccountsAction, AccountsControllerListAccountsAction, AccountsControllerListMultichainAccountsAction, AccountsControllerGetSelectedAccountAction, AccountsControllerGetSelectedMultichainAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerSetSelectedAccountAction, AccountsControllerSetAccountNameAction, AccountsControllerSetAccountNameAndSelectAccountAction, AccountsControllerUpdateAccountMetadataAction, AccountsControllerUpdateAccountsAction, AccountsControllerLoadBackupAction, } from "./AccountsController-method-action-types.cjs";
|
|
3
3
|
export { EMPTY_ACCOUNT, AccountsController } from "./AccountsController.cjs";
|
|
4
4
|
export { keyringTypeToName, getUUIDOptionsFromAddressOfNormalAccount, getUUIDFromAddressOfNormalAccount, isNormalKeyringType, } from "./utils.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,uBAAuB,EACvB,gCAAgC,EAChC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,4CAA4C,EAC5C,+CAA+C,EAC/C,mCAAmC,EACnC,qCAAqC,EACrC,qCAAqC,EACrC,6CAA6C,EAC7C,iDAAiD,EACjD,8CAA8C,EAC9C,aAAa,EACb,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B;AAC9B,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,0CAA0C,EAC1C,oDAAoD,EACpD,2CAA2C,EAC3C,0CAA0C,EAC1C,sCAAsC,EACtC,sDAAsD,EACtD,6CAA6C,EAC7C,sCAAsC,EACtC,kCAAkC,GACnC,qDAAiD;AAClD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iCAA6B;AACzE,OAAO,EACL,iBAAiB,EACjB,wCAAwC,EACxC,iCAAiC,EACjC,mBAAmB,GACpB,oBAAgB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,uBAAuB,EACvB,gCAAgC,EAChC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,4CAA4C,EAC5C,+CAA+C,EAC/C,mCAAmC,EACnC,oCAAoC,EACpC,qCAAqC,EACrC,sCAAsC,EACtC,qCAAqC,EACrC,6CAA6C,EAC7C,iDAAiD,EACjD,8CAA8C,EAC9C,aAAa,EACb,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B;AAC9B,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,0CAA0C,EAC1C,oDAAoD,EACpD,2CAA2C,EAC3C,0CAA0C,EAC1C,sCAAsC,EACtC,sDAAsD,EACtD,6CAA6C,EAC7C,sCAAsC,EACtC,kCAAkC,GACnC,qDAAiD;AAClD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iCAA6B;AACzE,OAAO,EACL,iBAAiB,EACjB,wCAAwC,EACxC,iCAAiC,EACjC,mBAAmB,GACpB,oBAAgB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AccountId, AccountsControllerState, AccountsControllerGetStateAction, AllowedActions, AccountsControllerActions, AccountsControllerChangeEvent, AccountsControllerSelectedAccountChangeEvent, AccountsControllerSelectedEvmAccountChangeEvent, AccountsControllerAccountAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerAccountRenamedEvent, AccountsControllerAccountBalancesUpdatesEvent, AccountsControllerAccountTransactionsUpdatedEvent, AccountsControllerAccountAssetListUpdatedEvent, AllowedEvents, AccountsControllerEvents, AccountsControllerMessenger, } from "./AccountsController.mjs";
|
|
1
|
+
export type { AccountId, AccountsControllerState, AccountsControllerGetStateAction, AllowedActions, AccountsControllerActions, AccountsControllerChangeEvent, AccountsControllerSelectedAccountChangeEvent, AccountsControllerSelectedEvmAccountChangeEvent, AccountsControllerAccountAddedEvent, AccountsControllerAccountsAddedEvent, AccountsControllerAccountRemovedEvent, AccountsControllerAccountsRemovedEvent, AccountsControllerAccountRenamedEvent, AccountsControllerAccountBalancesUpdatesEvent, AccountsControllerAccountTransactionsUpdatedEvent, AccountsControllerAccountAssetListUpdatedEvent, AllowedEvents, AccountsControllerEvents, AccountsControllerMessenger, } from "./AccountsController.mjs";
|
|
2
2
|
export type { AccountsControllerGetAccountAction, AccountsControllerGetAccountsAction, AccountsControllerListAccountsAction, AccountsControllerListMultichainAccountsAction, AccountsControllerGetSelectedAccountAction, AccountsControllerGetSelectedMultichainAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerSetSelectedAccountAction, AccountsControllerSetAccountNameAction, AccountsControllerSetAccountNameAndSelectAccountAction, AccountsControllerUpdateAccountMetadataAction, AccountsControllerUpdateAccountsAction, AccountsControllerLoadBackupAction, } from "./AccountsController-method-action-types.mjs";
|
|
3
3
|
export { EMPTY_ACCOUNT, AccountsController } from "./AccountsController.mjs";
|
|
4
4
|
export { keyringTypeToName, getUUIDOptionsFromAddressOfNormalAccount, getUUIDFromAddressOfNormalAccount, isNormalKeyringType, } from "./utils.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,uBAAuB,EACvB,gCAAgC,EAChC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,4CAA4C,EAC5C,+CAA+C,EAC/C,mCAAmC,EACnC,qCAAqC,EACrC,qCAAqC,EACrC,6CAA6C,EAC7C,iDAAiD,EACjD,8CAA8C,EAC9C,aAAa,EACb,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B;AAC9B,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,0CAA0C,EAC1C,oDAAoD,EACpD,2CAA2C,EAC3C,0CAA0C,EAC1C,sCAAsC,EACtC,sDAAsD,EACtD,6CAA6C,EAC7C,sCAAsC,EACtC,kCAAkC,GACnC,qDAAiD;AAClD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iCAA6B;AACzE,OAAO,EACL,iBAAiB,EACjB,wCAAwC,EACxC,iCAAiC,EACjC,mBAAmB,GACpB,oBAAgB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,uBAAuB,EACvB,gCAAgC,EAChC,cAAc,EACd,yBAAyB,EACzB,6BAA6B,EAC7B,4CAA4C,EAC5C,+CAA+C,EAC/C,mCAAmC,EACnC,oCAAoC,EACpC,qCAAqC,EACrC,sCAAsC,EACtC,qCAAqC,EACrC,6CAA6C,EAC7C,iDAAiD,EACjD,8CAA8C,EAC9C,aAAa,EACb,wBAAwB,EACxB,2BAA2B,GAC5B,iCAA6B;AAC9B,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,oCAAoC,EACpC,8CAA8C,EAC9C,0CAA0C,EAC1C,oDAAoD,EACpD,2CAA2C,EAC3C,0CAA0C,EAC1C,sCAAsC,EACtC,sDAAsD,EACtD,6CAA6C,EAC7C,sCAAsC,EACtC,kCAAkC,GACnC,qDAAiD;AAClD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iCAA6B;AACzE,OAAO,EACL,iBAAiB,EACjB,wCAAwC,EACxC,iCAAiC,EACjC,mBAAmB,GACpB,oBAAgB"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iCAA6B;AACzE,OAAO,EACL,iBAAiB,EACjB,wCAAwC,EACxC,iCAAiC,EACjC,mBAAmB,EACpB,oBAAgB","sourcesContent":["export type {\n AccountId,\n AccountsControllerState,\n AccountsControllerGetStateAction,\n AllowedActions,\n AccountsControllerActions,\n AccountsControllerChangeEvent,\n AccountsControllerSelectedAccountChangeEvent,\n AccountsControllerSelectedEvmAccountChangeEvent,\n AccountsControllerAccountAddedEvent,\n AccountsControllerAccountsAddedEvent,\n AccountsControllerAccountRemovedEvent,\n AccountsControllerAccountsRemovedEvent,\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountBalancesUpdatesEvent,\n AccountsControllerAccountTransactionsUpdatedEvent,\n AccountsControllerAccountAssetListUpdatedEvent,\n AllowedEvents,\n AccountsControllerEvents,\n AccountsControllerMessenger,\n} from './AccountsController';\nexport type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountsAction,\n AccountsControllerListAccountsAction,\n AccountsControllerListMultichainAccountsAction,\n AccountsControllerGetSelectedAccountAction,\n AccountsControllerGetSelectedMultichainAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerSetSelectedAccountAction,\n AccountsControllerSetAccountNameAction,\n AccountsControllerSetAccountNameAndSelectAccountAction,\n AccountsControllerUpdateAccountMetadataAction,\n AccountsControllerUpdateAccountsAction,\n AccountsControllerLoadBackupAction,\n} from './AccountsController-method-action-types';\nexport { EMPTY_ACCOUNT, AccountsController } from './AccountsController';\nexport {\n keyringTypeToName,\n getUUIDOptionsFromAddressOfNormalAccount,\n getUUIDFromAddressOfNormalAccount,\n isNormalKeyringType,\n} from './utils';\n"]}
|
package/dist/utils.d.cts
CHANGED
|
@@ -76,9 +76,9 @@ export declare function getEvmGroupIndexFromAddressIndex(keyring: KeyringObject,
|
|
|
76
76
|
* extra-properties than a Snap might add in its `options`.
|
|
77
77
|
*/
|
|
78
78
|
export declare const HdSnapKeyringAccountOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
79
|
+
derivationPath: string;
|
|
79
80
|
entropySource: string;
|
|
80
81
|
index: number;
|
|
81
|
-
derivationPath: string;
|
|
82
82
|
}, {
|
|
83
83
|
entropySource: import("@metamask/superstruct").Struct<string, null>;
|
|
84
84
|
index: import("@metamask/superstruct").Struct<number, null>;
|
package/dist/utils.d.mts
CHANGED
|
@@ -76,9 +76,9 @@ export declare function getEvmGroupIndexFromAddressIndex(keyring: KeyringObject,
|
|
|
76
76
|
* extra-properties than a Snap might add in its `options`.
|
|
77
77
|
*/
|
|
78
78
|
export declare const HdSnapKeyringAccountOptionsStruct: import("@metamask/superstruct").Struct<{
|
|
79
|
+
derivationPath: string;
|
|
79
80
|
entropySource: string;
|
|
80
81
|
index: number;
|
|
81
|
-
derivationPath: string;
|
|
82
82
|
}, {
|
|
83
83
|
entropySource: import("@metamask/superstruct").Struct<string, null>;
|
|
84
84
|
index: import("@metamask/superstruct").Struct<number, null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/accounts-controller",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.1.1",
|
|
4
4
|
"description": "Manages internal accounts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@ethereumjs/util": "^9.1.0",
|
|
52
|
-
"@metamask/base-controller": "^9.0.
|
|
52
|
+
"@metamask/base-controller": "^9.0.1",
|
|
53
53
|
"@metamask/eth-snap-keyring": "^19.0.0",
|
|
54
|
-
"@metamask/keyring-api": "^21.
|
|
55
|
-
"@metamask/keyring-controller": "^25.1.
|
|
54
|
+
"@metamask/keyring-api": "^21.6.0",
|
|
55
|
+
"@metamask/keyring-controller": "^25.1.1",
|
|
56
56
|
"@metamask/keyring-internal-api": "^10.0.0",
|
|
57
57
|
"@metamask/keyring-utils": "^3.1.0",
|
|
58
|
-
"@metamask/messenger": "^0.
|
|
59
|
-
"@metamask/network-controller": "^30.0.
|
|
60
|
-
"@metamask/snaps-controllers": "^
|
|
61
|
-
"@metamask/snaps-sdk": "^
|
|
62
|
-
"@metamask/snaps-utils": "^
|
|
58
|
+
"@metamask/messenger": "^1.0.0",
|
|
59
|
+
"@metamask/network-controller": "^30.0.1",
|
|
60
|
+
"@metamask/snaps-controllers": "^19.0.0",
|
|
61
|
+
"@metamask/snaps-sdk": "^11.0.0",
|
|
62
|
+
"@metamask/snaps-utils": "^12.1.2",
|
|
63
63
|
"@metamask/superstruct": "^3.1.0",
|
|
64
64
|
"@metamask/utils": "^11.9.0",
|
|
65
65
|
"deepmerge": "^4.2.2",
|