@metamask-previews/assets-controller 19.1.0-preview-5990812f2 → 19.1.0-preview-7fb08ad32
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 -20
- package/dist/AssetsController-method-action-types.d.ts +1 -18
- package/dist/AssetsController-method-action-types.d.ts.map +1 -1
- package/dist/AssetsController-method-action-types.js.map +1 -1
- package/dist/AssetsController.d.ts +10 -15
- package/dist/AssetsController.d.ts.map +1 -1
- package/dist/AssetsController.js +135 -77
- package/dist/AssetsController.js.map +1 -1
- package/dist/data-sources/PriceDataSource.d.ts +17 -22
- package/dist/data-sources/PriceDataSource.d.ts.map +1 -1
- package/dist/data-sources/PriceDataSource.js +123 -60
- package/dist/data-sources/PriceDataSource.js.map +1 -1
- package/dist/data-sources/RpcDataSource.d.ts.map +1 -1
- package/dist/data-sources/RpcDataSource.js +6 -0
- package/dist/data-sources/RpcDataSource.js.map +1 -1
- package/dist/data-sources/TokenDataSource.d.ts +19 -19
- package/dist/data-sources/TokenDataSource.d.ts.map +1 -1
- package/dist/data-sources/TokenDataSource.js +87 -32
- package/dist/data-sources/TokenDataSource.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/middlewares/DetectionMiddleware.d.ts +48 -0
- package/dist/middlewares/DetectionMiddleware.d.ts.map +1 -0
- package/dist/middlewares/DetectionMiddleware.js +130 -0
- package/dist/middlewares/DetectionMiddleware.js.map +1 -0
- package/dist/middlewares/ParallelMiddleware.d.ts.map +1 -1
- package/dist/middlewares/ParallelMiddleware.js +6 -0
- package/dist/middlewares/ParallelMiddleware.js.map +1 -1
- package/dist/middlewares/index.d.ts +2 -0
- package/dist/middlewares/index.d.ts.map +1 -1
- package/dist/middlewares/index.js +1 -0
- package/dist/middlewares/index.js.map +1 -1
- package/dist/pipeline/buildFastFetchSources.d.ts +12 -9
- package/dist/pipeline/buildFastFetchSources.d.ts.map +1 -1
- package/dist/pipeline/buildFastFetchSources.js +13 -10
- package/dist/pipeline/buildFastFetchSources.js.map +1 -1
- package/dist/pipeline/buildUpdateSources.d.ts +1 -0
- package/dist/pipeline/buildUpdateSources.d.ts.map +1 -1
- package/dist/pipeline/buildUpdateSources.js +2 -1
- package/dist/pipeline/buildUpdateSources.js.map +1 -1
- package/dist/pipeline/buildWsUpdateSources.d.ts +1 -0
- package/dist/pipeline/buildWsUpdateSources.d.ts.map +1 -1
- package/dist/pipeline/buildWsUpdateSources.js +2 -1
- package/dist/pipeline/buildWsUpdateSources.js.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +21 -18
- package/dist/utils/getAssetIdsForMetadataFetch.d.ts +0 -36
- package/dist/utils/getAssetIdsForMetadataFetch.d.ts.map +0 -1
- package/dist/utils/getAssetIdsForMetadataFetch.js +0 -145
- package/dist/utils/getAssetIdsForMetadataFetch.js.map +0 -1
- package/dist/utils/getAssetIdsForPriceFetch.d.ts +0 -74
- package/dist/utils/getAssetIdsForPriceFetch.d.ts.map +0 -1
- package/dist/utils/getAssetIdsForPriceFetch.js +0 -224
- package/dist/utils/getAssetIdsForPriceFetch.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,26 +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 `syncAssetsPrices(assetIds)`, exposed as the `AssetsController:syncAssetsPrices` messenger action. It force-fetches spot prices for an explicit CAIP-19 asset list through `PriceDataSource` and merges them into state ([#10892](https://github.com/MetaMask/core/pull/10892))
|
|
13
|
-
- Add support for Node.js 26 ([#10981](https://github.com/MetaMask/core/pull/10981))
|
|
14
|
-
|
|
15
|
-
### Changed
|
|
16
|
-
|
|
17
|
-
- Fetch token metadata again when stored metadata is missing a field that controller logic or a client reads (`symbol`, `name`, `decimals`, `image`, `aggregators`, or `occurrences`), instead of treating an `image` as complete
|
|
18
|
-
- **BREAKING:** Remove `DetectionMiddleware`. A balance refresh prices balances on the current response only when they have no stored price, and excludes hidden assets. The price poll still refreshes stored prices for held balances and custom assets, and does not price metadata that has no balance. `TokenDataSource` fetches metadata for state balances that have none and for response balances, and excludes hidden assets ([#10892](https://github.com/MetaMask/core/pull/10892))
|
|
19
|
-
- **BREAKING:** Remove `assetsForPriceUpdate` from `getAssets` options. Refresh an explicit asset list with `syncAssetsPrices` instead ([#10892](https://github.com/MetaMask/core/pull/10892))
|
|
20
|
-
- Bump `@metamask/account-tree-controller` from `^11.0.1` to `^11.2.0` ([#10891](https://github.com/MetaMask/core/pull/10891), [#10925](https://github.com/MetaMask/core/pull/10925), [#11092](https://github.com/MetaMask/core/pull/11092))
|
|
21
|
-
- Bump `@metamask/assets-controllers` from `^112.1.2` to `^112.2.0` ([#10925](https://github.com/MetaMask/core/pull/10925), [#11092](https://github.com/MetaMask/core/pull/11092))
|
|
22
|
-
- Bump `@metamask/network-controller` from `^37.1.0` to `^37.1.1` ([#10982](https://github.com/MetaMask/core/pull/10982))
|
|
23
|
-
- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1` ([#11107](https://github.com/MetaMask/core/pull/11107))
|
|
24
|
-
|
|
25
|
-
### Removed
|
|
26
|
-
|
|
27
|
-
- **BREAKING:** Remove the `AssetsController:assetsDetected` event and the `AssetsControllerAssetsDetectedEvent` type. No client subscribed to it ([#10892](https://github.com/MetaMask/core/pull/10892))
|
|
28
|
-
- **BREAKING:** Remove `detectedAssets` from `DataResponse` and the unused `AssetsDetectedEvent` type. Newly detected tokens still arrive as balances and metadata ([#10892](https://github.com/MetaMask/core/pull/10892))
|
|
29
|
-
|
|
30
10
|
## [19.1.0]
|
|
31
11
|
|
|
32
12
|
### Changed
|
|
@@ -7,23 +7,6 @@ export type AssetsControllerGetAssetsAction = {
|
|
|
7
7
|
type: `AssetsController:getAssets`;
|
|
8
8
|
handler: AssetsController['getAssets'];
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Force-fetch spot prices for an explicit asset list.
|
|
12
|
-
*
|
|
13
|
-
* Calls `PriceDataSource` directly and merges the result into `assetsPrice`.
|
|
14
|
-
* Prices are shared across accounts, so this does not take an account or
|
|
15
|
-
* chain scope and does not run the balance pipeline.
|
|
16
|
-
*
|
|
17
|
-
* Returns without calling the Price API when basic functionality is off.
|
|
18
|
-
* That matches the asset pipeline, which drops the price source in RPC-only
|
|
19
|
-
* mode, and `setSelectedCurrency`, which skips its price refresh.
|
|
20
|
-
*
|
|
21
|
-
* @param assetIds - CAIP-19 asset IDs to sync.
|
|
22
|
-
*/
|
|
23
|
-
export type AssetsControllerSyncAssetsPricesAction = {
|
|
24
|
-
type: `AssetsController:syncAssetsPrices`;
|
|
25
|
-
handler: AssetsController['syncAssetsPrices'];
|
|
26
|
-
};
|
|
27
10
|
export type AssetsControllerGetAssetsBalanceAction = {
|
|
28
11
|
type: `AssetsController:getAssetsBalance`;
|
|
29
12
|
handler: AssetsController['getAssetsBalance'];
|
|
@@ -198,5 +181,5 @@ export type AssetsControllerSetSelectedCurrencyAction = {
|
|
|
198
181
|
/**
|
|
199
182
|
* Union of all AssetsController action types.
|
|
200
183
|
*/
|
|
201
|
-
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction |
|
|
184
|
+
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAccountAssetByIDAction | AssetsControllerGetAccountAssetsByIDsAction | AssetsControllerGetAccountAssetsByScopeAction | AssetsControllerGetAssetsPriceAction | AssetsControllerGetExchangeRatesForBridgeAction | AssetsControllerGetStateForTransactionPayAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction | AssetsControllerSetSelectedCurrencyAction;
|
|
202
185
|
//# sourceMappingURL=AssetsController-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsController-method-action-types.d.ts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.d.ts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CAC/C,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI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AgB,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,sCAAsC,GACtC,yCAAyC,GACzC,2CAA2C,GAC3C,6CAA6C,GAC7C,oCAAoC,GACpC,+CAA+C,GAC/C,+CAA+C,GAC/C,oCAAoC,GACpC,uCAAuC,GACvC,qCAAqC,GACrC,+BAA+B,GAC/B,iCAAiC,GACjC,yCAAyC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsController-method-action-types.js","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AssetsController } from './AssetsController.js';\n\nexport type AssetsControllerGetAssetsAction = {\n type: `AssetsController:getAssets`;\n handler: AssetsController['getAssets'];\n};\n\
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.js","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AssetsController } from './AssetsController.js';\n\nexport type AssetsControllerGetAssetsAction = {\n type: `AssetsController:getAssets`;\n handler: AssetsController['getAssets'];\n};\n\nexport type AssetsControllerGetAssetsBalanceAction = {\n type: `AssetsController:getAssetsBalance`;\n handler: AssetsController['getAssetsBalance'];\n};\n\nexport type AssetsControllerGetAssetMetadataAction = {\n type: `AssetsController:getAssetMetadata`;\n handler: AssetsController['getAssetMetadata'];\n};\n\n/**\n * Get a single combined asset (balance + metadata + price + computed\n * `fiatValue`) for an account directly from controller state.\n *\n * Reuses the same state-composition and filtering logic as `getAssets`\n * (balance and metadata are required, a missing price falls back to\n * `{ price: 0, lastUpdated: 0 }` with `fiatValue: 0`, and hidden or\n * otherwise filtered assets are excluded) so the returned shape never\n * drifts from `getAssets`. Reads from current state only and does not\n * trigger a data-source refresh.\n *\n * @param accountId - The account ID (`InternalAccount.id`, not an address).\n * @param assetId - The CAIP-19 asset ID including chain scope\n * (e.g. `eip155:1/erc20:0x...`).\n * @returns The combined `Asset`, or `undefined` when no complete\n * renderable asset (balance + metadata) exists for the account/asset pair.\n * @throws If `accountId` is empty or `assetId` is not a valid CAIP-19 asset ID.\n */\nexport type AssetsControllerGetAccountAssetByIDAction = {\n type: `AssetsController:getAccountAssetByID`;\n handler: AssetsController['getAccountAssetByID'];\n};\n\n/**\n * Get multiple combined assets (balance + metadata + price + computed\n * `fiatValue`) for an account directly from controller state.\n *\n * Applies the same state-composition and filtering rules as\n * `getAccountAssetByID` to each requested asset ID. Asset IDs that do not\n * resolve to a complete renderable asset (missing balance/metadata, hidden,\n * or otherwise filtered out) are omitted from the result. Reads from\n * current state only and does not trigger a data-source refresh.\n *\n * @param accountId - The account ID (`InternalAccount.id`, not an address).\n * @param assetIds - The CAIP-19 asset IDs including chain scope\n * (e.g. `eip155:1/erc20:0x...`).\n * @returns A record of combined `Asset`s keyed by normalized CAIP-19 asset\n * ID, containing only the requested assets that resolved.\n * @throws If `accountId` is empty or any `assetIds` entry is not a valid\n * CAIP-19 asset ID.\n */\nexport type AssetsControllerGetAccountAssetsByIDsAction = {\n type: `AssetsController:getAccountAssetsByIDs`;\n handler: AssetsController['getAccountAssetsByIDs'];\n};\n\n/**\n * Get all combined assets (balance + metadata + price + computed\n * `fiatValue`) an account holds on a given chain scope, directly from\n * controller state.\n *\n * Applies the same state-composition and filtering rules as\n * `getAccountAssetByID` (hidden or otherwise filtered assets are excluded).\n * Reads from current state only and does not trigger a data-source refresh.\n *\n * @param accountId - The account ID (`InternalAccount.id`, not an address).\n * @param scope - The CAIP-2 chain ID to filter by (e.g. `eip155:1`).\n * @returns A record of combined `Asset`s keyed by CAIP-19 asset ID,\n * containing only the account's assets on the given scope.\n * @throws If `accountId` is empty or `scope` is not a valid CAIP-2 chain ID.\n */\nexport type AssetsControllerGetAccountAssetsByScopeAction = {\n type: `AssetsController:getAccountAssetsByScope`;\n handler: AssetsController['getAccountAssetsByScope'];\n};\n\nexport type AssetsControllerGetAssetsPriceAction = {\n type: `AssetsController:getAssetsPrice`;\n handler: AssetsController['getAssetsPrice'];\n};\n\n/**\n * Returns exchange rates in the format expected by the bridge controller\n * (conversionRates, currencyRates, marketData, currentCurrency) so that\n * when useAssetsControllerForRates is true the bridge can use a single\n * action instead of MultichainAssetsRatesController, TokenRatesController,\n * and CurrencyRateController.\n *\n * @returns Bridge-compatible exchange rate state derived from assetsPrice and selectedCurrency.\n */\nexport type AssetsControllerGetExchangeRatesForBridgeAction = {\n type: `AssetsController:getExchangeRatesForBridge`;\n handler: AssetsController['getExchangeRatesForBridge'];\n};\n\n/**\n * Returns state in the legacy format expected by transaction-pay-controller\n * (TokenBalancesController, AccountTrackerController, TokensController,\n * TokenRatesController, CurrencyRateController shapes) so that when\n * useAssetsController is true the transaction-pay-controller can use a\n * single action instead of five separate getState calls.\n *\n * @returns Legacy-compatible state for transaction-pay-controller.\n */\nexport type AssetsControllerGetStateForTransactionPayAction = {\n type: `AssetsController:getStateForTransactionPay`;\n handler: AssetsController['getStateForTransactionPay'];\n};\n\n/**\n * Add a custom asset for an account.\n * Custom assets are included in subscription and fetch operations.\n * Adding a custom asset also unhides it if it was previously hidden,\n * and force-fetches that asset's chain (including every visible pin).\n *\n * When `pendingMetadata` is provided (e.g. from the extension's pending-tokens\n * flow), the token metadata is persisted immediately into `assetsInfo` so the\n * UI can render it without waiting for the next pipeline fetch.\n *\n * @param accountId - The account ID to add the custom asset for.\n * @param assetId - The CAIP-19 asset ID to add.\n * @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).\n */\nexport type AssetsControllerAddCustomAssetAction = {\n type: `AssetsController:addCustomAsset`;\n handler: AssetsController['addCustomAsset'];\n};\n\n/**\n * Remove a custom asset from an account.\n *\n * @param accountId - The account ID to remove the custom asset from.\n * @param assetId - The CAIP-19 asset ID to remove.\n */\nexport type AssetsControllerRemoveCustomAssetAction = {\n type: `AssetsController:removeCustomAsset`;\n handler: AssetsController['removeCustomAsset'];\n};\n\n/**\n * Get all custom assets for an account.\n *\n * @param accountId - The account ID to get custom assets for.\n * @returns Array of CAIP-19 asset IDs for the account's custom assets.\n */\nexport type AssetsControllerGetCustomAssetsAction = {\n type: `AssetsController:getCustomAssets`;\n handler: AssetsController['getCustomAssets'];\n};\n\n/**\n * Hide an asset globally.\n * Hidden assets are excluded from the asset list returned by getAssets.\n * The hidden state is stored in assetPreferences.\n *\n * @param assetId - The CAIP-19 asset ID to hide.\n */\nexport type AssetsControllerHideAssetAction = {\n type: `AssetsController:hideAsset`;\n handler: AssetsController['hideAsset'];\n};\n\n/**\n * Unhide an asset globally.\n * Force-fetches that asset's chain (including every visible pin) so a\n * `full` snapshot can restore the balance immediately, then re-evaluates\n * subscriptions so later polls stop excluding it.\n *\n * @param assetId - The CAIP-19 asset ID to unhide.\n */\nexport type AssetsControllerUnhideAssetAction = {\n type: `AssetsController:unhideAsset`;\n handler: AssetsController['unhideAsset'];\n};\n\n/**\n * Set the current currency.\n *\n * @param selectedCurrency - The ISO 4217 currency code to set.\n */\nexport type AssetsControllerSetSelectedCurrencyAction = {\n type: `AssetsController:setSelectedCurrency`;\n handler: AssetsController['setSelectedCurrency'];\n};\n\n/**\n * Union of all AssetsController action types.\n */\nexport type AssetsControllerMethodActions =\n | AssetsControllerGetAssetsAction\n | AssetsControllerGetAssetsBalanceAction\n | AssetsControllerGetAssetMetadataAction\n | AssetsControllerGetAccountAssetByIDAction\n | AssetsControllerGetAccountAssetsByIDsAction\n | AssetsControllerGetAccountAssetsByScopeAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
@@ -72,7 +72,14 @@ export type AssetsControllerPriceChangedEvent = {
|
|
|
72
72
|
prices: Record<Caip19AssetId, AssetPrice>;
|
|
73
73
|
}];
|
|
74
74
|
};
|
|
75
|
-
export type
|
|
75
|
+
export type AssetsControllerAssetsDetectedEvent = {
|
|
76
|
+
type: `${typeof CONTROLLER_NAME}:assetsDetected`;
|
|
77
|
+
payload: [{
|
|
78
|
+
accountId: AccountId;
|
|
79
|
+
assetIds: Caip19AssetId[];
|
|
80
|
+
}];
|
|
81
|
+
};
|
|
82
|
+
export type AssetsControllerEvents = AssetsControllerStateChangeEvent | AssetsControllerBalanceChangedEvent | AssetsControllerPriceChangedEvent | AssetsControllerAssetsDetectedEvent;
|
|
76
83
|
type AllowedActions = AccountsControllerGetSelectedAccountAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AccountTreeControllerIsInitializedAction | ClientControllerGetStateAction | KeyringControllerIsUnlockedAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | ConfigRegistryControllerGetNetworkConfigByCaip2ChainIdAction | NetworkEnablementControllerGetStateAction | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | PhishingControllerBulkScanTokensAction | RemoteFeatureFlagControllerGetStateAction;
|
|
77
84
|
type AllowedEvents = AccountTreeControllerSelectedAccountGroupChangeEvent | AccountTreeControllerInitializedEvent | AccountTreeControllerUninitializedEvent | ClientControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | PreferencesControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionConfirmedEvent | MultichainTransactionsControllerTransactionConfirmedEvent | NetworkControllerStateChangeEvent | NetworkControllerNetworkAddedEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerNetworkRemovedEvent | NetworkEnablementControllerEvents | AccountsControllerAccountBalancesUpdatedEvent | PermissionControllerStateChange | SnapControllerSnapInstalledEvent | AccountActivityServiceBalanceUpdatedEvent | AccountActivityServiceStatusChangedEvent | RemoteFeatureFlagControllerStateChangeEvent;
|
|
78
85
|
export type AssetsControllerMessenger = Messenger<typeof CONTROLLER_NAME, AssetsControllerActions | AllowedActions, AssetsControllerEvents | AllowedEvents>;
|
|
@@ -188,21 +195,9 @@ export declare class AssetsController extends BaseController<typeof CONTROLLER_N
|
|
|
188
195
|
*/
|
|
189
196
|
bypassServerCache?: boolean;
|
|
190
197
|
dataTypes?: DataType[];
|
|
198
|
+
/** Specific CAIP-19 asset IDs whose prices should be refreshed. */
|
|
199
|
+
assetsForPriceUpdate?: Caip19AssetId[];
|
|
191
200
|
}): Promise<Record<AccountId, Record<Caip19AssetId, Asset>>>;
|
|
192
|
-
/**
|
|
193
|
-
* Force-fetch spot prices for an explicit asset list.
|
|
194
|
-
*
|
|
195
|
-
* Calls `PriceDataSource` directly and merges the result into `assetsPrice`.
|
|
196
|
-
* Prices are shared across accounts, so this does not take an account or
|
|
197
|
-
* chain scope and does not run the balance pipeline.
|
|
198
|
-
*
|
|
199
|
-
* Returns without calling the Price API when basic functionality is off.
|
|
200
|
-
* That matches the asset pipeline, which drops the price source in RPC-only
|
|
201
|
-
* mode, and `setSelectedCurrency`, which skips its price refresh.
|
|
202
|
-
*
|
|
203
|
-
* @param assetIds - CAIP-19 asset IDs to sync.
|
|
204
|
-
*/
|
|
205
|
-
syncAssetsPrices(assetIds: Caip19AssetId[]): Promise<void>;
|
|
206
201
|
getAssetsBalance(accounts: InternalAccount[], options?: {
|
|
207
202
|
chainIds?: ChainId[];
|
|
208
203
|
assetTypes?: AssetType[];
|
|
@@ -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,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,yDAAyD,EAAE,MAAM,8CAA8C,CAAC;AAC9H,OAAO,KAAK,EACV,2CAA2C,EAC3C,+BAA+B,EAC/B,kCAAkC,EAClC,sCAAsC,EACtC,oCAAoC,EAEpC,iCAAiC,EAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,yCAAyC,EACzC,iCAAiC,EAElC,MAAM,yC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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;IA4qBD;;;;;;;;;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
|
@@ -42,7 +42,7 @@ import { AccountActivityDataSource } from './data-sources/AccountActivityDataSou
|
|
|
42
42
|
import { AccountsApiDataSource } from './data-sources/AccountsApiDataSource.js';
|
|
43
43
|
import { isStakingContractAssetId } from './data-sources/evm-rpc-services/index.js';
|
|
44
44
|
import { shouldSkipNativeForCaipChainId } from './data-sources/evm-rpc-services/utils/assets.js';
|
|
45
|
-
import { PriceDataSource } from './data-sources/PriceDataSource.js';
|
|
45
|
+
import { isPriceableAsset, PriceDataSource, } from './data-sources/PriceDataSource.js';
|
|
46
46
|
import { RpcDataSource } from './data-sources/RpcDataSource.js';
|
|
47
47
|
import { SnapDataSource } from './data-sources/SnapDataSource.js';
|
|
48
48
|
import { StakedBalanceDataSource } from './data-sources/StakedBalanceDataSource.js';
|
|
@@ -50,6 +50,7 @@ import { CaipAssetNamespace, TokenDataSource, } from './data-sources/TokenDataSo
|
|
|
50
50
|
import { CHAINS_WITH_DEFAULT_TRACKED_ASSETS, DEFAULT_TRACKED_ASSETS_BY_CHAIN, buildDefaultAssetsInfo, getDefaultAssetMetadata, } from './defaults.js';
|
|
51
51
|
import { projectLogger, createModuleLogger } from './logger.js';
|
|
52
52
|
import { CustomAssetGraduationMiddleware } from './middlewares/CustomAssetGraduationMiddleware.js';
|
|
53
|
+
import { DetectionMiddleware } from './middlewares/DetectionMiddleware.js';
|
|
53
54
|
import { createParallelBalanceMiddleware, createParallelMiddleware, } from './middlewares/ParallelMiddleware.js';
|
|
54
55
|
import { RpcFallbackMiddleware } from './middlewares/RpcFallbackMiddleware.js';
|
|
55
56
|
import { dropBalancesOutsideAccountScopes } from './migrations/dropBalancesOutsideAccountScopes.js';
|
|
@@ -77,7 +78,6 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
77
78
|
'getAccountAssetsByIDs',
|
|
78
79
|
'getAccountAssetsByScope',
|
|
79
80
|
'getAssetsPrice',
|
|
80
|
-
'syncAssetsPrices',
|
|
81
81
|
'getExchangeRatesForBridge',
|
|
82
82
|
'getStateForTransactionPay',
|
|
83
83
|
'addCustomAsset',
|
|
@@ -213,6 +213,13 @@ function normalizeResponse(response) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
+
// Preserve detectedAssets with normalized asset IDs
|
|
217
|
+
if (response.detectedAssets) {
|
|
218
|
+
normalized.detectedAssets = {};
|
|
219
|
+
for (const [accountId, assetIds] of Object.entries(response.detectedAssets)) {
|
|
220
|
+
normalized.detectedAssets[accountId] = assetIds.map((assetId) => normalizeAssetId(assetId));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
216
223
|
// Preserve errors (chain IDs don't need normalization)
|
|
217
224
|
if (response.errors) {
|
|
218
225
|
normalized.errors = { ...response.errors };
|
|
@@ -491,6 +498,7 @@ let AssetsController = (() => {
|
|
|
491
498
|
];
|
|
492
499
|
}
|
|
493
500
|
#priceDataSource;
|
|
501
|
+
#detectionMiddleware;
|
|
494
502
|
#customAssetGraduationMiddleware;
|
|
495
503
|
#rpcFallbackMiddleware;
|
|
496
504
|
#tokenDataSource;
|
|
@@ -588,6 +596,9 @@ let AssetsController = (() => {
|
|
|
588
596
|
getAssetsState: () => this.state,
|
|
589
597
|
...priceDataSourceConfig,
|
|
590
598
|
});
|
|
599
|
+
this.#detectionMiddleware = new DetectionMiddleware({
|
|
600
|
+
getAssetsState: () => this.state,
|
|
601
|
+
});
|
|
591
602
|
this.#customAssetGraduationMiddleware = new CustomAssetGraduationMiddleware({
|
|
592
603
|
getSelectedAccountId: () => {
|
|
593
604
|
try {
|
|
@@ -924,12 +935,14 @@ let AssetsController = (() => {
|
|
|
924
935
|
this.#ensureDefaultTrackedAssetsSeeded();
|
|
925
936
|
// Balances were just force-fetched — skip AccountsApi's subscribe-time poll.
|
|
926
937
|
this.#subscribeAssets({ skipInitialFetch: true });
|
|
938
|
+
this.#fetchMissingPricesWithoutCache(accounts, [...this.#enabledChains]);
|
|
927
939
|
}
|
|
928
940
|
catch (error) {
|
|
929
941
|
log('Failed to fetch assets on startup', error);
|
|
930
942
|
this.#ensureNativeBalancesDefaultZero();
|
|
931
943
|
this.#ensureDefaultTrackedAssetsSeeded();
|
|
932
944
|
this.#subscribeAssets({ skipInitialFetch: true });
|
|
945
|
+
this.#fetchMissingPricesWithoutCache(accounts, [...this.#enabledChains]);
|
|
933
946
|
}
|
|
934
947
|
finally {
|
|
935
948
|
releaseLock();
|
|
@@ -1016,74 +1029,36 @@ let AssetsController = (() => {
|
|
|
1016
1029
|
return this.#getAssetsFromState(accounts, chainIds, assetTypes);
|
|
1017
1030
|
}
|
|
1018
1031
|
if (options?.forceUpdate) {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1032
|
+
const pipelineTrace = this.#firstInitFetchReported
|
|
1033
|
+
? undefined
|
|
1034
|
+
: this.#trace;
|
|
1035
|
+
const requestOptions = {
|
|
1036
|
+
assetTypes,
|
|
1037
|
+
dataTypes,
|
|
1038
|
+
forceUpdate: true,
|
|
1039
|
+
bypassServerCache: options?.bypassServerCache,
|
|
1040
|
+
assetsForPriceUpdate: options?.assetsForPriceUpdate,
|
|
1041
|
+
};
|
|
1042
|
+
if (this.#isBalanceV6Enabled()) {
|
|
1043
|
+
await this.#forceUpdateAssetsV6({
|
|
1044
|
+
accounts,
|
|
1045
|
+
chainIds,
|
|
1046
|
+
request: this.#buildDataRequest(accounts, chainIds, requestOptions),
|
|
1047
|
+
pipelineTrace,
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
await this.#forceUpdateAssetsV5({
|
|
1052
|
+
accounts,
|
|
1053
|
+
chainIds,
|
|
1054
|
+
request: this.#buildForceUpdateRequestV5(accounts, chainIds, requestOptions),
|
|
1055
|
+
pipelineTrace,
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1029
1058
|
}
|
|
1030
1059
|
const result = this.#getAssetsFromState(accounts, chainIds, assetTypes);
|
|
1031
1060
|
return result;
|
|
1032
1061
|
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Force-fetch spot prices for an explicit asset list.
|
|
1035
|
-
*
|
|
1036
|
-
* Calls `PriceDataSource` directly and merges the result into `assetsPrice`.
|
|
1037
|
-
* Prices are shared across accounts, so this does not take an account or
|
|
1038
|
-
* chain scope and does not run the balance pipeline.
|
|
1039
|
-
*
|
|
1040
|
-
* Returns without calling the Price API when basic functionality is off.
|
|
1041
|
-
* That matches the asset pipeline, which drops the price source in RPC-only
|
|
1042
|
-
* mode, and `setSelectedCurrency`, which skips its price refresh.
|
|
1043
|
-
*
|
|
1044
|
-
* @param assetIds - CAIP-19 asset IDs to sync.
|
|
1045
|
-
*/
|
|
1046
|
-
async syncAssetsPrices(assetIds) {
|
|
1047
|
-
if (!this.#isBasicFunctionality() || assetIds.length === 0) {
|
|
1048
|
-
return;
|
|
1049
|
-
}
|
|
1050
|
-
const assetsPrice = await this.#priceDataSource.fetchAssetPrices(assetIds);
|
|
1051
|
-
if (Object.keys(assetsPrice).length === 0) {
|
|
1052
|
-
return;
|
|
1053
|
-
}
|
|
1054
|
-
await this.#updateState({
|
|
1055
|
-
assetsPrice,
|
|
1056
|
-
updateMode: 'merge',
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
/**
|
|
1060
|
-
* Run a forced fetch on the v5 or v6 pipeline.
|
|
1061
|
-
*
|
|
1062
|
-
* @param params - Accounts, chains, and request fields for this fetch.
|
|
1063
|
-
* @param params.accounts - Accounts in this fetch.
|
|
1064
|
-
* @param params.chainIds - Chains in this fetch.
|
|
1065
|
-
* @param params.requestOptions - Shared force-update request fields.
|
|
1066
|
-
*/
|
|
1067
|
-
async #forceUpdateAssets({ accounts, chainIds, requestOptions, }) {
|
|
1068
|
-
const pipelineTrace = this.#firstInitFetchReported
|
|
1069
|
-
? undefined
|
|
1070
|
-
: this.#trace;
|
|
1071
|
-
if (this.#isBalanceV6Enabled()) {
|
|
1072
|
-
await this.#forceUpdateAssetsV6({
|
|
1073
|
-
accounts,
|
|
1074
|
-
chainIds,
|
|
1075
|
-
request: this.#buildDataRequest(accounts, chainIds, requestOptions),
|
|
1076
|
-
pipelineTrace,
|
|
1077
|
-
});
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
await this.#forceUpdateAssetsV5({
|
|
1081
|
-
accounts,
|
|
1082
|
-
chainIds,
|
|
1083
|
-
request: this.#buildForceUpdateRequestV5(accounts, chainIds, requestOptions),
|
|
1084
|
-
pipelineTrace,
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
1062
|
/**
|
|
1088
1063
|
* v5 force-update request: every pin of the requested accounts, unscoped.
|
|
1089
1064
|
* Delete with the rest of the v5 path when `assetsAccountsApiV6` is the default.
|
|
@@ -1095,6 +1070,7 @@ let AssetsController = (() => {
|
|
|
1095
1070
|
* @param requestOptions.dataTypes - Data types to fetch.
|
|
1096
1071
|
* @param requestOptions.forceUpdate - Always `true` to bypass caches.
|
|
1097
1072
|
* @param requestOptions.bypassServerCache - Also bypass server-side HTTP caches.
|
|
1073
|
+
* @param requestOptions.assetsForPriceUpdate - Assets to refresh prices for.
|
|
1098
1074
|
* @returns The v5 data request.
|
|
1099
1075
|
*/
|
|
1100
1076
|
#buildForceUpdateRequestV5(accounts, chainIds, requestOptions) {
|
|
@@ -1113,6 +1089,7 @@ let AssetsController = (() => {
|
|
|
1113
1089
|
accountsApiDataSource: this.#accountsApiDataSource,
|
|
1114
1090
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
1115
1091
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
1092
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
1116
1093
|
tokenDataSource: this.#tokenDataSource,
|
|
1117
1094
|
priceDataSource: this.#priceDataSource,
|
|
1118
1095
|
}, { isBasicFunctionality, includeCustomAssetGraduation: true });
|
|
@@ -1139,6 +1116,7 @@ let AssetsController = (() => {
|
|
|
1139
1116
|
accountsApiDataSource: this.#accountsApiDataSource,
|
|
1140
1117
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
1141
1118
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
1119
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
1142
1120
|
tokenDataSource: this.#tokenDataSource,
|
|
1143
1121
|
priceDataSource: this.#priceDataSource,
|
|
1144
1122
|
}, {
|
|
@@ -1249,6 +1227,7 @@ let AssetsController = (() => {
|
|
|
1249
1227
|
const { response } = await this.#executeMiddlewares({
|
|
1250
1228
|
sources: [
|
|
1251
1229
|
createParallelBalanceMiddleware(slowSources),
|
|
1230
|
+
this.#detectionMiddleware,
|
|
1252
1231
|
...(isBasicFunctionality
|
|
1253
1232
|
? [
|
|
1254
1233
|
createParallelMiddleware([
|
|
@@ -1704,10 +1683,60 @@ let AssetsController = (() => {
|
|
|
1704
1683
|
}
|
|
1705
1684
|
// Currency changed — old cached prices are in the wrong currency.
|
|
1706
1685
|
this.#priceDataSource.invalidatePriceCache();
|
|
1707
|
-
this.
|
|
1686
|
+
this.getAssets(this.#getSelectedAccounts(), {
|
|
1687
|
+
forceUpdate: true,
|
|
1688
|
+
dataTypes: ['price'],
|
|
1689
|
+
assetsForPriceUpdate: Object.values(this.state.assetsBalance).flatMap((balances) => Object.keys(balances)),
|
|
1690
|
+
}).catch((error) => {
|
|
1708
1691
|
log('Failed to fetch asset prices after current currency change', error);
|
|
1709
1692
|
});
|
|
1710
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Fetch spot prices (bypassing deduper cache) for held assets that have no
|
|
1696
|
+
* entry in `assetsPrice` yet. Used when switching or adding a network.
|
|
1697
|
+
*
|
|
1698
|
+
* @param accounts - Accounts whose held assets should be priced.
|
|
1699
|
+
* @param chainIds - Chains to scope the check and fetch.
|
|
1700
|
+
*/
|
|
1701
|
+
#fetchMissingPricesWithoutCache(accounts, chainIds) {
|
|
1702
|
+
if (!this.#isBasicFunctionality() || accounts.length === 0) {
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const accountIds = new Set(accounts.map((account) => account.id));
|
|
1706
|
+
const chainFilter = new Set(chainIds);
|
|
1707
|
+
const assetsForPriceUpdate = [];
|
|
1708
|
+
const prices = this.state.assetsPrice;
|
|
1709
|
+
for (const [accountId, accountBalances] of Object.entries(this.state.assetsBalance)) {
|
|
1710
|
+
if (!accountIds.has(accountId)) {
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
for (const assetId of Object.keys(accountBalances)) {
|
|
1714
|
+
if (!chainFilter.has(assetId.split('/')[0])) {
|
|
1715
|
+
continue;
|
|
1716
|
+
}
|
|
1717
|
+
const normalizedAssetId = normalizeAssetId(assetId);
|
|
1718
|
+
if (prices[normalizedAssetId] ?? prices[assetId]) {
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
if (!isPriceableAsset(normalizedAssetId)) {
|
|
1722
|
+
continue;
|
|
1723
|
+
}
|
|
1724
|
+
assetsForPriceUpdate.push(normalizedAssetId);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
if (assetsForPriceUpdate.length === 0) {
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
this.#priceDataSource.invalidatePriceCache();
|
|
1731
|
+
this.getAssets(accounts, {
|
|
1732
|
+
forceUpdate: true,
|
|
1733
|
+
dataTypes: ['price'],
|
|
1734
|
+
chainIds,
|
|
1735
|
+
assetsForPriceUpdate,
|
|
1736
|
+
}).catch((error) => {
|
|
1737
|
+
log('Failed to fetch missing prices', { error });
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1711
1740
|
// ============================================================================
|
|
1712
1741
|
// SUBSCRIPTIONS
|
|
1713
1742
|
// ============================================================================
|
|
@@ -2026,6 +2055,8 @@ let AssetsController = (() => {
|
|
|
2026
2055
|
try {
|
|
2027
2056
|
const previousState = this.state;
|
|
2028
2057
|
const previousPrices = { ...this.state.assetsPrice };
|
|
2058
|
+
// Use detectedAssets from response (assets without metadata)
|
|
2059
|
+
const detectedAssets = normalizedResponse.detectedAssets ?? {};
|
|
2029
2060
|
// Track actual changes for logging
|
|
2030
2061
|
const changedBalances = [];
|
|
2031
2062
|
const changedMetadata = [];
|
|
@@ -2195,6 +2226,12 @@ let AssetsController = (() => {
|
|
|
2195
2226
|
changedBalances: changedBalances.length > 0 ? changedBalances : undefined,
|
|
2196
2227
|
changedMetadata: changedMetadata.length > 0 ? changedMetadata : undefined,
|
|
2197
2228
|
changedPrices: changedPriceAssets.length > 0 ? changedPriceAssets : undefined,
|
|
2229
|
+
newAssets: Object.keys(detectedAssets).length > 0
|
|
2230
|
+
? Object.entries(detectedAssets).map(([accountId, assets]) => ({
|
|
2231
|
+
accountId,
|
|
2232
|
+
assets,
|
|
2233
|
+
}))
|
|
2234
|
+
: undefined,
|
|
2198
2235
|
});
|
|
2199
2236
|
}
|
|
2200
2237
|
// Publish balance changed events
|
|
@@ -2220,6 +2257,15 @@ let AssetsController = (() => {
|
|
|
2220
2257
|
prices: changedPrices,
|
|
2221
2258
|
});
|
|
2222
2259
|
}
|
|
2260
|
+
// Publish assets detected events
|
|
2261
|
+
for (const [accountId, assetIds] of Object.entries(detectedAssets)) {
|
|
2262
|
+
if (assetIds.length > 0) {
|
|
2263
|
+
this.messenger.publish('AssetsController:assetsDetected', {
|
|
2264
|
+
accountId,
|
|
2265
|
+
assetIds,
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2223
2269
|
}
|
|
2224
2270
|
finally {
|
|
2225
2271
|
releaseLock();
|
|
@@ -2782,15 +2828,16 @@ let AssetsController = (() => {
|
|
|
2782
2828
|
});
|
|
2783
2829
|
const releaseLock = await this.#accountRefreshMutex.acquire();
|
|
2784
2830
|
try {
|
|
2785
|
-
this.#ensureNativeBalancesDefaultZero();
|
|
2786
|
-
this.#ensureDefaultTrackedAssetsSeeded();
|
|
2787
2831
|
if (accounts.length > 0) {
|
|
2788
2832
|
await this.getAssets(accounts, {
|
|
2789
2833
|
chainIds: [...this.#enabledChains],
|
|
2790
2834
|
forceUpdate: true,
|
|
2791
2835
|
});
|
|
2792
2836
|
}
|
|
2837
|
+
this.#ensureNativeBalancesDefaultZero();
|
|
2838
|
+
this.#ensureDefaultTrackedAssetsSeeded();
|
|
2793
2839
|
this.#subscribeAssets({ skipInitialFetch: true });
|
|
2840
|
+
this.#fetchMissingPricesWithoutCache(accounts, [...this.#enabledChains]);
|
|
2794
2841
|
}
|
|
2795
2842
|
finally {
|
|
2796
2843
|
releaseLock();
|
|
@@ -2822,21 +2869,25 @@ let AssetsController = (() => {
|
|
|
2822
2869
|
// Note: We intentionally do NOT delete balance data for disabled chains.
|
|
2823
2870
|
// Users may want to see historical balances even if the network is currently disabled.
|
|
2824
2871
|
// The data will simply not be updated until the network is re-enabled.
|
|
2825
|
-
const accounts = this.#getSelectedAccounts();
|
|
2826
|
-
this.#ensureNativeBalancesDefaultZero();
|
|
2827
|
-
if (addedChains.length > 0) {
|
|
2828
|
-
this.#ensureDefaultTrackedAssetsSeeded(addedChains);
|
|
2829
|
-
}
|
|
2830
2872
|
// Refresh subscriptions for new chain set
|
|
2831
2873
|
this.#subscribeAssets();
|
|
2832
2874
|
// One-time fetch for newly enabled chains. v6 `full` replace is scoped to
|
|
2833
2875
|
// those chains; existing balances on other chains are left untouched.
|
|
2876
|
+
const accounts = this.#getSelectedAccounts();
|
|
2834
2877
|
if (addedChains.length > 0 && accounts.length > 0) {
|
|
2835
2878
|
await this.getAssets(accounts, {
|
|
2836
2879
|
chainIds: addedChains,
|
|
2837
2880
|
forceUpdate: true,
|
|
2838
2881
|
});
|
|
2839
2882
|
}
|
|
2883
|
+
this.#ensureNativeBalancesDefaultZero();
|
|
2884
|
+
// Seed default tracked assets (mUSD) for any chain the user has
|
|
2885
|
+
// *just* enabled. This is what makes mUSD appear on Monad after
|
|
2886
|
+
// the user finally adds it to NetworkEnablementController.
|
|
2887
|
+
if (addedChains.length > 0) {
|
|
2888
|
+
this.#ensureDefaultTrackedAssetsSeeded(addedChains);
|
|
2889
|
+
}
|
|
2890
|
+
this.#fetchMissingPricesWithoutCache(accounts, [...this.#enabledChains]);
|
|
2840
2891
|
}
|
|
2841
2892
|
/**
|
|
2842
2893
|
* Handle a `NetworkController:networkAdded` event. When the user
|
|
@@ -2865,6 +2916,8 @@ let AssetsController = (() => {
|
|
|
2865
2916
|
caipChainId,
|
|
2866
2917
|
});
|
|
2867
2918
|
this.#ensureDefaultTrackedAssetsSeeded([caipChainId]);
|
|
2919
|
+
const accounts = this.#getSelectedAccounts();
|
|
2920
|
+
this.#fetchMissingPricesWithoutCache(accounts, [caipChainId]);
|
|
2868
2921
|
}
|
|
2869
2922
|
/**
|
|
2870
2923
|
* Refresh data-source `activeChains` after an EVM network switch so API/Rpc
|
|
@@ -2918,13 +2971,14 @@ let AssetsController = (() => {
|
|
|
2918
2971
|
const releaseLock = await this.#accountRefreshMutex.acquire();
|
|
2919
2972
|
try {
|
|
2920
2973
|
await this.#refreshActiveChainsOnNetworkSwitch();
|
|
2921
|
-
this.#ensureNativeBalancesDefaultZero();
|
|
2922
2974
|
this.#subscribeAssets();
|
|
2923
2975
|
await this.getAssets(accounts, {
|
|
2924
2976
|
chainIds: [selectedChainId],
|
|
2925
2977
|
forceUpdate: true,
|
|
2926
2978
|
dataTypes: ['balance', 'metadata', 'price'],
|
|
2927
2979
|
});
|
|
2980
|
+
this.#ensureNativeBalancesDefaultZero();
|
|
2981
|
+
this.#fetchMissingPricesWithoutCache(accounts, [selectedChainId]);
|
|
2928
2982
|
}
|
|
2929
2983
|
finally {
|
|
2930
2984
|
releaseLock();
|
|
@@ -2962,12 +3016,13 @@ let AssetsController = (() => {
|
|
|
2962
3016
|
catch {
|
|
2963
3017
|
return;
|
|
2964
3018
|
}
|
|
2965
|
-
this.#ensureNativeBalancesDefaultZero();
|
|
2966
3019
|
await this.getAssets(accounts, {
|
|
2967
3020
|
chainIds: [caipChainId],
|
|
2968
3021
|
forceUpdate: true,
|
|
2969
3022
|
dataTypes: ['balance', 'metadata', 'price'],
|
|
2970
3023
|
});
|
|
3024
|
+
this.#ensureNativeBalancesDefaultZero();
|
|
3025
|
+
this.#fetchMissingPricesWithoutCache(accounts, [caipChainId]);
|
|
2971
3026
|
}
|
|
2972
3027
|
/**
|
|
2973
3028
|
* Handle assets updated from a data source.
|
|
@@ -3008,12 +3063,14 @@ let AssetsController = (() => {
|
|
|
3008
3063
|
? buildWsUpdateSources({
|
|
3009
3064
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
3010
3065
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
3066
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
3011
3067
|
tokenDataSource: this.#tokenDataSource,
|
|
3012
3068
|
priceDataSource: this.#priceDataSource,
|
|
3013
3069
|
}, { isBasicFunctionality, includeCustomAssetGraduation: true })
|
|
3014
3070
|
: buildUpdateSources({
|
|
3015
3071
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
3016
3072
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
3073
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
3017
3074
|
tokenDataSource: this.#tokenDataSource,
|
|
3018
3075
|
priceDataSource: this.#priceDataSource,
|
|
3019
3076
|
}, {
|
|
@@ -3059,12 +3116,14 @@ let AssetsController = (() => {
|
|
|
3059
3116
|
? buildWsUpdateSources({
|
|
3060
3117
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
3061
3118
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
3119
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
3062
3120
|
tokenDataSource: this.#tokenDataSource,
|
|
3063
3121
|
priceDataSource: this.#priceDataSource,
|
|
3064
3122
|
}, { isBasicFunctionality, includeCustomAssetGraduation: false })
|
|
3065
3123
|
: buildUpdateSources({
|
|
3066
3124
|
customAssetGraduationMiddleware: this.#customAssetGraduationMiddleware,
|
|
3067
3125
|
rpcFallbackMiddleware: this.#rpcFallbackMiddleware,
|
|
3126
|
+
detectionMiddleware: this.#detectionMiddleware,
|
|
3068
3127
|
tokenDataSource: this.#tokenDataSource,
|
|
3069
3128
|
priceDataSource: this.#priceDataSource,
|
|
3070
3129
|
}, {
|
|
@@ -3160,7 +3219,6 @@ let AssetsController = (() => {
|
|
|
3160
3219
|
this.messenger.unregisterActionHandler('AssetsController:getAccountAssetsByIDs');
|
|
3161
3220
|
this.messenger.unregisterActionHandler('AssetsController:getAccountAssetsByScope');
|
|
3162
3221
|
this.messenger.unregisterActionHandler('AssetsController:getAssetsPrice');
|
|
3163
|
-
this.messenger.unregisterActionHandler('AssetsController:syncAssetsPrices');
|
|
3164
3222
|
this.messenger.unregisterActionHandler('AssetsController:getExchangeRatesForBridge');
|
|
3165
3223
|
this.messenger.unregisterActionHandler('AssetsController:getStateForTransactionPay');
|
|
3166
3224
|
this.messenger.unregisterActionHandler('AssetsController:addCustomAsset');
|