@metamask/assets-controller 0.1.0
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 +37 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/AssetsController.cjs +1057 -0
- package/dist/AssetsController.cjs.map +1 -0
- package/dist/AssetsController.d.cts +260 -0
- package/dist/AssetsController.d.cts.map +1 -0
- package/dist/AssetsController.d.mts +260 -0
- package/dist/AssetsController.d.mts.map +1 -0
- package/dist/AssetsController.mjs +1050 -0
- package/dist/AssetsController.mjs.map +1 -0
- package/dist/data-sources/AbstractDataSource.cjs +103 -0
- package/dist/data-sources/AbstractDataSource.cjs.map +1 -0
- package/dist/data-sources/AbstractDataSource.d.cts +92 -0
- package/dist/data-sources/AbstractDataSource.d.cts.map +1 -0
- package/dist/data-sources/AbstractDataSource.d.mts +92 -0
- package/dist/data-sources/AbstractDataSource.d.mts.map +1 -0
- package/dist/data-sources/AbstractDataSource.mjs +99 -0
- package/dist/data-sources/AbstractDataSource.mjs.map +1 -0
- package/dist/data-sources/AccountsApiDataSource.cjs +421 -0
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -0
- package/dist/data-sources/AccountsApiDataSource.d.cts +103 -0
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -0
- package/dist/data-sources/AccountsApiDataSource.d.mts +103 -0
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -0
- package/dist/data-sources/AccountsApiDataSource.mjs +416 -0
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -0
- package/dist/data-sources/BackendWebsocketDataSource.cjs +388 -0
- package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -0
- package/dist/data-sources/BackendWebsocketDataSource.d.cts +95 -0
- package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -0
- package/dist/data-sources/BackendWebsocketDataSource.d.mts +95 -0
- package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -0
- package/dist/data-sources/BackendWebsocketDataSource.mjs +383 -0
- package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -0
- package/dist/data-sources/PriceDataSource.cjs +343 -0
- package/dist/data-sources/PriceDataSource.cjs.map +1 -0
- package/dist/data-sources/PriceDataSource.d.cts +153 -0
- package/dist/data-sources/PriceDataSource.d.cts.map +1 -0
- package/dist/data-sources/PriceDataSource.d.mts +153 -0
- package/dist/data-sources/PriceDataSource.d.mts.map +1 -0
- package/dist/data-sources/PriceDataSource.mjs +339 -0
- package/dist/data-sources/PriceDataSource.mjs.map +1 -0
- package/dist/data-sources/RpcDataSource.cjs +829 -0
- package/dist/data-sources/RpcDataSource.cjs.map +1 -0
- package/dist/data-sources/RpcDataSource.d.cts +243 -0
- package/dist/data-sources/RpcDataSource.d.cts.map +1 -0
- package/dist/data-sources/RpcDataSource.d.mts +243 -0
- package/dist/data-sources/RpcDataSource.d.mts.map +1 -0
- package/dist/data-sources/RpcDataSource.mjs +820 -0
- package/dist/data-sources/RpcDataSource.mjs.map +1 -0
- package/dist/data-sources/SnapDataSource.cjs +463 -0
- package/dist/data-sources/SnapDataSource.cjs.map +1 -0
- package/dist/data-sources/SnapDataSource.d.cts +155 -0
- package/dist/data-sources/SnapDataSource.d.cts.map +1 -0
- package/dist/data-sources/SnapDataSource.d.mts +155 -0
- package/dist/data-sources/SnapDataSource.d.mts.map +1 -0
- package/dist/data-sources/SnapDataSource.mjs +456 -0
- package/dist/data-sources/SnapDataSource.mjs.map +1 -0
- package/dist/data-sources/TokenDataSource.cjs +211 -0
- package/dist/data-sources/TokenDataSource.cjs.map +1 -0
- package/dist/data-sources/TokenDataSource.d.cts +62 -0
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -0
- package/dist/data-sources/TokenDataSource.d.mts +62 -0
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -0
- package/dist/data-sources/TokenDataSource.mjs +207 -0
- package/dist/data-sources/TokenDataSource.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs +638 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts +47 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts +47 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs +632 -0
- package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.cjs +8 -0
- package/dist/data-sources/evm-rpc-services/clients/index.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.cts +3 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.mts +3 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/clients/index.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/index.cjs +12 -0
- package/dist/data-sources/evm-rpc-services/index.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/index.d.cts +5 -0
- package/dist/data-sources/evm-rpc-services/index.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/index.d.mts +5 -0
- package/dist/data-sources/evm-rpc-services/index.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/index.mjs +4 -0
- package/dist/data-sources/evm-rpc-services/index.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs +202 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.cts +75 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.mts +75 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.mjs +198 -0
- package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs +214 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts +71 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts +71 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs +210 -0
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.cjs +8 -0
- package/dist/data-sources/evm-rpc-services/services/index.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.cts +3 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.mts +3 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.mjs +3 -0
- package/dist/data-sources/evm-rpc-services/services/index.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/assets.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/assets.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/assets.d.cts +53 -0
- package/dist/data-sources/evm-rpc-services/types/assets.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/assets.d.mts +53 -0
- package/dist/data-sources/evm-rpc-services/types/assets.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/assets.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/assets.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/config.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/config.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/config.d.cts +18 -0
- package/dist/data-sources/evm-rpc-services/types/config.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/config.d.mts +18 -0
- package/dist/data-sources/evm-rpc-services/types/config.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/config.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/config.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/core.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/core.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/core.d.cts +19 -0
- package/dist/data-sources/evm-rpc-services/types/core.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/core.d.mts +19 -0
- package/dist/data-sources/evm-rpc-services/types/core.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/core.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/core.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/index.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/index.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/index.d.cts +7 -0
- package/dist/data-sources/evm-rpc-services/types/index.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/index.d.mts +7 -0
- package/dist/data-sources/evm-rpc-services/types/index.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/index.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/index.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.d.cts +24 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.d.mts +24 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/multicall.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/services.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/services.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/services.d.cts +74 -0
- package/dist/data-sources/evm-rpc-services/types/services.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/services.d.mts +74 -0
- package/dist/data-sources/evm-rpc-services/types/services.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/services.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/services.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/state.cjs +3 -0
- package/dist/data-sources/evm-rpc-services/types/state.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/state.d.cts +52 -0
- package/dist/data-sources/evm-rpc-services/types/state.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/state.d.mts +52 -0
- package/dist/data-sources/evm-rpc-services/types/state.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/types/state.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/types/state.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.cjs +45 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.d.cts +28 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.d.mts +28 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.mjs +40 -0
- package/dist/data-sources/evm-rpc-services/utils/batch.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/index.cjs +7 -0
- package/dist/data-sources/evm-rpc-services/utils/index.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/index.d.cts +2 -0
- package/dist/data-sources/evm-rpc-services/utils/index.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/index.d.mts +2 -0
- package/dist/data-sources/evm-rpc-services/utils/index.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/index.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/utils/index.mjs.map +1 -0
- package/dist/data-sources/index.cjs +33 -0
- package/dist/data-sources/index.cjs.map +1 -0
- package/dist/data-sources/index.d.cts +9 -0
- package/dist/data-sources/index.d.cts.map +1 -0
- package/dist/data-sources/index.d.mts +9 -0
- package/dist/data-sources/index.d.mts.map +1 -0
- package/dist/data-sources/index.mjs +15 -0
- package/dist/data-sources/index.mjs.map +1 -0
- package/dist/data-sources/initDataSources.cjs +215 -0
- package/dist/data-sources/initDataSources.cjs.map +1 -0
- package/dist/data-sources/initDataSources.d.cts +140 -0
- package/dist/data-sources/initDataSources.d.cts.map +1 -0
- package/dist/data-sources/initDataSources.d.mts +140 -0
- package/dist/data-sources/initDataSources.d.mts.map +1 -0
- package/dist/data-sources/initDataSources.mjs +210 -0
- package/dist/data-sources/initDataSources.mjs.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +21 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +25 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +4 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/middlewares/DetectionMiddleware.cjs +101 -0
- package/dist/middlewares/DetectionMiddleware.cjs.map +1 -0
- package/dist/middlewares/DetectionMiddleware.d.cts +54 -0
- package/dist/middlewares/DetectionMiddleware.d.cts.map +1 -0
- package/dist/middlewares/DetectionMiddleware.d.mts +54 -0
- package/dist/middlewares/DetectionMiddleware.d.mts.map +1 -0
- package/dist/middlewares/DetectionMiddleware.mjs +97 -0
- package/dist/middlewares/DetectionMiddleware.mjs.map +1 -0
- package/dist/middlewares/index.cjs +6 -0
- package/dist/middlewares/index.cjs.map +1 -0
- package/dist/middlewares/index.d.cts +2 -0
- package/dist/middlewares/index.d.cts.map +1 -0
- package/dist/middlewares/index.d.mts +2 -0
- package/dist/middlewares/index.d.mts.map +1 -0
- package/dist/middlewares/index.mjs +2 -0
- package/dist/middlewares/index.mjs.map +1 -0
- package/dist/types.cjs +39 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +433 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +433 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +35 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.cjs +28 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +13 -0
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +13 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +24 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Address } from "./core.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Balance request for batch balance fetching.
|
|
4
|
+
*/
|
|
5
|
+
export type BalanceOfRequest = {
|
|
6
|
+
/** Token contract address (zero address for native) */
|
|
7
|
+
tokenAddress: Address;
|
|
8
|
+
/** Account address to check balance for */
|
|
9
|
+
accountAddress: Address;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Balance response from batch balance fetching.
|
|
13
|
+
*/
|
|
14
|
+
export type BalanceOfResponse = {
|
|
15
|
+
/** Token contract address */
|
|
16
|
+
tokenAddress: Address;
|
|
17
|
+
/** Account address */
|
|
18
|
+
accountAddress: Address;
|
|
19
|
+
/** Whether the call succeeded */
|
|
20
|
+
success: boolean;
|
|
21
|
+
/** Balance as string (raw value) */
|
|
22
|
+
balance?: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=multicall.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multicall.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/multicall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAe;AAEtC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6BAA6B;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Address } from "./core.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Balance request for batch balance fetching.
|
|
4
|
+
*/
|
|
5
|
+
export type BalanceOfRequest = {
|
|
6
|
+
/** Token contract address (zero address for native) */
|
|
7
|
+
tokenAddress: Address;
|
|
8
|
+
/** Account address to check balance for */
|
|
9
|
+
accountAddress: Address;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Balance response from batch balance fetching.
|
|
13
|
+
*/
|
|
14
|
+
export type BalanceOfResponse = {
|
|
15
|
+
/** Token contract address */
|
|
16
|
+
tokenAddress: Address;
|
|
17
|
+
/** Account address */
|
|
18
|
+
accountAddress: Address;
|
|
19
|
+
/** Whether the call succeeded */
|
|
20
|
+
success: boolean;
|
|
21
|
+
/** Balance as string (raw value) */
|
|
22
|
+
balance?: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=multicall.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multicall.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/multicall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAe;AAEtC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;IACtB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6BAA6B;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multicall.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/multicall.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from './core';\n\n/**\n * Balance request for batch balance fetching.\n */\nexport type BalanceOfRequest = {\n /** Token contract address (zero address for native) */\n tokenAddress: Address;\n /** Account address to check balance for */\n accountAddress: Address;\n};\n\n/**\n * Balance response from batch balance fetching.\n */\nexport type BalanceOfResponse = {\n /** Token contract address */\n tokenAddress: Address;\n /** Account address */\n accountAddress: Address;\n /** Whether the call succeeded */\n success: boolean;\n /** Balance as string (raw value) */\n balance?: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/services.ts"],"names":[],"mappings":"","sourcesContent":["import type { Asset, AssetBalance } from './assets';\nimport type { AccountId, Address, ChainId } from './core';\n\n/**\n * Token detection result.\n */\nexport type TokenDetectionResult = {\n /** Chain ID */\n chainId: ChainId;\n /** Account ID */\n accountId: AccountId;\n /** Account address used for detection */\n accountAddress: Address;\n /** Newly detected tokens with non-zero balances */\n detectedAssets: Asset[];\n /** Balances for newly detected tokens */\n detectedBalances: AssetBalance[];\n /** Tokens that were checked but had zero balance */\n zeroBalanceAddresses: Address[];\n /** Tokens that failed to be checked */\n failedAddresses: Address[];\n /** Timestamp of detection */\n timestamp: number;\n};\n\n/**\n * Token detection options.\n */\nexport type TokenDetectionOptions = {\n /** Maximum number of tokens to check per batch */\n batchSize?: number;\n /** Timeout for detection in milliseconds */\n timeout?: number;\n};\n\n/**\n * Balance fetch result.\n */\nexport type BalanceFetchResult = {\n /** Chain ID */\n chainId: ChainId;\n /** Account ID */\n accountId: AccountId;\n /** Account address */\n accountAddress: Address;\n /** Fetched balances */\n balances: AssetBalance[];\n /** Token addresses that failed to fetch */\n failedAddresses: Address[];\n /** Block number when balances were fetched */\n blockNumber?: number;\n /** Timestamp of fetch */\n timestamp: number;\n};\n\n/**\n * Balance fetch options.\n */\nexport type BalanceFetchOptions = {\n /** Maximum number of tokens to fetch per batch */\n batchSize?: number;\n /** Timeout for fetch in milliseconds */\n timeout?: number;\n /** Include native token balance */\n includeNative?: boolean;\n};\n\n/**\n * Token info for balance fetching.\n */\nexport type TokenFetchInfo = {\n /** Token contract address */\n address: Address;\n /** Token decimals */\n decimals: number;\n /** Token symbol (optional) */\n symbol?: string;\n};\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Asset, AssetBalance } from "./assets.cjs";
|
|
2
|
+
import type { AccountId, Address, ChainId } from "./core.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Token detection result.
|
|
5
|
+
*/
|
|
6
|
+
export type TokenDetectionResult = {
|
|
7
|
+
/** Chain ID */
|
|
8
|
+
chainId: ChainId;
|
|
9
|
+
/** Account ID */
|
|
10
|
+
accountId: AccountId;
|
|
11
|
+
/** Account address used for detection */
|
|
12
|
+
accountAddress: Address;
|
|
13
|
+
/** Newly detected tokens with non-zero balances */
|
|
14
|
+
detectedAssets: Asset[];
|
|
15
|
+
/** Balances for newly detected tokens */
|
|
16
|
+
detectedBalances: AssetBalance[];
|
|
17
|
+
/** Tokens that were checked but had zero balance */
|
|
18
|
+
zeroBalanceAddresses: Address[];
|
|
19
|
+
/** Tokens that failed to be checked */
|
|
20
|
+
failedAddresses: Address[];
|
|
21
|
+
/** Timestamp of detection */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Token detection options.
|
|
26
|
+
*/
|
|
27
|
+
export type TokenDetectionOptions = {
|
|
28
|
+
/** Maximum number of tokens to check per batch */
|
|
29
|
+
batchSize?: number;
|
|
30
|
+
/** Timeout for detection in milliseconds */
|
|
31
|
+
timeout?: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Balance fetch result.
|
|
35
|
+
*/
|
|
36
|
+
export type BalanceFetchResult = {
|
|
37
|
+
/** Chain ID */
|
|
38
|
+
chainId: ChainId;
|
|
39
|
+
/** Account ID */
|
|
40
|
+
accountId: AccountId;
|
|
41
|
+
/** Account address */
|
|
42
|
+
accountAddress: Address;
|
|
43
|
+
/** Fetched balances */
|
|
44
|
+
balances: AssetBalance[];
|
|
45
|
+
/** Token addresses that failed to fetch */
|
|
46
|
+
failedAddresses: Address[];
|
|
47
|
+
/** Block number when balances were fetched */
|
|
48
|
+
blockNumber?: number;
|
|
49
|
+
/** Timestamp of fetch */
|
|
50
|
+
timestamp: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Balance fetch options.
|
|
54
|
+
*/
|
|
55
|
+
export type BalanceFetchOptions = {
|
|
56
|
+
/** Maximum number of tokens to fetch per batch */
|
|
57
|
+
batchSize?: number;
|
|
58
|
+
/** Timeout for fetch in milliseconds */
|
|
59
|
+
timeout?: number;
|
|
60
|
+
/** Include native token balance */
|
|
61
|
+
includeNative?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Token info for balance fetching.
|
|
65
|
+
*/
|
|
66
|
+
export type TokenFetchInfo = {
|
|
67
|
+
/** Token contract address */
|
|
68
|
+
address: Address;
|
|
69
|
+
/** Token decimals */
|
|
70
|
+
decimals: number;
|
|
71
|
+
/** Token symbol (optional) */
|
|
72
|
+
symbol?: string;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=services.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,qBAAiB;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAe;AAE1D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,yCAAyC;IACzC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,oDAAoD;IACpD,oBAAoB,EAAE,OAAO,EAAE,CAAC;IAChC,uCAAuC;IACvC,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB;IACvB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,2CAA2C;IAC3C,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Asset, AssetBalance } from "./assets.mjs";
|
|
2
|
+
import type { AccountId, Address, ChainId } from "./core.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Token detection result.
|
|
5
|
+
*/
|
|
6
|
+
export type TokenDetectionResult = {
|
|
7
|
+
/** Chain ID */
|
|
8
|
+
chainId: ChainId;
|
|
9
|
+
/** Account ID */
|
|
10
|
+
accountId: AccountId;
|
|
11
|
+
/** Account address used for detection */
|
|
12
|
+
accountAddress: Address;
|
|
13
|
+
/** Newly detected tokens with non-zero balances */
|
|
14
|
+
detectedAssets: Asset[];
|
|
15
|
+
/** Balances for newly detected tokens */
|
|
16
|
+
detectedBalances: AssetBalance[];
|
|
17
|
+
/** Tokens that were checked but had zero balance */
|
|
18
|
+
zeroBalanceAddresses: Address[];
|
|
19
|
+
/** Tokens that failed to be checked */
|
|
20
|
+
failedAddresses: Address[];
|
|
21
|
+
/** Timestamp of detection */
|
|
22
|
+
timestamp: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Token detection options.
|
|
26
|
+
*/
|
|
27
|
+
export type TokenDetectionOptions = {
|
|
28
|
+
/** Maximum number of tokens to check per batch */
|
|
29
|
+
batchSize?: number;
|
|
30
|
+
/** Timeout for detection in milliseconds */
|
|
31
|
+
timeout?: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Balance fetch result.
|
|
35
|
+
*/
|
|
36
|
+
export type BalanceFetchResult = {
|
|
37
|
+
/** Chain ID */
|
|
38
|
+
chainId: ChainId;
|
|
39
|
+
/** Account ID */
|
|
40
|
+
accountId: AccountId;
|
|
41
|
+
/** Account address */
|
|
42
|
+
accountAddress: Address;
|
|
43
|
+
/** Fetched balances */
|
|
44
|
+
balances: AssetBalance[];
|
|
45
|
+
/** Token addresses that failed to fetch */
|
|
46
|
+
failedAddresses: Address[];
|
|
47
|
+
/** Block number when balances were fetched */
|
|
48
|
+
blockNumber?: number;
|
|
49
|
+
/** Timestamp of fetch */
|
|
50
|
+
timestamp: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Balance fetch options.
|
|
54
|
+
*/
|
|
55
|
+
export type BalanceFetchOptions = {
|
|
56
|
+
/** Maximum number of tokens to fetch per batch */
|
|
57
|
+
batchSize?: number;
|
|
58
|
+
/** Timeout for fetch in milliseconds */
|
|
59
|
+
timeout?: number;
|
|
60
|
+
/** Include native token balance */
|
|
61
|
+
includeNative?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Token info for balance fetching.
|
|
65
|
+
*/
|
|
66
|
+
export type TokenFetchInfo = {
|
|
67
|
+
/** Token contract address */
|
|
68
|
+
address: Address;
|
|
69
|
+
/** Token decimals */
|
|
70
|
+
decimals: number;
|
|
71
|
+
/** Token symbol (optional) */
|
|
72
|
+
symbol?: string;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=services.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,qBAAiB;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAe;AAE1D;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,yCAAyC;IACzC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,oDAAoD;IACpD,oBAAoB,EAAE,OAAO,EAAE,CAAC;IAChC,uCAAuC;IACvC,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB;IACvB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,2CAA2C;IAC3C,eAAe,EAAE,OAAO,EAAE,CAAC;IAC3B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/services.ts"],"names":[],"mappings":"","sourcesContent":["import type { Asset, AssetBalance } from './assets';\nimport type { AccountId, Address, ChainId } from './core';\n\n/**\n * Token detection result.\n */\nexport type TokenDetectionResult = {\n /** Chain ID */\n chainId: ChainId;\n /** Account ID */\n accountId: AccountId;\n /** Account address used for detection */\n accountAddress: Address;\n /** Newly detected tokens with non-zero balances */\n detectedAssets: Asset[];\n /** Balances for newly detected tokens */\n detectedBalances: AssetBalance[];\n /** Tokens that were checked but had zero balance */\n zeroBalanceAddresses: Address[];\n /** Tokens that failed to be checked */\n failedAddresses: Address[];\n /** Timestamp of detection */\n timestamp: number;\n};\n\n/**\n * Token detection options.\n */\nexport type TokenDetectionOptions = {\n /** Maximum number of tokens to check per batch */\n batchSize?: number;\n /** Timeout for detection in milliseconds */\n timeout?: number;\n};\n\n/**\n * Balance fetch result.\n */\nexport type BalanceFetchResult = {\n /** Chain ID */\n chainId: ChainId;\n /** Account ID */\n accountId: AccountId;\n /** Account address */\n accountAddress: Address;\n /** Fetched balances */\n balances: AssetBalance[];\n /** Token addresses that failed to fetch */\n failedAddresses: Address[];\n /** Block number when balances were fetched */\n blockNumber?: number;\n /** Timestamp of fetch */\n timestamp: number;\n};\n\n/**\n * Balance fetch options.\n */\nexport type BalanceFetchOptions = {\n /** Maximum number of tokens to fetch per batch */\n batchSize?: number;\n /** Timeout for fetch in milliseconds */\n timeout?: number;\n /** Include native token balance */\n includeNative?: boolean;\n};\n\n/**\n * Token info for balance fetching.\n */\nexport type TokenFetchInfo = {\n /** Token contract address */\n address: Address;\n /** Token decimals */\n decimals: number;\n /** Token symbol (optional) */\n symbol?: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address, ChainId } from './core';\n\n/**\n * Single token entry from token list.\n */\nexport type TokenListEntry = {\n /** Contract address */\n address: Address;\n /** Token symbol */\n symbol: string;\n /** Token name */\n name: string;\n /** Token decimals */\n decimals: number;\n /** Logo URL */\n iconUrl?: string;\n /** Aggregator sources */\n aggregators?: string[];\n /** Occurrence count in lists */\n occurrences?: number;\n};\n\n/**\n * Cache entry for a chain's token list.\n */\nexport type TokenChainsCacheEntry = {\n /** Timestamp when the cache was last updated */\n timestamp: number;\n /** Token list data: address -> TokenListEntry */\n data: Record<Address, TokenListEntry>;\n};\n\n/**\n * Token list state shape (from TokenListController).\n */\nexport type TokenListState = {\n /** Map of chain ID to token list cache entry */\n tokensChainsCache: Record<ChainId, TokenChainsCacheEntry>;\n};\n\n/**\n * Single asset balance entry.\n */\nexport type AssetBalanceEntry = {\n /** Human-readable balance amount */\n amount: string;\n};\n\n/**\n * Assets balance state shape (from AssetsController).\n * Maps accountId -> assetId (CAIP-19) -> balance entry.\n */\nexport type AssetsBalanceState = {\n /** Balance data per account: accountId -> assetId -> balance */\n assetsBalance: Record<string, Record<string, AssetBalanceEntry>>;\n};\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Address, ChainId } from "./core.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Single token entry from token list.
|
|
4
|
+
*/
|
|
5
|
+
export type TokenListEntry = {
|
|
6
|
+
/** Contract address */
|
|
7
|
+
address: Address;
|
|
8
|
+
/** Token symbol */
|
|
9
|
+
symbol: string;
|
|
10
|
+
/** Token name */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Token decimals */
|
|
13
|
+
decimals: number;
|
|
14
|
+
/** Logo URL */
|
|
15
|
+
iconUrl?: string;
|
|
16
|
+
/** Aggregator sources */
|
|
17
|
+
aggregators?: string[];
|
|
18
|
+
/** Occurrence count in lists */
|
|
19
|
+
occurrences?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Cache entry for a chain's token list.
|
|
23
|
+
*/
|
|
24
|
+
export type TokenChainsCacheEntry = {
|
|
25
|
+
/** Timestamp when the cache was last updated */
|
|
26
|
+
timestamp: number;
|
|
27
|
+
/** Token list data: address -> TokenListEntry */
|
|
28
|
+
data: Record<Address, TokenListEntry>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Token list state shape (from TokenListController).
|
|
32
|
+
*/
|
|
33
|
+
export type TokenListState = {
|
|
34
|
+
/** Map of chain ID to token list cache entry */
|
|
35
|
+
tokensChainsCache: Record<ChainId, TokenChainsCacheEntry>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Single asset balance entry.
|
|
39
|
+
*/
|
|
40
|
+
export type AssetBalanceEntry = {
|
|
41
|
+
/** Human-readable balance amount */
|
|
42
|
+
amount: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Assets balance state shape (from AssetsController).
|
|
46
|
+
* Maps accountId -> assetId (CAIP-19) -> balance entry.
|
|
47
|
+
*/
|
|
48
|
+
export type AssetsBalanceState = {
|
|
49
|
+
/** Balance data per account: accountId -> assetId -> balance */
|
|
50
|
+
assetsBalance: Record<string, Record<string, AssetBalanceEntry>>;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=state.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAe;AAE/C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAClE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Address, ChainId } from "./core.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Single token entry from token list.
|
|
4
|
+
*/
|
|
5
|
+
export type TokenListEntry = {
|
|
6
|
+
/** Contract address */
|
|
7
|
+
address: Address;
|
|
8
|
+
/** Token symbol */
|
|
9
|
+
symbol: string;
|
|
10
|
+
/** Token name */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Token decimals */
|
|
13
|
+
decimals: number;
|
|
14
|
+
/** Logo URL */
|
|
15
|
+
iconUrl?: string;
|
|
16
|
+
/** Aggregator sources */
|
|
17
|
+
aggregators?: string[];
|
|
18
|
+
/** Occurrence count in lists */
|
|
19
|
+
occurrences?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Cache entry for a chain's token list.
|
|
23
|
+
*/
|
|
24
|
+
export type TokenChainsCacheEntry = {
|
|
25
|
+
/** Timestamp when the cache was last updated */
|
|
26
|
+
timestamp: number;
|
|
27
|
+
/** Token list data: address -> TokenListEntry */
|
|
28
|
+
data: Record<Address, TokenListEntry>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Token list state shape (from TokenListController).
|
|
32
|
+
*/
|
|
33
|
+
export type TokenListState = {
|
|
34
|
+
/** Map of chain ID to token list cache entry */
|
|
35
|
+
tokensChainsCache: Record<ChainId, TokenChainsCacheEntry>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Single asset balance entry.
|
|
39
|
+
*/
|
|
40
|
+
export type AssetBalanceEntry = {
|
|
41
|
+
/** Human-readable balance amount */
|
|
42
|
+
amount: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Assets balance state shape (from AssetsController).
|
|
46
|
+
* Maps accountId -> assetId (CAIP-19) -> balance entry.
|
|
47
|
+
*/
|
|
48
|
+
export type AssetsBalanceState = {
|
|
49
|
+
/** Balance data per account: accountId -> assetId -> balance */
|
|
50
|
+
assetsBalance: Record<string, Record<string, AssetBalanceEntry>>;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=state.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,mBAAe;AAE/C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,gDAAgD;IAChD,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address, ChainId } from './core';\n\n/**\n * Single token entry from token list.\n */\nexport type TokenListEntry = {\n /** Contract address */\n address: Address;\n /** Token symbol */\n symbol: string;\n /** Token name */\n name: string;\n /** Token decimals */\n decimals: number;\n /** Logo URL */\n iconUrl?: string;\n /** Aggregator sources */\n aggregators?: string[];\n /** Occurrence count in lists */\n occurrences?: number;\n};\n\n/**\n * Cache entry for a chain's token list.\n */\nexport type TokenChainsCacheEntry = {\n /** Timestamp when the cache was last updated */\n timestamp: number;\n /** Token list data: address -> TokenListEntry */\n data: Record<Address, TokenListEntry>;\n};\n\n/**\n * Token list state shape (from TokenListController).\n */\nexport type TokenListState = {\n /** Map of chain ID to token list cache entry */\n tokensChainsCache: Record<ChainId, TokenChainsCacheEntry>;\n};\n\n/**\n * Single asset balance entry.\n */\nexport type AssetBalanceEntry = {\n /** Human-readable balance amount */\n amount: string;\n};\n\n/**\n * Assets balance state shape (from AssetsController).\n * Maps accountId -> assetId (CAIP-19) -> balance entry.\n */\nexport type AssetsBalanceState = {\n /** Balance data per account: accountId -> assetId -> balance */\n assetsBalance: Record<string, Record<string, AssetBalanceEntry>>;\n};\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reduceInBatchesSerially = exports.divideIntoBatches = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Divides an array into batches of specified size.
|
|
6
|
+
*
|
|
7
|
+
* @param values - Array of values to divide.
|
|
8
|
+
* @param options - Options containing batchSize.
|
|
9
|
+
* @param options.batchSize - The size of each batch.
|
|
10
|
+
* @returns Array of batches.
|
|
11
|
+
*/
|
|
12
|
+
function divideIntoBatches(values, { batchSize }) {
|
|
13
|
+
if (batchSize <= 0) {
|
|
14
|
+
throw new Error('batchSize must be greater than 0');
|
|
15
|
+
}
|
|
16
|
+
const batches = [];
|
|
17
|
+
for (let i = 0; i < values.length; i += batchSize) {
|
|
18
|
+
batches.push(values.slice(i, i + batchSize));
|
|
19
|
+
}
|
|
20
|
+
return batches;
|
|
21
|
+
}
|
|
22
|
+
exports.divideIntoBatches = divideIntoBatches;
|
|
23
|
+
/**
|
|
24
|
+
* Reduces an array in serial batches, applying an async function to each batch.
|
|
25
|
+
*
|
|
26
|
+
* @param options - The options for batch reduction.
|
|
27
|
+
* @param options.values - Array of values to process.
|
|
28
|
+
* @param options.batchSize - Size of each batch.
|
|
29
|
+
* @param options.eachBatch - Async function to apply to each batch.
|
|
30
|
+
* @param options.initialResult - Initial result value.
|
|
31
|
+
* @returns The final reduced result.
|
|
32
|
+
*/
|
|
33
|
+
async function reduceInBatchesSerially({ values, batchSize, eachBatch, initialResult, }) {
|
|
34
|
+
const batches = divideIntoBatches(values, { batchSize });
|
|
35
|
+
let workingResult = initialResult;
|
|
36
|
+
for (const [index, batch] of batches.entries()) {
|
|
37
|
+
workingResult = await eachBatch(workingResult, batch, index);
|
|
38
|
+
}
|
|
39
|
+
// There's no way around this — we have to assume that in the end, the result
|
|
40
|
+
// matches the intended type.
|
|
41
|
+
const finalResult = workingResult;
|
|
42
|
+
return finalResult;
|
|
43
|
+
}
|
|
44
|
+
exports.reduceInBatchesSerially = reduceInBatchesSerially;
|
|
45
|
+
//# sourceMappingURL=batch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/batch.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,MAAsB,EACtB,EAAE,SAAS,EAAyB;IAEpC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAbD,8CAaC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,uBAAuB,CAAgB,EAC3D,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GAUd;IACC,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACzD,IAAI,aAAa,GAAG,aAAa,CAAC;IAClC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,aAAa,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IACD,6EAA6E;IAC7E,6BAA6B;IAC7B,MAAM,WAAW,GAAG,aAAuB,CAAC;IAC5C,OAAO,WAAW,CAAC;AACrB,CAAC;AAxBD,0DAwBC","sourcesContent":["/**\n * Divides an array into batches of specified size.\n *\n * @param values - Array of values to divide.\n * @param options - Options containing batchSize.\n * @param options.batchSize - The size of each batch.\n * @returns Array of batches.\n */\nexport function divideIntoBatches<ArrayElement>(\n values: ArrayElement[],\n { batchSize }: { batchSize: number },\n): ArrayElement[][] {\n if (batchSize <= 0) {\n throw new Error('batchSize must be greater than 0');\n }\n\n const batches: ArrayElement[][] = [];\n for (let i = 0; i < values.length; i += batchSize) {\n batches.push(values.slice(i, i + batchSize));\n }\n return batches;\n}\n\n/**\n * Reduces an array in serial batches, applying an async function to each batch.\n *\n * @param options - The options for batch reduction.\n * @param options.values - Array of values to process.\n * @param options.batchSize - Size of each batch.\n * @param options.eachBatch - Async function to apply to each batch.\n * @param options.initialResult - Initial result value.\n * @returns The final reduced result.\n */\nexport async function reduceInBatchesSerially<Value, Result>({\n values,\n batchSize,\n eachBatch,\n initialResult,\n}: {\n values: Value[];\n batchSize: number;\n eachBatch: (\n workingResult: Partial<Result>,\n batch: Value[],\n index: number,\n ) => Partial<Result> | Promise<Partial<Result>>;\n initialResult: Partial<Result>;\n}): Promise<Result> {\n const batches = divideIntoBatches(values, { batchSize });\n let workingResult = initialResult;\n for (const [index, batch] of batches.entries()) {\n workingResult = await eachBatch(workingResult, batch, index);\n }\n // There's no way around this — we have to assume that in the end, the result\n // matches the intended type.\n const finalResult = workingResult as Result;\n return finalResult;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divides an array into batches of specified size.
|
|
3
|
+
*
|
|
4
|
+
* @param values - Array of values to divide.
|
|
5
|
+
* @param options - Options containing batchSize.
|
|
6
|
+
* @param options.batchSize - The size of each batch.
|
|
7
|
+
* @returns Array of batches.
|
|
8
|
+
*/
|
|
9
|
+
export declare function divideIntoBatches<ArrayElement>(values: ArrayElement[], { batchSize }: {
|
|
10
|
+
batchSize: number;
|
|
11
|
+
}): ArrayElement[][];
|
|
12
|
+
/**
|
|
13
|
+
* Reduces an array in serial batches, applying an async function to each batch.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The options for batch reduction.
|
|
16
|
+
* @param options.values - Array of values to process.
|
|
17
|
+
* @param options.batchSize - Size of each batch.
|
|
18
|
+
* @param options.eachBatch - Async function to apply to each batch.
|
|
19
|
+
* @param options.initialResult - Initial result value.
|
|
20
|
+
* @returns The final reduced result.
|
|
21
|
+
*/
|
|
22
|
+
export declare function reduceInBatchesSerially<Value, Result>({ values, batchSize, eachBatch, initialResult, }: {
|
|
23
|
+
values: Value[];
|
|
24
|
+
batchSize: number;
|
|
25
|
+
eachBatch: (workingResult: Partial<Result>, batch: Value[], index: number) => Partial<Result> | Promise<Partial<Result>>;
|
|
26
|
+
initialResult: Partial<Result>;
|
|
27
|
+
}): Promise<Result>;
|
|
28
|
+
//# sourceMappingURL=batch.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAC5C,MAAM,EAAE,YAAY,EAAE,EACtB,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACnC,YAAY,EAAE,EAAE,CAUlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,EAC3D,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GACd,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CACT,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,EAC9B,KAAK,EAAE,KAAK,EAAE,EACd,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divides an array into batches of specified size.
|
|
3
|
+
*
|
|
4
|
+
* @param values - Array of values to divide.
|
|
5
|
+
* @param options - Options containing batchSize.
|
|
6
|
+
* @param options.batchSize - The size of each batch.
|
|
7
|
+
* @returns Array of batches.
|
|
8
|
+
*/
|
|
9
|
+
export declare function divideIntoBatches<ArrayElement>(values: ArrayElement[], { batchSize }: {
|
|
10
|
+
batchSize: number;
|
|
11
|
+
}): ArrayElement[][];
|
|
12
|
+
/**
|
|
13
|
+
* Reduces an array in serial batches, applying an async function to each batch.
|
|
14
|
+
*
|
|
15
|
+
* @param options - The options for batch reduction.
|
|
16
|
+
* @param options.values - Array of values to process.
|
|
17
|
+
* @param options.batchSize - Size of each batch.
|
|
18
|
+
* @param options.eachBatch - Async function to apply to each batch.
|
|
19
|
+
* @param options.initialResult - Initial result value.
|
|
20
|
+
* @returns The final reduced result.
|
|
21
|
+
*/
|
|
22
|
+
export declare function reduceInBatchesSerially<Value, Result>({ values, batchSize, eachBatch, initialResult, }: {
|
|
23
|
+
values: Value[];
|
|
24
|
+
batchSize: number;
|
|
25
|
+
eachBatch: (workingResult: Partial<Result>, batch: Value[], index: number) => Partial<Result> | Promise<Partial<Result>>;
|
|
26
|
+
initialResult: Partial<Result>;
|
|
27
|
+
}): Promise<Result>;
|
|
28
|
+
//# sourceMappingURL=batch.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAC5C,MAAM,EAAE,YAAY,EAAE,EACtB,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACnC,YAAY,EAAE,EAAE,CAUlB;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,EAC3D,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GACd,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CACT,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,EAC9B,KAAK,EAAE,KAAK,EAAE,EACd,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divides an array into batches of specified size.
|
|
3
|
+
*
|
|
4
|
+
* @param values - Array of values to divide.
|
|
5
|
+
* @param options - Options containing batchSize.
|
|
6
|
+
* @param options.batchSize - The size of each batch.
|
|
7
|
+
* @returns Array of batches.
|
|
8
|
+
*/
|
|
9
|
+
export function divideIntoBatches(values, { batchSize }) {
|
|
10
|
+
if (batchSize <= 0) {
|
|
11
|
+
throw new Error('batchSize must be greater than 0');
|
|
12
|
+
}
|
|
13
|
+
const batches = [];
|
|
14
|
+
for (let i = 0; i < values.length; i += batchSize) {
|
|
15
|
+
batches.push(values.slice(i, i + batchSize));
|
|
16
|
+
}
|
|
17
|
+
return batches;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reduces an array in serial batches, applying an async function to each batch.
|
|
21
|
+
*
|
|
22
|
+
* @param options - The options for batch reduction.
|
|
23
|
+
* @param options.values - Array of values to process.
|
|
24
|
+
* @param options.batchSize - Size of each batch.
|
|
25
|
+
* @param options.eachBatch - Async function to apply to each batch.
|
|
26
|
+
* @param options.initialResult - Initial result value.
|
|
27
|
+
* @returns The final reduced result.
|
|
28
|
+
*/
|
|
29
|
+
export async function reduceInBatchesSerially({ values, batchSize, eachBatch, initialResult, }) {
|
|
30
|
+
const batches = divideIntoBatches(values, { batchSize });
|
|
31
|
+
let workingResult = initialResult;
|
|
32
|
+
for (const [index, batch] of batches.entries()) {
|
|
33
|
+
workingResult = await eachBatch(workingResult, batch, index);
|
|
34
|
+
}
|
|
35
|
+
// There's no way around this — we have to assume that in the end, the result
|
|
36
|
+
// matches the intended type.
|
|
37
|
+
const finalResult = workingResult;
|
|
38
|
+
return finalResult;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=batch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAsB,EACtB,EAAE,SAAS,EAAyB;IAEpC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,SAAS,EAAE,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAgB,EAC3D,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,GAUd;IACC,MAAM,OAAO,GAAG,iBAAiB,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACzD,IAAI,aAAa,GAAG,aAAa,CAAC;IAClC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,aAAa,GAAG,MAAM,SAAS,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IACD,6EAA6E;IAC7E,6BAA6B;IAC7B,MAAM,WAAW,GAAG,aAAuB,CAAC;IAC5C,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Divides an array into batches of specified size.\n *\n * @param values - Array of values to divide.\n * @param options - Options containing batchSize.\n * @param options.batchSize - The size of each batch.\n * @returns Array of batches.\n */\nexport function divideIntoBatches<ArrayElement>(\n values: ArrayElement[],\n { batchSize }: { batchSize: number },\n): ArrayElement[][] {\n if (batchSize <= 0) {\n throw new Error('batchSize must be greater than 0');\n }\n\n const batches: ArrayElement[][] = [];\n for (let i = 0; i < values.length; i += batchSize) {\n batches.push(values.slice(i, i + batchSize));\n }\n return batches;\n}\n\n/**\n * Reduces an array in serial batches, applying an async function to each batch.\n *\n * @param options - The options for batch reduction.\n * @param options.values - Array of values to process.\n * @param options.batchSize - Size of each batch.\n * @param options.eachBatch - Async function to apply to each batch.\n * @param options.initialResult - Initial result value.\n * @returns The final reduced result.\n */\nexport async function reduceInBatchesSerially<Value, Result>({\n values,\n batchSize,\n eachBatch,\n initialResult,\n}: {\n values: Value[];\n batchSize: number;\n eachBatch: (\n workingResult: Partial<Result>,\n batch: Value[],\n index: number,\n ) => Partial<Result> | Promise<Partial<Result>>;\n initialResult: Partial<Result>;\n}): Promise<Result> {\n const batches = divideIntoBatches(values, { batchSize });\n let workingResult = initialResult;\n for (const [index, batch] of batches.entries()) {\n workingResult = await eachBatch(workingResult, batch, index);\n }\n // There's no way around this — we have to assume that in the end, the result\n // matches the intended type.\n const finalResult = workingResult as Result;\n return finalResult;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reduceInBatchesSerially = exports.divideIntoBatches = void 0;
|
|
4
|
+
var batch_1 = require("./batch.cjs");
|
|
5
|
+
Object.defineProperty(exports, "divideIntoBatches", { enumerable: true, get: function () { return batch_1.divideIntoBatches; } });
|
|
6
|
+
Object.defineProperty(exports, "reduceInBatchesSerially", { enumerable: true, get: function () { return batch_1.reduceInBatchesSerially; } });
|
|
7
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/index.ts"],"names":[],"mappings":";;;AAAA,qCAAqE;AAA5D,0GAAA,iBAAiB,OAAA;AAAE,gHAAA,uBAAuB,OAAA","sourcesContent":["export { divideIntoBatches, reduceInBatchesSerially } from './batch';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAgB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAgB","sourcesContent":["export { divideIntoBatches, reduceInBatchesSerially } from './batch';\n"]}
|