@metamask-previews/assets-controller 12.0.0-preview-d2f661012 → 13.1.0-preview-5a03e1b92
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 +31 -1
- package/dist/AssetsController-method-action-types.cjs.map +1 -1
- package/dist/AssetsController-method-action-types.d.cts +45 -4
- package/dist/AssetsController-method-action-types.d.cts.map +1 -1
- package/dist/AssetsController-method-action-types.d.mts +45 -4
- 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 +89 -14
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +38 -2
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +38 -2
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +89 -14
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/RpcDataSource.cjs +10 -2
- 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 +11 -3
- package/dist/data-sources/RpcDataSource.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs +9 -4
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts +16 -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 +16 -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 +9 -4
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Bump `@metamask/phishing-controller` from `^17.3.0` to `^17.3.1` ([#9746](https://github.com/MetaMask/core/pull/9746))
|
|
13
|
+
|
|
14
|
+
## [13.1.0]
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Add Somnia (`5031`/`0x13a7`) in `MulticallClient` ([#9665](https://github.com/MetaMask/core/pull/9665))
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Bump `@metamask/assets-controllers` from `^110.0.3` to `^110.1.0` ([#9743](https://github.com/MetaMask/core/pull/9743))
|
|
23
|
+
|
|
24
|
+
## [13.0.0]
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Add `getAccountAssetsByIDs(accountId, assetIds)` and `getAccountAssetsByScope(accountId, scope)` methods to look up several of an account's assets in one call — by a list of CAIP-19 asset IDs or by a CAIP-2 chain scope (e.g. `eip155:1`). Both return a record of combined `Asset`s keyed by CAIP-19 asset ID, omitting assets that are not renderable (missing balance/metadata, or hidden). ([#9738](https://github.com/MetaMask/core/pull/9738))
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- **BREAKING:** Rename `getAsset` to `getAccountAssetByID` ([#9738](https://github.com/MetaMask/core/pull/9738))
|
|
33
|
+
- **BREAKING:** `AssetsControllerMessenger` now requires the `ConfigRegistryController:getNetworkConfigByCaip2ChainId` action to be delegated ([#9717](https://github.com/MetaMask/core/pull/9717))
|
|
34
|
+
- `AssetsController` now uses `ConfigRegistryController:getNetworkConfigByCaip2ChainId` to resolve the multicall3 contract address using `@metamask/config-registry-controller` as primary source, falling back to `MulticallClient`'s hardcoded default addresses for known chains.
|
|
35
|
+
- Bump `@metamask/config-registry-controller` from `^1.0.1` to `^2.0.0` ([#9740](https://github.com/MetaMask/core/pull/9740))
|
|
36
|
+
- Bump `@metamask/network-enablement-controller` from `^6.0.1` to `^6.0.2` ([#9740](https://github.com/MetaMask/core/pull/9740))
|
|
37
|
+
|
|
10
38
|
## [12.0.0]
|
|
11
39
|
|
|
12
40
|
### Changed
|
|
@@ -834,7 +862,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
834
862
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
835
863
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
836
864
|
|
|
837
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@
|
|
865
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@13.1.0...HEAD
|
|
866
|
+
[13.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@13.0.0...@metamask/assets-controller@13.1.0
|
|
867
|
+
[13.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@12.0.0...@metamask/assets-controller@13.0.0
|
|
838
868
|
[12.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.3.1...@metamask/assets-controller@12.0.0
|
|
839
869
|
[11.3.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.3.0...@metamask/assets-controller@11.3.1
|
|
840
870
|
[11.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.2.1...@metamask/assets-controller@11.3.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.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
|
|
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 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 *\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 | AssetsControllerGetAccountAssetByIDAction\n | AssetsControllerGetAccountAssetsByIDsAction\n | AssetsControllerGetAccountAssetsByScopeAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
@@ -33,9 +33,50 @@ export type AssetsControllerGetAssetMetadataAction = {
|
|
|
33
33
|
* renderable asset (balance + metadata) exists for the account/asset pair.
|
|
34
34
|
* @throws If `accountId` is empty or `assetId` is not a valid CAIP-19 asset ID.
|
|
35
35
|
*/
|
|
36
|
-
export type
|
|
37
|
-
type: `AssetsController:
|
|
38
|
-
handler: AssetsController['
|
|
36
|
+
export type AssetsControllerGetAccountAssetByIDAction = {
|
|
37
|
+
type: `AssetsController:getAccountAssetByID`;
|
|
38
|
+
handler: AssetsController['getAccountAssetByID'];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get multiple combined assets (balance + metadata + price + computed
|
|
42
|
+
* `fiatValue`) for an account directly from controller state.
|
|
43
|
+
*
|
|
44
|
+
* Applies the same state-composition and filtering rules as
|
|
45
|
+
* `getAccountAssetByID` to each requested asset ID. Asset IDs that do not
|
|
46
|
+
* resolve to a complete renderable asset (missing balance/metadata, hidden,
|
|
47
|
+
* or otherwise filtered out) are omitted from the result. Reads from
|
|
48
|
+
* current state only and does not trigger a data-source refresh.
|
|
49
|
+
*
|
|
50
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
51
|
+
* @param assetIds - The CAIP-19 asset IDs including chain scope
|
|
52
|
+
* (e.g. `eip155:1/erc20:0x...`).
|
|
53
|
+
* @returns A record of combined `Asset`s keyed by normalized CAIP-19 asset
|
|
54
|
+
* ID, containing only the requested assets that resolved.
|
|
55
|
+
* @throws If `accountId` is empty or any `assetIds` entry is not a valid
|
|
56
|
+
* CAIP-19 asset ID.
|
|
57
|
+
*/
|
|
58
|
+
export type AssetsControllerGetAccountAssetsByIDsAction = {
|
|
59
|
+
type: `AssetsController:getAccountAssetsByIDs`;
|
|
60
|
+
handler: AssetsController['getAccountAssetsByIDs'];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Get all combined assets (balance + metadata + price + computed
|
|
64
|
+
* `fiatValue`) an account holds on a given chain scope, directly from
|
|
65
|
+
* controller state.
|
|
66
|
+
*
|
|
67
|
+
* Applies the same state-composition and filtering rules as
|
|
68
|
+
* `getAccountAssetByID` (hidden or otherwise filtered assets are excluded).
|
|
69
|
+
* Reads from current state only and does not trigger a data-source refresh.
|
|
70
|
+
*
|
|
71
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
72
|
+
* @param scope - The CAIP-2 chain ID to filter by (e.g. `eip155:1`).
|
|
73
|
+
* @returns A record of combined `Asset`s keyed by CAIP-19 asset ID,
|
|
74
|
+
* containing only the account's assets on the given scope.
|
|
75
|
+
* @throws If `accountId` is empty or `scope` is not a valid CAIP-2 chain ID.
|
|
76
|
+
*/
|
|
77
|
+
export type AssetsControllerGetAccountAssetsByScopeAction = {
|
|
78
|
+
type: `AssetsController:getAccountAssetsByScope`;
|
|
79
|
+
handler: AssetsController['getAccountAssetsByScope'];
|
|
39
80
|
};
|
|
40
81
|
export type AssetsControllerGetAssetsPriceAction = {
|
|
41
82
|
type: `AssetsController:getAssetsPrice`;
|
|
@@ -136,5 +177,5 @@ export type AssetsControllerSetSelectedCurrencyAction = {
|
|
|
136
177
|
/**
|
|
137
178
|
* Union of all AssetsController action types.
|
|
138
179
|
*/
|
|
139
|
-
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction |
|
|
180
|
+
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAccountAssetByIDAction | AssetsControllerGetAccountAssetsByIDsAction | AssetsControllerGetAccountAssetsByScopeAction | AssetsControllerGetAssetsPriceAction | AssetsControllerGetExchangeRatesForBridgeAction | AssetsControllerGetStateForTransactionPayAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction | AssetsControllerSetSelectedCurrencyAction;
|
|
140
181
|
//# sourceMappingURL=AssetsController-method-action-types.d.cts.map
|
|
@@ -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,+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,
|
|
1
|
+
{"version":3,"file":"AssetsController-method-action-types.d.cts","sourceRoot":"","sources":["../src/AssetsController-method-action-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -33,9 +33,50 @@ export type AssetsControllerGetAssetMetadataAction = {
|
|
|
33
33
|
* renderable asset (balance + metadata) exists for the account/asset pair.
|
|
34
34
|
* @throws If `accountId` is empty or `assetId` is not a valid CAIP-19 asset ID.
|
|
35
35
|
*/
|
|
36
|
-
export type
|
|
37
|
-
type: `AssetsController:
|
|
38
|
-
handler: AssetsController['
|
|
36
|
+
export type AssetsControllerGetAccountAssetByIDAction = {
|
|
37
|
+
type: `AssetsController:getAccountAssetByID`;
|
|
38
|
+
handler: AssetsController['getAccountAssetByID'];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get multiple combined assets (balance + metadata + price + computed
|
|
42
|
+
* `fiatValue`) for an account directly from controller state.
|
|
43
|
+
*
|
|
44
|
+
* Applies the same state-composition and filtering rules as
|
|
45
|
+
* `getAccountAssetByID` to each requested asset ID. Asset IDs that do not
|
|
46
|
+
* resolve to a complete renderable asset (missing balance/metadata, hidden,
|
|
47
|
+
* or otherwise filtered out) are omitted from the result. Reads from
|
|
48
|
+
* current state only and does not trigger a data-source refresh.
|
|
49
|
+
*
|
|
50
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
51
|
+
* @param assetIds - The CAIP-19 asset IDs including chain scope
|
|
52
|
+
* (e.g. `eip155:1/erc20:0x...`).
|
|
53
|
+
* @returns A record of combined `Asset`s keyed by normalized CAIP-19 asset
|
|
54
|
+
* ID, containing only the requested assets that resolved.
|
|
55
|
+
* @throws If `accountId` is empty or any `assetIds` entry is not a valid
|
|
56
|
+
* CAIP-19 asset ID.
|
|
57
|
+
*/
|
|
58
|
+
export type AssetsControllerGetAccountAssetsByIDsAction = {
|
|
59
|
+
type: `AssetsController:getAccountAssetsByIDs`;
|
|
60
|
+
handler: AssetsController['getAccountAssetsByIDs'];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Get all combined assets (balance + metadata + price + computed
|
|
64
|
+
* `fiatValue`) an account holds on a given chain scope, directly from
|
|
65
|
+
* controller state.
|
|
66
|
+
*
|
|
67
|
+
* Applies the same state-composition and filtering rules as
|
|
68
|
+
* `getAccountAssetByID` (hidden or otherwise filtered assets are excluded).
|
|
69
|
+
* Reads from current state only and does not trigger a data-source refresh.
|
|
70
|
+
*
|
|
71
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
72
|
+
* @param scope - The CAIP-2 chain ID to filter by (e.g. `eip155:1`).
|
|
73
|
+
* @returns A record of combined `Asset`s keyed by CAIP-19 asset ID,
|
|
74
|
+
* containing only the account's assets on the given scope.
|
|
75
|
+
* @throws If `accountId` is empty or `scope` is not a valid CAIP-2 chain ID.
|
|
76
|
+
*/
|
|
77
|
+
export type AssetsControllerGetAccountAssetsByScopeAction = {
|
|
78
|
+
type: `AssetsController:getAccountAssetsByScope`;
|
|
79
|
+
handler: AssetsController['getAccountAssetsByScope'];
|
|
39
80
|
};
|
|
40
81
|
export type AssetsControllerGetAssetsPriceAction = {
|
|
41
82
|
type: `AssetsController:getAssetsPrice`;
|
|
@@ -136,5 +177,5 @@ export type AssetsControllerSetSelectedCurrencyAction = {
|
|
|
136
177
|
/**
|
|
137
178
|
* Union of all AssetsController action types.
|
|
138
179
|
*/
|
|
139
|
-
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction |
|
|
180
|
+
export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAccountAssetByIDAction | AssetsControllerGetAccountAssetsByIDsAction | AssetsControllerGetAccountAssetsByScopeAction | AssetsControllerGetAssetsPriceAction | AssetsControllerGetExchangeRatesForBridgeAction | AssetsControllerGetStateForTransactionPayAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction | AssetsControllerSetSelectedCurrencyAction;
|
|
140
181
|
//# sourceMappingURL=AssetsController-method-action-types.d.mts.map
|
|
@@ -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,+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,
|
|
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,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,6CAA6C,GAAG;IAC1D,IAAI,EAAE,0CAA0C,CAAC;IACjD,OAAO,EAAE,gBAAgB,CAAC,yBAAyB,CAAC,CAAC;CACtD,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,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.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
|
|
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 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 *\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 | AssetsControllerGetAccountAssetByIDAction\n | AssetsControllerGetAccountAssetsByIDsAction\n | AssetsControllerGetAccountAssetsByScopeAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerGetExchangeRatesForBridgeAction\n | AssetsControllerGetStateForTransactionPayAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction\n | AssetsControllerSetSelectedCurrencyAction;\n"]}
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_trace, _AssetsController_captureException, _AssetsController_firstInitFetchReported, _AssetsController_stateSizeReported, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked, _AssetsController_controllerMutex, _AssetsController_accountRefreshMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_lastKnownAccountIds, _AssetsController_getSelectedAccounts, _AssetsController_accountActivityDataSource, _AssetsController_accountsApiDataSource, _AssetsController_snapDataSource, _AssetsController_rpcDataSource, _AssetsController_stakedBalanceDataSource, _AssetsController_allBalanceDataSources_get, _AssetsController_priceDataSource, _AssetsController_detectionMiddleware, _AssetsController_customAssetGraduationMiddleware, _AssetsController_rpcFallbackMiddleware, _AssetsController_tokenDataSource, _AssetsController_unsubscribeBasicFunctionality, _AssetsController_queryApiClient, _AssetsController_onActiveChainsUpdated, _AssetsController_initializeNativeAssetsMap, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_onUnapprovedTransactionAdded, _AssetsController_onTransactionConfirmed, _AssetsController_updateActive, _AssetsController_handleAccountTreeStateChange, _AssetsController_runAccountTreeRefresh, _AssetsController_runStartupRefresh, _AssetsController_registerActionHandlers, _AssetsController_handleActiveChainsUpdate, _AssetsController_executeMiddlewares, _AssetsController_fetchMissingPricesWithoutCache, _AssetsController_getNativeAssetMap, _AssetsController_isNativeAsset, _AssetsController_getAssetType, _AssetsController_resolveNativeAssetIds, _AssetsController_getNativeAssetIdsForEnabledChains, _AssetsController_getNativeAssetIdsForAccount, _AssetsController_getSlowPipelineChainIds, _AssetsController_ensureNativeBalancesDefaultZero, _AssetsController_ensureDefaultTrackedAssetsSeeded, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_getAssetFromState, _AssetsController_shouldHideNativeToken, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeAssets, _AssetsController_subscribeAssetsBalance, _AssetsController_subscribeRpcCustomAssetsSupplement, _AssetsController_unsubscribeBySubscriptionKey, _AssetsController_subscribeStakedBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_subscribeDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_buildDataRequest, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged, _AssetsController_handleNetworkAdded, _AssetsController_refreshActiveChainsOnNetworkSwitch, _AssetsController_getSelectedEvmChainIdFromNetworkState, _AssetsController_handleNetworkDidChange, _AssetsController_refreshAssetsAfterNetworkChange, _AssetsController_refreshAssetsAfterNetworkAdded;
|
|
16
|
+
var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_trace, _AssetsController_captureException, _AssetsController_firstInitFetchReported, _AssetsController_stateSizeReported, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked, _AssetsController_controllerMutex, _AssetsController_accountRefreshMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_lastKnownAccountIds, _AssetsController_getSelectedAccounts, _AssetsController_accountActivityDataSource, _AssetsController_accountsApiDataSource, _AssetsController_snapDataSource, _AssetsController_rpcDataSource, _AssetsController_stakedBalanceDataSource, _AssetsController_allBalanceDataSources_get, _AssetsController_priceDataSource, _AssetsController_detectionMiddleware, _AssetsController_customAssetGraduationMiddleware, _AssetsController_rpcFallbackMiddleware, _AssetsController_tokenDataSource, _AssetsController_unsubscribeBasicFunctionality, _AssetsController_queryApiClient, _AssetsController_onActiveChainsUpdated, _AssetsController_initializeNativeAssetsMap, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_onUnapprovedTransactionAdded, _AssetsController_onTransactionConfirmed, _AssetsController_updateActive, _AssetsController_handleAccountTreeStateChange, _AssetsController_runAccountTreeRefresh, _AssetsController_runStartupRefresh, _AssetsController_registerActionHandlers, _AssetsController_handleActiveChainsUpdate, _AssetsController_executeMiddlewares, _AssetsController_assertNonEmptyAccountId, _AssetsController_normalizeAssetIdOrThrow, _AssetsController_fetchMissingPricesWithoutCache, _AssetsController_getNativeAssetMap, _AssetsController_isNativeAsset, _AssetsController_getAssetType, _AssetsController_resolveNativeAssetIds, _AssetsController_getNativeAssetIdsForEnabledChains, _AssetsController_getNativeAssetIdsForAccount, _AssetsController_getSlowPipelineChainIds, _AssetsController_ensureNativeBalancesDefaultZero, _AssetsController_ensureDefaultTrackedAssetsSeeded, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_getAssetFromState, _AssetsController_shouldHideNativeToken, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeAssets, _AssetsController_subscribeAssetsBalance, _AssetsController_subscribeRpcCustomAssetsSupplement, _AssetsController_unsubscribeBySubscriptionKey, _AssetsController_subscribeStakedBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_subscribeDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_buildDataRequest, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged, _AssetsController_handleNetworkAdded, _AssetsController_refreshActiveChainsOnNetworkSwitch, _AssetsController_getSelectedEvmChainIdFromNetworkState, _AssetsController_handleNetworkDidChange, _AssetsController_refreshAssetsAfterNetworkChange, _AssetsController_refreshAssetsAfterNetworkAdded;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.AssetsController = exports.getDefaultAssetsControllerState = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -54,7 +54,9 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
54
54
|
'getAssets',
|
|
55
55
|
'getAssetsBalance',
|
|
56
56
|
'getAssetMetadata',
|
|
57
|
-
'
|
|
57
|
+
'getAccountAssetByID',
|
|
58
|
+
'getAccountAssetsByIDs',
|
|
59
|
+
'getAccountAssetsByScope',
|
|
58
60
|
'getAssetsPrice',
|
|
59
61
|
'getExchangeRatesForBridge',
|
|
60
62
|
'getStateForTransactionPay',
|
|
@@ -640,21 +642,81 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
640
642
|
* renderable asset (balance + metadata) exists for the account/asset pair.
|
|
641
643
|
* @throws If `accountId` is empty or `assetId` is not a valid CAIP-19 asset ID.
|
|
642
644
|
*/
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
let normalizedAssetId;
|
|
648
|
-
try {
|
|
649
|
-
normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
650
|
-
}
|
|
651
|
-
catch {
|
|
652
|
-
throw new Error(`AssetsController.getAsset: invalid CAIP-19 assetId "${assetId}"`);
|
|
653
|
-
}
|
|
645
|
+
getAccountAssetByID(accountId, assetId) {
|
|
646
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_assertNonEmptyAccountId).call(this, accountId, 'getAccountAssetByID');
|
|
647
|
+
const normalizedAssetId = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_normalizeAssetIdOrThrow).call(this, assetId, 'getAccountAssetByID');
|
|
654
648
|
return __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetFromState).call(this, accountId, normalizedAssetId, {
|
|
655
649
|
assetTypeSet: new Set(['fungible']),
|
|
656
650
|
});
|
|
657
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Get multiple combined assets (balance + metadata + price + computed
|
|
654
|
+
* `fiatValue`) for an account directly from controller state.
|
|
655
|
+
*
|
|
656
|
+
* Applies the same state-composition and filtering rules as
|
|
657
|
+
* `getAccountAssetByID` to each requested asset ID. Asset IDs that do not
|
|
658
|
+
* resolve to a complete renderable asset (missing balance/metadata, hidden,
|
|
659
|
+
* or otherwise filtered out) are omitted from the result. Reads from
|
|
660
|
+
* current state only and does not trigger a data-source refresh.
|
|
661
|
+
*
|
|
662
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
663
|
+
* @param assetIds - The CAIP-19 asset IDs including chain scope
|
|
664
|
+
* (e.g. `eip155:1/erc20:0x...`).
|
|
665
|
+
* @returns A record of combined `Asset`s keyed by normalized CAIP-19 asset
|
|
666
|
+
* ID, containing only the requested assets that resolved.
|
|
667
|
+
* @throws If `accountId` is empty or any `assetIds` entry is not a valid
|
|
668
|
+
* CAIP-19 asset ID.
|
|
669
|
+
*/
|
|
670
|
+
getAccountAssetsByIDs(accountId, assetIds) {
|
|
671
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_assertNonEmptyAccountId).call(this, accountId, 'getAccountAssetsByIDs');
|
|
672
|
+
const result = Object.create(null);
|
|
673
|
+
for (const assetId of assetIds) {
|
|
674
|
+
const normalizedAssetId = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_normalizeAssetIdOrThrow).call(this, assetId, 'getAccountAssetsByIDs');
|
|
675
|
+
const asset = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetFromState).call(this, accountId, normalizedAssetId, {
|
|
676
|
+
assetTypeSet: new Set(['fungible']),
|
|
677
|
+
});
|
|
678
|
+
if (asset) {
|
|
679
|
+
result[normalizedAssetId] = asset;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return result;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Get all combined assets (balance + metadata + price + computed
|
|
686
|
+
* `fiatValue`) an account holds on a given chain scope, directly from
|
|
687
|
+
* controller state.
|
|
688
|
+
*
|
|
689
|
+
* Applies the same state-composition and filtering rules as
|
|
690
|
+
* `getAccountAssetByID` (hidden or otherwise filtered assets are excluded).
|
|
691
|
+
* Reads from current state only and does not trigger a data-source refresh.
|
|
692
|
+
*
|
|
693
|
+
* @param accountId - The account ID (`InternalAccount.id`, not an address).
|
|
694
|
+
* @param scope - The CAIP-2 chain ID to filter by (e.g. `eip155:1`).
|
|
695
|
+
* @returns A record of combined `Asset`s keyed by CAIP-19 asset ID,
|
|
696
|
+
* containing only the account's assets on the given scope.
|
|
697
|
+
* @throws If `accountId` is empty or `scope` is not a valid CAIP-2 chain ID.
|
|
698
|
+
*/
|
|
699
|
+
getAccountAssetsByScope(accountId, scope) {
|
|
700
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_assertNonEmptyAccountId).call(this, accountId, 'getAccountAssetsByScope');
|
|
701
|
+
if (!(0, utils_1.isCaipChainId)(scope)) {
|
|
702
|
+
throw new Error(`AssetsController.getAccountAssetsByScope: invalid CAIP-2 scope "${String(scope)}"`);
|
|
703
|
+
}
|
|
704
|
+
const result = Object.create(null);
|
|
705
|
+
const chainIdSet = new Set([scope]);
|
|
706
|
+
const assetTypeSet = new Set(['fungible']);
|
|
707
|
+
const accountBalances = this.state.assetsBalance[accountId] ?? {};
|
|
708
|
+
for (const assetId of Object.keys(accountBalances)) {
|
|
709
|
+
const typedAssetId = assetId;
|
|
710
|
+
const asset = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetFromState).call(this, accountId, typedAssetId, {
|
|
711
|
+
chainIdSet,
|
|
712
|
+
assetTypeSet,
|
|
713
|
+
});
|
|
714
|
+
if (asset) {
|
|
715
|
+
result[typedAssetId] = asset;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return result;
|
|
719
|
+
}
|
|
658
720
|
async getAssetsPrice(accounts, options) {
|
|
659
721
|
const assets = await this.getAssets(accounts, {
|
|
660
722
|
chainIds: options?.chainIds,
|
|
@@ -1080,7 +1142,9 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
1080
1142
|
this.messenger.unregisterActionHandler('AssetsController:getAssets');
|
|
1081
1143
|
this.messenger.unregisterActionHandler('AssetsController:getAssetsBalance');
|
|
1082
1144
|
this.messenger.unregisterActionHandler('AssetsController:getAssetMetadata');
|
|
1083
|
-
this.messenger.unregisterActionHandler('AssetsController:
|
|
1145
|
+
this.messenger.unregisterActionHandler('AssetsController:getAccountAssetByID');
|
|
1146
|
+
this.messenger.unregisterActionHandler('AssetsController:getAccountAssetsByIDs');
|
|
1147
|
+
this.messenger.unregisterActionHandler('AssetsController:getAccountAssetsByScope');
|
|
1084
1148
|
this.messenger.unregisterActionHandler('AssetsController:getAssetsPrice');
|
|
1085
1149
|
this.messenger.unregisterActionHandler('AssetsController:getExchangeRatesForBridge');
|
|
1086
1150
|
this.messenger.unregisterActionHandler('AssetsController:getStateForTransactionPay');
|
|
@@ -1534,6 +1598,17 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1534
1598
|
});
|
|
1535
1599
|
}
|
|
1536
1600
|
return { response: result.response, durationByDataSource };
|
|
1601
|
+
}, _AssetsController_assertNonEmptyAccountId = function _AssetsController_assertNonEmptyAccountId(accountId, methodName) {
|
|
1602
|
+
if (typeof accountId !== 'string' || accountId.length === 0) {
|
|
1603
|
+
throw new Error(`AssetsController.${methodName}: accountId must be a non-empty string`);
|
|
1604
|
+
}
|
|
1605
|
+
}, _AssetsController_normalizeAssetIdOrThrow = function _AssetsController_normalizeAssetIdOrThrow(assetId, methodName) {
|
|
1606
|
+
try {
|
|
1607
|
+
return (0, index_js_1.normalizeAssetId)(assetId);
|
|
1608
|
+
}
|
|
1609
|
+
catch {
|
|
1610
|
+
throw new Error(`AssetsController.${methodName}: invalid CAIP-19 assetId "${assetId}"`);
|
|
1611
|
+
}
|
|
1537
1612
|
}, _AssetsController_fetchMissingPricesWithoutCache = function _AssetsController_fetchMissingPricesWithoutCache(accounts, chainIds) {
|
|
1538
1613
|
if (!__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this) || accounts.length === 0) {
|
|
1539
1614
|
return;
|