@metamask-previews/assets-controller 20.4.1-preview-e9ac9ffe1 → 20.4.1-preview-70269bbdb
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 +14 -0
- package/README.md +3 -0
- package/dist/AssetsController-method-action-types.d.ts +6 -2
- 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 +11 -13
- package/dist/AssetsController.d.ts.map +1 -1
- package/dist/AssetsController.js +27 -17
- package/dist/AssetsController.js.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.d.ts +4 -2
- package/dist/data-sources/AccountActivityDataSource.d.ts.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.js +3 -1
- package/dist/data-sources/AccountActivityDataSource.js.map +1 -1
- package/dist/data-sources/MarketStatsPriceStream.d.ts +67 -0
- package/dist/data-sources/MarketStatsPriceStream.d.ts.map +1 -0
- package/dist/data-sources/MarketStatsPriceStream.js +181 -0
- package/dist/data-sources/MarketStatsPriceStream.js.map +1 -0
- package/dist/data-sources/PriceDataSource.d.ts +29 -2
- package/dist/data-sources/PriceDataSource.d.ts.map +1 -1
- package/dist/data-sources/PriceDataSource.js +113 -37
- package/dist/data-sources/PriceDataSource.js.map +1 -1
- package/dist/data-sources/index.d.ts +1 -1
- package/dist/data-sources/index.d.ts.map +1 -1
- package/dist/data-sources/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/store/MarketStatsStore.d.ts +72 -0
- package/dist/store/MarketStatsStore.d.ts.map +1 -0
- package/dist/store/MarketStatsStore.js +182 -0
- package/dist/store/MarketStatsStore.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,11 +7,20 @@ 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 optional `bypassServerCache` parameter to `addCustomAsset` (and the `AssetsController:addCustomAsset` action) ([#11613](https://github.com/MetaMask/core/pull/11613))
|
|
13
|
+
- When `true`, the force-fetch of the asset's chain also bypasses server-side HTTP caches such as the Accounts API's 60s cache. It only applies when the account is in the selected account group.
|
|
14
|
+
- Add `MarketStatsStore`, a UI cache of live quotes from `MarketStatsService:pricesUpdated`. It keeps one currency, keyed by CAIP-19 asset id, and is not `AssetsController` state ([#11193](https://github.com/MetaMask/core/pull/11193))
|
|
15
|
+
- Poll `/v3/spot-prices` for every tracked asset, and also stream prices over `market-stats.v1` when the spot price reports `wssSupport`. An open channel does not take that asset off the poll. Without a registered `MarketStatsService`, every asset stays on the poll ([#11193](https://github.com/MetaMask/core/pull/11193))
|
|
16
|
+
|
|
10
17
|
### Changed
|
|
11
18
|
|
|
12
19
|
- **BREAKING:** Remove `getAssetsState` from `AccountsApiDataSourceOptions`. Include and exclude asset IDs come from `getAssetVisibility`.
|
|
13
20
|
- **BREAKING:** Balance data sources always use the Accounts API v6 path. `isBalanceV6Enabled` is no longer accepted. Fetches use the v6 balances endpoint and `full` snapshots, and the stale-asset RPC supplement is removed. The `assetsAccountsApiV6` remote feature flag is no longer read ([#11564](https://github.com/MetaMask/core/pull/11564))
|
|
14
21
|
- **BREAKING:** Remove `CustomAssetGraduationMiddleware` and `includeCustomAssetGraduation`. A reported balance no longer removes a pin from `customAssets` ([#11564](https://github.com/MetaMask/core/pull/11564))
|
|
22
|
+
- **BREAKING:** `AssetsControllerMessenger` now includes `MarketStatsService:subscribe`, `unsubscribe`, `getSubscriptions`, `getChainStatuses`, and `chainStatusChanged`. Delegate them from the root messenger ([#11193](https://github.com/MetaMask/core/pull/11193))
|
|
23
|
+
- **BREAKING:** `PriceDataSource` requires `messenger` ([#11193](https://github.com/MetaMask/core/pull/11193))
|
|
15
24
|
- Bump `@metamask/transaction-controller` from `^74.0.0` to `^74.2.0` ([#11579](https://github.com/MetaMask/core/pull/11579), [#11605](https://github.com/MetaMask/core/pull/11605))
|
|
16
25
|
- Bump `@metamask/keyring-controller` from `^28.2.0` to `^28.2.2` ([#11474](https://github.com/MetaMask/core/pull/11474), [#11537](https://github.com/MetaMask/core/pull/11537))
|
|
17
26
|
- Bump `@metamask/utils` from `^12.0.1` to `^12.0.2` ([#11474](https://github.com/MetaMask/core/pull/11474))
|
|
@@ -19,6 +28,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
28
|
### Removed
|
|
20
29
|
|
|
21
30
|
- Remove Blast Mainnet (`0x13e31`) from the EVM RPC Multicall3 address map, as the network is being terminated ([#11598](https://github.com/MetaMask/core/pull/11598))
|
|
31
|
+
- **BREAKING:** Remove `AssetsController:priceChanged`. Socket prices are not written to `assetsPrice`. Read them from `MarketStatsStore`, or subscribe to `MarketStatsService:pricesUpdated` ([#11193](https://github.com/MetaMask/core/pull/11193))
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Open a market-stats channel after a balance update writes a spot price with `wssSupport`, instead of waiting for the next price poll
|
|
22
36
|
|
|
23
37
|
## [20.4.1]
|
|
24
38
|
|
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Tracks assets balances/prices and handles token detection across all digital assets.
|
|
4
4
|
|
|
5
|
+
Live spot prices (backend stream, `MarketStatsService`, this controller,
|
|
6
|
+
Extension UI) are described in [docs/decisions/2026-11-05-market-stats.md](./docs/decisions/2026-11-05-market-stats.md).
|
|
7
|
+
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
7
10
|
`yarn add @metamask/assets-controller`
|
|
@@ -37,8 +37,8 @@ export type AssetsControllerGetAssetMetadataAction = {
|
|
|
37
37
|
* `fiatValue`) for an account directly from controller state.
|
|
38
38
|
*
|
|
39
39
|
* Reuses the same state-composition and filtering logic as `getAssets`
|
|
40
|
-
* (balance and metadata are required, a missing price falls back to
|
|
41
|
-
*
|
|
40
|
+
* (balance and metadata are required, a missing price falls back to a
|
|
41
|
+
* fungible price of `0` with `fiatValue: 0`, and hidden or
|
|
42
42
|
* otherwise filtered assets are excluded) so the returned shape never
|
|
43
43
|
* drifts from `getAssets`. Reads from current state only and does not
|
|
44
44
|
* trigger a data-source refresh.
|
|
@@ -138,6 +138,10 @@ export type AssetsControllerGetStateForTransactionPayAction = {
|
|
|
138
138
|
* @param accountId - The account ID to add the custom asset for.
|
|
139
139
|
* @param assetId - The CAIP-19 asset ID to add.
|
|
140
140
|
* @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).
|
|
141
|
+
* @param bypassServerCache - Also bypass server-side HTTP caches (e.g. the
|
|
142
|
+
* Accounts API's 60s cache) on the force-fetch, e.g. right after a
|
|
143
|
+
* transaction that changed this asset's balance. Only applies when
|
|
144
|
+
* `accountId` belongs to the selected account group.
|
|
141
145
|
*/
|
|
142
146
|
export type AssetsControllerAddCustomAssetAction = {
|
|
143
147
|
type: `AssetsController:addCustomAsset`;
|
|
@@ -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;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CAC/C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B,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,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\n/**\n * Force-fetch spot prices for an explicit asset list.\n *\n * Calls `PriceDataSource` directly and merges the result into `assetsPrice`.\n * Prices are shared across accounts, so this does not take an account or\n * chain scope and does not run the balance pipeline.\n *\n * Returns without calling the Price API when basic functionality is off.\n * That matches the asset pipeline, which drops the price source in RPC-only\n * mode, and `setSelectedCurrency`, which skips its price refresh.\n *\n * @param assetIds - CAIP-19 asset IDs to sync.\n */\nexport type AssetsControllerSyncAssetsPricesAction = {\n type: `AssetsController:syncAssetsPrices`;\n handler: AssetsController['syncAssetsPrices'];\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 *
|
|
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\n/**\n * Force-fetch spot prices for an explicit asset list.\n *\n * Calls `PriceDataSource` directly and merges the result into `assetsPrice`.\n * Prices are shared across accounts, so this does not take an account or\n * chain scope and does not run the balance pipeline.\n *\n * Returns without calling the Price API when basic functionality is off.\n * That matches the asset pipeline, which drops the price source in RPC-only\n * mode, and `setSelectedCurrency`, which skips its price refresh.\n *\n * @param assetIds - CAIP-19 asset IDs to sync.\n */\nexport type AssetsControllerSyncAssetsPricesAction = {\n type: `AssetsController:syncAssetsPrices`;\n handler: AssetsController['syncAssetsPrices'];\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 a\n * fungible price of `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 * @param bypassServerCache - Also bypass server-side HTTP caches (e.g. the\n * Accounts API's 60s cache) on the force-fetch, e.g. right after a\n * transaction that changed this asset's balance. Only applies when\n * `accountId` belongs to the selected account group.\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 | AssetsControllerSyncAssetsPricesAction\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"]}
|
|
@@ -6,7 +6,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@meta
|
|
|
6
6
|
import type { ClientControllerGetStateAction, ClientControllerStateChangeEvent } from '@metamask/client-controller';
|
|
7
7
|
import type { ConfigRegistryControllerGetNetworkConfigByCaip2ChainIdAction } from '@metamask/config-registry-controller';
|
|
8
8
|
import type { TraceCallback } from '@metamask/controller-utils';
|
|
9
|
-
import type { ApiPlatformClient, AccountActivityServiceBalanceUpdatedEvent, AccountActivityServiceStatusChangedEvent, SupportedCurrency } from '@metamask/core-backend';
|
|
9
|
+
import type { ApiPlatformClient, AccountActivityServiceBalanceUpdatedEvent, AccountActivityServiceStatusChangedEvent, MarketStatsServiceActions, MarketStatsServiceChainStatusChangedEvent, SupportedCurrency } from '@metamask/core-backend';
|
|
10
10
|
import type { KeyringControllerIsUnlockedAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent } from '@metamask/keyring-controller';
|
|
11
11
|
import type { InternalAccount } from '@metamask/keyring-internal-api';
|
|
12
12
|
import type { Messenger } from '@metamask/messenger';
|
|
@@ -67,15 +67,9 @@ export type AssetsControllerBalanceChangedEvent = {
|
|
|
67
67
|
}
|
|
68
68
|
];
|
|
69
69
|
};
|
|
70
|
-
export type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
prices: Record<Caip19AssetId, AssetPrice>;
|
|
74
|
-
}];
|
|
75
|
-
};
|
|
76
|
-
export type AssetsControllerEvents = AssetsControllerStateChangeEvent | AssetsControllerBalanceChangedEvent | AssetsControllerPriceChangedEvent;
|
|
77
|
-
type AllowedActions = AccountsControllerGetSelectedAccountAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AccountTreeControllerIsInitializedAction | ClientControllerGetStateAction | KeyringControllerIsUnlockedAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | ConfigRegistryControllerGetNetworkConfigByCaip2ChainIdAction | NetworkEnablementControllerGetStateAction | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | PhishingControllerBulkScanTokensAction | RemoteFeatureFlagControllerGetStateAction | AuthenticatedUserStorageServiceGetUserAssetsAction | AuthenticatedUserStorageServiceSetUserAssetsAction | AuthenticatedUserStorageServiceImportTokensAction | AuthenticatedUserStorageServiceHideTokensAction;
|
|
78
|
-
type AllowedEvents = AccountTreeControllerSelectedAccountGroupChangeEvent | AccountTreeControllerInitializedEvent | AccountTreeControllerUninitializedEvent | ClientControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | PreferencesControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionConfirmedEvent | MultichainTransactionsControllerTransactionConfirmedEvent | NetworkControllerStateChangeEvent | NetworkControllerNetworkAddedEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerNetworkRemovedEvent | NetworkEnablementControllerEvents | AccountsControllerAccountBalancesUpdatedEvent | PermissionControllerStateChange | SnapControllerSnapInstalledEvent | AccountActivityServiceBalanceUpdatedEvent | AccountActivityServiceStatusChangedEvent | RemoteFeatureFlagControllerStateChangeEvent;
|
|
70
|
+
export type AssetsControllerEvents = AssetsControllerStateChangeEvent | AssetsControllerBalanceChangedEvent;
|
|
71
|
+
type AllowedActions = AccountsControllerGetSelectedAccountAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AccountTreeControllerIsInitializedAction | ClientControllerGetStateAction | KeyringControllerIsUnlockedAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | ConfigRegistryControllerGetNetworkConfigByCaip2ChainIdAction | NetworkEnablementControllerGetStateAction | SnapControllerGetRunnableSnapsAction | SnapControllerHandleRequestAction | GetPermissions | PhishingControllerBulkScanTokensAction | RemoteFeatureFlagControllerGetStateAction | AuthenticatedUserStorageServiceGetUserAssetsAction | AuthenticatedUserStorageServiceSetUserAssetsAction | AuthenticatedUserStorageServiceImportTokensAction | AuthenticatedUserStorageServiceHideTokensAction | MarketStatsServiceActions;
|
|
72
|
+
type AllowedEvents = AccountTreeControllerSelectedAccountGroupChangeEvent | AccountTreeControllerInitializedEvent | AccountTreeControllerUninitializedEvent | ClientControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | PreferencesControllerStateChangeEvent | TransactionControllerUnapprovedTransactionAddedEvent | TransactionControllerTransactionConfirmedEvent | MultichainTransactionsControllerTransactionConfirmedEvent | NetworkControllerStateChangeEvent | NetworkControllerNetworkAddedEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerNetworkRemovedEvent | NetworkEnablementControllerEvents | AccountsControllerAccountBalancesUpdatedEvent | PermissionControllerStateChange | SnapControllerSnapInstalledEvent | AccountActivityServiceBalanceUpdatedEvent | AccountActivityServiceStatusChangedEvent | RemoteFeatureFlagControllerStateChangeEvent | MarketStatsServiceChainStatusChangedEvent;
|
|
79
73
|
export type AssetsControllerMessenger = Messenger<typeof CONTROLLER_NAME, AssetsControllerActions | AllowedActions, AssetsControllerEvents | AllowedEvents>;
|
|
80
74
|
export type AssetsControllerOptions = {
|
|
81
75
|
messenger: AssetsControllerMessenger;
|
|
@@ -215,8 +209,8 @@ export declare class AssetsController extends BaseController<typeof CONTROLLER_N
|
|
|
215
209
|
* `fiatValue`) for an account directly from controller state.
|
|
216
210
|
*
|
|
217
211
|
* Reuses the same state-composition and filtering logic as `getAssets`
|
|
218
|
-
* (balance and metadata are required, a missing price falls back to
|
|
219
|
-
*
|
|
212
|
+
* (balance and metadata are required, a missing price falls back to a
|
|
213
|
+
* fungible price of `0` with `fiatValue: 0`, and hidden or
|
|
220
214
|
* otherwise filtered assets are excluded) so the returned shape never
|
|
221
215
|
* drifts from `getAssets`. Reads from current state only and does not
|
|
222
216
|
* trigger a data-source refresh.
|
|
@@ -302,8 +296,12 @@ export declare class AssetsController extends BaseController<typeof CONTROLLER_N
|
|
|
302
296
|
* @param accountId - The account ID to add the custom asset for.
|
|
303
297
|
* @param assetId - The CAIP-19 asset ID to add.
|
|
304
298
|
* @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).
|
|
299
|
+
* @param bypassServerCache - Also bypass server-side HTTP caches (e.g. the
|
|
300
|
+
* Accounts API's 60s cache) on the force-fetch, e.g. right after a
|
|
301
|
+
* transaction that changed this asset's balance. Only applies when
|
|
302
|
+
* `accountId` belongs to the selected account group.
|
|
305
303
|
*/
|
|
306
|
-
addCustomAsset(accountId: AccountId, assetId: Caip19AssetId, pendingMetadata?: PendingTokenMetadata): Promise<void>;
|
|
304
|
+
addCustomAsset(accountId: AccountId, assetId: Caip19AssetId, pendingMetadata?: PendingTokenMetadata, bypassServerCache?: boolean): Promise<void>;
|
|
307
305
|
/**
|
|
308
306
|
* Remove a custom asset from an account.
|
|
309
307
|
*
|
|
@@ -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,KAAK,EACV,kDAAkD,EAClD,+CAA+C,EAC/C,iDAAiD,EACjD,kDAAkD,EACnD,MAAM,sCAAsC,CAAC;AAC9C,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,EAC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;;OAQG;IACH,yBAAyB,IAAI,0BAA0B,CActD;IAMD;;;;;;;;;;;;;;;;;OAiBG;IAEG,cAAc,CAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,aAAa,EACtB,eAAe,CAAC,EAAE,oBAAoB,EACtC,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC,CA4Ef;IAED;;;;;OAKG;IAEH,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAoBpE;IAED;;;;;OAKG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,EAAE,CAErD;IAMD;;;;;;OAMG;IAEH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CActC;IAED;;;;;;;OAOG;IAEG,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BvD;IAMD;;;;OAIG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAiC7D;IAMD;;;;;;OAMG;IACH,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAkC3E;IAED;;OAEG;IACH,sBAAsB,IAAI,IAAI,CAS7B;IAwxBD;;;;;;;OAOG;IACH,8BAA8B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGtD;IAimBD;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Df;IAkED,OAAO,IAAI,IAAI,CAoDd;CACF"}
|
package/dist/AssetsController.js
CHANGED
|
@@ -553,6 +553,7 @@ let AssetsController = (() => {
|
|
|
553
553
|
});
|
|
554
554
|
this.#priceDataSource = new PriceDataSource({
|
|
555
555
|
queryApiClient,
|
|
556
|
+
messenger: this.messenger,
|
|
556
557
|
getSelectedCurrency: () => this.state.selectedCurrency,
|
|
557
558
|
getAssetsState: () => this.state,
|
|
558
559
|
...priceDataSourceConfig,
|
|
@@ -1174,8 +1175,8 @@ let AssetsController = (() => {
|
|
|
1174
1175
|
* `fiatValue`) for an account directly from controller state.
|
|
1175
1176
|
*
|
|
1176
1177
|
* Reuses the same state-composition and filtering logic as `getAssets`
|
|
1177
|
-
* (balance and metadata are required, a missing price falls back to
|
|
1178
|
-
*
|
|
1178
|
+
* (balance and metadata are required, a missing price falls back to a
|
|
1179
|
+
* fungible price of `0` with `fiatValue: 0`, and hidden or
|
|
1179
1180
|
* otherwise filtered assets are excluded) so the returned shape never
|
|
1180
1181
|
* drifts from `getAssets`. Reads from current state only and does not
|
|
1181
1182
|
* trigger a data-source refresh.
|
|
@@ -1364,8 +1365,12 @@ let AssetsController = (() => {
|
|
|
1364
1365
|
* @param accountId - The account ID to add the custom asset for.
|
|
1365
1366
|
* @param assetId - The CAIP-19 asset ID to add.
|
|
1366
1367
|
* @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).
|
|
1368
|
+
* @param bypassServerCache - Also bypass server-side HTTP caches (e.g. the
|
|
1369
|
+
* Accounts API's 60s cache) on the force-fetch, e.g. right after a
|
|
1370
|
+
* transaction that changed this asset's balance. Only applies when
|
|
1371
|
+
* `accountId` belongs to the selected account group.
|
|
1367
1372
|
*/
|
|
1368
|
-
async addCustomAsset(accountId, assetId, pendingMetadata) {
|
|
1373
|
+
async addCustomAsset(accountId, assetId, pendingMetadata, bypassServerCache) {
|
|
1369
1374
|
const normalizedAssetId = normalizeAssetId(assetId);
|
|
1370
1375
|
log('Adding custom asset', { accountId, assetId: normalizedAssetId });
|
|
1371
1376
|
this.update((state) => {
|
|
@@ -1422,6 +1427,7 @@ let AssetsController = (() => {
|
|
|
1422
1427
|
dataTypes: ['balance', 'metadata', 'price'],
|
|
1423
1428
|
assetTypes: ['fungible'],
|
|
1424
1429
|
forceUpdate: true,
|
|
1430
|
+
bypassServerCache,
|
|
1425
1431
|
});
|
|
1426
1432
|
}
|
|
1427
1433
|
// Re-evaluate subscriptions so polls pick up the new pin.
|
|
@@ -1536,6 +1542,9 @@ let AssetsController = (() => {
|
|
|
1536
1542
|
}
|
|
1537
1543
|
// Currency changed — old cached prices are in the wrong currency.
|
|
1538
1544
|
this.#priceDataSource.invalidatePriceCache();
|
|
1545
|
+
this.#priceDataSource.resubscribeForCurrencyChange().catch((error) => {
|
|
1546
|
+
log('Failed to resubscribe market stats after currency change', error);
|
|
1547
|
+
});
|
|
1539
1548
|
this.syncAssetsPrices(Object.values(this.state.assetsBalance).flatMap((balances) => Object.keys(balances))).catch((error) => {
|
|
1540
1549
|
log('Failed to fetch asset prices after current currency change', error);
|
|
1541
1550
|
});
|
|
@@ -1853,6 +1862,7 @@ let AssetsController = (() => {
|
|
|
1853
1862
|
async #updateState(response) {
|
|
1854
1863
|
const normalizedResponse = normalizeResponse(response);
|
|
1855
1864
|
const mode = normalizedResponse.updateMode ?? 'merge';
|
|
1865
|
+
let wroteBalances = false;
|
|
1856
1866
|
const releaseLock = await this.#controllerMutex.acquire();
|
|
1857
1867
|
try {
|
|
1858
1868
|
const previousState = this.state;
|
|
@@ -1978,24 +1988,22 @@ let AssetsController = (() => {
|
|
|
1978
1988
|
newAmount: change.newAmount,
|
|
1979
1989
|
});
|
|
1980
1990
|
}
|
|
1981
|
-
|
|
1982
|
-
if (changedPriceAssets.length > 0 && normalizedResponse.assetsPrice) {
|
|
1983
|
-
// Build prices object with only changed prices
|
|
1984
|
-
const changedPrices = {};
|
|
1985
|
-
for (const assetId of changedPriceAssets) {
|
|
1986
|
-
const price = normalizedResponse.assetsPrice[assetId];
|
|
1987
|
-
if (price) {
|
|
1988
|
-
changedPrices[assetId] = price;
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
this.messenger.publish('AssetsController:priceChanged', {
|
|
1992
|
-
prices: changedPrices,
|
|
1993
|
-
});
|
|
1994
|
-
}
|
|
1991
|
+
wroteBalances = Boolean(normalizedResponse.assetsBalance);
|
|
1995
1992
|
}
|
|
1996
1993
|
finally {
|
|
1997
1994
|
releaseLock();
|
|
1998
1995
|
}
|
|
1996
|
+
// Balances and any prices fetched for them are in state now. The price
|
|
1997
|
+
// poll reconciles itself; a price-only write does not reach here.
|
|
1998
|
+
if (wroteBalances) {
|
|
1999
|
+
await this.#priceDataSource
|
|
2000
|
+
.reconcileMarketStreams()
|
|
2001
|
+
.catch((error) => {
|
|
2002
|
+
log('Failed to reconcile market stats after balance update', {
|
|
2003
|
+
error,
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
1999
2007
|
}
|
|
2000
2008
|
#getAssetsFromState(accounts, chainIds, assetTypes) {
|
|
2001
2009
|
const result = Object.create(null);
|
|
@@ -2064,7 +2072,9 @@ let AssetsController = (() => {
|
|
|
2064
2072
|
}
|
|
2065
2073
|
const priceRaw = this.state.assetsPrice[assetId];
|
|
2066
2074
|
const price = priceRaw ?? {
|
|
2075
|
+
assetPriceType: 'fungible',
|
|
2067
2076
|
price: 0,
|
|
2077
|
+
usdPrice: 0,
|
|
2068
2078
|
lastUpdated: 0,
|
|
2069
2079
|
};
|
|
2070
2080
|
// Compute fiat value using BigNumber for precision
|