@metamask-previews/accounts-controller 27.0.0-preview-bf2d2c4c → 27.0.0-preview-8ea9b81f

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_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;
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;
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,14 +126,15 @@ 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;
129
130
  // Edge case where the extension is setup but the srp is not yet created
130
131
  // certain ui elements will query the selected address before any accounts are created.
131
- if (this.state.internalAccounts.selectedAccount === '') {
132
+ if (selectedAccount === '') {
132
133
  return exports.EMPTY_ACCOUNT;
133
134
  }
134
- const selectedAccount = this.getAccountExpect(this.state.internalAccounts.selectedAccount);
135
- if ((0, keyring_api_1.isEvmAccountType)(selectedAccount.type)) {
136
- return selectedAccount;
135
+ const account = this.getAccountExpect(selectedAccount);
136
+ if ((0, keyring_api_1.isEvmAccountType)(account.type)) {
137
+ return account;
137
138
  }
138
139
  const accounts = this.listAccounts();
139
140
  if (!accounts.length) {
@@ -153,13 +154,14 @@ class AccountsController extends base_controller_1.BaseController {
153
154
  * @returns The last selected account compatible with the specified chain ID or undefined.
154
155
  */
155
156
  getSelectedMultichainAccount(chainId) {
157
+ const { internalAccounts: { selectedAccount }, } = this.state;
156
158
  // Edge case where the extension is setup but the srp is not yet created
157
159
  // certain ui elements will query the selected address before any accounts are created.
158
- if (this.state.internalAccounts.selectedAccount === '') {
160
+ if (selectedAccount === '') {
159
161
  return exports.EMPTY_ACCOUNT;
160
162
  }
161
163
  if (!chainId) {
162
- return this.getAccountExpect(this.state.internalAccounts.selectedAccount);
164
+ return this.getAccountExpect(selectedAccount);
163
165
  }
164
166
  const accounts = this.listMultichainAccounts(chainId);
165
167
  return __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getLastSelectedAccount).call(this, accounts);
@@ -181,12 +183,11 @@ class AccountsController extends base_controller_1.BaseController {
181
183
  */
182
184
  setSelectedAccount(accountId) {
183
185
  const account = this.getAccountExpect(accountId);
184
- this.update((currentState) => {
185
- currentState.internalAccounts.accounts[account.id].metadata.lastSelected =
186
- Date.now();
187
- currentState.internalAccounts.selectedAccount = account.id;
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;
188
190
  });
189
- __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_publishAccountChangeEvent).call(this, account);
190
191
  }
191
192
  /**
192
193
  * Sets the name of the account with the given ID.
@@ -216,19 +217,19 @@ class AccountsController extends base_controller_1.BaseController {
216
217
  internalAccount.id !== accountId)) {
217
218
  throw new Error('Account name already exists');
218
219
  }
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.
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.
225
226
  // See: https://github.com/MetaMask/utils/issues/168
226
227
  // // @ts-expect-error Known issue - `Json` causes recursive error in immer `Draft`/`WritableDraft` types
227
- currentState.internalAccounts.accounts[accountId] = internalAccount;
228
- if (metadata.name) {
229
- this.messagingSystem.publish('AccountsController:accountRenamed', internalAccount);
230
- }
228
+ state.internalAccounts.accounts[accountId] = internalAccount;
231
229
  });
230
+ if (metadata.name) {
231
+ this.messagingSystem.publish('AccountsController:accountRenamed', internalAccount);
232
+ }
232
233
  }
233
234
  /**
234
235
  * Updates the internal accounts list by retrieving normal and snap accounts,
@@ -267,21 +268,8 @@ class AccountsController extends base_controller_1.BaseController {
267
268
  };
268
269
  return internalAccountMap;
269
270
  }, {});
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
- }
271
+ __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_update).call(this, (state) => {
272
+ state.internalAccounts.accounts = accounts;
285
273
  });
286
274
  }
287
275
  /**
@@ -348,6 +336,11 @@ _AccountsController_instances = new WeakSet(), _AccountsController_generateInter
348
336
  },
349
337
  },
350
338
  };
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;
351
344
  }, _AccountsController_listSnapAccounts =
352
345
  /**
353
346
  * Returns a list of internal accounts created using the SnapKeyring.
@@ -355,13 +348,11 @@ _AccountsController_instances = new WeakSet(), _AccountsController_generateInter
355
348
  * @returns A promise that resolves to an array of InternalAccount objects.
356
349
  */
357
350
  async function _AccountsController_listSnapAccounts() {
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) {
351
+ const keyring = __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_getSnapKeyring).call(this);
352
+ if (!keyring) {
361
353
  return [];
362
354
  }
363
- const snapAccounts = snapKeyring.listAccounts();
364
- return snapAccounts;
355
+ return keyring.listAccounts();
365
356
  }, _AccountsController_listNormalAccounts =
366
357
  /**
367
358
  * Returns a list of normal accounts.
@@ -411,104 +402,153 @@ async function _AccountsController_listNormalAccounts() {
411
402
  return internalAccounts;
412
403
  }, _AccountsController_handleOnSnapKeyringAccountEvent = function _AccountsController_handleOnSnapKeyringAccountEvent(event, ...payload) {
413
404
  this.messagingSystem.publish(event, ...payload);
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
405
+ }, _AccountsController_handleOnKeyringStateChange = function _AccountsController_handleOnKeyringStateChange({ isUnlocked, keyrings, }) {
406
+ // TODO: Change when accountAdded event is added to the keyring controller.
417
407
  // We check for keyrings length to be greater than 0 because the extension client may try execute
418
408
  // submit password twice and clear the keyring state.
419
409
  // https://github.com/MetaMask/KeyringController/blob/2d73a4deed8d013913f6ef0c9f5c0bb7c614f7d3/src/KeyringController.ts#L910
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
- }));
431
- }
432
- else {
433
- updatedNormalKeyringAddresses.push(...keyring.accounts.map((address) => {
434
- return {
435
- address,
436
- type: keyring.type,
437
- };
438
- }));
439
- }
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;
440
431
  }
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);
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);
444
451
  }
445
452
  else {
446
- accumulator.previousNormalInternalAccounts.push(account);
447
- }
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);
453
+ // Otherwise, that's a new account.
454
+ patch.added.push({
455
+ address,
456
+ type: keyring.type,
457
+ });
462
458
  }
459
+ // Keep track of those address to check for removed accounts later.
460
+ addresses.add(address);
463
461
  }
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);
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);
469
470
  }
470
471
  }
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);
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);
475
484
  }
476
- }
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);
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
+ }
481
506
  }
482
507
  }
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
- }
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);
488
533
  }
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
- }
534
+ else {
535
+ // It will be undefined if there are no accounts.
536
+ internalAccounts.selectedAccount = '';
494
537
  }
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
- }
538
+ }
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);
510
549
  }
511
- });
550
+ this.messagingSystem.publish('AccountsController:selectedAccountChange', account);
551
+ }
512
552
  }
513
553
  }, _AccountsController_handleOnSnapStateChange = function _AccountsController_handleOnSnapStateChange(snapState) {
514
554
  // only check if snaps changed in status
@@ -549,43 +589,18 @@ async function _AccountsController_listNormalAccounts() {
549
589
  // NOTE: For now we use the current date, since we know this value
550
590
  // will always be higher than any already selected account index.
551
591
  return Date.now();
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;
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;
563
598
  }
599
+ // This might be undefined if the Snap deleted the account before
600
+ // reaching that point.
601
+ return keyring.getAccountByAddress(address);
564
602
  }
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;
603
+ return __classPrivateFieldGet(this, _AccountsController_instances, "m", _AccountsController_generateInternalAccountForNonSnapAccount).call(this, address, type);
589
604
  }, _AccountsController_handleOnMultichainNetworkDidChange = function _AccountsController_handleOnMultichainNetworkDidChange(id) {
590
605
  let accountId;
591
606
  // We only support non-EVM Caip chain IDs at the moment. Ex Solana and Bitcoin