@metamask-previews/assets-controller 20.2.3-preview-70090cfe4 → 20.2.3-preview-d13fc5171
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 +0 -17
- package/dist/AssetsController.d.ts +4 -7
- package/dist/AssetsController.d.ts.map +1 -1
- package/dist/AssetsController.js +40 -191
- package/dist/AssetsController.js.map +1 -1
- package/dist/data-sources/AbstractDataSource.d.ts +0 -13
- package/dist/data-sources/AbstractDataSource.d.ts.map +1 -1
- package/dist/data-sources/AbstractDataSource.js +0 -15
- package/dist/data-sources/AbstractDataSource.js.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.ts +0 -8
- package/dist/data-sources/AccountsApiDataSource.d.ts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.js +1 -23
- package/dist/data-sources/AccountsApiDataSource.js.map +1 -1
- package/dist/data-sources/RpcDataSource.d.ts +0 -8
- package/dist/data-sources/RpcDataSource.d.ts.map +1 -1
- package/dist/data-sources/RpcDataSource.js +0 -9
- package/dist/data-sources/RpcDataSource.js.map +1 -1
- package/dist/data-sources/SnapDataSource.d.ts +0 -8
- package/dist/data-sources/SnapDataSource.d.ts.map +1 -1
- package/dist/data-sources/SnapDataSource.js +1 -9
- package/dist/data-sources/SnapDataSource.js.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.d.ts +0 -10
- package/dist/data-sources/StakedBalanceDataSource.d.ts.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.js +2 -5
- package/dist/data-sources/StakedBalanceDataSource.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,23 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Added
|
|
11
|
-
|
|
12
|
-
- Add `bootstrap()` to `AbstractDataSource` for setup that reads other controllers or makes requests ([#11351](https://github.com/MetaMask/core/pull/11351))
|
|
13
|
-
- The default implementation does nothing. `AssetsController` calls it on every balance data source the first time the UI opens.
|
|
14
|
-
|
|
15
|
-
### Changed
|
|
16
|
-
|
|
17
|
-
- **BREAKING:** `AssetsController` no longer calls other controllers or makes requests in its constructor; it bootstraps the first time the UI opens ([#11351](https://github.com/MetaMask/core/pull/11351))
|
|
18
|
-
- The constructor only subscribes to events and registers action handlers, so it no longer depends on the order in which controllers are constructed.
|
|
19
|
-
- The first `ClientController:stateChange` with `isUiOpen: true` reads `NetworkEnablementController:getState`, bootstraps the balance data sources, fetches the native asset map, calls `subscribeToBasicFunctionalityChange`, and runs the unlock cleanups if the keyring is already unlocked. Assets are then tracked as before, once the keyring is unlocked and the account tree is initialized.
|
|
20
|
-
- Until then, `NetworkEnablementController:stateChange` only records the enabled chains; network, transaction and `KeyringController:unlock` events and `handleBasicFunctionalityChange` are ignored.
|
|
21
|
-
- Clients must call `ClientController:setUiOpen(true)` when the UI opens, or assets are never loaded.
|
|
22
|
-
- **BREAKING:** `AccountsApiDataSource`, `RpcDataSource` and `SnapDataSource` no longer call other controllers or make requests in their constructors ([#11351](https://github.com/MetaMask/core/pull/11351))
|
|
23
|
-
- Call `bootstrap()` to fetch the Accounts API supported networks (and start refreshing them), read `NetworkController` state, or discover keyring snaps, respectively. `AssetsController` does this for you.
|
|
24
|
-
- `AccountsApiDataSource` ignores `RemoteFeatureFlagController:stateChange` until it has been bootstrapped.
|
|
25
|
-
- `AssetsController` treats a controller whose actions are not registered (such as `AccountTreeController`, `ClientController` or `KeyringController`) as not ready instead of throwing ([#11351](https://github.com/MetaMask/core/pull/11351))
|
|
26
|
-
|
|
27
10
|
## [20.2.3]
|
|
28
11
|
|
|
29
12
|
### Changed
|
|
@@ -155,13 +155,10 @@ export type AssetsControllerOptions = {
|
|
|
155
155
|
* based on which chains they support. When active chains change, the controller
|
|
156
156
|
* dynamically adjusts subscriptions.
|
|
157
157
|
*
|
|
158
|
-
* 4. **Client + Keyring Lifecycle**:
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* wallet is unlocked (KeyringController), and stops when either the UI
|
|
163
|
-
* closes or the keyring locks. See client-controller README for the
|
|
164
|
-
* combined pattern.
|
|
158
|
+
* 4. **Client + Keyring Lifecycle**: Starts subscriptions only when both the UI is
|
|
159
|
+
* open (ClientController) and the wallet is unlocked (KeyringController).
|
|
160
|
+
* Stops when either the UI closes or the keyring locks. See client-controller
|
|
161
|
+
* README for the combined pattern.
|
|
165
162
|
*
|
|
166
163
|
* ## Architecture
|
|
167
164
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsController.d.ts","sourceRoot":"","sources":["../src/AssetsController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAC9D,qCAAqC,EACrC,wCAAwC,EACxC,oDAAoD,EACpD,uCAAuC,EACxC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,4DAA4D,EAAE,MAAM,sCAAsC,CAAC;AACzH,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EACV,iBAAiB,EACjB,yCAAyC,EACzC,wCAAwC,EACxC,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACV,iCAAiC,EACjC,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,K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AoB,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAkC3E;IAED;;OAEG;IACH,sBAAsB,IAAI,IAAI,CAS7B;IA23BD;;;;;;;OAOG;IACH,8BAA8B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGtD;IAkqBD;;;;;;;;;OASG;IACG,kBAAkB,CACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CAYf;IAsMD,OAAO,IAAI,IAAI,CAoDd;CACF"}
|
package/dist/AssetsController.js
CHANGED
|
@@ -321,13 +321,10 @@ function effectiveAccountBalancesV6(previousBalances, updatedBalances, undeletab
|
|
|
321
321
|
* based on which chains they support. When active chains change, the controller
|
|
322
322
|
* dynamically adjusts subscriptions.
|
|
323
323
|
*
|
|
324
|
-
* 4. **Client + Keyring Lifecycle**:
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* wallet is unlocked (KeyringController), and stops when either the UI
|
|
329
|
-
* closes or the keyring locks. See client-controller README for the
|
|
330
|
-
* combined pattern.
|
|
324
|
+
* 4. **Client + Keyring Lifecycle**: Starts subscriptions only when both the UI is
|
|
325
|
+
* open (ClientController) and the wallet is unlocked (KeyringController).
|
|
326
|
+
* Stops when either the UI closes or the keyring locks. See client-controller
|
|
327
|
+
* README for the combined pattern.
|
|
331
328
|
*
|
|
332
329
|
* ## Architecture
|
|
333
330
|
*
|
|
@@ -429,23 +426,8 @@ let AssetsController = (() => {
|
|
|
429
426
|
* its forced `getAssets()` call) runs a second time for the same accounts.
|
|
430
427
|
*/
|
|
431
428
|
#startInFlight = false;
|
|
432
|
-
/**
|
|
433
|
-
* Currently enabled chains from NetworkEnablementController.
|
|
434
|
-
*
|
|
435
|
-
* Empty until `NetworkEnablementController:stateChange` is published or the
|
|
436
|
-
* controller is bootstrapped, because the constructor must not read other
|
|
437
|
-
* controllers' state.
|
|
438
|
-
*/
|
|
429
|
+
/** Currently enabled chains from NetworkEnablementController */
|
|
439
430
|
#enabledChains = new Set();
|
|
440
|
-
/**
|
|
441
|
-
* Whether `#bootstrap()` has finished. Until then, event handlers only
|
|
442
|
-
* record state (such as enabled chains) and never fetch.
|
|
443
|
-
*/
|
|
444
|
-
#isBootstrapped = false;
|
|
445
|
-
/** Set by the first `#bootstrap()` call; later calls reuse it. */
|
|
446
|
-
#bootstrapPromise = null;
|
|
447
|
-
#isDestroyed = false;
|
|
448
|
-
#subscribeToBasicFunctionalityChange;
|
|
449
431
|
/**
|
|
450
432
|
* Get the currently selected accounts from AccountTreeController.
|
|
451
433
|
* This includes all accounts in the same group as the selected account
|
|
@@ -454,44 +436,23 @@ let AssetsController = (() => {
|
|
|
454
436
|
* @returns Array of InternalAccount objects from the selected account group.
|
|
455
437
|
*/
|
|
456
438
|
#getSelectedAccounts() {
|
|
457
|
-
const accounts = this
|
|
439
|
+
const accounts = this.messenger.call('AccountTreeController:getAccountsFromSelectedAccountGroup');
|
|
458
440
|
if (accounts.length > 0) {
|
|
459
441
|
return accounts;
|
|
460
442
|
}
|
|
461
|
-
const selectedAccount = this
|
|
443
|
+
const selectedAccount = this.messenger.call('AccountsController:getSelectedAccount');
|
|
462
444
|
if (selectedAccount) {
|
|
463
445
|
return [selectedAccount];
|
|
464
446
|
}
|
|
465
447
|
return [];
|
|
466
448
|
}
|
|
467
|
-
/**
|
|
468
|
-
* Run a messenger call, returning `fallback` if it throws.
|
|
469
|
-
*
|
|
470
|
-
* The wallet may construct this controller before (or without) the
|
|
471
|
-
* controllers it reads from. A missing handler means that controller is not
|
|
472
|
-
* ready, which is treated the same as "not initialized" rather than crashing
|
|
473
|
-
* the caller.
|
|
474
|
-
*
|
|
475
|
-
* @param call - The messenger call to run.
|
|
476
|
-
* @param fallback - The value to return if the call throws.
|
|
477
|
-
* @returns The call's result, or `fallback`.
|
|
478
|
-
*/
|
|
479
|
-
#callIfRegistered(call, fallback) {
|
|
480
|
-
try {
|
|
481
|
-
return call();
|
|
482
|
-
}
|
|
483
|
-
catch (error) {
|
|
484
|
-
log('Messenger call failed; treating dependency as not ready', error);
|
|
485
|
-
return fallback;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
449
|
/**
|
|
489
450
|
* Whether `AccountTreeController.init()` has completed and the tree is ready.
|
|
490
451
|
*
|
|
491
452
|
* @returns True when the account tree has been initialized.
|
|
492
453
|
*/
|
|
493
454
|
#isAccountTreeInitialized() {
|
|
494
|
-
return this
|
|
455
|
+
return this.messenger.call('AccountTreeController:isInitialized');
|
|
495
456
|
}
|
|
496
457
|
/**
|
|
497
458
|
* Whether the client (UI) is open, read from ClientController state.
|
|
@@ -499,7 +460,7 @@ let AssetsController = (() => {
|
|
|
499
460
|
* @returns True when the UI is open.
|
|
500
461
|
*/
|
|
501
462
|
#isUiOpen() {
|
|
502
|
-
return
|
|
463
|
+
return clientControllerSelectors.selectIsUiOpen(this.messenger.call('ClientController:getState'));
|
|
503
464
|
}
|
|
504
465
|
/**
|
|
505
466
|
* Whether the keyring is unlocked, read from KeyringController.
|
|
@@ -507,7 +468,7 @@ let AssetsController = (() => {
|
|
|
507
468
|
* @returns True when the wallet vault is unlocked.
|
|
508
469
|
*/
|
|
509
470
|
#isKeyringUnlocked() {
|
|
510
|
-
return this
|
|
471
|
+
return this.messenger.call('KeyringController:isUnlocked');
|
|
511
472
|
}
|
|
512
473
|
#accountActivityDataSource;
|
|
513
474
|
#accountsApiDataSource;
|
|
@@ -562,9 +523,7 @@ let AssetsController = (() => {
|
|
|
562
523
|
captureException,
|
|
563
524
|
}));
|
|
564
525
|
}
|
|
565
|
-
this.#
|
|
566
|
-
this.#subscribeToBasicFunctionalityChange =
|
|
567
|
-
subscribeToBasicFunctionalityChange;
|
|
526
|
+
this.#initializeNativeAssetsMap(queryApiClient);
|
|
568
527
|
this.#onActiveChainsUpdated = (dataSourceName, chains, previousChains) => {
|
|
569
528
|
try {
|
|
570
529
|
this.#handleActiveChainsUpdate(dataSourceName, chains, previousChains);
|
|
@@ -649,23 +608,24 @@ let AssetsController = (() => {
|
|
|
649
608
|
log('Initializing AssetsController', {
|
|
650
609
|
defaultUpdateInterval: this.#defaultUpdateInterval,
|
|
651
610
|
});
|
|
652
|
-
|
|
653
|
-
// handlers. It never calls other controllers, so it does not depend on
|
|
654
|
-
// the order in which the wallet constructs them. Everything that reads
|
|
655
|
-
// other controllers or makes requests happens in `#bootstrap()`, the first
|
|
656
|
-
// time the UI opens.
|
|
611
|
+
this.#initializeState();
|
|
657
612
|
this.#subscribeToEvents();
|
|
658
613
|
this.#registerActionHandlers();
|
|
614
|
+
// Subscriptions start only when both UI is open and keyring unlocked -> #updateActive().
|
|
615
|
+
// Subscribe to basic-functionality changes after construction so a synchronous
|
|
616
|
+
// onChange during subscribe cannot run before data sources are initialized.
|
|
617
|
+
if (subscribeToBasicFunctionalityChange) {
|
|
618
|
+
const unsubscribe = subscribeToBasicFunctionalityChange((isBasic) => this.handleBasicFunctionalityChange(isBasic));
|
|
619
|
+
if (typeof unsubscribe === 'function') {
|
|
620
|
+
this.#unsubscribeBasicFunctionality = unsubscribe;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
659
623
|
}
|
|
660
624
|
// ============================================================================
|
|
661
625
|
// INITIALIZATION
|
|
662
626
|
// ============================================================================
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
* written by {@link AssetsController.#seedNativeAssetsMap}.
|
|
666
|
-
*/
|
|
667
|
-
#fetchNativeAssetsMap() {
|
|
668
|
-
this.#queryApiClient.queryClient
|
|
627
|
+
#initializeNativeAssetsMap(queryApiClient) {
|
|
628
|
+
queryApiClient.queryClient
|
|
669
629
|
.fetchQuery({
|
|
670
630
|
queryKey: NATIVE_ASSETS_QUERY_KEY,
|
|
671
631
|
queryFn: buildNativeAssetsFromApi,
|
|
@@ -677,13 +637,6 @@ let AssetsController = (() => {
|
|
|
677
637
|
// #isNativeAsset falls back to the seed data from buildNativeAssetsFromConstant.
|
|
678
638
|
log('Failed to populate native asset cache, falling back to seed data', error);
|
|
679
639
|
});
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Seed the native asset map in the query cache from constants.
|
|
683
|
-
*
|
|
684
|
-
* @param queryApiClient - The API client whose cache to seed.
|
|
685
|
-
*/
|
|
686
|
-
#seedNativeAssetsMap(queryApiClient) {
|
|
687
640
|
// Seed the cache synchronously so that synchronous consumers (e.g.
|
|
688
641
|
// #isNativeAsset, #resolveNativeAssetIds) have data available immediately.
|
|
689
642
|
// When fetchQuery resolves (currently instant, future: API), it overwrites
|
|
@@ -691,76 +644,12 @@ let AssetsController = (() => {
|
|
|
691
644
|
const initialNativeAssetMap = buildNativeAssetsFromConstant();
|
|
692
645
|
queryApiClient.setCachedData(NATIVE_ASSETS_QUERY_KEY, initialNativeAssetMap);
|
|
693
646
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
* which time the wallet has constructed every controller. Only the first
|
|
701
|
-
* call does the work; later calls return the same promise.
|
|
702
|
-
*
|
|
703
|
-
* @returns A promise that resolves once bootstrapping has finished.
|
|
704
|
-
*/
|
|
705
|
-
async #bootstrap() {
|
|
706
|
-
this.#bootstrapPromise ??= this.#runBootstrap();
|
|
707
|
-
return this.#bootstrapPromise;
|
|
708
|
-
}
|
|
709
|
-
async #runBootstrap() {
|
|
710
|
-
log('Bootstrapping AssetsController');
|
|
711
|
-
this.#readEnabledChains();
|
|
712
|
-
this.#fetchNativeAssetsMap();
|
|
713
|
-
// Data sources report their active chains through `#onActiveChainsUpdated`
|
|
714
|
-
// while bootstrapping. Those reports are ignored until `#isBootstrapped`
|
|
715
|
-
// is set; `#updateActive()` below subscribes with the final chains.
|
|
716
|
-
await Promise.allSettled([...this.#allBalanceDataSources, this.#stakedBalanceDataSource].map(async (source) => source.bootstrap()));
|
|
717
|
-
if (this.#isDestroyed) {
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
this.#isBootstrapped = true;
|
|
721
|
-
if (this.#subscribeToBasicFunctionalityChange) {
|
|
722
|
-
const unsubscribe = this.#subscribeToBasicFunctionalityChange((isBasic) => this.handleBasicFunctionalityChange(isBasic));
|
|
723
|
-
if (typeof unsubscribe === 'function') {
|
|
724
|
-
this.#unsubscribeBasicFunctionality = unsubscribe;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
// `KeyringController:unlock` handlers skip their work before bootstrap,
|
|
728
|
-
// so run it now if the wallet was unlocked before the UI opened.
|
|
729
|
-
if (this.#isKeyringUnlocked()) {
|
|
730
|
-
await this.#runUnlockCleanups();
|
|
731
|
-
}
|
|
732
|
-
this.#updateActive();
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* Read enabled chains from NetworkEnablementController.
|
|
736
|
-
*
|
|
737
|
-
* `NetworkEnablementController:stateChange` keeps `#enabledChains` current,
|
|
738
|
-
* but it is only published when the state changes. If the controller
|
|
739
|
-
* restored persisted state and nothing has changed since, this read is the
|
|
740
|
-
* only way to learn which chains are enabled. If the controller is not
|
|
741
|
-
* registered, the chains received from events are kept.
|
|
742
|
-
*/
|
|
743
|
-
#readEnabledChains() {
|
|
744
|
-
const enabledNetworkMap = this.#callIfRegistered(() => this.messenger.call('NetworkEnablementController:getState')
|
|
745
|
-
.enabledNetworkMap, undefined);
|
|
746
|
-
if (enabledNetworkMap) {
|
|
747
|
-
this.#enabledChains = this.#extractEnabledChains(enabledNetworkMap);
|
|
748
|
-
}
|
|
749
|
-
log('Read enabled chains', { enabledChains: this.#enabledChains });
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Remove balances outside the current scope and spam tokens. Runs on
|
|
753
|
-
* unlock, and at bootstrap when the wallet was already unlocked.
|
|
754
|
-
*/
|
|
755
|
-
async #runUnlockCleanups() {
|
|
756
|
-
try {
|
|
757
|
-
this.#runOutOfScopeBalanceCleanup();
|
|
758
|
-
}
|
|
759
|
-
catch {
|
|
760
|
-
/* Do nothing */
|
|
761
|
-
}
|
|
762
|
-
await this.#runSpamCleanup().catch(() => {
|
|
763
|
-
/* Do nothing */
|
|
647
|
+
#initializeState() {
|
|
648
|
+
const { enabledNetworkMap } = this.messenger.call('NetworkEnablementController:getState');
|
|
649
|
+
this.#enabledChains = this.#extractEnabledChains(enabledNetworkMap);
|
|
650
|
+
log('Initialized state', {
|
|
651
|
+
enabledNetworkMap,
|
|
652
|
+
enabledChains: this.#enabledChains,
|
|
764
653
|
});
|
|
765
654
|
}
|
|
766
655
|
/**
|
|
@@ -820,11 +709,6 @@ let AssetsController = (() => {
|
|
|
820
709
|
});
|
|
821
710
|
// Subscribe to network enablement changes (only enabledNetworkMap)
|
|
822
711
|
this.messenger.subscribe('NetworkEnablementController:stateChange', ({ enabledNetworkMap }) => {
|
|
823
|
-
if (!this.#isBootstrapped) {
|
|
824
|
-
// Only record the chains; `#bootstrap()` starts fetching.
|
|
825
|
-
this.#enabledChains = this.#extractEnabledChains(enabledNetworkMap);
|
|
826
|
-
return;
|
|
827
|
-
}
|
|
828
712
|
this.#handleEnabledNetworksChanged(enabledNetworkMap).catch(console.error);
|
|
829
713
|
});
|
|
830
714
|
// When a network is added or removed from NetworkController, refresh
|
|
@@ -834,50 +718,34 @@ let AssetsController = (() => {
|
|
|
834
718
|
// entries appear immediately without waiting for it to also be
|
|
835
719
|
// enabled in NetworkEnablementController.
|
|
836
720
|
this.messenger.subscribe('NetworkController:networkAdded', (networkConfiguration) => {
|
|
837
|
-
// Seeding default tracked assets only updates state, so it runs even
|
|
838
|
-
// before bootstrap; the refresh fetches, so it waits for bootstrap.
|
|
839
721
|
this.#handleNetworkAdded(networkConfiguration.chainId);
|
|
840
|
-
if (!this.#isBootstrapped) {
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
722
|
this.#refreshAssetsAfterNetworkAdded(networkConfiguration.chainId).catch((error) => {
|
|
844
723
|
log('Failed to refresh assets after network added', { error });
|
|
845
724
|
});
|
|
846
725
|
});
|
|
847
726
|
this.messenger.subscribe('NetworkController:networkRemoved', () => {
|
|
848
|
-
if (!this.#isBootstrapped) {
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
727
|
this.#refreshAssetsAfterNetworkChange();
|
|
852
728
|
});
|
|
853
729
|
// Selected EVM network switch (network picker). Enablement changes are
|
|
854
730
|
// handled separately via NetworkEnablementController:stateChange.
|
|
855
731
|
this.messenger.subscribe('NetworkController:networkDidChange', (networkState) => {
|
|
856
|
-
if (!this.#isBootstrapped) {
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
859
732
|
this.#handleNetworkDidChange(networkState).catch(console.error);
|
|
860
733
|
});
|
|
861
|
-
// Client + Keyring lifecycle:
|
|
862
|
-
|
|
863
|
-
this.messenger.subscribe('ClientController:stateChange', (isUiOpen) => {
|
|
864
|
-
if (!this.#isBootstrapped) {
|
|
865
|
-
if (isUiOpen) {
|
|
866
|
-
this.#bootstrap().catch((error) => {
|
|
867
|
-
log('Failed to bootstrap AssetsController', error);
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
734
|
+
// Client + Keyring lifecycle: only run when UI is open AND keyring is unlocked
|
|
735
|
+
this.messenger.subscribe('ClientController:stateChange', () => {
|
|
872
736
|
this.#updateActive();
|
|
873
737
|
}, clientControllerSelectors.selectIsUiOpen);
|
|
874
738
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
875
739
|
this.messenger.subscribe('KeyringController:unlock', async () => {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
740
|
+
try {
|
|
741
|
+
this.#runOutOfScopeBalanceCleanup();
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
/* Do nothing */
|
|
879
745
|
}
|
|
880
|
-
await this.#
|
|
746
|
+
await this.#runSpamCleanup().catch(() => {
|
|
747
|
+
/* Do nothing */
|
|
748
|
+
});
|
|
881
749
|
this.#updateActive();
|
|
882
750
|
});
|
|
883
751
|
this.messenger.subscribe('KeyringController:lock', () => {
|
|
@@ -887,9 +755,6 @@ let AssetsController = (() => {
|
|
|
887
755
|
// Ensures balances for the account making the transaction are updated
|
|
888
756
|
// (e.g. for gas estimations), except on AccountActivity-active chains.
|
|
889
757
|
this.messenger.subscribe('TransactionController:unapprovedTransactionAdded', (transactionMeta) => {
|
|
890
|
-
if (!this.#isBootstrapped) {
|
|
891
|
-
return;
|
|
892
|
-
}
|
|
893
758
|
this.#refreshAssetsForEVMTransaction(transactionMeta);
|
|
894
759
|
});
|
|
895
760
|
// Post-tx refresh via the full fetch pipeline (Accounts API + RPC fallback).
|
|
@@ -897,9 +762,6 @@ let AssetsController = (() => {
|
|
|
897
762
|
// RpcDataSource also listens for transactionConfirmed, but only refreshes
|
|
898
763
|
// chains it owns via an active subscription.
|
|
899
764
|
this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
|
|
900
|
-
if (!this.#isBootstrapped) {
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
765
|
this.#refreshAssetsForEVMTransaction(transactionMeta);
|
|
904
766
|
});
|
|
905
767
|
// Non-EVM equivalent of the above: Snap keyrings report transaction
|
|
@@ -907,9 +769,6 @@ let AssetsController = (() => {
|
|
|
907
769
|
// not covered by AccountActivity (WebSocket down / unsupported), refresh
|
|
908
770
|
// via the Accounts API with the server cache bypassed.
|
|
909
771
|
this.messenger.subscribe('MultichainTransactionsController:transactionConfirmed', (transaction) => {
|
|
910
|
-
if (!this.#isBootstrapped) {
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
772
|
this.#refreshAssetsForNonEvmTransaction(transaction);
|
|
914
773
|
});
|
|
915
774
|
}
|
|
@@ -1037,9 +896,6 @@ let AssetsController = (() => {
|
|
|
1037
896
|
* the keyring is unlocked, and the account tree has finished `init()`.
|
|
1038
897
|
*/
|
|
1039
898
|
#updateActive() {
|
|
1040
|
-
if (!this.#isBootstrapped) {
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
899
|
const shouldRun = this.#isUiOpen() &&
|
|
1044
900
|
this.#isKeyringUnlocked() &&
|
|
1045
901
|
this.#isAccountTreeInitialized();
|
|
@@ -1099,10 +955,7 @@ let AssetsController = (() => {
|
|
|
1099
955
|
* @param previousChains - Previous chains; used to compute added/removed.
|
|
1100
956
|
*/
|
|
1101
957
|
#handleActiveChainsUpdate(dataSourceId, activeChains, previousChains) {
|
|
1102
|
-
if (!this.#
|
|
1103
|
-
!this.#isUiOpen() ||
|
|
1104
|
-
!this.#isKeyringUnlocked() ||
|
|
1105
|
-
!this.#isEnabled()) {
|
|
958
|
+
if (!this.#isUiOpen() || !this.#isKeyringUnlocked() || !this.#isEnabled()) {
|
|
1106
959
|
return;
|
|
1107
960
|
}
|
|
1108
961
|
log('Data source active chains changed', {
|
|
@@ -2566,9 +2419,6 @@ let AssetsController = (() => {
|
|
|
2566
2419
|
* @param _isBasic - The new value (for call-site clarity; the getter is the source of truth).
|
|
2567
2420
|
*/
|
|
2568
2421
|
handleBasicFunctionalityChange(_isBasic) {
|
|
2569
|
-
if (!this.#isBootstrapped) {
|
|
2570
|
-
return;
|
|
2571
|
-
}
|
|
2572
2422
|
this.#stop();
|
|
2573
2423
|
this.#subscribeAssets();
|
|
2574
2424
|
}
|
|
@@ -3286,7 +3136,6 @@ let AssetsController = (() => {
|
|
|
3286
3136
|
// CLEANUP
|
|
3287
3137
|
// ============================================================================
|
|
3288
3138
|
destroy() {
|
|
3289
|
-
this.#isDestroyed = true;
|
|
3290
3139
|
log('Destroying AssetsController', {
|
|
3291
3140
|
dataSourceCount: this.#allBalanceDataSources.length,
|
|
3292
3141
|
subscriptionCount: this.#activeSubscriptions.size,
|