@metamask-previews/assets-controller 17.0.0-preview-0f8c056e2 → 18.0.0-preview-c2be02bd4
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 +23 -1
- package/dist/AssetsController.d.ts +2 -1
- package/dist/AssetsController.d.ts.map +1 -1
- package/dist/AssetsController.js +72 -15
- package/dist/AssetsController.js.map +1 -1
- package/dist/data-sources/PriceDataSource.d.ts.map +1 -1
- package/dist/data-sources/PriceDataSource.js +28 -3
- package/dist/data-sources/PriceDataSource.js.map +1 -1
- package/dist/migrations/dropBalancesOutsideAccountScopes.d.ts +19 -0
- package/dist/migrations/dropBalancesOutsideAccountScopes.d.ts.map +1 -0
- package/dist/migrations/dropBalancesOutsideAccountScopes.js +66 -0
- package/dist/migrations/dropBalancesOutsideAccountScopes.js.map +1 -0
- package/package.json +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -9,8 +9,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
+
- Bump `@metamask/transaction-controller` from `^72.0.1` to `^72.1.0` ([#10652](https://github.com/MetaMask/core/pull/10652))
|
|
13
|
+
|
|
14
|
+
## [18.0.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **BREAKING:** `AssetsControllerMessenger` now requires the `MultichainTransactionsControllerTransactionConfirmedEvent` allowed event ([#10585](https://github.com/MetaMask/core/pull/10585))
|
|
19
|
+
- `AssetsController` subscribes to `MultichainTransactionsController:transactionConfirmed` so non-EVM (Snap keyring) transactions trigger the same post-transaction balance refresh as EVM `TransactionController:transactionConfirmed`.
|
|
20
|
+
- Consumers must delegate `MultichainTransactionsController:transactionConfirmed` onto the Assets controller messenger. Without that delegation the subscription is registered and never fires.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
12
24
|
- Bump `lodash-es` from `^4.17.21` to `^4.18.1` ([#10447](https://github.com/MetaMask/core/pull/10447))
|
|
13
25
|
- Bump `@ethersproject/providers` from `^5.7.0` to `^5.8.0` ([#10482](https://github.com/MetaMask/core/pull/10482))
|
|
26
|
+
- Bump `@metamask/assets-controllers` from `^112.0.4` to `^112.1.1` ([#10633](https://github.com/MetaMask/core/pull/10633), [#10648](https://github.com/MetaMask/core/pull/10648))
|
|
27
|
+
- Bump `@metamask/phishing-controller` from `^18.1.1` to `^18.2.0` ([#10633](https://github.com/MetaMask/core/pull/10633))
|
|
28
|
+
- Bump `@metamask/core-backend` from `^11.0.0` to `^12.0.0` ([#10648](https://github.com/MetaMask/core/pull/10648))
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Fix `PriceDataSource` supported-network filtering so it reads the object-shaped `partialSupport` returned by the Price API `/v2/supportedNetworks` endpoint ([#10582](https://github.com/MetaMask/core/pull/10582))
|
|
33
|
+
- On the v5 balance path, stop seeding every enabled chain's native onto an account when the update arrives after that account is no longer selected ([#10567](https://github.com/MetaMask/core/pull/10567))
|
|
34
|
+
- On unlock, drop stored balances whose chain namespace is outside the selected account's scopes ([#10567](https://github.com/MetaMask/core/pull/10567))
|
|
14
35
|
|
|
15
36
|
## [17.0.0]
|
|
16
37
|
|
|
@@ -1109,7 +1130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1109
1130
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
1110
1131
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
1111
1132
|
|
|
1112
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@
|
|
1133
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@18.0.0...HEAD
|
|
1134
|
+
[18.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@17.0.0...@metamask/assets-controller@18.0.0
|
|
1113
1135
|
[17.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@16.1.2...@metamask/assets-controller@17.0.0
|
|
1114
1136
|
[16.1.2]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@16.1.1...@metamask/assets-controller@16.1.2
|
|
1115
1137
|
[16.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@16.1.0...@metamask/assets-controller@16.1.1
|
|
@@ -9,6 +9,7 @@ import type { ApiPlatformClient, AccountActivityServiceBalanceUpdatedEvent, Acco
|
|
|
9
9
|
import type { KeyringControllerIsUnlockedAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent } from '@metamask/keyring-controller';
|
|
10
10
|
import type { InternalAccount } from '@metamask/keyring-internal-api';
|
|
11
11
|
import type { Messenger } from '@metamask/messenger';
|
|
12
|
+
import type { MultichainTransactionsControllerTransactionConfirmedEvent } from '@metamask/multichain-transactions-controller';
|
|
12
13
|
import type { NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetStateAction, NetworkControllerNetworkAddedEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerNetworkRemovedEvent, NetworkControllerStateChangeEvent } from '@metamask/network-controller';
|
|
13
14
|
import type { NetworkEnablementControllerGetStateAction, NetworkEnablementControllerEvents } from '@metamask/network-enablement-controller';
|
|
14
15
|
import type { GetPermissions, PermissionControllerStateChange } from '@metamask/permission-controller';
|
|
@@ -80,7 +81,7 @@ export type AssetsControllerAssetsDetectedEvent = {
|
|
|
80
81
|
};
|
|
81
82
|
export type AssetsControllerEvents = AssetsControllerStateChangeEvent | AssetsControllerBalanceChangedEvent | AssetsControllerPriceChangedEvent | AssetsControllerAssetsDetectedEvent;
|
|
82
83
|
type AllowedActions = AccountsControllerGetSelectedAccountAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AccountTreeControllerIsInitializedAction | ClientControllerGetStateAction | KeyringControllerIsUnlockedAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | ConfigRegistryControllerGetNetworkConfigByCaip2ChainIdAction | NetworkEnablementControllerGetStateAction | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | PhishingControllerBulkScanTokensAction | RemoteFeatureFlagControllerGetStateAction;
|
|
83
|
-
type AllowedEvents = AccountTreeControllerSelectedAccountGroupChangeEvent | AccountTreeControllerInitializedEvent | AccountTreeControllerUninitializedEvent | ClientControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | PreferencesControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionConfirmedEvent | NetworkControllerStateChangeEvent | NetworkControllerNetworkAddedEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerNetworkRemovedEvent | NetworkEnablementControllerEvents | AccountsControllerAccountBalancesUpdatedEvent | PermissionControllerStateChange | SnapControllerSnapInstalledEvent | AccountActivityServiceBalanceUpdatedEvent | AccountActivityServiceStatusChangedEvent | RemoteFeatureFlagControllerStateChangeEvent;
|
|
84
|
+
type AllowedEvents = AccountTreeControllerSelectedAccountGroupChangeEvent | AccountTreeControllerInitializedEvent | AccountTreeControllerUninitializedEvent | ClientControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | PreferencesControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionConfirmedEvent | MultichainTransactionsControllerTransactionConfirmedEvent | NetworkControllerStateChangeEvent | NetworkControllerNetworkAddedEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerNetworkRemovedEvent | NetworkEnablementControllerEvents | AccountsControllerAccountBalancesUpdatedEvent | PermissionControllerStateChange | SnapControllerSnapInstalledEvent | AccountActivityServiceBalanceUpdatedEvent | AccountActivityServiceStatusChangedEvent | RemoteFeatureFlagControllerStateChangeEvent;
|
|
84
85
|
export type AssetsControllerMessenger = Messenger<typeof CONTROLLER_NAME, AssetsControllerActions | AllowedActions, AssetsControllerEvents | AllowedEvents>;
|
|
85
86
|
export type AssetsControllerOptions = {
|
|
86
87
|
messenger: AssetsControllerMessenger;
|
|
@@ -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;
|
|
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,8B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AS,EAAE,SAAS,GAAG,aAAa,EAAE,CAErD;IAMD;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CActC;IAED;;;;;;;OAOG;IACG,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BvD;IA0BD;;;;OAIG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAgC7D;IA+DD;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAkC3E;IAED;;OAEG;IACH,sBAAsB,IAAI,IAAI,CAS7B;IA+4BD;;;;;;;OAOG;IACH,8BAA8B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGtD;IAwqBD;;;;;;;;;OASG;IACG,kBAAkB,CACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CAYf;IA0MD,OAAO,IAAI,IAAI,CAmDd;CACF"}
|
package/dist/AssetsController.js
CHANGED
|
@@ -19,6 +19,7 @@ import { CustomAssetGraduationMiddleware } from './middlewares/CustomAssetGradua
|
|
|
19
19
|
import { DetectionMiddleware } from './middlewares/DetectionMiddleware.js';
|
|
20
20
|
import { createParallelBalanceMiddleware, createParallelMiddleware, } from './middlewares/ParallelMiddleware.js';
|
|
21
21
|
import { RpcFallbackMiddleware } from './middlewares/RpcFallbackMiddleware.js';
|
|
22
|
+
import { dropBalancesOutsideAccountScopes } from './migrations/dropBalancesOutsideAccountScopes.js';
|
|
22
23
|
import { cleanSpamAssets, isUnlockCleanupEnabled, tempHealAssetsInfoMetadata, } from './migrations/healAssetsInfoMetadata.js';
|
|
23
24
|
import { buildFastFetchSources, buildUpdateSources, buildWsUpdateSources, executeAssetsPipeline, } from './pipeline/index.js';
|
|
24
25
|
import { getAssetVisibility } from './utils/assetVisibility.js';
|
|
@@ -700,6 +701,12 @@ export class AssetsController extends BaseController {
|
|
|
700
701
|
}, clientControllerSelectors.selectIsUiOpen);
|
|
701
702
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
702
703
|
this.messenger.subscribe('KeyringController:unlock', async () => {
|
|
704
|
+
try {
|
|
705
|
+
this.#runOutOfScopeBalanceCleanup();
|
|
706
|
+
}
|
|
707
|
+
catch {
|
|
708
|
+
/* Do nothing */
|
|
709
|
+
}
|
|
703
710
|
await this.#runSpamCleanup().catch(() => {
|
|
704
711
|
/* Do nothing */
|
|
705
712
|
});
|
|
@@ -712,42 +719,77 @@ export class AssetsController extends BaseController {
|
|
|
712
719
|
// Ensures balances for the account making the transaction are updated
|
|
713
720
|
// (e.g. for gas estimations), except on AccountActivity-active chains.
|
|
714
721
|
this.messenger.subscribe('TransactionController:unapprovedTransactionAdded', (transactionMeta) => {
|
|
715
|
-
this.#
|
|
722
|
+
this.#refreshAssetsForEVMTransaction(transactionMeta);
|
|
716
723
|
});
|
|
717
724
|
// Post-tx refresh via the full fetch pipeline (Accounts API + RPC fallback).
|
|
718
725
|
// Skipped for chains covered by AccountActivity (real-time WS updates).
|
|
719
726
|
// RpcDataSource also listens for transactionConfirmed, but only refreshes
|
|
720
727
|
// chains it owns via an active subscription.
|
|
721
728
|
this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
|
|
722
|
-
this.#
|
|
729
|
+
this.#refreshAssetsForEVMTransaction(transactionMeta);
|
|
730
|
+
});
|
|
731
|
+
// Non-EVM equivalent of the above: Snap keyrings report transaction
|
|
732
|
+
// lifecycle through MultichainTransactionsController. When the chain is
|
|
733
|
+
// not covered by AccountActivity (WebSocket down / unsupported), refresh
|
|
734
|
+
// via the Accounts API with the server cache bypassed.
|
|
735
|
+
this.messenger.subscribe('MultichainTransactionsController:transactionConfirmed', (transaction) => {
|
|
736
|
+
this.#refreshAssetsForNonEvmTransaction(transaction);
|
|
723
737
|
});
|
|
724
738
|
}
|
|
725
739
|
/**
|
|
726
|
-
* Force-refresh assets for the account/chain of
|
|
727
|
-
* chain is already covered by AccountActivity (real-time WebSocket
|
|
728
|
-
* Always bypasses the Accounts API's server-side cache so a
|
|
729
|
-
* be answered with a stale pre-transaction snapshot.
|
|
740
|
+
* Force-refresh assets for the account/chain of an EVM transaction, unless
|
|
741
|
+
* the chain is already covered by AccountActivity (real-time WebSocket
|
|
742
|
+
* balances). Always bypasses the Accounts API's server-side cache so a
|
|
743
|
+
* refresh cannot be answered with a stale pre-transaction snapshot.
|
|
730
744
|
*
|
|
731
745
|
* @param transactionMeta - The transaction that triggered the refresh.
|
|
732
746
|
*/
|
|
733
|
-
#
|
|
747
|
+
#refreshAssetsForEVMTransaction(transactionMeta) {
|
|
734
748
|
const hexChainId = transactionMeta.chainId;
|
|
735
749
|
if (!hexChainId) {
|
|
736
750
|
return;
|
|
737
751
|
}
|
|
738
752
|
const caipChainId = `eip155:${parseInt(hexChainId, 16)}`;
|
|
739
|
-
|
|
740
|
-
|
|
753
|
+
const fromAddress = transactionMeta.txParams.from?.toLowerCase();
|
|
754
|
+
if (!fromAddress) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
this.#refreshAssetsAfterConfirmed(caipChainId, (account) => account.address.toLowerCase() === fromAddress);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Non-EVM counterpart of `#refreshAssetsForEVMTransaction` for transactions
|
|
761
|
+
* reported by Snap keyrings via
|
|
762
|
+
* `MultichainTransactionsController`. The keyring `Transaction` already
|
|
763
|
+
* carries a CAIP-2 `chain` and the internal `account` id, so no address
|
|
764
|
+
* normalisation is needed.
|
|
765
|
+
*
|
|
766
|
+
* @param transaction - The confirmed keyring transaction.
|
|
767
|
+
*/
|
|
768
|
+
#refreshAssetsForNonEvmTransaction(transaction) {
|
|
769
|
+
const { chain, account: accountId } = transaction;
|
|
770
|
+
if (!chain || !accountId || !isCaipChainId(chain)) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
this.#refreshAssetsAfterConfirmed(chain, (account) => account.id === accountId);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Shared post-transaction refresh: skip when AccountActivity already pushes
|
|
777
|
+
* live balances for `caipChainId` (a force fetch would be redundant and can
|
|
778
|
+
* race the WebSocket path); otherwise run a force `getAssets` for the first
|
|
779
|
+
* selected account matching `matchAccount`, bypassing the Accounts API's
|
|
780
|
+
* server-side cache.
|
|
781
|
+
*
|
|
782
|
+
* @param caipChainId - CAIP-2 chain the transaction was on.
|
|
783
|
+
* @param matchAccount - Predicate selecting the originating account among
|
|
784
|
+
* the currently selected accounts.
|
|
785
|
+
*/
|
|
786
|
+
#refreshAssetsAfterConfirmed(caipChainId, matchAccount) {
|
|
741
787
|
if (this.#accountActivityDataSource
|
|
742
788
|
.getActiveChainsSync()
|
|
743
789
|
.includes(caipChainId)) {
|
|
744
790
|
return;
|
|
745
791
|
}
|
|
746
|
-
const
|
|
747
|
-
if (!fromAddress) {
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
const matchedAccount = this.#getSelectedAccounts().find((account) => account.address.toLowerCase() === fromAddress);
|
|
792
|
+
const matchedAccount = this.#getSelectedAccounts().find(matchAccount);
|
|
751
793
|
if (!matchedAccount) {
|
|
752
794
|
return;
|
|
753
795
|
}
|
|
@@ -759,6 +801,21 @@ export class AssetsController extends BaseController {
|
|
|
759
801
|
log('Failed to refresh assets after transaction event', { error });
|
|
760
802
|
});
|
|
761
803
|
}
|
|
804
|
+
/**
|
|
805
|
+
* One-time cleanup of balances a v5 update stamped onto accounts after a
|
|
806
|
+
* group switch. Runs on unlock, the same point as spam cleanup, and only
|
|
807
|
+
* touches the selected accounts (their scopes are what define ownership).
|
|
808
|
+
*/
|
|
809
|
+
#runOutOfScopeBalanceCleanup() {
|
|
810
|
+
const accounts = this.#getSelectedAccounts();
|
|
811
|
+
if (accounts.length === 0) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
this.update((state) => {
|
|
815
|
+
const balances = state.assetsBalance;
|
|
816
|
+
dropBalancesOutsideAccountScopes(balances, accounts);
|
|
817
|
+
});
|
|
818
|
+
}
|
|
762
819
|
async #runSpamCleanup() {
|
|
763
820
|
try {
|
|
764
821
|
const shouldRun = this.#isKeyringUnlocked() &&
|
|
@@ -2017,7 +2074,7 @@ export class AssetsController extends BaseController {
|
|
|
2017
2074
|
const account = this.#getSelectedAccounts().find((a) => a.id === accountId);
|
|
2018
2075
|
const nativeAssetIdsForAccount = account
|
|
2019
2076
|
? this.#getNativeAssetIdsForAccount(account)
|
|
2020
|
-
:
|
|
2077
|
+
: [];
|
|
2021
2078
|
for (const nativeAssetId of nativeAssetIdsForAccount) {
|
|
2022
2079
|
if (!Object.prototype.hasOwnProperty.call(effectiveAccountBalances, nativeAssetId)) {
|
|
2023
2080
|
effectiveAccountBalances[nativeAssetId] =
|