@metamask-previews/assets-controller 11.1.1-preview-7aad920a3 → 11.2.0-preview-ec4680201
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 +17 -1
- package/dist/AssetsController-method-action-types.cjs.map +1 -1
- package/dist/AssetsController-method-action-types.d.cts.map +1 -1
- package/dist/AssetsController-method-action-types.d.mts.map +1 -1
- package/dist/AssetsController-method-action-types.mjs.map +1 -1
- package/dist/AssetsController.cjs +82 -69
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +2 -2
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +2 -2
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +19 -6
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AbstractDataSource.cjs.map +1 -1
- package/dist/data-sources/AbstractDataSource.d.cts.map +1 -1
- package/dist/data-sources/AbstractDataSource.d.mts.map +1 -1
- package/dist/data-sources/AbstractDataSource.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +52 -18
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts +2 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts +2 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs +43 -9
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.cjs +6 -6
- package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
- package/dist/data-sources/PriceDataSource.cjs +33 -15
- package/dist/data-sources/PriceDataSource.cjs.map +1 -1
- package/dist/data-sources/PriceDataSource.d.cts +9 -1
- package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
- package/dist/data-sources/PriceDataSource.d.mts +9 -1
- package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
- package/dist/data-sources/PriceDataSource.mjs +20 -3
- package/dist/data-sources/PriceDataSource.mjs.map +1 -1
- package/dist/data-sources/RpcDataSource.cjs +17 -17
- package/dist/data-sources/RpcDataSource.cjs.map +1 -1
- package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
- package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
- package/dist/data-sources/RpcDataSource.mjs +1 -1
- package/dist/data-sources/RpcDataSource.mjs.map +1 -1
- package/dist/data-sources/SnapDataSource.cjs +4 -4
- package/dist/data-sources/SnapDataSource.cjs.map +1 -1
- package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
- package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
- package/dist/data-sources/SnapDataSource.mjs.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.cjs +11 -11
- package/dist/data-sources/StakedBalanceDataSource.cjs.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.d.cts.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.d.mts.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.mjs.map +1 -1
- package/dist/data-sources/TokenDataSource.cjs +12 -12
- package/dist/data-sources/TokenDataSource.cjs.map +1 -1
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
- package/dist/data-sources/TokenDataSource.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs +6 -6
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.cjs +6 -6
- package/dist/data-sources/evm-rpc-services/clients/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.cjs +13 -13
- package/dist/data-sources/evm-rpc-services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs +5 -5
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs +6 -6
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts +2 -2
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts +2 -2
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs +4 -4
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.cjs +9 -9
- package/dist/data-sources/evm-rpc-services/services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/assets.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/assets.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/assets.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/assets.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/config.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/config.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/config.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/config.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/multicall.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/multicall.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/multicall.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/multicall.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/services.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/services.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/services.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/services.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/index.cjs +11 -11
- package/dist/data-sources/evm-rpc-services/utils/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/parsing.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/parsing.mjs.map +1 -1
- package/dist/data-sources/index.cjs +23 -23
- package/dist/data-sources/index.cjs.map +1 -1
- package/dist/data-sources/index.d.cts.map +1 -1
- package/dist/data-sources/index.d.mts.map +1 -1
- package/dist/data-sources/index.mjs.map +1 -1
- package/dist/defaults.cjs.map +1 -1
- package/dist/defaults.d.cts.map +1 -1
- package/dist/defaults.d.mts.map +1 -1
- package/dist/defaults.mjs.map +1 -1
- package/dist/index.cjs +56 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.cjs +6 -6
- package/dist/middlewares/CustomAssetGraduationMiddleware.cjs.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.d.cts.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.d.mts.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.mjs.map +1 -1
- package/dist/middlewares/DetectionMiddleware.cjs +35 -20
- package/dist/middlewares/DetectionMiddleware.cjs.map +1 -1
- package/dist/middlewares/DetectionMiddleware.d.cts.map +1 -1
- package/dist/middlewares/DetectionMiddleware.d.mts.map +1 -1
- package/dist/middlewares/DetectionMiddleware.mjs +30 -15
- package/dist/middlewares/DetectionMiddleware.mjs.map +1 -1
- package/dist/middlewares/ParallelMiddleware.cjs.map +1 -1
- package/dist/middlewares/ParallelMiddleware.d.cts.map +1 -1
- package/dist/middlewares/ParallelMiddleware.d.mts.map +1 -1
- package/dist/middlewares/ParallelMiddleware.mjs.map +1 -1
- package/dist/middlewares/RpcFallbackMiddleware.cjs +6 -6
- package/dist/middlewares/RpcFallbackMiddleware.cjs.map +1 -1
- package/dist/middlewares/RpcFallbackMiddleware.d.cts.map +1 -1
- package/dist/middlewares/RpcFallbackMiddleware.d.mts.map +1 -1
- package/dist/middlewares/RpcFallbackMiddleware.mjs.map +1 -1
- package/dist/middlewares/index.cjs +10 -10
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.d.cts.map +1 -1
- package/dist/middlewares/index.d.mts.map +1 -1
- package/dist/middlewares/index.mjs.map +1 -1
- package/dist/migrations/healAssetsInfoMetadata.cjs +2 -2
- package/dist/migrations/healAssetsInfoMetadata.cjs.map +1 -1
- package/dist/migrations/healAssetsInfoMetadata.d.cts.map +1 -1
- package/dist/migrations/healAssetsInfoMetadata.d.mts.map +1 -1
- package/dist/migrations/healAssetsInfoMetadata.mjs.map +1 -1
- package/dist/selectors/balance.cjs.map +1 -1
- package/dist/selectors/balance.d.cts.map +1 -1
- package/dist/selectors/balance.d.mts.map +1 -1
- package/dist/selectors/balance.mjs.map +1 -1
- package/dist/utils/customAssetsRpcSupplement.cjs.map +1 -1
- package/dist/utils/customAssetsRpcSupplement.d.cts.map +1 -1
- package/dist/utils/customAssetsRpcSupplement.d.mts.map +1 -1
- package/dist/utils/customAssetsRpcSupplement.mjs.map +1 -1
- package/dist/utils/formatExchangeRatesForBridge.cjs.map +1 -1
- package/dist/utils/formatExchangeRatesForBridge.d.cts.map +1 -1
- package/dist/utils/formatExchangeRatesForBridge.d.mts.map +1 -1
- package/dist/utils/formatExchangeRatesForBridge.mjs.map +1 -1
- package/dist/utils/formatStateForTransactionPay.cjs +2 -2
- package/dist/utils/formatStateForTransactionPay.cjs.map +1 -1
- package/dist/utils/formatStateForTransactionPay.d.cts.map +1 -1
- package/dist/utils/formatStateForTransactionPay.d.mts.map +1 -1
- package/dist/utils/formatStateForTransactionPay.mjs.map +1 -1
- package/dist/utils/index.cjs +16 -16
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/native-assets.cjs +2 -2
- package/dist/utils/native-assets.cjs.map +1 -1
- package/dist/utils/native-assets.d.cts.map +1 -1
- package/dist/utils/native-assets.d.mts.map +1 -1
- package/dist/utils/native-assets.mjs.map +1 -1
- package/dist/utils/normalizeAssetId.cjs.map +1 -1
- package/dist/utils/normalizeAssetId.d.cts.map +1 -1
- package/dist/utils/normalizeAssetId.d.mts.map +1 -1
- package/dist/utils/normalizeAssetId.mjs.map +1 -1
- package/dist/utils/processAccountActivityBalanceUpdates.cjs.map +1 -1
- package/dist/utils/processAccountActivityBalanceUpdates.d.cts.map +1 -1
- package/dist/utils/processAccountActivityBalanceUpdates.d.mts.map +1 -1
- package/dist/utils/processAccountActivityBalanceUpdates.mjs.map +1 -1
- package/dist/utils/snaps-assets-migration.cjs +171 -0
- package/dist/utils/snaps-assets-migration.cjs.map +1 -0
- package/dist/utils/snaps-assets-migration.d.cts +113 -0
- package/dist/utils/snaps-assets-migration.d.cts.map +1 -0
- package/dist/utils/snaps-assets-migration.d.mts +113 -0
- package/dist/utils/snaps-assets-migration.d.mts.map +1 -0
- package/dist/utils/snaps-assets-migration.mjs +162 -0
- package/dist/utils/snaps-assets-migration.mjs.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Fetch spot prices immediately on price-subscription updates and after seeding native / default tracked assets so held assets are not left unpriced until the next poll after onboarding ([#9631](https://github.com/MetaMask/core/pull/9631))
|
|
13
|
+
|
|
14
|
+
## [11.2.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Add stage-gated ingestion of the Snaps → AssetsController migration networks (Solana, Stellar, Tron) ([#9534](https://github.com/MetaMask/core/pull/9534))
|
|
19
|
+
- `AssetsController` and `AccountsApiDataSource` now resolve a per-network migration stage from `RemoteFeatureFlagController` state (via `RemoteFeatureFlagController:getState`) using the `networkAssetsSnapsMigrationSolana`, `networkAssetsSnapsMigrationStellar`, and `networkAssetsSnapsMigrationTron` flags. Migration networks are only ingested and surfaced as active chains from `SnapsAssetsMigrationStage.ReadAssetsControllerWithFallback` onward, and left to the Snap when the stage is `Off` (the fail-safe when the flag is missing). Non-migration namespaces (e.g. `eip155`) are never gated.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- `AccountsApiDataSource` `forceUpdate` balance fetches now use `staleTime`/`gcTime` of `100`ms (previously `0`/`0`) so bursts of near-simultaneous forced refreshes are de-duplicated by TanStack Query into a single Accounts API request instead of one request per trigger ([#9591](https://github.com/MetaMask/core/pull/9591))
|
|
24
|
+
|
|
10
25
|
## [11.1.1]
|
|
11
26
|
|
|
12
27
|
### Changed
|
|
@@ -766,7 +781,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
766
781
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
767
782
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
768
783
|
|
|
769
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.
|
|
784
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.2.0...HEAD
|
|
785
|
+
[11.2.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.1.1...@metamask/assets-controller@11.2.0
|
|
770
786
|
[11.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.1.0...@metamask/assets-controller@11.1.1
|
|
771
787
|
[11.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.0.0...@metamask/assets-controller@11.1.0
|
|
772
788
|
[11.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@10.2.1...@metamask/assets-controller@11.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsController-method-action-types.cjs","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';\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 AssetsControllerGetAssetAction = {\n type: `AssetsController:getAsset`;\n handler: AssetsController['getAsset'];\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 *\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 *\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 | AssetsControllerGetAssetAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.cjs","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 AssetsControllerGetAssetAction = {\n type: `AssetsController:getAsset`;\n handler: AssetsController['getAsset'];\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 *\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 *\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 | AssetsControllerGetAssetAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA8B;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,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF;;;;GAIG;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,8BAA8B,GAC9B,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.d.mts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.d.mts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA8B;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,8BAA8B,GAAG;IAC3C,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,gBAAgB,CAAC,2BAA2B,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF;;;;GAIG;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,8BAA8B,GAC9B,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.mjs","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';\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 AssetsControllerGetAssetAction = {\n type: `AssetsController:getAsset`;\n handler: AssetsController['getAsset'];\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 *\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 *\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 | AssetsControllerGetAssetAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.mjs","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 AssetsControllerGetAssetAction = {\n type: `AssetsController:getAsset`;\n handler: AssetsController['getAsset'];\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 *\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 *\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 | AssetsControllerGetAssetAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
@@ -22,26 +22,26 @@ const utils_1 = require("@metamask/utils");
|
|
|
22
22
|
const async_mutex_1 = require("async-mutex");
|
|
23
23
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
24
24
|
const lodash_1 = require("lodash");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
25
|
+
const AccountsApiDataSource_js_1 = require("./data-sources/AccountsApiDataSource.cjs");
|
|
26
|
+
const BackendWebsocketDataSource_js_1 = require("./data-sources/BackendWebsocketDataSource.cjs");
|
|
27
|
+
const assets_js_1 = require("./data-sources/evm-rpc-services/utils/assets.cjs");
|
|
28
|
+
const PriceDataSource_js_1 = require("./data-sources/PriceDataSource.cjs");
|
|
29
|
+
const RpcDataSource_js_1 = require("./data-sources/RpcDataSource.cjs");
|
|
30
|
+
const SnapDataSource_js_1 = require("./data-sources/SnapDataSource.cjs");
|
|
31
|
+
const StakedBalanceDataSource_js_1 = require("./data-sources/StakedBalanceDataSource.cjs");
|
|
32
|
+
const TokenDataSource_js_1 = require("./data-sources/TokenDataSource.cjs");
|
|
33
|
+
const defaults_js_1 = require("./defaults.cjs");
|
|
34
|
+
const errors_js_1 = require("./errors.cjs");
|
|
35
|
+
const logger_js_1 = require("./logger.cjs");
|
|
36
|
+
const CustomAssetGraduationMiddleware_js_1 = require("./middlewares/CustomAssetGraduationMiddleware.cjs");
|
|
37
|
+
const DetectionMiddleware_js_1 = require("./middlewares/DetectionMiddleware.cjs");
|
|
38
|
+
const ParallelMiddleware_js_1 = require("./middlewares/ParallelMiddleware.cjs");
|
|
39
|
+
const RpcFallbackMiddleware_js_1 = require("./middlewares/RpcFallbackMiddleware.cjs");
|
|
40
|
+
const healAssetsInfoMetadata_js_1 = require("./migrations/healAssetsInfoMetadata.cjs");
|
|
41
|
+
const constants_js_1 = require("./utils/constants.cjs");
|
|
42
|
+
const customAssetsRpcSupplement_js_1 = require("./utils/customAssetsRpcSupplement.cjs");
|
|
43
|
+
const index_js_1 = require("./utils/index.cjs");
|
|
44
|
+
const processAccountActivityBalanceUpdates_js_1 = require("./utils/processAccountActivityBalanceUpdates.cjs");
|
|
45
45
|
const NATIVE_ASSETS_QUERY_KEY = ['nativeAssets'];
|
|
46
46
|
/** Stable empty map so memoized formatters are not busted by `?? {}` identity churn. */
|
|
47
47
|
const EMPTY_NATIVE_ASSET_MAP = {};
|
|
@@ -77,7 +77,7 @@ const TRACE_DATA_SOURCE_ERROR = 'AssetsDataSourceError';
|
|
|
77
77
|
const TRACE_UPDATE_PIPELINE = 'AssetsUpdatePipeline';
|
|
78
78
|
const TRACE_SUBSCRIPTION_ERROR = 'AssetsSubscriptionError';
|
|
79
79
|
const TRACE_STATE_SIZE = 'AssetsStateSize';
|
|
80
|
-
const log = (0,
|
|
80
|
+
const log = (0, logger_js_1.createModuleLogger)(logger_js_1.projectLogger, CONTROLLER_NAME);
|
|
81
81
|
/**
|
|
82
82
|
* Returns the default state for AssetsController.
|
|
83
83
|
*
|
|
@@ -92,7 +92,7 @@ function getDefaultAssetsControllerState() {
|
|
|
92
92
|
// immediately renderable in the UI before any RPC poll completes.
|
|
93
93
|
// Per-account zero-balance entries are filled into `assetsBalance`
|
|
94
94
|
// by `#ensureDefaultTrackedAssetsSeeded` once accounts are known.
|
|
95
|
-
assetsInfo: (0,
|
|
95
|
+
assetsInfo: (0, defaults_js_1.buildDefaultAssetsInfo)(),
|
|
96
96
|
assetsBalance: {},
|
|
97
97
|
assetsPrice: {},
|
|
98
98
|
customAssets: {},
|
|
@@ -162,14 +162,14 @@ function normalizeResponse(response) {
|
|
|
162
162
|
if (response.assetsInfo) {
|
|
163
163
|
normalized.assetsInfo = {};
|
|
164
164
|
for (const [assetId, metadata] of Object.entries(response.assetsInfo)) {
|
|
165
|
-
const normalizedId = (0,
|
|
165
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
166
166
|
normalized.assetsInfo[normalizedId] = metadata;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
if (response.assetsPrice) {
|
|
170
170
|
normalized.assetsPrice = {};
|
|
171
171
|
for (const [assetId, price] of Object.entries(response.assetsPrice)) {
|
|
172
|
-
const normalizedId = (0,
|
|
172
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
173
173
|
normalized.assetsPrice[normalizedId] = price;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -178,7 +178,7 @@ function normalizeResponse(response) {
|
|
|
178
178
|
for (const [accountId, balances] of Object.entries(response.assetsBalance)) {
|
|
179
179
|
normalized.assetsBalance[accountId] = {};
|
|
180
180
|
for (const [assetId, balance] of Object.entries(balances)) {
|
|
181
|
-
const normalizedId = (0,
|
|
181
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
182
182
|
normalized.assetsBalance[accountId][normalizedId] = balance;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -187,7 +187,7 @@ function normalizeResponse(response) {
|
|
|
187
187
|
if (response.detectedAssets) {
|
|
188
188
|
normalized.detectedAssets = {};
|
|
189
189
|
for (const [accountId, assetIds] of Object.entries(response.detectedAssets)) {
|
|
190
|
-
normalized.detectedAssets[accountId] = assetIds.map((assetId) => (0,
|
|
190
|
+
normalized.detectedAssets[accountId] = assetIds.map((assetId) => (0, index_js_1.normalizeAssetId)(assetId));
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
// Preserve errors (chain IDs don't need normalization)
|
|
@@ -333,7 +333,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
333
333
|
// TEMPORARY: heal assetsInfo metadata wiped by a prior defect
|
|
334
334
|
// (see extension migration #215 / ASSETS-3346). Remove in a future release.
|
|
335
335
|
if (tempMigrateAssetsInfoMetadataAssets3346) {
|
|
336
|
-
this.update(() => (0,
|
|
336
|
+
this.update(() => (0, healAssetsInfoMetadata_js_1.tempHealAssetsInfoMetadata)({
|
|
337
337
|
state: this.state,
|
|
338
338
|
getMigrationState: tempMigrateAssetsInfoMetadataAssets3346,
|
|
339
339
|
captureException,
|
|
@@ -351,27 +351,27 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
}, "f");
|
|
354
|
-
__classPrivateFieldSet(this, _AssetsController_backendWebsocketDataSource, new
|
|
354
|
+
__classPrivateFieldSet(this, _AssetsController_backendWebsocketDataSource, new BackendWebsocketDataSource_js_1.BackendWebsocketDataSource({
|
|
355
355
|
messenger: this.messenger,
|
|
356
356
|
queryApiClient,
|
|
357
357
|
onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
|
|
358
358
|
getAssetType: (assetId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetType).call(this, assetId),
|
|
359
359
|
}), "f");
|
|
360
|
-
__classPrivateFieldSet(this, _AssetsController_accountsApiDataSource, new
|
|
360
|
+
__classPrivateFieldSet(this, _AssetsController_accountsApiDataSource, new AccountsApiDataSource_js_1.AccountsApiDataSource({
|
|
361
361
|
messenger: this.messenger,
|
|
362
362
|
queryApiClient,
|
|
363
363
|
onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
|
|
364
364
|
...accountsApiDataSourceConfig,
|
|
365
365
|
}), "f");
|
|
366
|
-
__classPrivateFieldSet(this, _AssetsController_snapDataSource, new
|
|
366
|
+
__classPrivateFieldSet(this, _AssetsController_snapDataSource, new SnapDataSource_js_1.SnapDataSource({
|
|
367
367
|
messenger: this.messenger,
|
|
368
368
|
onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
|
|
369
369
|
}), "f");
|
|
370
|
-
__classPrivateFieldSet(this, _AssetsController_rpcDataSource, new
|
|
370
|
+
__classPrivateFieldSet(this, _AssetsController_rpcDataSource, new RpcDataSource_js_1.RpcDataSource({
|
|
371
371
|
messenger: this.messenger,
|
|
372
372
|
onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
|
|
373
373
|
getNativeAssetForChain: (chainId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getNativeAssetMap).call(this)[chainId] ??
|
|
374
|
-
`${chainId}/erc20:${
|
|
374
|
+
`${chainId}/erc20:${constants_js_1.ZERO_ADDRESS}`,
|
|
375
375
|
// Share the API platform's TanStack Query client so the RPC token
|
|
376
376
|
// detector caches/dedupes its top-token-list fetches alongside the rest
|
|
377
377
|
// of the package's API calls. Caller-provided rpcConfig.queryClient
|
|
@@ -381,25 +381,25 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
381
381
|
isOnboarded: rpcConfig.isOnboarded ?? isOnboarded,
|
|
382
382
|
getAssetType: (assetId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetType).call(this, assetId),
|
|
383
383
|
}), "f");
|
|
384
|
-
__classPrivateFieldSet(this, _AssetsController_stakedBalanceDataSource, new
|
|
384
|
+
__classPrivateFieldSet(this, _AssetsController_stakedBalanceDataSource, new StakedBalanceDataSource_js_1.StakedBalanceDataSource({
|
|
385
385
|
messenger: this.messenger,
|
|
386
386
|
onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
|
|
387
387
|
...stakedBalanceDataSourceConfig,
|
|
388
388
|
}), "f");
|
|
389
|
-
__classPrivateFieldSet(this, _AssetsController_tokenDataSource, new
|
|
389
|
+
__classPrivateFieldSet(this, _AssetsController_tokenDataSource, new TokenDataSource_js_1.TokenDataSource(this.messenger, {
|
|
390
390
|
queryApiClient,
|
|
391
391
|
getNativeAssetIds: () => {
|
|
392
392
|
return __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getNativeAssetIdsForEnabledChains).call(this);
|
|
393
393
|
},
|
|
394
394
|
getAssetType: (assetId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetType).call(this, assetId),
|
|
395
395
|
}), "f");
|
|
396
|
-
__classPrivateFieldSet(this, _AssetsController_priceDataSource, new
|
|
396
|
+
__classPrivateFieldSet(this, _AssetsController_priceDataSource, new PriceDataSource_js_1.PriceDataSource({
|
|
397
397
|
queryApiClient,
|
|
398
398
|
getSelectedCurrency: () => this.state.selectedCurrency,
|
|
399
399
|
...priceDataSourceConfig,
|
|
400
400
|
}), "f");
|
|
401
|
-
__classPrivateFieldSet(this, _AssetsController_detectionMiddleware, new
|
|
402
|
-
__classPrivateFieldSet(this, _AssetsController_customAssetGraduationMiddleware, new
|
|
401
|
+
__classPrivateFieldSet(this, _AssetsController_detectionMiddleware, new DetectionMiddleware_js_1.DetectionMiddleware(), "f");
|
|
402
|
+
__classPrivateFieldSet(this, _AssetsController_customAssetGraduationMiddleware, new CustomAssetGraduationMiddleware_js_1.CustomAssetGraduationMiddleware({
|
|
403
403
|
getSelectedAccountId: () => {
|
|
404
404
|
try {
|
|
405
405
|
return __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this)[0]?.id;
|
|
@@ -410,7 +410,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
410
410
|
},
|
|
411
411
|
removeCustomAsset: (accountId, assetId) => this.removeCustomAsset(accountId, assetId),
|
|
412
412
|
}), "f");
|
|
413
|
-
__classPrivateFieldSet(this, _AssetsController_rpcFallbackMiddleware, new
|
|
413
|
+
__classPrivateFieldSet(this, _AssetsController_rpcFallbackMiddleware, new RpcFallbackMiddleware_js_1.RpcFallbackMiddleware({
|
|
414
414
|
rpcDataSource: __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f"),
|
|
415
415
|
}), "f");
|
|
416
416
|
log('Initializing AssetsController', {
|
|
@@ -473,7 +473,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
473
473
|
// is returned). Balances present in the response are still refreshed.
|
|
474
474
|
const fastSources = __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
475
475
|
? [
|
|
476
|
-
(0,
|
|
476
|
+
(0, ParallelMiddleware_js_1.createParallelBalanceMiddleware)([
|
|
477
477
|
__classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f"),
|
|
478
478
|
__classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"),
|
|
479
479
|
]),
|
|
@@ -483,7 +483,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
483
483
|
__classPrivateFieldGet(this, _AssetsController_customAssetGraduationMiddleware, "f"),
|
|
484
484
|
__classPrivateFieldGet(this, _AssetsController_rpcFallbackMiddleware, "f"),
|
|
485
485
|
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
486
|
-
(0,
|
|
486
|
+
(0, ParallelMiddleware_js_1.createParallelMiddleware)([
|
|
487
487
|
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
488
488
|
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
489
489
|
]),
|
|
@@ -506,11 +506,11 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
506
506
|
: [__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")];
|
|
507
507
|
const slowRequest = { ...request, chainIds: slowPipelineChainIds };
|
|
508
508
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, [
|
|
509
|
-
(0,
|
|
509
|
+
(0, ParallelMiddleware_js_1.createParallelBalanceMiddleware)(slowSources),
|
|
510
510
|
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
511
511
|
...(__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
512
512
|
? [
|
|
513
|
-
(0,
|
|
513
|
+
(0, ParallelMiddleware_js_1.createParallelMiddleware)([
|
|
514
514
|
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
515
515
|
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
516
516
|
]),
|
|
@@ -594,7 +594,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
594
594
|
}
|
|
595
595
|
let normalizedAssetId;
|
|
596
596
|
try {
|
|
597
|
-
normalizedAssetId = (0,
|
|
597
|
+
normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
598
598
|
}
|
|
599
599
|
catch {
|
|
600
600
|
throw new Error(`AssetsController.getAsset: invalid CAIP-19 assetId "${assetId}"`);
|
|
@@ -632,7 +632,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
632
632
|
*/
|
|
633
633
|
getExchangeRatesForBridge() {
|
|
634
634
|
const { networkConfigurationsByChainId } = this.messenger.call('NetworkController:getState');
|
|
635
|
-
return (0,
|
|
635
|
+
return (0, index_js_1.formatExchangeRatesForBridge)({
|
|
636
636
|
assetsInfo: this.state.assetsInfo,
|
|
637
637
|
assetsPrice: this.state.assetsPrice,
|
|
638
638
|
selectedCurrency: this.state.selectedCurrency,
|
|
@@ -652,7 +652,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
652
652
|
getStateForTransactionPay() {
|
|
653
653
|
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
654
654
|
const { networkConfigurationsByChainId } = this.messenger.call('NetworkController:getState');
|
|
655
|
-
return (0,
|
|
655
|
+
return (0, index_js_1.formatStateForTransactionPay)({
|
|
656
656
|
assetsBalance: this.state.assetsBalance,
|
|
657
657
|
assetsInfo: this.state.assetsInfo,
|
|
658
658
|
assetsPrice: this.state.assetsPrice,
|
|
@@ -679,7 +679,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
679
679
|
* @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).
|
|
680
680
|
*/
|
|
681
681
|
async addCustomAsset(accountId, assetId, pendingMetadata) {
|
|
682
|
-
const normalizedAssetId = (0,
|
|
682
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
683
683
|
log('Adding custom asset', { accountId, assetId: normalizedAssetId });
|
|
684
684
|
this.update((state) => {
|
|
685
685
|
var _a;
|
|
@@ -707,7 +707,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
707
707
|
tokenType = 'native';
|
|
708
708
|
}
|
|
709
709
|
else if (parsed.chain.namespace === utils_1.KnownCaipNamespace.Solana &&
|
|
710
|
-
parsed.assetNamespace ===
|
|
710
|
+
parsed.assetNamespace === TokenDataSource_js_1.CaipAssetNamespace.Token) {
|
|
711
711
|
tokenType = 'spl';
|
|
712
712
|
}
|
|
713
713
|
const assetMetadata = {
|
|
@@ -751,7 +751,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
751
751
|
* @param assetId - The CAIP-19 asset ID to remove.
|
|
752
752
|
*/
|
|
753
753
|
removeCustomAsset(accountId, assetId) {
|
|
754
|
-
const normalizedAssetId = (0,
|
|
754
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
755
755
|
log('Removing custom asset', { accountId, assetId: normalizedAssetId });
|
|
756
756
|
this.update((state) => {
|
|
757
757
|
if (state.customAssets[accountId]) {
|
|
@@ -786,7 +786,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
786
786
|
* @param assetId - The CAIP-19 asset ID to hide.
|
|
787
787
|
*/
|
|
788
788
|
hideAsset(assetId) {
|
|
789
|
-
const normalizedAssetId = (0,
|
|
789
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
790
790
|
log('Hiding asset', { assetId: normalizedAssetId });
|
|
791
791
|
this.update((state) => {
|
|
792
792
|
if (!state.assetPreferences[normalizedAssetId]) {
|
|
@@ -801,7 +801,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
801
801
|
* @param assetId - The CAIP-19 asset ID to unhide.
|
|
802
802
|
*/
|
|
803
803
|
unhideAsset(assetId) {
|
|
804
|
-
const normalizedAssetId = (0,
|
|
804
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
805
805
|
log('Unhiding asset', { assetId: normalizedAssetId });
|
|
806
806
|
this.update((state) => {
|
|
807
807
|
const prefs = state.assetPreferences[normalizedAssetId];
|
|
@@ -953,7 +953,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
953
953
|
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
954
954
|
];
|
|
955
955
|
if (__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
|
|
956
|
-
enrichmentSources.push((0,
|
|
956
|
+
enrichmentSources.push((0, ParallelMiddleware_js_1.createParallelMiddleware)([
|
|
957
957
|
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
958
958
|
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
959
959
|
]));
|
|
@@ -1078,7 +1078,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1078
1078
|
queryApiClient.queryClient
|
|
1079
1079
|
.fetchQuery({
|
|
1080
1080
|
queryKey: NATIVE_ASSETS_QUERY_KEY,
|
|
1081
|
-
queryFn:
|
|
1081
|
+
queryFn: index_js_1.buildNativeAssetsFromApi,
|
|
1082
1082
|
staleTime: Infinity,
|
|
1083
1083
|
gcTime: Infinity,
|
|
1084
1084
|
})
|
|
@@ -1091,7 +1091,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1091
1091
|
// #isNativeAsset, #resolveNativeAssetIds) have data available immediately.
|
|
1092
1092
|
// When fetchQuery resolves (currently instant, future: API), it overwrites
|
|
1093
1093
|
// this with potentially fresher data.
|
|
1094
|
-
const initialNativeAssetMap = (0,
|
|
1094
|
+
const initialNativeAssetMap = (0, index_js_1.buildNativeAssetsFromConstant)();
|
|
1095
1095
|
queryApiClient.setCachedData(NATIVE_ASSETS_QUERY_KEY, initialNativeAssetMap);
|
|
1096
1096
|
}, _AssetsController_initializeState = function _AssetsController_initializeState() {
|
|
1097
1097
|
const { enabledNetworkMap } = this.messenger.call('NetworkEnablementController:getState');
|
|
@@ -1244,7 +1244,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1244
1244
|
return;
|
|
1245
1245
|
}
|
|
1246
1246
|
const chainId = chain;
|
|
1247
|
-
const response = (0,
|
|
1247
|
+
const response = (0, processAccountActivityBalanceUpdates_js_1.processAccountActivityBalanceUpdates)(updates, account.id, (assetId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetType).call(this, assetId));
|
|
1248
1248
|
if (!response.assetsBalance) {
|
|
1249
1249
|
return;
|
|
1250
1250
|
}
|
|
@@ -1310,10 +1310,12 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1310
1310
|
forceUpdate: true,
|
|
1311
1311
|
});
|
|
1312
1312
|
}
|
|
1313
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1313
1314
|
}
|
|
1314
1315
|
catch (error) {
|
|
1315
1316
|
log('Failed to fetch assets after tree change', error);
|
|
1316
1317
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1318
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1317
1319
|
}
|
|
1318
1320
|
finally {
|
|
1319
1321
|
releaseLock();
|
|
@@ -1331,15 +1333,19 @@ async function _AssetsController_runStartupRefresh(accounts) {
|
|
|
1331
1333
|
chainIds: [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")],
|
|
1332
1334
|
forceUpdate: true,
|
|
1333
1335
|
});
|
|
1334
|
-
|
|
1336
|
+
// Seed before subscribe so the price poll / update fetch sees natives
|
|
1337
|
+
// and default tracked assets that were never returned by balance APIs.
|
|
1335
1338
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1336
1339
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1340
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1341
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1337
1342
|
}
|
|
1338
1343
|
catch (error) {
|
|
1339
1344
|
log('Failed to fetch assets on startup', error);
|
|
1340
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1341
1345
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1342
1346
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1347
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1348
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1343
1349
|
}
|
|
1344
1350
|
finally {
|
|
1345
1351
|
releaseLock();
|
|
@@ -1435,7 +1441,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1435
1441
|
// Failed middlewares: Issues (optional) + perf/Dashboard spans
|
|
1436
1442
|
if (middlewareErrors.length > 0) {
|
|
1437
1443
|
const failedSources = middlewareErrors.join(',');
|
|
1438
|
-
const assetsError = new
|
|
1444
|
+
const assetsError = new errors_js_1.AssetsDataSourceError({
|
|
1439
1445
|
failedSources,
|
|
1440
1446
|
errorCount: middlewareErrors.length,
|
|
1441
1447
|
chainCount: request.chainIds.length,
|
|
@@ -1473,10 +1479,13 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1473
1479
|
if (!chainFilter.has(assetId.split('/')[0])) {
|
|
1474
1480
|
continue;
|
|
1475
1481
|
}
|
|
1476
|
-
const normalizedAssetId = (0,
|
|
1482
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
1477
1483
|
if (prices[normalizedAssetId] ?? prices[assetId]) {
|
|
1478
1484
|
continue;
|
|
1479
1485
|
}
|
|
1486
|
+
if (!(0, PriceDataSource_js_1.isPriceableAsset)(normalizedAssetId)) {
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1480
1489
|
assetsForPriceUpdate.push(normalizedAssetId);
|
|
1481
1490
|
}
|
|
1482
1491
|
}
|
|
@@ -1505,7 +1514,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1505
1514
|
return true;
|
|
1506
1515
|
}
|
|
1507
1516
|
if (parsed.assetNamespace === 'erc20' &&
|
|
1508
|
-
parsed.assetReference ===
|
|
1517
|
+
parsed.assetReference === constants_js_1.ZERO_ADDRESS) {
|
|
1509
1518
|
return true;
|
|
1510
1519
|
}
|
|
1511
1520
|
return false;
|
|
@@ -1515,7 +1524,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1515
1524
|
return 'native';
|
|
1516
1525
|
}
|
|
1517
1526
|
if (parsed.chain.namespace === utils_1.KnownCaipNamespace.Solana &&
|
|
1518
|
-
parsed.assetNamespace ===
|
|
1527
|
+
parsed.assetNamespace === TokenDataSource_js_1.CaipAssetNamespace.Token) {
|
|
1519
1528
|
return 'spl';
|
|
1520
1529
|
}
|
|
1521
1530
|
return 'erc20';
|
|
@@ -1584,7 +1593,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1584
1593
|
// enabled at startup) but only appears on Monad once the user
|
|
1585
1594
|
// turns the Monad network on.
|
|
1586
1595
|
const candidateChains = chainsToSeed ?? [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")];
|
|
1587
|
-
const targetChains = candidateChains.filter((chainId) =>
|
|
1596
|
+
const targetChains = candidateChains.filter((chainId) => defaults_js_1.CHAINS_WITH_DEFAULT_TRACKED_ASSETS.has(chainId));
|
|
1588
1597
|
if (targetChains.length === 0) {
|
|
1589
1598
|
return;
|
|
1590
1599
|
}
|
|
@@ -1593,12 +1602,12 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1593
1602
|
const balances = state.assetsBalance;
|
|
1594
1603
|
const metadata = state.assetsInfo;
|
|
1595
1604
|
for (const chainId of targetChains) {
|
|
1596
|
-
const defaultAssetIds =
|
|
1605
|
+
const defaultAssetIds = defaults_js_1.DEFAULT_TRACKED_ASSETS_BY_CHAIN.get(chainId) ?? [];
|
|
1597
1606
|
for (const assetId of defaultAssetIds) {
|
|
1598
1607
|
// Re-seed metadata if state was hydrated from a prior version
|
|
1599
1608
|
// that didn't include defaults.
|
|
1600
1609
|
if (!metadata[assetId]) {
|
|
1601
|
-
const seed = (0,
|
|
1610
|
+
const seed = (0, defaults_js_1.getDefaultAssetMetadata)(assetId);
|
|
1602
1611
|
if (seed) {
|
|
1603
1612
|
metadata[assetId] = seed;
|
|
1604
1613
|
}
|
|
@@ -1701,7 +1710,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1701
1710
|
// exponent form is rewritten) so balances arriving before
|
|
1702
1711
|
// their metadata aren't lossily truncated.
|
|
1703
1712
|
const assetDecimals = metadata[assetId]?.decimals;
|
|
1704
|
-
const newAmount = (0,
|
|
1713
|
+
const newAmount = (0, index_js_1.normalizeAmountString)(balance.amount, assetDecimals);
|
|
1705
1714
|
effective[assetId] = { ...balance, amount: newAmount };
|
|
1706
1715
|
const oldAmount = previousBalance?.amount;
|
|
1707
1716
|
const isNewDefaultNativeZero = oldAmount === undefined &&
|
|
@@ -1856,7 +1865,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1856
1865
|
};
|
|
1857
1866
|
}, _AssetsController_shouldHideNativeToken = function _AssetsController_shouldHideNativeToken(chainId, metadata) {
|
|
1858
1867
|
// Check if it's a chain that should skip native tokens
|
|
1859
|
-
if (!(0,
|
|
1868
|
+
if (!(0, assets_js_1.shouldSkipNativeForCaipChainId)(chainId)) {
|
|
1860
1869
|
return false;
|
|
1861
1870
|
}
|
|
1862
1871
|
return metadata.type === 'native';
|
|
@@ -1989,7 +1998,7 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1989
1998
|
}, _AssetsController_subscribeRpcCustomAssetsSupplement = function _AssetsController_subscribeRpcCustomAssetsSupplement(accounts, chainToAccounts, rpcAssignedChains) {
|
|
1990
1999
|
const rpc = __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f");
|
|
1991
2000
|
const supplementalKey = `ds:${rpc.getName()}:custom`;
|
|
1992
|
-
const decision = (0,
|
|
2001
|
+
const decision = (0, customAssetsRpcSupplement_js_1.pickRpcCustomAssetsSupplement)({
|
|
1993
2002
|
accountIds: accounts.map((account) => account.id),
|
|
1994
2003
|
customAssetsByAccount: this.state.customAssets,
|
|
1995
2004
|
rpcAssignedChains,
|
|
@@ -2169,10 +2178,11 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
2169
2178
|
forceUpdate: true,
|
|
2170
2179
|
});
|
|
2171
2180
|
}
|
|
2172
|
-
// Subscribe after fetch so WS notifications can recover state
|
|
2173
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
2174
2181
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
2175
2182
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
2183
|
+
// Subscribe after seed so the price poll sees natives / defaults.
|
|
2184
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
2185
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
2176
2186
|
}
|
|
2177
2187
|
finally {
|
|
2178
2188
|
releaseLock();
|
|
@@ -2221,6 +2231,7 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
2221
2231
|
if (addedChains.length > 0) {
|
|
2222
2232
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this, addedChains);
|
|
2223
2233
|
}
|
|
2234
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
2224
2235
|
}, _AssetsController_handleNetworkAdded = function _AssetsController_handleNetworkAdded(hexChainId) {
|
|
2225
2236
|
let caipChainId;
|
|
2226
2237
|
try {
|
|
@@ -2229,7 +2240,7 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
2229
2240
|
catch {
|
|
2230
2241
|
return;
|
|
2231
2242
|
}
|
|
2232
|
-
if (!
|
|
2243
|
+
if (!defaults_js_1.CHAINS_WITH_DEFAULT_TRACKED_ASSETS.has(caipChainId)) {
|
|
2233
2244
|
return;
|
|
2234
2245
|
}
|
|
2235
2246
|
log('Network added — seeding default tracked assets', {
|
|
@@ -2237,6 +2248,8 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
2237
2248
|
caipChainId,
|
|
2238
2249
|
});
|
|
2239
2250
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this, [caipChainId]);
|
|
2251
|
+
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
2252
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [caipChainId]);
|
|
2240
2253
|
}, _AssetsController_refreshActiveChainsOnNetworkSwitch =
|
|
2241
2254
|
/**
|
|
2242
2255
|
* Refresh data-source `activeChains` after an EVM network switch so API/WS/Rpc
|