@metamask-previews/assets-controller 1.0.0-preview-6a225bc30 → 1.0.0-preview-1ad6631

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/AssetsController-method-action-types.cjs.map +1 -1
  3. package/dist/AssetsController-method-action-types.d.cts +26 -1
  4. package/dist/AssetsController-method-action-types.d.cts.map +1 -1
  5. package/dist/AssetsController-method-action-types.d.mts +26 -1
  6. package/dist/AssetsController-method-action-types.d.mts.map +1 -1
  7. package/dist/AssetsController-method-action-types.mjs.map +1 -1
  8. package/dist/AssetsController.cjs +84 -9
  9. package/dist/AssetsController.cjs.map +1 -1
  10. package/dist/AssetsController.d.cts +47 -2
  11. package/dist/AssetsController.d.cts.map +1 -1
  12. package/dist/AssetsController.d.mts +47 -2
  13. package/dist/AssetsController.d.mts.map +1 -1
  14. package/dist/AssetsController.mjs +84 -9
  15. package/dist/AssetsController.mjs.map +1 -1
  16. package/dist/data-sources/RpcDataSource.cjs +117 -4
  17. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  18. package/dist/data-sources/RpcDataSource.d.cts +14 -0
  19. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  20. package/dist/data-sources/RpcDataSource.d.mts +14 -0
  21. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  22. package/dist/data-sources/RpcDataSource.mjs +117 -4
  23. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  24. package/dist/data-sources/StakedBalanceDataSource.cjs +536 -0
  25. package/dist/data-sources/StakedBalanceDataSource.cjs.map +1 -0
  26. package/dist/data-sources/StakedBalanceDataSource.d.cts +72 -0
  27. package/dist/data-sources/StakedBalanceDataSource.d.cts.map +1 -0
  28. package/dist/data-sources/StakedBalanceDataSource.d.mts +72 -0
  29. package/dist/data-sources/StakedBalanceDataSource.d.mts.map +1 -0
  30. package/dist/data-sources/StakedBalanceDataSource.mjs +532 -0
  31. package/dist/data-sources/StakedBalanceDataSource.mjs.map +1 -0
  32. package/dist/data-sources/TokenDataSource.cjs +5 -0
  33. package/dist/data-sources/TokenDataSource.cjs.map +1 -1
  34. package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
  35. package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
  36. package/dist/data-sources/TokenDataSource.mjs +5 -0
  37. package/dist/data-sources/TokenDataSource.mjs.map +1 -1
  38. package/dist/data-sources/evm-rpc-services/index.cjs +5 -1
  39. package/dist/data-sources/evm-rpc-services/index.cjs.map +1 -1
  40. package/dist/data-sources/evm-rpc-services/index.d.cts +1 -1
  41. package/dist/data-sources/evm-rpc-services/index.d.cts.map +1 -1
  42. package/dist/data-sources/evm-rpc-services/index.d.mts +1 -1
  43. package/dist/data-sources/evm-rpc-services/index.d.mts.map +1 -1
  44. package/dist/data-sources/evm-rpc-services/index.mjs +1 -1
  45. package/dist/data-sources/evm-rpc-services/index.mjs.map +1 -1
  46. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs +133 -0
  47. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs.map +1 -0
  48. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts +78 -0
  49. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts.map +1 -0
  50. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts +78 -0
  51. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts.map +1 -0
  52. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.mjs +127 -0
  53. package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.mjs.map +1 -0
  54. package/dist/data-sources/evm-rpc-services/services/index.cjs +6 -1
  55. package/dist/data-sources/evm-rpc-services/services/index.cjs.map +1 -1
  56. package/dist/data-sources/evm-rpc-services/services/index.d.cts +1 -0
  57. package/dist/data-sources/evm-rpc-services/services/index.d.cts.map +1 -1
  58. package/dist/data-sources/evm-rpc-services/services/index.d.mts +1 -0
  59. package/dist/data-sources/evm-rpc-services/services/index.d.mts.map +1 -1
  60. package/dist/data-sources/evm-rpc-services/services/index.mjs +1 -0
  61. package/dist/data-sources/evm-rpc-services/services/index.mjs.map +1 -1
  62. package/dist/data-sources/evm-rpc-services/utils/index.cjs +9 -1
  63. package/dist/data-sources/evm-rpc-services/utils/index.cjs.map +1 -1
  64. package/dist/data-sources/evm-rpc-services/utils/index.d.cts +2 -0
  65. package/dist/data-sources/evm-rpc-services/utils/index.d.cts.map +1 -1
  66. package/dist/data-sources/evm-rpc-services/utils/index.d.mts +2 -0
  67. package/dist/data-sources/evm-rpc-services/utils/index.d.mts.map +1 -1
  68. package/dist/data-sources/evm-rpc-services/utils/index.mjs +2 -0
  69. package/dist/data-sources/evm-rpc-services/utils/index.mjs.map +1 -1
  70. package/dist/data-sources/evm-rpc-services/utils/parsing.cjs +34 -0
  71. package/dist/data-sources/evm-rpc-services/utils/parsing.cjs.map +1 -0
  72. package/dist/data-sources/evm-rpc-services/utils/parsing.d.cts +18 -0
  73. package/dist/data-sources/evm-rpc-services/utils/parsing.d.cts.map +1 -0
  74. package/dist/data-sources/evm-rpc-services/utils/parsing.d.mts +18 -0
  75. package/dist/data-sources/evm-rpc-services/utils/parsing.d.mts.map +1 -0
  76. package/dist/data-sources/evm-rpc-services/utils/parsing.mjs +29 -0
  77. package/dist/data-sources/evm-rpc-services/utils/parsing.mjs.map +1 -0
  78. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.cjs +50 -0
  79. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.cjs.map +1 -0
  80. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.cts +24 -0
  81. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.cts.map +1 -0
  82. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.mts +24 -0
  83. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.mts.map +1 -0
  84. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.mjs +44 -0
  85. package/dist/data-sources/evm-rpc-services/utils/staking-contracts.mjs.map +1 -0
  86. package/dist/data-sources/index.cjs +3 -1
  87. package/dist/data-sources/index.cjs.map +1 -1
  88. package/dist/data-sources/index.d.cts +1 -0
  89. package/dist/data-sources/index.d.cts.map +1 -1
  90. package/dist/data-sources/index.d.mts +1 -0
  91. package/dist/data-sources/index.d.mts.map +1 -1
  92. package/dist/data-sources/index.mjs +1 -0
  93. package/dist/data-sources/index.mjs.map +1 -1
  94. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Added
11
11
 
12
+ - Add `StakedBalanceDataSource` that polls supported staking contracts on enabled chains and merges staked balances into `assetsBalance`. Configurable via `stakedBalanceDataSourceConfig` (`enabled`, `pollInterval`); the controller subscribes to it when enabled and cleans up on destroy ([#7936](https://github.com/MetaMask/core/pull/7936))
12
13
  - Add optional `trackMetaMetricsEvent` callback to measure and report first init/fetch historical time (duration in ms) to MetaMetrics when the initial asset fetch completes after unlock or app open ([#7871](https://github.com/MetaMask/core/pull/7871))
13
14
  - Add `AccountsApiDataSourceConfig` and `PriceDataSourceConfig` types; add `accountsApiDataSourceConfig` and `priceDataSourceConfig` options to `AssetsControllerOptions` for per-data-source configuration (pollInterval, tokenDetectionEnabled, etc.). When `tokenDetectionEnabled` is false, `AccountsApiDataSource` only returns balances for tokens already in state and does not add new tokens ([#7926](https://github.com/MetaMask/core/pull/7926))
14
15
  - Add `useExternalService` option to `TokenDetector`, `TokenDetectionOptions`, `RpcDataSourceConfig`, and `RpcDataSourceOptions`. Token detection runs only when both `tokenDetectionEnabled` and `useExternalService` are true and stops when either is false ([#7924](https://github.com/MetaMask/core/pull/7924))
@@ -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 by `scripts/generate-method-action-types.ts`.\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\nexport type AssetsControllerGetAssetsPriceAction = {\n type: `AssetsController:getAssetsPrice`;\n handler: AssetsController['getAssetsPrice'];\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 * @param accountId - The account ID to add the custom asset for.\n * @param assetId - The CAIP-19 asset ID to add.\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 * Union of all AssetsController action types.\n */\nexport type AssetsControllerMethodActions =\n | AssetsControllerGetAssetsAction\n | AssetsControllerGetAssetsBalanceAction\n | AssetsControllerGetAssetMetadataAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction;\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 by `scripts/generate-method-action-types.ts`.\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\nexport type AssetsControllerGetAssetsPriceAction = {\n type: `AssetsController:getAssetsPrice`;\n handler: AssetsController['getAssetsPrice'];\n};\n\n/**\n * Refresh balances from RPC for selected accounts/chains and update state.\n * Exposed for UI (e.g. pull-to-refresh). Only used when RPC is the data source;\n * websocket/API update automatically. Also triggered on transaction events (RPC path).\n */\nexport type AssetsControllerRefreshBalancesAction = {\n type: `AssetsController:refreshBalances`;\n handler: AssetsController['refreshBalances'];\n};\n\n/**\n * Run token detection for selected accounts/chains (RPC path) and update state.\n * Exposed for UI. Only used when RPC is the data source; websocket/API update automatically.\n */\nexport type AssetsControllerRefreshDetectedTokensAction = {\n type: `AssetsController:refreshDetectedTokens`;\n handler: AssetsController['refreshDetectedTokens'];\n};\n\n/**\n * Refresh staked balances for all subscribed accounts/chains and update state.\n * Exposed for UI. Also triggered automatically on transaction events.\n */\nexport type AssetsControllerRefreshStakedBalanceAction = {\n type: `AssetsController:refreshStakedBalance`;\n handler: AssetsController['refreshStakedBalance'];\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 * @param accountId - The account ID to add the custom asset for.\n * @param assetId - The CAIP-19 asset ID to add.\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 * Union of all AssetsController action types.\n */\nexport type AssetsControllerMethodActions =\n | AssetsControllerGetAssetsAction\n | AssetsControllerGetAssetsBalanceAction\n | AssetsControllerGetAssetMetadataAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerRefreshBalancesAction\n | AssetsControllerRefreshDetectedTokensAction\n | AssetsControllerRefreshStakedBalanceAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction;\n"]}
@@ -19,6 +19,31 @@ export type AssetsControllerGetAssetsPriceAction = {
19
19
  type: `AssetsController:getAssetsPrice`;
20
20
  handler: AssetsController['getAssetsPrice'];
21
21
  };
22
+ /**
23
+ * Refresh balances from RPC for selected accounts/chains and update state.
24
+ * Exposed for UI (e.g. pull-to-refresh). Only used when RPC is the data source;
25
+ * websocket/API update automatically. Also triggered on transaction events (RPC path).
26
+ */
27
+ export type AssetsControllerRefreshBalancesAction = {
28
+ type: `AssetsController:refreshBalances`;
29
+ handler: AssetsController['refreshBalances'];
30
+ };
31
+ /**
32
+ * Run token detection for selected accounts/chains (RPC path) and update state.
33
+ * Exposed for UI. Only used when RPC is the data source; websocket/API update automatically.
34
+ */
35
+ export type AssetsControllerRefreshDetectedTokensAction = {
36
+ type: `AssetsController:refreshDetectedTokens`;
37
+ handler: AssetsController['refreshDetectedTokens'];
38
+ };
39
+ /**
40
+ * Refresh staked balances for all subscribed accounts/chains and update state.
41
+ * Exposed for UI. Also triggered automatically on transaction events.
42
+ */
43
+ export type AssetsControllerRefreshStakedBalanceAction = {
44
+ type: `AssetsController:refreshStakedBalance`;
45
+ handler: AssetsController['refreshStakedBalance'];
46
+ };
22
47
  /**
23
48
  * Add a custom asset for an account.
24
49
  * Custom assets are included in subscription and fetch operations.
@@ -74,5 +99,5 @@ export type AssetsControllerUnhideAssetAction = {
74
99
  /**
75
100
  * Union of all AssetsController action types.
76
101
  */
77
- export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction;
102
+ export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerRefreshBalancesAction | AssetsControllerRefreshDetectedTokensAction | AssetsControllerRefreshStakedBalanceAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction;
78
103
  //# 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,+BAA2B;AAE3D,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,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;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;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,sCAAsC,GACtC,oCAAoC,GACpC,oCAAoC,GACpC,uCAAuC,GACvC,qCAAqC,GACrC,+BAA+B,GAC/B,iCAAiC,CAAC"}
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,+BAA2B;AAE3D,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,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;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;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,sCAAsC,GACtC,oCAAoC,GACpC,qCAAqC,GACrC,2CAA2C,GAC3C,0CAA0C,GAC1C,oCAAoC,GACpC,uCAAuC,GACvC,qCAAqC,GACrC,+BAA+B,GAC/B,iCAAiC,CAAC"}
@@ -19,6 +19,31 @@ export type AssetsControllerGetAssetsPriceAction = {
19
19
  type: `AssetsController:getAssetsPrice`;
20
20
  handler: AssetsController['getAssetsPrice'];
21
21
  };
22
+ /**
23
+ * Refresh balances from RPC for selected accounts/chains and update state.
24
+ * Exposed for UI (e.g. pull-to-refresh). Only used when RPC is the data source;
25
+ * websocket/API update automatically. Also triggered on transaction events (RPC path).
26
+ */
27
+ export type AssetsControllerRefreshBalancesAction = {
28
+ type: `AssetsController:refreshBalances`;
29
+ handler: AssetsController['refreshBalances'];
30
+ };
31
+ /**
32
+ * Run token detection for selected accounts/chains (RPC path) and update state.
33
+ * Exposed for UI. Only used when RPC is the data source; websocket/API update automatically.
34
+ */
35
+ export type AssetsControllerRefreshDetectedTokensAction = {
36
+ type: `AssetsController:refreshDetectedTokens`;
37
+ handler: AssetsController['refreshDetectedTokens'];
38
+ };
39
+ /**
40
+ * Refresh staked balances for all subscribed accounts/chains and update state.
41
+ * Exposed for UI. Also triggered automatically on transaction events.
42
+ */
43
+ export type AssetsControllerRefreshStakedBalanceAction = {
44
+ type: `AssetsController:refreshStakedBalance`;
45
+ handler: AssetsController['refreshStakedBalance'];
46
+ };
22
47
  /**
23
48
  * Add a custom asset for an account.
24
49
  * Custom assets are included in subscription and fetch operations.
@@ -74,5 +99,5 @@ export type AssetsControllerUnhideAssetAction = {
74
99
  /**
75
100
  * Union of all AssetsController action types.
76
101
  */
77
- export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction;
102
+ export type AssetsControllerMethodActions = AssetsControllerGetAssetsAction | AssetsControllerGetAssetsBalanceAction | AssetsControllerGetAssetMetadataAction | AssetsControllerGetAssetsPriceAction | AssetsControllerRefreshBalancesAction | AssetsControllerRefreshDetectedTokensAction | AssetsControllerRefreshStakedBalanceAction | AssetsControllerAddCustomAssetAction | AssetsControllerRemoveCustomAssetAction | AssetsControllerGetCustomAssetsAction | AssetsControllerHideAssetAction | AssetsControllerUnhideAssetAction;
78
103
  //# 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,+BAA2B;AAE3D,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,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;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;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,sCAAsC,GACtC,oCAAoC,GACpC,oCAAoC,GACpC,uCAAuC,GACvC,qCAAqC,GACrC,+BAA+B,GAC/B,iCAAiC,CAAC"}
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,+BAA2B;AAE3D,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,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;GAOG;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;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,sCAAsC,GACtC,sCAAsC,GACtC,oCAAoC,GACpC,qCAAqC,GACrC,2CAA2C,GAC3C,0CAA0C,GAC1C,oCAAoC,GACpC,uCAAuC,GACvC,qCAAqC,GACrC,+BAA+B,GAC/B,iCAAiC,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 by `scripts/generate-method-action-types.ts`.\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\nexport type AssetsControllerGetAssetsPriceAction = {\n type: `AssetsController:getAssetsPrice`;\n handler: AssetsController['getAssetsPrice'];\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 * @param accountId - The account ID to add the custom asset for.\n * @param assetId - The CAIP-19 asset ID to add.\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 * Union of all AssetsController action types.\n */\nexport type AssetsControllerMethodActions =\n | AssetsControllerGetAssetsAction\n | AssetsControllerGetAssetsBalanceAction\n | AssetsControllerGetAssetMetadataAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction;\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 by `scripts/generate-method-action-types.ts`.\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\nexport type AssetsControllerGetAssetsPriceAction = {\n type: `AssetsController:getAssetsPrice`;\n handler: AssetsController['getAssetsPrice'];\n};\n\n/**\n * Refresh balances from RPC for selected accounts/chains and update state.\n * Exposed for UI (e.g. pull-to-refresh). Only used when RPC is the data source;\n * websocket/API update automatically. Also triggered on transaction events (RPC path).\n */\nexport type AssetsControllerRefreshBalancesAction = {\n type: `AssetsController:refreshBalances`;\n handler: AssetsController['refreshBalances'];\n};\n\n/**\n * Run token detection for selected accounts/chains (RPC path) and update state.\n * Exposed for UI. Only used when RPC is the data source; websocket/API update automatically.\n */\nexport type AssetsControllerRefreshDetectedTokensAction = {\n type: `AssetsController:refreshDetectedTokens`;\n handler: AssetsController['refreshDetectedTokens'];\n};\n\n/**\n * Refresh staked balances for all subscribed accounts/chains and update state.\n * Exposed for UI. Also triggered automatically on transaction events.\n */\nexport type AssetsControllerRefreshStakedBalanceAction = {\n type: `AssetsController:refreshStakedBalance`;\n handler: AssetsController['refreshStakedBalance'];\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 * @param accountId - The account ID to add the custom asset for.\n * @param assetId - The CAIP-19 asset ID to add.\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 * Union of all AssetsController action types.\n */\nexport type AssetsControllerMethodActions =\n | AssetsControllerGetAssetsAction\n | AssetsControllerGetAssetsBalanceAction\n | AssetsControllerGetAssetMetadataAction\n | AssetsControllerGetAssetsPriceAction\n | AssetsControllerRefreshBalancesAction\n | AssetsControllerRefreshDetectedTokensAction\n | AssetsControllerRefreshStakedBalanceAction\n | AssetsControllerAddCustomAssetAction\n | AssetsControllerRemoveCustomAssetAction\n | AssetsControllerGetCustomAssetsAction\n | AssetsControllerHideAssetAction\n | AssetsControllerUnhideAssetAction;\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_trackMetaMetricsEvent, _AssetsController_firstInitFetchReported, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_selectedAccounts_get, _AssetsController_backendWebsocketDataSource, _AssetsController_accountsApiDataSource, _AssetsController_snapDataSource, _AssetsController_rpcDataSource, _AssetsController_allBalanceDataSources_get, _AssetsController_priceDataSource, _AssetsController_detectionMiddleware, _AssetsController_tokenDataSource, _AssetsController_unsubscribeBasicFunctionality, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_registerActionHandlers, _AssetsController_executeMiddlewares, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeAssets, _AssetsController_subscribeAssetsBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_subscribeDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_buildDataRequest, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged;
16
+ var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_pricePollInterval, _AssetsController_trackMetaMetricsEvent, _AssetsController_firstInitFetchReported, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_selectedAccounts_get, _AssetsController_backendWebsocketDataSource, _AssetsController_accountsApiDataSource, _AssetsController_snapDataSource, _AssetsController_rpcDataSource, _AssetsController_stakedBalanceDataSource, _AssetsController_allBalanceDataSources_get, _AssetsController_priceDataSource, _AssetsController_detectionMiddleware, _AssetsController_tokenDataSource, _AssetsController_unsubscribeBasicFunctionality, _AssetsController_constructionState, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_registerActionHandlers, _AssetsController_executeMiddlewares, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeAssets, _AssetsController_subscribeAssetsBalance, _AssetsController_subscribeStakedBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_subscribeDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_buildDataRequest, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged;
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");
@@ -26,6 +26,7 @@ const BackendWebsocketDataSource_1 = require("./data-sources/BackendWebsocketDat
26
26
  const PriceDataSource_1 = require("./data-sources/PriceDataSource.cjs");
27
27
  const RpcDataSource_1 = require("./data-sources/RpcDataSource.cjs");
28
28
  const SnapDataSource_1 = require("./data-sources/SnapDataSource.cjs");
29
+ const StakedBalanceDataSource_1 = require("./data-sources/StakedBalanceDataSource.cjs");
29
30
  const TokenDataSource_1 = require("./data-sources/TokenDataSource.cjs");
30
31
  const logger_1 = require("./logger.cjs");
31
32
  const DetectionMiddleware_1 = require("./middlewares/DetectionMiddleware.cjs");
@@ -45,6 +46,9 @@ const MESSENGER_EXPOSED_METHODS = [
45
46
  'getCustomAssets',
46
47
  'hideAsset',
47
48
  'unhideAsset',
49
+ 'refreshBalances',
50
+ 'refreshDetectedTokens',
51
+ 'refreshStakedBalance',
48
52
  ];
49
53
  /** Default polling interval hint for data sources (30 seconds) */
50
54
  const DEFAULT_POLLING_INTERVAL_MS = 30000;
@@ -182,7 +186,7 @@ function normalizeResponse(response) {
182
186
  * - The controller does NOT manage polling - it simply receives pushed updates
183
187
  */
184
188
  class AssetsController extends base_controller_1.BaseController {
185
- constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, isEnabled = () => true, isBasicFunctionality, subscribeToBasicFunctionalityChange, queryApiClient, rpcDataSourceConfig, trackMetaMetricsEvent, accountsApiDataSourceConfig, priceDataSourceConfig, }) {
189
+ constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, isEnabled = () => true, isBasicFunctionality, subscribeToBasicFunctionalityChange, queryApiClient, rpcDataSourceConfig, trackMetaMetricsEvent, accountsApiDataSourceConfig, priceDataSourceConfig, stakedBalanceDataSourceConfig, }) {
186
190
  super({
187
191
  name: CONTROLLER_NAME,
188
192
  messenger,
@@ -199,6 +203,8 @@ class AssetsController extends base_controller_1.BaseController {
199
203
  _AssetsController_isBasicFunctionality.set(this, void 0);
200
204
  /** Default update interval hint passed to data sources */
201
205
  _AssetsController_defaultUpdateInterval.set(this, void 0);
206
+ /** Price polling interval from priceDataSourceConfig (overrides default when set). */
207
+ _AssetsController_pricePollInterval.set(this, void 0);
202
208
  /** Optional callback for first init/fetch MetaMetrics (duration). */
203
209
  _AssetsController_trackMetaMetricsEvent.set(this, void 0);
204
210
  /** Whether we have already reported first init fetch for this session (reset on #stop). */
@@ -217,16 +223,24 @@ class AssetsController extends base_controller_1.BaseController {
217
223
  _AssetsController_accountsApiDataSource.set(this, void 0);
218
224
  _AssetsController_snapDataSource.set(this, void 0);
219
225
  _AssetsController_rpcDataSource.set(this, void 0);
226
+ _AssetsController_stakedBalanceDataSource.set(this, void 0);
220
227
  _AssetsController_priceDataSource.set(this, void 0);
221
228
  _AssetsController_detectionMiddleware.set(this, void 0);
222
229
  _AssetsController_tokenDataSource.set(this, void 0);
223
230
  _AssetsController_unsubscribeBasicFunctionality.set(this, null);
231
+ _AssetsController_constructionState.set(this, { initialized: false });
224
232
  __classPrivateFieldSet(this, _AssetsController_isEnabled, isEnabled(), "f");
225
233
  __classPrivateFieldSet(this, _AssetsController_isBasicFunctionality, isBasicFunctionality ?? (() => true), "f");
226
234
  __classPrivateFieldSet(this, _AssetsController_defaultUpdateInterval, defaultUpdateInterval, "f");
235
+ __classPrivateFieldSet(this, _AssetsController_pricePollInterval, priceDataSourceConfig?.pollInterval, "f");
227
236
  __classPrivateFieldSet(this, _AssetsController_trackMetaMetricsEvent, trackMetaMetricsEvent, "f");
228
237
  const rpcConfig = rpcDataSourceConfig ?? {};
229
- const onActiveChainsUpdated = (dataSourceName, chains, previousChains) => this.handleActiveChainsUpdate(dataSourceName, chains, previousChains);
238
+ const onActiveChainsUpdated = (dataSourceName, chains, previousChains) => {
239
+ if (!__classPrivateFieldGet(this, _AssetsController_constructionState, "f").initialized) {
240
+ return;
241
+ }
242
+ this.handleActiveChainsUpdate(dataSourceName, chains, previousChains);
243
+ };
230
244
  __classPrivateFieldSet(this, _AssetsController_backendWebsocketDataSource, new BackendWebsocketDataSource_1.BackendWebsocketDataSource({
231
245
  messenger: this.messenger,
232
246
  queryApiClient,
@@ -246,6 +260,11 @@ class AssetsController extends base_controller_1.BaseController {
246
260
  onActiveChainsUpdated,
247
261
  ...rpcConfig,
248
262
  }), "f");
263
+ __classPrivateFieldSet(this, _AssetsController_stakedBalanceDataSource, new StakedBalanceDataSource_1.StakedBalanceDataSource({
264
+ messenger: this.messenger,
265
+ onActiveChainsUpdated,
266
+ ...stakedBalanceDataSourceConfig,
267
+ }), "f");
249
268
  __classPrivateFieldSet(this, _AssetsController_tokenDataSource, new TokenDataSource_1.TokenDataSource({
250
269
  queryApiClient,
251
270
  }), "f");
@@ -264,6 +283,8 @@ class AssetsController extends base_controller_1.BaseController {
264
283
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_initializeState).call(this);
265
284
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeToEvents).call(this);
266
285
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_registerActionHandlers).call(this);
286
+ __classPrivateFieldGet(this, _AssetsController_constructionState, "f").initialized = true;
287
+ // Subscriptions start only on KeyringController:unlock -> #start(), not here.
267
288
  // Subscribe to basic-functionality changes after construction so a synchronous
268
289
  // onChange during subscribe cannot run before data sources are initialized.
269
290
  if (subscribeToBasicFunctionalityChange) {
@@ -290,6 +311,9 @@ class AssetsController extends base_controller_1.BaseController {
290
311
  * @param previousChains - Previous chains; used to compute added/removed.
291
312
  */
292
313
  handleActiveChainsUpdate(dataSourceId, activeChains, previousChains) {
314
+ if (!__classPrivateFieldGet(this, _AssetsController_isEnabled, "f")) {
315
+ return;
316
+ }
293
317
  log('Data source active chains changed', {
294
318
  dataSourceId,
295
319
  chainCount: activeChains.length,
@@ -343,11 +367,16 @@ class AssetsController extends base_controller_1.BaseController {
343
367
  __classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f"),
344
368
  __classPrivateFieldGet(this, _AssetsController_snapDataSource, "f"),
345
369
  __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f"),
370
+ __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"),
346
371
  __classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
347
372
  __classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
348
373
  __classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
349
374
  ]
350
- : [__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f"), __classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f")];
375
+ : [
376
+ __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f"),
377
+ __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"),
378
+ __classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
379
+ ];
351
380
  const { response, durationByDataSource } = await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, sources, request);
352
381
  await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateState).call(this, response);
353
382
  if (__classPrivateFieldGet(this, _AssetsController_trackMetaMetricsEvent, "f") && !__classPrivateFieldGet(this, _AssetsController_firstInitFetchReported, "f")) {
@@ -403,6 +432,28 @@ class AssetsController extends base_controller_1.BaseController {
403
432
  }
404
433
  return result;
405
434
  }
435
+ /**
436
+ * Refresh balances from RPC for selected accounts/chains and update state.
437
+ * Exposed for UI (e.g. pull-to-refresh). Only used when RPC is the data source;
438
+ * websocket/API update automatically. Also triggered on transaction events (RPC path).
439
+ */
440
+ async refreshBalances() {
441
+ await __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f").refreshBalances();
442
+ }
443
+ /**
444
+ * Run token detection for selected accounts/chains (RPC path) and update state.
445
+ * Exposed for UI. Only used when RPC is the data source; websocket/API update automatically.
446
+ */
447
+ async refreshDetectedTokens() {
448
+ await __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f").refreshDetectedTokens();
449
+ }
450
+ /**
451
+ * Refresh staked balances for all subscribed accounts/chains and update state.
452
+ * Exposed for UI. Also triggered automatically on transaction events.
453
+ */
454
+ async refreshStakedBalance() {
455
+ await __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f").refreshStakedBalance();
456
+ }
406
457
  // ============================================================================
407
458
  // CUSTOM ASSETS MANAGEMENT
408
459
  // ============================================================================
@@ -527,7 +578,7 @@ class AssetsController extends base_controller_1.BaseController {
527
578
  if (!__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
528
579
  return;
529
580
  }
530
- const { updateInterval = __classPrivateFieldGet(this, _AssetsController_defaultUpdateInterval, "f") } = options;
581
+ const { updateInterval = __classPrivateFieldGet(this, _AssetsController_pricePollInterval, "f") ?? __classPrivateFieldGet(this, _AssetsController_defaultUpdateInterval, "f"), } = options;
531
582
  const subscriptionKey = 'ds:PriceDataSource';
532
583
  const existingSubscription = __classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").get(subscriptionKey);
533
584
  const isUpdate = existingSubscription !== undefined;
@@ -615,6 +666,7 @@ class AssetsController extends base_controller_1.BaseController {
615
666
  __classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f")?.destroy?.();
616
667
  __classPrivateFieldGet(this, _AssetsController_snapDataSource, "f")?.destroy?.();
617
668
  __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")?.destroy?.();
669
+ __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f")?.destroy?.();
618
670
  // Stop all active subscriptions
619
671
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_stop).call(this);
620
672
  if (__classPrivateFieldGet(this, _AssetsController_unsubscribeBasicFunctionality, "f")) {
@@ -631,10 +683,13 @@ class AssetsController extends base_controller_1.BaseController {
631
683
  this.messenger.unregisterActionHandler('AssetsController:getCustomAssets');
632
684
  this.messenger.unregisterActionHandler('AssetsController:hideAsset');
633
685
  this.messenger.unregisterActionHandler('AssetsController:unhideAsset');
686
+ this.messenger.unregisterActionHandler('AssetsController:refreshBalances');
687
+ this.messenger.unregisterActionHandler('AssetsController:refreshDetectedTokens');
688
+ this.messenger.unregisterActionHandler('AssetsController:refreshStakedBalance');
634
689
  }
635
690
  }
636
691
  exports.AssetsController = AssetsController;
637
- _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctionality = new WeakMap(), _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_trackMetaMetricsEvent = new WeakMap(), _AssetsController_firstInitFetchReported = new WeakMap(), _AssetsController_controllerMutex = new WeakMap(), _AssetsController_activeSubscriptions = new WeakMap(), _AssetsController_enabledChains = new WeakMap(), _AssetsController_backendWebsocketDataSource = new WeakMap(), _AssetsController_accountsApiDataSource = new WeakMap(), _AssetsController_snapDataSource = new WeakMap(), _AssetsController_rpcDataSource = new WeakMap(), _AssetsController_priceDataSource = new WeakMap(), _AssetsController_detectionMiddleware = new WeakMap(), _AssetsController_tokenDataSource = new WeakMap(), _AssetsController_unsubscribeBasicFunctionality = new WeakMap(), _AssetsController_instances = new WeakSet(), _AssetsController_selectedAccounts_get = function _AssetsController_selectedAccounts_get() {
692
+ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctionality = new WeakMap(), _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_pricePollInterval = new WeakMap(), _AssetsController_trackMetaMetricsEvent = new WeakMap(), _AssetsController_firstInitFetchReported = new WeakMap(), _AssetsController_controllerMutex = new WeakMap(), _AssetsController_activeSubscriptions = new WeakMap(), _AssetsController_enabledChains = new WeakMap(), _AssetsController_backendWebsocketDataSource = new WeakMap(), _AssetsController_accountsApiDataSource = new WeakMap(), _AssetsController_snapDataSource = new WeakMap(), _AssetsController_rpcDataSource = new WeakMap(), _AssetsController_stakedBalanceDataSource = new WeakMap(), _AssetsController_priceDataSource = new WeakMap(), _AssetsController_detectionMiddleware = new WeakMap(), _AssetsController_tokenDataSource = new WeakMap(), _AssetsController_unsubscribeBasicFunctionality = new WeakMap(), _AssetsController_constructionState = new WeakMap(), _AssetsController_instances = new WeakSet(), _AssetsController_selectedAccounts_get = function _AssetsController_selectedAccounts_get() {
638
693
  return this.messenger.call('AccountTreeController:getAccountsFromSelectedAccountGroup');
639
694
  }, _AssetsController_allBalanceDataSources_get = function _AssetsController_allBalanceDataSources_get() {
640
695
  return [
@@ -949,13 +1004,17 @@ async function _AssetsController_updateState(response) {
949
1004
  this.unsubscribeAssetsPrice();
950
1005
  // Stop balance subscriptions by properly notifying data sources via messenger
951
1006
  // This ensures data sources stop their polling timers.
952
- // Use #allBalanceDataSources so we unsubscribe from every source that may have
953
- // been subscribed (e.g. when switching from full to basic functionality).
1007
+ // Use #allBalanceDataSources + staked balance source so we unsubscribe from
1008
+ // every source that may have been subscribed.
1009
+ const allSources = [
1010
+ ...__classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_allBalanceDataSources_get),
1011
+ __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"),
1012
+ ];
954
1013
  const subscriptionKeys = [...__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").keys()];
955
1014
  for (const subscriptionKey of subscriptionKeys) {
956
1015
  if (subscriptionKey.startsWith('ds:')) {
957
1016
  const sourceId = subscriptionKey.slice(3);
958
- const source = __classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_allBalanceDataSources_get).find((ds) => ds.getName() === sourceId);
1017
+ const source = allSources.find((ds) => ds.getName() === sourceId);
959
1018
  if (source) {
960
1019
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_unsubscribeDataSource).call(this, source);
961
1020
  }
@@ -970,6 +1029,10 @@ async function _AssetsController_updateState(response) {
970
1029
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssetsBalance).call(this, __classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get), [
971
1030
  ...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f"),
972
1031
  ]);
1032
+ // Subscribe to staked balance updates (separate from regular balance chain-claiming)
1033
+ __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeStakedBalance).call(this, __classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get), [
1034
+ ...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f"),
1035
+ ]);
973
1036
  // Subscribe to price updates for all assets held by selected accounts
974
1037
  this.subscribeAssetsPrice(__classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get), [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
975
1038
  }, _AssetsController_subscribeAssetsBalance = function _AssetsController_subscribeAssetsBalance(accounts, chainIds) {
@@ -1000,6 +1063,18 @@ async function _AssetsController_updateState(response) {
1000
1063
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeDataSource).call(this, source, accountsForSource, assignedChains);
1001
1064
  }
1002
1065
  }
1066
+ }, _AssetsController_subscribeStakedBalance = function _AssetsController_subscribeStakedBalance(accounts, chainIds) {
1067
+ const source = __classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f");
1068
+ if (!source) {
1069
+ return;
1070
+ }
1071
+ const availableChains = new Set(source.getActiveChainsSync());
1072
+ const assignedChains = chainIds.filter((chainId) => availableChains.has(chainId));
1073
+ if (assignedChains.length === 0) {
1074
+ __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_unsubscribeDataSource).call(this, source);
1075
+ return;
1076
+ }
1077
+ __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeDataSource).call(this, source, accounts, assignedChains);
1003
1078
  }, _AssetsController_buildChainToAccountsMap = function _AssetsController_buildChainToAccountsMap(accounts, chainsToSubscribe) {
1004
1079
  const chainToAccounts = new Map();
1005
1080
  for (const account of accounts) {