@metamask-previews/accounts-controller 27.0.0-preview-8365901 → 27.0.0-preview-bf2d2c4c

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.
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
5
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
6
  };
7
- var _AccountsController_instances, _AccountsController_generateInternalAccountForNonSnapAccount, _AccountsController_getSnapKeyring, _AccountsController_listSnapAccounts, _AccountsController_listNormalAccounts, _AccountsController_handleOnSnapKeyringAccountEvent, _AccountsController_handleOnKeyringStateChange, _AccountsController_update, _AccountsController_handleOnSnapStateChange, _AccountsController_getAccountsByKeyringType, _AccountsController_getLastSelectedAccount, _AccountsController_getLastSelectedIndex, _AccountsController_getInternalAccountFromAddressAndType, _AccountsController_handleOnMultichainNetworkDidChange, _AccountsController_populateExistingMetadata, _AccountsController_subscribeToMessageEvents, _AccountsController_registerMessageHandlers;
7
+ var _AccountsController_instances, _AccountsController_generateInternalAccountForNonSnapAccount, _AccountsController_listSnapAccounts, _AccountsController_listNormalAccounts, _AccountsController_handleOnSnapKeyringAccountEvent, _AccountsController_handleOnKeyringStateChange, _AccountsController_handleOnSnapStateChange, _AccountsController_getAccountsByKeyringType, _AccountsController_getLastSelectedAccount, _AccountsController_getLastSelectedIndex, _AccountsController_handleNewAccountAdded, _AccountsController_publishAccountChangeEvent, _AccountsController_handleAccountRemoved, _AccountsController_handleOnMultichainNetworkDidChange, _AccountsController_populateExistingMetadata, _AccountsController_subscribeToMessageEvents, _AccountsController_registerMessageHandlers;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AccountsController = exports.EMPTY_ACCOUNT = void 0;
10
10
  const base_controller_1 = require("@metamask/base-controller");
@@ -126,15 +126,14 @@ class AccountsController extends base_controller_1.BaseController {
126
126
  * @returns The selected internal account.
127
127
  */
128
128
  getSelectedAccount() {
129
- const { internalAccounts: { selectedAccount }, } = this.state;
130
129
  // Edge case where the extension is setup but the srp is not yet created
131
130
  // certain ui elements will query the selected address before any accounts are created.
132
- if (selectedAccount === '') {
131
+ if (this.state.internalAccounts.selectedAccount === '') {
133
132
  return exports.EMPTY_ACCOUNT;
134
133
  }
135
- const account = this.getAccountExpect(selectedAccount);
136
- if ((0, keyring_api_1.isEvmAccountType)(account.type)) {
137
- return account;
134
+ const selectedAccount = this.getAccountExpect(this.state.internalAccounts.selectedAccount);
135
+ if ((0, keyring_api_1.isEvmAccountType)(selectedAccount.type)) {
136
+ return selectedAccount;
138
137
  }
139
138
  const accounts = this.listAccounts();
140
139
  if (!accounts.length) {
@@ -154,14 +153,13 @@ class AccountsController extends base_controller_1.BaseController {
154
153
  * @returns The last selected account compatible with the specified chain ID or undefined.
155
154
  */
156
155
  getSelectedMultichainAccount(chainId) {
157
- const { internalAccounts: { selectedAccount }, } = this.state;
158
156
  // Edge case where the extension is setup but the srp is not yet created
159
157
  // certain ui elements will query the selected address before any accounts are created.
160
- if (selectedAccount === '') {
158
+ if (this.state.internalAccounts.selectedAccount === '') {
161
159
  return exports.EMPTY_ACCOUNT;
162
160
  }
163
161
  if (!chainId) {
164
- return this.getAccountExpect(selectedAccount);
162
+ return this.getAccountExpect(this.state.internalAccounts.selectedAccount);
165
163
  }
166
164
  const accounts = this.listMultichainAccounts(chainId);
167
165
  return __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedAccount).call(this, accounts);
@@ -183,11 +181,12 @@ class AccountsController extends base_controller_1.BaseController {
183
181
  */
184
182
  setSelectedAccount(accountId) {
185
183
  const account = this.getAccountExpect(accountId);
186
- __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_update).call(this, (state) => {
187
- const { internalAccounts } = state;
188
- internalAccounts.accounts[account.id].metadata.lastSelected = Date.now();
189
- internalAccounts.selectedAccount = account.id;
184
+ this.update((currentState) => {
185
+ currentState.internalAccounts.accounts[account.id].metadata.lastSelected =
186
+ Date.now();
187
+ currentState.internalAccounts.selectedAccount = account.id;
190
188
  });
189
+ __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_publishAccountChangeEvent).call(this, account);
191
190
  }
192
191
  /**
193
192
  * Sets the name of the account with the given ID.
@@ -217,19 +216,19 @@ class AccountsController extends base_controller_1.BaseController {
217
216
  internalAccount.id !== accountId)) {
218
217
  throw new Error('Account name already exists');
219
218
  }
220
- const internalAccount = {
221
- ...account,
222
- metadata: { ...account.metadata, ...metadata },
223
- };
224
- __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_update).call(this, (state) => {
225
- // FIXME: Do not remove this comment - This error is flaky: Comment out or restore the `ts-expect-error` directive below as needed.
219
+ this.update((currentState) => {
220
+ const internalAccount = {
221
+ ...account,
222
+ metadata: { ...account.metadata, ...metadata },
223
+ };
224
+ // Do not remove this comment - This error is flaky: Comment out or restore the `ts-expect-error` directive below as needed.
226
225
  // See: https://github.com/MetaMask/utils/issues/168
227
226
  // // @ts-expect-error Known issue - `Json` causes recursive error in immer `Draft`/`WritableDraft` types
228
- state.internalAccounts.accounts[accountId] = internalAccount;
227
+ currentState.internalAccounts.accounts[accountId] = internalAccount;
228
+ if (metadata.name) {
229
+ this.messagingSystem.publish('AccountsController:accountRenamed', internalAccount);
230
+ }
229
231
  });
230
- if (metadata.name) {
231
- this.messagingSystem.publish('AccountsController:accountRenamed', internalAccount);
232
- }
233
232
  }
234
233
  /**
235
234
  * Updates the internal accounts list by retrieving normal and snap accounts,
@@ -268,8 +267,21 @@ class AccountsController extends base_controller_1.BaseController {
268
267
  };
269
268
  return internalAccountMap;
270
269
  }, {});
271
- __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_update).call(this, (state) => {
272
- state.internalAccounts.accounts = accounts;
270
+ this.update((currentState) => {
271
+ currentState.internalAccounts.accounts = accounts;
272
+ if (!currentState.internalAccounts.accounts[currentState.internalAccounts.selectedAccount]) {
273
+ const lastSelectedAccount = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedAccount).call(this, Object.values(accounts));
274
+ if (lastSelectedAccount) {
275
+ currentState.internalAccounts.selectedAccount =
276
+ lastSelectedAccount.id;
277
+ currentState.internalAccounts.accounts[lastSelectedAccount.id].metadata.lastSelected = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedIndex).call(this);
278
+ __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_publishAccountChangeEvent).call(this, lastSelectedAccount);
279
+ }
280
+ else {
281
+ // It will be undefined if there are no accounts
282
+ currentState.internalAccounts.selectedAccount = '';
283
+ }
284
+ }
273
285
  });
274
286
  }
275
287
  /**
@@ -336,11 +348,6 @@ _AccountsController_instances = new WeakSet(), _AccountsController_generateInter
336
348
  },
337
349
  },
338
350
  };
339
- }, _AccountsController_getSnapKeyring = function _AccountsController_getSnapKeyring() {
340
- const [snapKeyring] = this.messagingSystem.call('KeyringController:getKeyringsByType', eth_snap_keyring_1.SnapKeyring.type);
341
- // Snap keyring is not available until the first account is created in the keyring
342
- // controller, so this might be undefined.
343
- return snapKeyring;
344
351
  }, _AccountsController_listSnapAccounts =
345
352
  /**
346
353
  * Returns a list of internal accounts created using the SnapKeyring.
@@ -348,11 +355,13 @@ _AccountsController_instances = new WeakSet(), _AccountsController_generateInter
348
355
  * @returns A promise that resolves to an array of InternalAccount objects.
349
356
  */
350
357
  async function _AccountsController_listSnapAccounts() {
351
- const keyring = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getSnapKeyring).call(this);
352
- if (!keyring) {
358
+ const [snapKeyring] = this.messagingSystem.call('KeyringController:getKeyringsByType', eth_snap_keyring_1.SnapKeyring.type);
359
+ // snap keyring is not available until the first account is created in the keyring controller
360
+ if (!snapKeyring) {
353
361
  return [];
354
362
  }
355
- return keyring.listAccounts();
363
+ const snapAccounts = snapKeyring.listAccounts();
364
+ return snapAccounts;
356
365
  }, _AccountsController_listNormalAccounts =
357
366
  /**
358
367
  * Returns a list of normal accounts.
@@ -402,153 +411,104 @@ async function _AccountsController_listNormalAccounts() {
402
411
  return internalAccounts;
403
412
  }, _AccountsController_handleOnSnapKeyringAccountEvent = function _AccountsController_handleOnSnapKeyringAccountEvent(event, ...payload) {
404
413
  this.messagingSystem.publish(event, ...payload);
405
- }, _AccountsController_handleOnKeyringStateChange = function _AccountsController_handleOnKeyringStateChange({ isUnlocked, keyrings, }) {
406
- // TODO: Change when accountAdded event is added to the keyring controller.
414
+ }, _AccountsController_handleOnKeyringStateChange = function _AccountsController_handleOnKeyringStateChange(keyringState) {
415
+ // check if there are any new accounts added
416
+ // TODO: change when accountAdded event is added to the keyring controller
407
417
  // We check for keyrings length to be greater than 0 because the extension client may try execute
408
418
  // submit password twice and clear the keyring state.
409
419
  // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910
410
- if (!isUnlocked || keyrings.length === 0) {
411
- return;
412
- }
413
- // State patches.
414
- const generatePatch = () => {
415
- return {
416
- previous: {},
417
- added: [],
418
- updated: [],
419
- removed: [],
420
- };
421
- };
422
- const patches = {
423
- snap: generatePatch(),
424
- normal: generatePatch(),
425
- };
426
- // Gets the patch object based on the keyring type (since Snap accounts and other accounts
427
- // are handled differently).
428
- const patchOf = (type) => {
429
- if (type === keyring_controller_1.KeyringTypes.snap) {
430
- return patches.snap;
431
- }
432
- return patches.normal;
433
- };
434
- // Create a map (with lower-cased addresses) of all existing accounts.
435
- for (const account of this.listMultichainAccounts()) {
436
- const address = account.address.toLowerCase();
437
- const patch = patchOf(account.metadata.keyring.type);
438
- patch.previous[address] = account;
439
- }
440
- // Go over all keyring changes and create patches out of it.
441
- const addresses = new Set();
442
- for (const keyring of keyrings) {
443
- const patch = patchOf(keyring.type);
444
- for (const accountAddress of keyring.accounts) {
445
- // Lower-case address to use it in the `previous` map.
446
- const address = accountAddress.toLowerCase();
447
- const account = patch.previous[address];
448
- if (account) {
449
- // If the account exists before, this might be an update.
450
- patch.updated.push(account);
420
+ if (keyringState.isUnlocked && keyringState.keyrings.length > 0) {
421
+ const updatedNormalKeyringAddresses = [];
422
+ const updatedSnapKeyringAddresses = [];
423
+ for (const keyring of keyringState.keyrings) {
424
+ if (keyring.type === keyring_controller_1.KeyringTypes.snap) {
425
+ updatedSnapKeyringAddresses.push(...keyring.accounts.map((address) => {
426
+ return {
427
+ address,
428
+ type: keyring.type,
429
+ };
430
+ }));
451
431
  }
452
432
  else {
453
- // Otherwise, that's a new account.
454
- patch.added.push({
455
- address,
456
- type: keyring.type,
457
- });
433
+ updatedNormalKeyringAddresses.push(...keyring.accounts.map((address) => {
434
+ return {
435
+ address,
436
+ type: keyring.type,
437
+ };
438
+ }));
458
439
  }
459
- // Keep track of those address to check for removed accounts later.
460
- addresses.add(address);
461
440
  }
462
- }
463
- // We might have accounts associated with removed keyrings, so we iterate
464
- // over all previous known accounts and check against the keyring addresses.
465
- for (const patch of [patches.snap, patches.normal]) {
466
- for (const [address, account] of Object.entries(patch.previous)) {
467
- // If a previous address is not part of the new addesses, then it got removed.
468
- if (!addresses.has(address)) {
469
- patch.removed.push(account);
441
+ const { previousNormalInternalAccounts, previousSnapInternalAccounts } = this.listMultichainAccounts().reduce((accumulator, account) => {
442
+ if (account.metadata.keyring.type === keyring_controller_1.KeyringTypes.snap) {
443
+ accumulator.previousSnapInternalAccounts.push(account);
470
444
  }
471
- }
472
- }
473
- // Diff that we will use to publish events afterward.
474
- const diff = {
475
- removed: [],
476
- added: [],
477
- };
478
- __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_update).call(this, (state) => {
479
- const { internalAccounts } = state;
480
- for (const patch of [patches.snap, patches.normal]) {
481
- for (const account of patch.removed) {
482
- delete internalAccounts.accounts[account.id];
483
- diff.removed.push(account.id);
445
+ else {
446
+ accumulator.previousNormalInternalAccounts.push(account);
484
447
  }
485
- for (const added of patch.added) {
486
- const account = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getInternalAccountFromAddressAndType).call(this, added.address, added.type);
487
- if (account) {
488
- // Re-compute the list of accounts everytime, so we can make sure new names
489
- // are also considered.
490
- const accounts = Object.values(internalAccounts.accounts);
491
- // Get next account name available for this given keyring.
492
- const name = this.getNextAvailableAccountName(account.metadata.keyring.type, accounts);
493
- // If it's the first account, we need to select it.
494
- const lastSelected = accounts.length === 0 ? __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedIndex).call(this) : 0;
495
- internalAccounts.accounts[account.id] = {
496
- ...account,
497
- metadata: {
498
- ...account.metadata,
499
- name,
500
- importTime: Date.now(),
501
- lastSelected,
502
- },
503
- };
504
- diff.added.push(internalAccounts.accounts[account.id]);
505
- }
448
+ return accumulator;
449
+ }, {
450
+ previousNormalInternalAccounts: [],
451
+ previousSnapInternalAccounts: [],
452
+ });
453
+ const addedAccounts = [];
454
+ const deletedAccounts = [];
455
+ // snap account ids are random uuid while normal accounts
456
+ // are determininistic based on the address
457
+ // ^NOTE: This will be removed when normal accounts also implement internal accounts
458
+ // finding all the normal accounts that were added
459
+ for (const account of updatedNormalKeyringAddresses) {
460
+ if (!this.state.internalAccounts.accounts[(0, utils_2.getUUIDFromAddressOfNormalAccount)(account.address)]) {
461
+ addedAccounts.push(account);
506
462
  }
507
463
  }
508
- });
509
- // Now publish events
510
- for (const id of diff.removed) {
511
- this.messagingSystem.publish('AccountsController:accountRemoved', id);
512
- }
513
- for (const account of diff.added) {
514
- this.messagingSystem.publish('AccountsController:accountAdded', account);
515
- }
516
- // NOTE: Since we also track "updated" accounts with our patches, we could fire a new event
517
- // like `accountUpdated` (we would still need to check if anything really changed on the account).
518
- }, _AccountsController_update = function _AccountsController_update(callback) {
519
- // The currently selected account might get deleted during the update, so keep track
520
- // of it before doing any change.
521
- const previouslySelectedAccount = this.state.internalAccounts.selectedAccount;
522
- this.update((state) => {
523
- callback(state);
524
- // If the account no longer exists (or none is selected), we need to re-select another one.
525
- const { internalAccounts } = state;
526
- if (!internalAccounts.accounts[previouslySelectedAccount]) {
527
- const accounts = Object.values(internalAccounts.accounts);
528
- // Get the lastly selected account (according to the current accounts).
529
- const lastSelectedAccount = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedAccount).call(this, accounts);
530
- if (lastSelectedAccount) {
531
- internalAccounts.selectedAccount = lastSelectedAccount.id;
532
- internalAccounts.accounts[lastSelectedAccount.id].metadata.lastSelected = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedIndex).call(this);
464
+ // finding all the snap accounts that were added
465
+ for (const account of updatedSnapKeyringAddresses) {
466
+ if (!previousSnapInternalAccounts.find((internalAccount) => internalAccount.address.toLowerCase() ===
467
+ account.address.toLowerCase())) {
468
+ addedAccounts.push(account);
533
469
  }
534
- else {
535
- // It will be undefined if there are no accounts.
536
- internalAccounts.selectedAccount = '';
470
+ }
471
+ // finding all the normal accounts that were deleted
472
+ for (const account of previousNormalInternalAccounts) {
473
+ if (!updatedNormalKeyringAddresses.find(({ address }) => address.toLowerCase() === account.address.toLowerCase())) {
474
+ deletedAccounts.push(account);
537
475
  }
538
476
  }
539
- });
540
- // Now, we compare the newly selected account, and we send event if different.
541
- const { selectedAccount } = this.state.internalAccounts;
542
- if (selectedAccount && selectedAccount !== previouslySelectedAccount) {
543
- const account = this.getSelectedMultichainAccount();
544
- // The account should always be defined at this point, since we have already checked for
545
- // `selectedAccount` to be non-empty.
546
- if (account) {
547
- if ((0, keyring_api_1.isEvmAccountType)(account.type)) {
548
- this.messagingSystem.publish('AccountsController:selectedEvmAccountChange', account);
477
+ // finding all the snap accounts that were deleted
478
+ for (const account of previousSnapInternalAccounts) {
479
+ if (!updatedSnapKeyringAddresses.find(({ address }) => address.toLowerCase() === account.address.toLowerCase())) {
480
+ deletedAccounts.push(account);
549
481
  }
550
- this.messagingSystem.publish('AccountsController:selectedAccountChange', account);
551
482
  }
483
+ this.update((currentState) => {
484
+ if (deletedAccounts.length > 0) {
485
+ for (const account of deletedAccounts) {
486
+ currentState.internalAccounts.accounts = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_handleAccountRemoved).call(this, currentState.internalAccounts.accounts, account.id);
487
+ }
488
+ }
489
+ if (addedAccounts.length > 0) {
490
+ for (const account of addedAccounts) {
491
+ currentState.internalAccounts.accounts =
492
+ __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_handleNewAccountAdded).call(this, currentState.internalAccounts.accounts, account);
493
+ }
494
+ }
495
+ // We don't use list accounts because it is not the updated state yet.
496
+ const existingAccounts = Object.values(currentState.internalAccounts.accounts);
497
+ // handle if the selected account was deleted
498
+ if (!currentState.internalAccounts.accounts[this.state.internalAccounts.selectedAccount]) {
499
+ const lastSelectedAccount = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedAccount).call(this, existingAccounts);
500
+ if (lastSelectedAccount) {
501
+ currentState.internalAccounts.selectedAccount =
502
+ lastSelectedAccount.id;
503
+ currentState.internalAccounts.accounts[lastSelectedAccount.id].metadata.lastSelected = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedIndex).call(this);
504
+ __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_publishAccountChangeEvent).call(this, lastSelectedAccount);
505
+ }
506
+ else {
507
+ // It will be undefined if there are no accounts
508
+ currentState.internalAccounts.selectedAccount = '';
509
+ }
510
+ }
511
+ });
552
512
  }
553
513
  }, _AccountsController_handleOnSnapStateChange = function _AccountsController_handleOnSnapStateChange(snapState) {
554
514
  // only check if snaps changed in status
@@ -589,18 +549,43 @@ async function _AccountsController_listNormalAccounts() {
589
549
  // NOTE: For now we use the current date, since we know this value
590
550
  // will always be higher than any already selected account index.
591
551
  return Date.now();
592
- }, _AccountsController_getInternalAccountFromAddressAndType = function _AccountsController_getInternalAccountFromAddressAndType(address, type) {
593
- if (type === keyring_controller_1.KeyringTypes.snap) {
594
- const keyring = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getSnapKeyring).call(this);
595
- // We need the Snap keyring to retrieve the account from its address.
596
- if (!keyring) {
597
- return undefined;
552
+ }, _AccountsController_handleNewAccountAdded = function _AccountsController_handleNewAccountAdded(accountsState, account) {
553
+ let newAccount;
554
+ if (account.type !== keyring_controller_1.KeyringTypes.snap) {
555
+ newAccount = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_generateInternalAccountForNonSnapAccount).call(this, account.address, account.type);
556
+ }
557
+ else {
558
+ const [snapKeyring] = this.messagingSystem.call('KeyringController:getKeyringsByType', eth_snap_keyring_1.SnapKeyring.type);
559
+ newAccount = snapKeyring.getAccountByAddress(account.address);
560
+ // The snap deleted the account before the keyring controller could add it
561
+ if (!newAccount) {
562
+ return accountsState;
598
563
  }
599
- // This might be undefined if the Snap deleted the account before
600
- // reaching that point.
601
- return keyring.getAccountByAddress(address);
602
564
  }
603
- return __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_generateInternalAccountForNonSnapAccount).call(this, address, type);
565
+ const isFirstAccount = Object.keys(accountsState).length === 0;
566
+ // Get next account name available for this given keyring
567
+ const accountName = this.getNextAvailableAccountName(newAccount.metadata.keyring.type, Object.values(accountsState));
568
+ const newAccountWithUpdatedMetadata = {
569
+ ...newAccount,
570
+ metadata: {
571
+ ...newAccount.metadata,
572
+ name: accountName,
573
+ importTime: Date.now(),
574
+ lastSelected: isFirstAccount ? __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedIndex).call(this) : 0,
575
+ },
576
+ };
577
+ accountsState[newAccount.id] = newAccountWithUpdatedMetadata;
578
+ this.messagingSystem.publish('AccountsController:accountAdded', newAccountWithUpdatedMetadata);
579
+ return accountsState;
580
+ }, _AccountsController_publishAccountChangeEvent = function _AccountsController_publishAccountChangeEvent(account) {
581
+ if ((0, keyring_api_1.isEvmAccountType)(account.type)) {
582
+ this.messagingSystem.publish('AccountsController:selectedEvmAccountChange', account);
583
+ }
584
+ this.messagingSystem.publish('AccountsController:selectedAccountChange', account);
585
+ }, _AccountsController_handleAccountRemoved = function _AccountsController_handleAccountRemoved(accountsState, accountId) {
586
+ delete accountsState[accountId];
587
+ this.messagingSystem.publish('AccountsController:accountRemoved', accountId);
588
+ return accountsState;
604
589
  }, _AccountsController_handleOnMultichainNetworkDidChange = function _AccountsController_handleOnMultichainNetworkDidChange(id) {
605
590
  let accountId;
606
591
  // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin