@metamask-previews/assets-controller 1.0.0-preview-ee8f1b28b → 2.0.0-preview-33dbba4f3
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 +6 -1
- package/dist/AssetsController.cjs +61 -18
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +13 -8
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +13 -8
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +62 -19
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +9 -11
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs +7 -9
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.cjs +6 -4
- package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.mjs +6 -4
- package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
- package/dist/data-sources/PriceDataSource.cjs +13 -3
- package/dist/data-sources/PriceDataSource.cjs.map +1 -1
- package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
- package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
- package/dist/data-sources/PriceDataSource.mjs +13 -3
- package/dist/data-sources/PriceDataSource.mjs.map +1 -1
- package/dist/data-sources/RpcDataSource.cjs +80 -10
- package/dist/data-sources/RpcDataSource.cjs.map +1 -1
- package/dist/data-sources/RpcDataSource.d.cts +8 -59
- package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
- package/dist/data-sources/RpcDataSource.d.mts +8 -59
- package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
- package/dist/data-sources/RpcDataSource.mjs +81 -11
- package/dist/data-sources/RpcDataSource.mjs.map +1 -1
- package/dist/data-sources/SnapDataSource.cjs +16 -4
- package/dist/data-sources/SnapDataSource.cjs.map +1 -1
- package/dist/data-sources/SnapDataSource.d.cts +2 -1
- package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
- package/dist/data-sources/SnapDataSource.d.mts +2 -1
- package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
- package/dist/data-sources/SnapDataSource.mjs +16 -4
- package/dist/data-sources/SnapDataSource.mjs.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.cjs +609 -0
- package/dist/data-sources/StakedBalanceDataSource.cjs.map +1 -0
- package/dist/data-sources/StakedBalanceDataSource.d.cts +72 -0
- package/dist/data-sources/StakedBalanceDataSource.d.cts.map +1 -0
- package/dist/data-sources/StakedBalanceDataSource.d.mts +72 -0
- package/dist/data-sources/StakedBalanceDataSource.d.mts.map +1 -0
- package/dist/data-sources/StakedBalanceDataSource.mjs +605 -0
- package/dist/data-sources/StakedBalanceDataSource.mjs.map +1 -0
- package/dist/data-sources/TokenDataSource.cjs +5 -0
- package/dist/data-sources/TokenDataSource.cjs.map +1 -1
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
- package/dist/data-sources/TokenDataSource.mjs +5 -0
- package/dist/data-sources/TokenDataSource.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.cjs +5 -1
- package/dist/data-sources/evm-rpc-services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.cts +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.mts +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.mjs +1 -1
- package/dist/data-sources/evm-rpc-services/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs +132 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts +78 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts +78 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.mjs +126 -0
- package/dist/data-sources/evm-rpc-services/services/StakedBalanceFetcher.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.cjs +6 -1
- package/dist/data-sources/evm-rpc-services/services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.cts +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.mts +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.mjs +1 -0
- package/dist/data-sources/evm-rpc-services/services/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.d.cts +3 -3
- package/dist/data-sources/evm-rpc-services/types/state.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.d.mts +3 -3
- package/dist/data-sources/evm-rpc-services/types/state.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/types/state.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/index.cjs +9 -1
- package/dist/data-sources/evm-rpc-services/utils/index.cjs.map +1 -1
- 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 -1
- 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 -1
- package/dist/data-sources/evm-rpc-services/utils/index.mjs +2 -0
- package/dist/data-sources/evm-rpc-services/utils/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/utils/parsing.cjs +47 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.cts +25 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.mts +25 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.mjs +39 -0
- package/dist/data-sources/evm-rpc-services/utils/parsing.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.cjs +68 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.cts +25 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.mts +25 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.mjs +62 -0
- package/dist/data-sources/evm-rpc-services/utils/staking-contracts.mjs.map +1 -0
- package/dist/data-sources/index.cjs +3 -1
- package/dist/data-sources/index.cjs.map +1 -1
- package/dist/data-sources/index.d.cts +1 -0
- package/dist/data-sources/index.d.cts.map +1 -1
- package/dist/data-sources/index.d.mts +1 -0
- package/dist/data-sources/index.d.mts.map +1 -1
- package/dist/data-sources/index.mjs +1 -0
- package/dist/data-sources/index.mjs.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Web3Provider } from "@ethersproject/providers";
|
|
2
|
+
import type { Address, AccountId, ChainId } from "../types/index.cjs";
|
|
3
|
+
import { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId } from "../utils/index.cjs";
|
|
4
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, };
|
|
5
|
+
export type StakedBalancePollingInput = {
|
|
6
|
+
/** Chain ID (hex format, e.g. 0x1) */
|
|
7
|
+
chainId: ChainId;
|
|
8
|
+
/** Account ID */
|
|
9
|
+
accountId: AccountId;
|
|
10
|
+
/** Account address */
|
|
11
|
+
accountAddress: Address;
|
|
12
|
+
};
|
|
13
|
+
/** Human-readable staked balance (e.g. "1.5" for 1.5 ETH). */
|
|
14
|
+
export type StakedBalance = {
|
|
15
|
+
amount: string;
|
|
16
|
+
};
|
|
17
|
+
/** Result reported via the update callback. */
|
|
18
|
+
export type StakedBalanceFetchResult = {
|
|
19
|
+
/** Account ID (UUID). */
|
|
20
|
+
accountId: AccountId;
|
|
21
|
+
/** Hex chain ID. */
|
|
22
|
+
chainId: ChainId;
|
|
23
|
+
/** Human-readable staked balance. */
|
|
24
|
+
balance: StakedBalance;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Callback type for staked balance updates.
|
|
28
|
+
*/
|
|
29
|
+
export type OnStakedBalanceUpdateCallback = (result: StakedBalanceFetchResult) => void;
|
|
30
|
+
export type StakedBalanceFetcherConfig = {
|
|
31
|
+
/** Polling interval in ms (default: 180s) */
|
|
32
|
+
pollingInterval?: number;
|
|
33
|
+
/** Returns the network provider for the given chain. Required for fetchStakedBalance. */
|
|
34
|
+
getNetworkProvider?: (chainId: ChainId) => Web3Provider | undefined;
|
|
35
|
+
};
|
|
36
|
+
declare const StakedBalanceFetcher_base: (abstract new (...args: any[]) => {
|
|
37
|
+
readonly "__#15@#intervalIds": Record<string, NodeJS.Timeout>;
|
|
38
|
+
"__#15@#intervalLength": number | undefined;
|
|
39
|
+
setIntervalLength(intervalLength: number): void;
|
|
40
|
+
getIntervalLength(): number | undefined; /** Chain ID (hex format, e.g. 0x1) */
|
|
41
|
+
_startPolling(input: StakedBalancePollingInput): void;
|
|
42
|
+
_stopPollingByPollingTokenSetId(key: string): void;
|
|
43
|
+
readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
|
|
44
|
+
readonly "__#3@#callbacks": Map<string, Set<(input: StakedBalancePollingInput) => void>>;
|
|
45
|
+
_executePoll(input: StakedBalancePollingInput): Promise<void>;
|
|
46
|
+
startPolling(input: StakedBalancePollingInput): string;
|
|
47
|
+
stopAllPolling(): void;
|
|
48
|
+
stopPollingByPollingToken(pollingToken: string): void;
|
|
49
|
+
onPollingComplete(input: StakedBalancePollingInput, callback: (input: StakedBalancePollingInput) => void): void;
|
|
50
|
+
}) & {
|
|
51
|
+
new (): {};
|
|
52
|
+
};
|
|
53
|
+
export declare class StakedBalanceFetcher extends StakedBalanceFetcher_base {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(config?: StakedBalanceFetcherConfig);
|
|
56
|
+
/**
|
|
57
|
+
* Register a callback that is invoked after every successful poll with
|
|
58
|
+
* the staked balance (including zero). Zero is reported so that merged
|
|
59
|
+
* updates can clear prior non-zero state.
|
|
60
|
+
*
|
|
61
|
+
* @param callback - The callback to invoke.
|
|
62
|
+
*/
|
|
63
|
+
setOnStakedBalanceUpdate(callback: OnStakedBalanceUpdateCallback): void;
|
|
64
|
+
_executePoll(input: StakedBalancePollingInput): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Fetches the staked balance for an account on a chain using the same
|
|
67
|
+
* staking contract as AccountTrackerController (getShares then convertToAssets).
|
|
68
|
+
* Returns a human-readable amount string (e.g. "1.5" for 1.5 ETH).
|
|
69
|
+
* Throws when no provider is available or when the RPC/contract call fails, so
|
|
70
|
+
* callers do not persist a false zero and overwrite existing balances.
|
|
71
|
+
*
|
|
72
|
+
* @param input - Chain, account ID, and address to query.
|
|
73
|
+
* @returns Human-readable staked balance (amount string).
|
|
74
|
+
* @throws When provider is missing or when getShares/convertToAssets fails.
|
|
75
|
+
*/
|
|
76
|
+
fetchStakedBalance(input: StakedBalancePollingInput): Promise<StakedBalance>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=StakedBalanceFetcher.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StakedBalanceFetcher.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/StakedBalanceFetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iCAAiC;AAGxD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,2BAAiB;AAC5D,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EAEzB,2BAAiB;AAElB,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,GACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,yBAAyB;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAC1C,MAAM,EAAE,wBAAwB,KAC7B,IAAI,CAAC;AAwBV,MAAM,MAAM,0BAA0B,GAAG;IACvC,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,YAAY,GAAG,SAAS,CAAC;CACrE,CAAC;;;;;6CAzDA,sCAAsC;;;;;;;;;;;;;AA6DxC,qBAAa,oBAAqB,SAAQ,yBAAgE;;gBAK5F,MAAM,CAAC,EAAE,0BAA0B;IAS/C;;;;;;OAMG;IACH,wBAAwB,CAAC,QAAQ,EAAE,6BAA6B,GAAG,IAAI;IAIjE,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBnE;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,aAAa,CAAC;CAoD1B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Web3Provider } from "@ethersproject/providers";
|
|
2
|
+
import type { Address, AccountId, ChainId } from "../types/index.mjs";
|
|
3
|
+
import { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId } from "../utils/index.mjs";
|
|
4
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, };
|
|
5
|
+
export type StakedBalancePollingInput = {
|
|
6
|
+
/** Chain ID (hex format, e.g. 0x1) */
|
|
7
|
+
chainId: ChainId;
|
|
8
|
+
/** Account ID */
|
|
9
|
+
accountId: AccountId;
|
|
10
|
+
/** Account address */
|
|
11
|
+
accountAddress: Address;
|
|
12
|
+
};
|
|
13
|
+
/** Human-readable staked balance (e.g. "1.5" for 1.5 ETH). */
|
|
14
|
+
export type StakedBalance = {
|
|
15
|
+
amount: string;
|
|
16
|
+
};
|
|
17
|
+
/** Result reported via the update callback. */
|
|
18
|
+
export type StakedBalanceFetchResult = {
|
|
19
|
+
/** Account ID (UUID). */
|
|
20
|
+
accountId: AccountId;
|
|
21
|
+
/** Hex chain ID. */
|
|
22
|
+
chainId: ChainId;
|
|
23
|
+
/** Human-readable staked balance. */
|
|
24
|
+
balance: StakedBalance;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Callback type for staked balance updates.
|
|
28
|
+
*/
|
|
29
|
+
export type OnStakedBalanceUpdateCallback = (result: StakedBalanceFetchResult) => void;
|
|
30
|
+
export type StakedBalanceFetcherConfig = {
|
|
31
|
+
/** Polling interval in ms (default: 180s) */
|
|
32
|
+
pollingInterval?: number;
|
|
33
|
+
/** Returns the network provider for the given chain. Required for fetchStakedBalance. */
|
|
34
|
+
getNetworkProvider?: (chainId: ChainId) => Web3Provider | undefined;
|
|
35
|
+
};
|
|
36
|
+
declare const StakedBalanceFetcher_base: (abstract new (...args: any[]) => {
|
|
37
|
+
readonly "__#15@#intervalIds": Record<string, NodeJS.Timeout>;
|
|
38
|
+
"__#15@#intervalLength": number | undefined;
|
|
39
|
+
setIntervalLength(intervalLength: number): void;
|
|
40
|
+
getIntervalLength(): number | undefined; /** Chain ID (hex format, e.g. 0x1) */
|
|
41
|
+
_startPolling(input: StakedBalancePollingInput): void;
|
|
42
|
+
_stopPollingByPollingTokenSetId(key: string): void;
|
|
43
|
+
readonly "__#3@#pollingTokenSets": Map<string, Set<string>>;
|
|
44
|
+
readonly "__#3@#callbacks": Map<string, Set<(input: StakedBalancePollingInput) => void>>;
|
|
45
|
+
_executePoll(input: StakedBalancePollingInput): Promise<void>;
|
|
46
|
+
startPolling(input: StakedBalancePollingInput): string;
|
|
47
|
+
stopAllPolling(): void;
|
|
48
|
+
stopPollingByPollingToken(pollingToken: string): void;
|
|
49
|
+
onPollingComplete(input: StakedBalancePollingInput, callback: (input: StakedBalancePollingInput) => void): void;
|
|
50
|
+
}) & {
|
|
51
|
+
new (): {};
|
|
52
|
+
};
|
|
53
|
+
export declare class StakedBalanceFetcher extends StakedBalanceFetcher_base {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(config?: StakedBalanceFetcherConfig);
|
|
56
|
+
/**
|
|
57
|
+
* Register a callback that is invoked after every successful poll with
|
|
58
|
+
* the staked balance (including zero). Zero is reported so that merged
|
|
59
|
+
* updates can clear prior non-zero state.
|
|
60
|
+
*
|
|
61
|
+
* @param callback - The callback to invoke.
|
|
62
|
+
*/
|
|
63
|
+
setOnStakedBalanceUpdate(callback: OnStakedBalanceUpdateCallback): void;
|
|
64
|
+
_executePoll(input: StakedBalancePollingInput): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Fetches the staked balance for an account on a chain using the same
|
|
67
|
+
* staking contract as AccountTrackerController (getShares then convertToAssets).
|
|
68
|
+
* Returns a human-readable amount string (e.g. "1.5" for 1.5 ETH).
|
|
69
|
+
* Throws when no provider is available or when the RPC/contract call fails, so
|
|
70
|
+
* callers do not persist a false zero and overwrite existing balances.
|
|
71
|
+
*
|
|
72
|
+
* @param input - Chain, account ID, and address to query.
|
|
73
|
+
* @returns Human-readable staked balance (amount string).
|
|
74
|
+
* @throws When provider is missing or when getShares/convertToAssets fails.
|
|
75
|
+
*/
|
|
76
|
+
fetchStakedBalance(input: StakedBalancePollingInput): Promise<StakedBalance>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=StakedBalanceFetcher.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StakedBalanceFetcher.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/StakedBalanceFetcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iCAAiC;AAGxD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,2BAAiB;AAC5D,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EAEzB,2BAAiB;AAElB,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,GACzB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,sBAAsB;IACtB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,yBAAyB;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAC1C,MAAM,EAAE,wBAAwB,KAC7B,IAAI,CAAC;AAwBV,MAAM,MAAM,0BAA0B,GAAG;IACvC,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,YAAY,GAAG,SAAS,CAAC;CACrE,CAAC;;;;;6CAzDA,sCAAsC;;;;;;;;;;;;;AA6DxC,qBAAa,oBAAqB,SAAQ,yBAAgE;;gBAK5F,MAAM,CAAC,EAAE,0BAA0B;IAS/C;;;;;;OAMG;IACH,wBAAwB,CAAC,QAAQ,EAAE,6BAA6B,GAAG,IAAI;IAIjE,YAAY,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBnE;;;;;;;;;;OAUG;IACG,kBAAkB,CACtB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,aAAa,CAAC;CAoD1B"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _StakedBalanceFetcher_providerGetter, _StakedBalanceFetcher_onStakedBalanceUpdate;
|
|
13
|
+
import { Interface } from "@ethersproject/abi";
|
|
14
|
+
import { Web3Provider } from "@ethersproject/providers";
|
|
15
|
+
import { StaticIntervalPollingControllerOnly } from "@metamask/polling-controller";
|
|
16
|
+
import { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, weiToHumanReadable } from "../utils/index.mjs";
|
|
17
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId };
|
|
18
|
+
/** Staking contract ABI: getShares(account) and convertToAssets(shares). */
|
|
19
|
+
const STAKING_CONTRACT_ABI = [
|
|
20
|
+
{
|
|
21
|
+
inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
|
|
22
|
+
name: 'getShares',
|
|
23
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
24
|
+
stateMutability: 'view',
|
|
25
|
+
type: 'function',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }],
|
|
29
|
+
name: 'convertToAssets',
|
|
30
|
+
outputs: [{ internalType: 'uint256', name: 'assets', type: 'uint256' }],
|
|
31
|
+
stateMutability: 'view',
|
|
32
|
+
type: 'function',
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
const STAKING_INTERFACE = new Interface(STAKING_CONTRACT_ABI);
|
|
36
|
+
const STAKING_DECIMALS = 18;
|
|
37
|
+
const DEFAULT_STAKED_BALANCE_INTERVAL = 180000; // 3 minutes
|
|
38
|
+
export class StakedBalanceFetcher extends StaticIntervalPollingControllerOnly() {
|
|
39
|
+
constructor(config) {
|
|
40
|
+
super();
|
|
41
|
+
_StakedBalanceFetcher_providerGetter.set(this, void 0);
|
|
42
|
+
_StakedBalanceFetcher_onStakedBalanceUpdate.set(this, void 0);
|
|
43
|
+
__classPrivateFieldSet(this, _StakedBalanceFetcher_providerGetter, config?.getNetworkProvider, "f");
|
|
44
|
+
this.setIntervalLength(config?.pollingInterval ?? DEFAULT_STAKED_BALANCE_INTERVAL);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Register a callback that is invoked after every successful poll with
|
|
48
|
+
* the staked balance (including zero). Zero is reported so that merged
|
|
49
|
+
* updates can clear prior non-zero state.
|
|
50
|
+
*
|
|
51
|
+
* @param callback - The callback to invoke.
|
|
52
|
+
*/
|
|
53
|
+
setOnStakedBalanceUpdate(callback) {
|
|
54
|
+
__classPrivateFieldSet(this, _StakedBalanceFetcher_onStakedBalanceUpdate, callback, "f");
|
|
55
|
+
}
|
|
56
|
+
async _executePoll(input) {
|
|
57
|
+
let result;
|
|
58
|
+
try {
|
|
59
|
+
result = await this.fetchStakedBalance(input);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Do not push an update on provider/RPC failure; otherwise we would
|
|
63
|
+
// overwrite existing non-zero staked balances with zero in state.
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (__classPrivateFieldGet(this, _StakedBalanceFetcher_onStakedBalanceUpdate, "f")) {
|
|
67
|
+
__classPrivateFieldGet(this, _StakedBalanceFetcher_onStakedBalanceUpdate, "f").call(this, {
|
|
68
|
+
accountId: input.accountId,
|
|
69
|
+
chainId: input.chainId,
|
|
70
|
+
balance: result,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fetches the staked balance for an account on a chain using the same
|
|
76
|
+
* staking contract as AccountTrackerController (getShares then convertToAssets).
|
|
77
|
+
* Returns a human-readable amount string (e.g. "1.5" for 1.5 ETH).
|
|
78
|
+
* Throws when no provider is available or when the RPC/contract call fails, so
|
|
79
|
+
* callers do not persist a false zero and overwrite existing balances.
|
|
80
|
+
*
|
|
81
|
+
* @param input - Chain, account ID, and address to query.
|
|
82
|
+
* @returns Human-readable staked balance (amount string).
|
|
83
|
+
* @throws When provider is missing or when getShares/convertToAssets fails.
|
|
84
|
+
*/
|
|
85
|
+
async fetchStakedBalance(input) {
|
|
86
|
+
const { chainId, accountAddress } = input;
|
|
87
|
+
const provider = __classPrivateFieldGet(this, _StakedBalanceFetcher_providerGetter, "f")?.call(this, chainId);
|
|
88
|
+
if (!provider) {
|
|
89
|
+
throw new Error('StakedBalanceFetcher: no provider available for chain');
|
|
90
|
+
}
|
|
91
|
+
const contractAddress = getStakingContractAddress(chainId);
|
|
92
|
+
if (!contractAddress) {
|
|
93
|
+
return { amount: '0' };
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const sharesCalldata = STAKING_INTERFACE.encodeFunctionData('getShares', [
|
|
97
|
+
accountAddress,
|
|
98
|
+
]);
|
|
99
|
+
const sharesResult = await provider.call({
|
|
100
|
+
to: contractAddress,
|
|
101
|
+
data: sharesCalldata,
|
|
102
|
+
});
|
|
103
|
+
const sharesRaw = STAKING_INTERFACE.decodeFunctionResult('getShares', sharesResult)[0];
|
|
104
|
+
const sharesBigNum = BigInt(sharesRaw.toString());
|
|
105
|
+
if (sharesBigNum === 0n) {
|
|
106
|
+
return { amount: '0' };
|
|
107
|
+
}
|
|
108
|
+
const assetsCalldata = STAKING_INTERFACE.encodeFunctionData('convertToAssets', [sharesBigNum]);
|
|
109
|
+
const assetsResult = await provider.call({
|
|
110
|
+
to: contractAddress,
|
|
111
|
+
data: assetsCalldata,
|
|
112
|
+
});
|
|
113
|
+
const assetsRaw = STAKING_INTERFACE.decodeFunctionResult('convertToAssets', assetsResult)[0];
|
|
114
|
+
const assetsWei = BigInt(assetsRaw.toString());
|
|
115
|
+
const amount = weiToHumanReadable(assetsWei, STAKING_DECIMALS);
|
|
116
|
+
return { amount };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw error instanceof Error
|
|
120
|
+
? error
|
|
121
|
+
: new Error('StakedBalanceFetcher: failed to fetch staked balance');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_StakedBalanceFetcher_providerGetter = new WeakMap(), _StakedBalanceFetcher_onStakedBalanceUpdate = new WeakMap();
|
|
126
|
+
//# sourceMappingURL=StakedBalanceFetcher.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StakedBalanceFetcher.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/StakedBalanceFetcher.ts"],"names":[],"mappings":"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","sourcesContent":["import { Interface } from '@ethersproject/abi';\nimport { Web3Provider } from '@ethersproject/providers';\nimport { StaticIntervalPollingControllerOnly } from '@metamask/polling-controller';\n\nimport type { Address, AccountId, ChainId } from '../types';\nimport {\n getStakingContractAddress,\n getSupportedStakingChainIds,\n isStakingContractAssetId,\n weiToHumanReadable,\n} from '../utils';\n\nexport {\n getStakingContractAddress,\n getSupportedStakingChainIds,\n isStakingContractAssetId,\n};\n\nexport type StakedBalancePollingInput = {\n /** Chain ID (hex format, e.g. 0x1) */\n chainId: ChainId;\n /** Account ID */\n accountId: AccountId;\n /** Account address */\n accountAddress: Address;\n};\n\n/** Human-readable staked balance (e.g. \"1.5\" for 1.5 ETH). */\nexport type StakedBalance = {\n amount: string;\n};\n\n/** Result reported via the update callback. */\nexport type StakedBalanceFetchResult = {\n /** Account ID (UUID). */\n accountId: AccountId;\n /** Hex chain ID. */\n chainId: ChainId;\n /** Human-readable staked balance. */\n balance: StakedBalance;\n};\n\n/**\n * Callback type for staked balance updates.\n */\nexport type OnStakedBalanceUpdateCallback = (\n result: StakedBalanceFetchResult,\n) => void;\n\n/** Staking contract ABI: getShares(account) and convertToAssets(shares). */\nconst STAKING_CONTRACT_ABI = [\n {\n inputs: [{ internalType: 'address', name: 'account', type: 'address' }],\n name: 'getShares',\n outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }],\n name: 'convertToAssets',\n outputs: [{ internalType: 'uint256', name: 'assets', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n];\n\nconst STAKING_INTERFACE = new Interface(STAKING_CONTRACT_ABI);\n\nconst STAKING_DECIMALS = 18;\n\nexport type StakedBalanceFetcherConfig = {\n /** Polling interval in ms (default: 180s) */\n pollingInterval?: number;\n /** Returns the network provider for the given chain. Required for fetchStakedBalance. */\n getNetworkProvider?: (chainId: ChainId) => Web3Provider | undefined;\n};\n\nconst DEFAULT_STAKED_BALANCE_INTERVAL = 180_000; // 3 minutes\n\nexport class StakedBalanceFetcher extends StaticIntervalPollingControllerOnly<StakedBalancePollingInput>() {\n readonly #providerGetter?: (chainId: ChainId) => Web3Provider | undefined;\n\n #onStakedBalanceUpdate: OnStakedBalanceUpdateCallback | undefined;\n\n constructor(config?: StakedBalanceFetcherConfig) {\n super();\n this.#providerGetter = config?.getNetworkProvider;\n\n this.setIntervalLength(\n config?.pollingInterval ?? DEFAULT_STAKED_BALANCE_INTERVAL,\n );\n }\n\n /**\n * Register a callback that is invoked after every successful poll with\n * the staked balance (including zero). Zero is reported so that merged\n * updates can clear prior non-zero state.\n *\n * @param callback - The callback to invoke.\n */\n setOnStakedBalanceUpdate(callback: OnStakedBalanceUpdateCallback): void {\n this.#onStakedBalanceUpdate = callback;\n }\n\n async _executePoll(input: StakedBalancePollingInput): Promise<void> {\n let result: StakedBalance;\n try {\n result = await this.fetchStakedBalance(input);\n } catch {\n // Do not push an update on provider/RPC failure; otherwise we would\n // overwrite existing non-zero staked balances with zero in state.\n return;\n }\n\n if (this.#onStakedBalanceUpdate) {\n this.#onStakedBalanceUpdate({\n accountId: input.accountId,\n chainId: input.chainId,\n balance: result,\n });\n }\n }\n\n /**\n * Fetches the staked balance for an account on a chain using the same\n * staking contract as AccountTrackerController (getShares then convertToAssets).\n * Returns a human-readable amount string (e.g. \"1.5\" for 1.5 ETH).\n * Throws when no provider is available or when the RPC/contract call fails, so\n * callers do not persist a false zero and overwrite existing balances.\n *\n * @param input - Chain, account ID, and address to query.\n * @returns Human-readable staked balance (amount string).\n * @throws When provider is missing or when getShares/convertToAssets fails.\n */\n async fetchStakedBalance(\n input: StakedBalancePollingInput,\n ): Promise<StakedBalance> {\n const { chainId, accountAddress } = input;\n const provider = this.#providerGetter?.(chainId);\n if (!provider) {\n throw new Error('StakedBalanceFetcher: no provider available for chain');\n }\n const contractAddress = getStakingContractAddress(chainId);\n\n if (!contractAddress) {\n return { amount: '0' };\n }\n\n try {\n const sharesCalldata = STAKING_INTERFACE.encodeFunctionData('getShares', [\n accountAddress,\n ]);\n const sharesResult = await provider.call({\n to: contractAddress,\n data: sharesCalldata,\n });\n const sharesRaw = STAKING_INTERFACE.decodeFunctionResult(\n 'getShares',\n sharesResult,\n )[0];\n const sharesBigNum = BigInt(sharesRaw.toString());\n\n if (sharesBigNum === 0n) {\n return { amount: '0' };\n }\n\n const assetsCalldata = STAKING_INTERFACE.encodeFunctionData(\n 'convertToAssets',\n [sharesBigNum],\n );\n const assetsResult = await provider.call({\n to: contractAddress,\n data: assetsCalldata,\n });\n const assetsRaw = STAKING_INTERFACE.decodeFunctionResult(\n 'convertToAssets',\n assetsResult,\n )[0];\n const assetsWei = BigInt(assetsRaw.toString());\n\n const amount = weiToHumanReadable(assetsWei, STAKING_DECIMALS);\n return { amount };\n } catch (error) {\n throw error instanceof Error\n ? error\n : new Error('StakedBalanceFetcher: failed to fetch staked balance');\n }\n }\n}\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BalanceFetcher = exports.TokenDetector = void 0;
|
|
3
|
+
exports.isStakingContractAssetId = exports.getStakingContractAddress = exports.getSupportedStakingChainIds = exports.StakedBalanceFetcher = exports.BalanceFetcher = exports.TokenDetector = void 0;
|
|
4
4
|
var TokenDetector_1 = require("./TokenDetector.cjs");
|
|
5
5
|
Object.defineProperty(exports, "TokenDetector", { enumerable: true, get: function () { return TokenDetector_1.TokenDetector; } });
|
|
6
6
|
var BalanceFetcher_1 = require("./BalanceFetcher.cjs");
|
|
7
7
|
Object.defineProperty(exports, "BalanceFetcher", { enumerable: true, get: function () { return BalanceFetcher_1.BalanceFetcher; } });
|
|
8
|
+
var StakedBalanceFetcher_1 = require("./StakedBalanceFetcher.cjs");
|
|
9
|
+
Object.defineProperty(exports, "StakedBalanceFetcher", { enumerable: true, get: function () { return StakedBalanceFetcher_1.StakedBalanceFetcher; } });
|
|
10
|
+
Object.defineProperty(exports, "getSupportedStakingChainIds", { enumerable: true, get: function () { return StakedBalanceFetcher_1.getSupportedStakingChainIds; } });
|
|
11
|
+
Object.defineProperty(exports, "getStakingContractAddress", { enumerable: true, get: function () { return StakedBalanceFetcher_1.getStakingContractAddress; } });
|
|
12
|
+
Object.defineProperty(exports, "isStakingContractAssetId", { enumerable: true, get: function () { return StakedBalanceFetcher_1.isStakingContractAssetId; } });
|
|
8
13
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":";;;AAAA,qDAMyB;AALvB,8GAAA,aAAa,OAAA;AAMf,uDAM0B;AALxB,gHAAA,cAAc,OAAA","sourcesContent":["export {\n TokenDetector,\n type TokenDetectorConfig,\n type TokenDetectorMessenger,\n type DetectionPollingInput,\n type OnDetectionUpdateCallback,\n} from './TokenDetector';\nexport {\n BalanceFetcher,\n type BalanceFetcherConfig,\n type BalanceFetcherMessenger,\n type BalancePollingInput,\n type OnBalanceUpdateCallback,\n} from './BalanceFetcher';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":";;;AAAA,qDAMyB;AALvB,8GAAA,aAAa,OAAA;AAMf,uDAM0B;AALxB,gHAAA,cAAc,OAAA;AAMhB,mEASgC;AAR9B,4HAAA,oBAAoB,OAAA;AACpB,mIAAA,2BAA2B,OAAA;AAC3B,iIAAA,yBAAyB,OAAA;AACzB,gIAAA,wBAAwB,OAAA","sourcesContent":["export {\n TokenDetector,\n type TokenDetectorConfig,\n type TokenDetectorMessenger,\n type DetectionPollingInput,\n type OnDetectionUpdateCallback,\n} from './TokenDetector';\nexport {\n BalanceFetcher,\n type BalanceFetcherConfig,\n type BalanceFetcherMessenger,\n type BalancePollingInput,\n type OnBalanceUpdateCallback,\n} from './BalanceFetcher';\nexport {\n StakedBalanceFetcher,\n getSupportedStakingChainIds,\n getStakingContractAddress,\n isStakingContractAssetId,\n type StakedBalanceFetcherConfig,\n type StakedBalancePollingInput,\n type StakedBalanceFetchResult,\n type OnStakedBalanceUpdateCallback,\n} from './StakedBalanceFetcher';\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { TokenDetector, type TokenDetectorConfig, type TokenDetectorMessenger, type DetectionPollingInput, type OnDetectionUpdateCallback, } from "./TokenDetector.cjs";
|
|
2
2
|
export { BalanceFetcher, type BalanceFetcherConfig, type BalanceFetcherMessenger, type BalancePollingInput, type OnBalanceUpdateCallback, } from "./BalanceFetcher.cjs";
|
|
3
|
+
export { StakedBalanceFetcher, getSupportedStakingChainIds, getStakingContractAddress, isStakingContractAssetId, type StakedBalanceFetcherConfig, type StakedBalancePollingInput, type StakedBalanceFetchResult, type OnStakedBalanceUpdateCallback, } from "./StakedBalanceFetcher.cjs";
|
|
3
4
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,4BAAwB;AACzB,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,6BAAyB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,4BAAwB;AACzB,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,6BAAyB;AAC1B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,GACnC,mCAA+B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { TokenDetector, type TokenDetectorConfig, type TokenDetectorMessenger, type DetectionPollingInput, type OnDetectionUpdateCallback, } from "./TokenDetector.mjs";
|
|
2
2
|
export { BalanceFetcher, type BalanceFetcherConfig, type BalanceFetcherMessenger, type BalancePollingInput, type OnBalanceUpdateCallback, } from "./BalanceFetcher.mjs";
|
|
3
|
+
export { StakedBalanceFetcher, getSupportedStakingChainIds, getStakingContractAddress, isStakingContractAssetId, type StakedBalanceFetcherConfig, type StakedBalancePollingInput, type StakedBalanceFetchResult, type OnStakedBalanceUpdateCallback, } from "./StakedBalanceFetcher.mjs";
|
|
3
4
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,4BAAwB;AACzB,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,6BAAyB"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,4BAAwB;AACzB,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,6BAAyB;AAC1B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,GACnC,mCAA+B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { TokenDetector } from "./TokenDetector.mjs";
|
|
2
2
|
export { BalanceFetcher } from "./BalanceFetcher.mjs";
|
|
3
|
+
export { StakedBalanceFetcher, getSupportedStakingChainIds, getStakingContractAddress, isStakingContractAssetId } from "./StakedBalanceFetcher.mjs";
|
|
3
4
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAKd,4BAAwB;AACzB,OAAO,EACL,cAAc,EAKf,6BAAyB","sourcesContent":["export {\n TokenDetector,\n type TokenDetectorConfig,\n type TokenDetectorMessenger,\n type DetectionPollingInput,\n type OnDetectionUpdateCallback,\n} from './TokenDetector';\nexport {\n BalanceFetcher,\n type BalanceFetcherConfig,\n type BalanceFetcherMessenger,\n type BalancePollingInput,\n type OnBalanceUpdateCallback,\n} from './BalanceFetcher';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAKd,4BAAwB;AACzB,OAAO,EACL,cAAc,EAKf,6BAAyB;AAC1B,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EAKzB,mCAA+B","sourcesContent":["export {\n TokenDetector,\n type TokenDetectorConfig,\n type TokenDetectorMessenger,\n type DetectionPollingInput,\n type OnDetectionUpdateCallback,\n} from './TokenDetector';\nexport {\n BalanceFetcher,\n type BalanceFetcherConfig,\n type BalanceFetcherMessenger,\n type BalancePollingInput,\n type OnBalanceUpdateCallback,\n} from './BalanceFetcher';\nexport {\n StakedBalanceFetcher,\n getSupportedStakingChainIds,\n getStakingContractAddress,\n isStakingContractAssetId,\n type StakedBalanceFetcherConfig,\n type StakedBalancePollingInput,\n type StakedBalanceFetchResult,\n type OnStakedBalanceUpdateCallback,\n} from './StakedBalanceFetcher';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"state.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { ChainId } from './core';\n\n/**\n * Single token entry from token list.\n */\nexport type TokenListEntry = {\n /** Contract address */\n address: string;\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<string, 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"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChainId } from "./core.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Single token entry from token list.
|
|
4
4
|
*/
|
|
5
5
|
export type TokenListEntry = {
|
|
6
6
|
/** Contract address */
|
|
7
|
-
address:
|
|
7
|
+
address: string;
|
|
8
8
|
/** Token symbol */
|
|
9
9
|
symbol: string;
|
|
10
10
|
/** Token name */
|
|
@@ -25,7 +25,7 @@ export type TokenChainsCacheEntry = {
|
|
|
25
25
|
/** Timestamp when the cache was last updated */
|
|
26
26
|
timestamp: number;
|
|
27
27
|
/** Token list data: address -> TokenListEntry */
|
|
28
|
-
data: Record<
|
|
28
|
+
data: Record<string, TokenListEntry>;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Token list state shape (from TokenListController).
|
|
@@ -1 +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,
|
|
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,mBAAe;AAEtC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,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,MAAM,EAAE,cAAc,CAAC,CAAC;CACtC,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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChainId } from "./core.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Single token entry from token list.
|
|
4
4
|
*/
|
|
5
5
|
export type TokenListEntry = {
|
|
6
6
|
/** Contract address */
|
|
7
|
-
address:
|
|
7
|
+
address: string;
|
|
8
8
|
/** Token symbol */
|
|
9
9
|
symbol: string;
|
|
10
10
|
/** Token name */
|
|
@@ -25,7 +25,7 @@ export type TokenChainsCacheEntry = {
|
|
|
25
25
|
/** Timestamp when the cache was last updated */
|
|
26
26
|
timestamp: number;
|
|
27
27
|
/** Token list data: address -> TokenListEntry */
|
|
28
|
-
data: Record<
|
|
28
|
+
data: Record<string, TokenListEntry>;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Token list state shape (from TokenListController).
|
|
@@ -1 +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,
|
|
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,mBAAe;AAEtC;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,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,MAAM,EAAE,cAAc,CAAC,CAAC;CACtC,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"state.mjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/types/state.ts"],"names":[],"mappings":"","sourcesContent":["import type { ChainId } from './core';\n\n/**\n * Single token entry from token list.\n */\nexport type TokenListEntry = {\n /** Contract address */\n address: string;\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<string, 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"]}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reduceInBatchesSerially = exports.divideIntoBatches = void 0;
|
|
3
|
+
exports.STAKING_CONTRACT_ADDRESS_BY_CHAINID = exports.isStakingContractAssetId = exports.getSupportedStakingChainIds = exports.getStakingContractAddress = exports.weiToHumanReadable = exports.chainIdToHex = exports.reduceInBatchesSerially = exports.divideIntoBatches = void 0;
|
|
4
4
|
var batch_1 = require("./batch.cjs");
|
|
5
5
|
Object.defineProperty(exports, "divideIntoBatches", { enumerable: true, get: function () { return batch_1.divideIntoBatches; } });
|
|
6
6
|
Object.defineProperty(exports, "reduceInBatchesSerially", { enumerable: true, get: function () { return batch_1.reduceInBatchesSerially; } });
|
|
7
|
+
var parsing_1 = require("./parsing.cjs");
|
|
8
|
+
Object.defineProperty(exports, "chainIdToHex", { enumerable: true, get: function () { return parsing_1.chainIdToHex; } });
|
|
9
|
+
Object.defineProperty(exports, "weiToHumanReadable", { enumerable: true, get: function () { return parsing_1.weiToHumanReadable; } });
|
|
10
|
+
var staking_contracts_1 = require("./staking-contracts.cjs");
|
|
11
|
+
Object.defineProperty(exports, "getStakingContractAddress", { enumerable: true, get: function () { return staking_contracts_1.getStakingContractAddress; } });
|
|
12
|
+
Object.defineProperty(exports, "getSupportedStakingChainIds", { enumerable: true, get: function () { return staking_contracts_1.getSupportedStakingChainIds; } });
|
|
13
|
+
Object.defineProperty(exports, "isStakingContractAssetId", { enumerable: true, get: function () { return staking_contracts_1.isStakingContractAssetId; } });
|
|
14
|
+
Object.defineProperty(exports, "STAKING_CONTRACT_ADDRESS_BY_CHAINID", { enumerable: true, get: function () { return staking_contracts_1.STAKING_CONTRACT_ADDRESS_BY_CHAINID; } });
|
|
7
15
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +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"]}
|
|
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;AACnD,yCAA6D;AAApD,uGAAA,YAAY,OAAA;AAAE,6GAAA,kBAAkB,OAAA;AACzC,6DAK6B;AAJ3B,8HAAA,yBAAyB,OAAA;AACzB,gIAAA,2BAA2B,OAAA;AAC3B,6HAAA,wBAAwB,OAAA;AACxB,wIAAA,mCAAmC,OAAA","sourcesContent":["export { divideIntoBatches, reduceInBatchesSerially } from './batch';\nexport { chainIdToHex, weiToHumanReadable } from './parsing';\nexport {\n getStakingContractAddress,\n getSupportedStakingChainIds,\n isStakingContractAssetId,\n STAKING_CONTRACT_ADDRESS_BY_CHAINID,\n} from './staking-contracts';\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { divideIntoBatches, reduceInBatchesSerially } from "./batch.cjs";
|
|
2
|
+
export { chainIdToHex, weiToHumanReadable } from "./parsing.cjs";
|
|
3
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, STAKING_CONTRACT_ADDRESS_BY_CHAINID, } from "./staking-contracts.cjs";
|
|
2
4
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +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"}
|
|
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;AACrE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAkB;AAC7D,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,mCAAmC,GACpC,gCAA4B"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { divideIntoBatches, reduceInBatchesSerially } from "./batch.mjs";
|
|
2
|
+
export { chainIdToHex, weiToHumanReadable } from "./parsing.mjs";
|
|
3
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, STAKING_CONTRACT_ADDRESS_BY_CHAINID, } from "./staking-contracts.mjs";
|
|
2
4
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +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"}
|
|
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;AACrE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAkB;AAC7D,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,mCAAmC,GACpC,gCAA4B"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { divideIntoBatches, reduceInBatchesSerially } from "./batch.mjs";
|
|
2
|
+
export { chainIdToHex, weiToHumanReadable } from "./parsing.mjs";
|
|
3
|
+
export { getStakingContractAddress, getSupportedStakingChainIds, isStakingContractAssetId, STAKING_CONTRACT_ADDRESS_BY_CHAINID } from "./staking-contracts.mjs";
|
|
2
4
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +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"]}
|
|
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;AACrE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAkB;AAC7D,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,mCAAmC,EACpC,gCAA4B","sourcesContent":["export { divideIntoBatches, reduceInBatchesSerially } from './batch';\nexport { chainIdToHex, weiToHumanReadable } from './parsing';\nexport {\n getStakingContractAddress,\n getSupportedStakingChainIds,\n isStakingContractAssetId,\n STAKING_CONTRACT_ADDRESS_BY_CHAINID,\n} from './staking-contracts';\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.chainIdToHex = exports.weiToHumanReadable = void 0;
|
|
7
|
+
const utils_1 = require("@metamask/utils");
|
|
8
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
/**
|
|
10
|
+
* Convert wei to human-readable amount with decimals, trim trailing zeros.
|
|
11
|
+
* Uses BigNumber for precision.
|
|
12
|
+
*
|
|
13
|
+
* Note: `.shiftedBy(-decimals).toFixed()` (no args) rounds to DECIMAL_PLACES (0
|
|
14
|
+
* by default in bignumber.js), producing integers (e.g. 1.5 ETH → "2").
|
|
15
|
+
* We use `.toFixed(decimals)` to preserve fractional precision, then trim
|
|
16
|
+
* trailing zeros so the result is e.g. "1.5" instead of "1.500000000000000000".
|
|
17
|
+
*
|
|
18
|
+
* @param wei - Balance in wei as bigint or decimal string.
|
|
19
|
+
* @param decimals - Token decimals (e.g. 18).
|
|
20
|
+
* @returns Human-readable amount string (e.g. "1.5").
|
|
21
|
+
*/
|
|
22
|
+
function weiToHumanReadable(wei, decimals) {
|
|
23
|
+
const weiStr = typeof wei === 'bigint' ? wei.toString() : wei;
|
|
24
|
+
const fixed = new bignumber_js_1.default(weiStr).shiftedBy(-decimals).toFixed(decimals);
|
|
25
|
+
const trimmed = fixed.replace(/\.?0+$/u, '');
|
|
26
|
+
return trimmed === '' ? '0' : trimmed;
|
|
27
|
+
}
|
|
28
|
+
exports.weiToHumanReadable = weiToHumanReadable;
|
|
29
|
+
/**
|
|
30
|
+
* Normalize chain ID to hex for contract lookup (e.g. eip155:1 -> 0x1).
|
|
31
|
+
* Uses @metamask/utils for CAIP parsing.
|
|
32
|
+
*
|
|
33
|
+
* @param chainId - CAIP-2 or hex chain ID.
|
|
34
|
+
* @returns Hex chain ID for contract map lookup.
|
|
35
|
+
*/
|
|
36
|
+
function chainIdToHex(chainId) {
|
|
37
|
+
if ((0, utils_1.isStrictHexString)(chainId)) {
|
|
38
|
+
return chainId;
|
|
39
|
+
}
|
|
40
|
+
if ((0, utils_1.isCaipChainId)(chainId)) {
|
|
41
|
+
const { reference } = (0, utils_1.parseCaipChainId)(chainId);
|
|
42
|
+
return (0, utils_1.numberToHex)(parseInt(reference, 10));
|
|
43
|
+
}
|
|
44
|
+
return chainId;
|
|
45
|
+
}
|
|
46
|
+
exports.chainIdToHex = chainIdToHex;
|
|
47
|
+
//# sourceMappingURL=parsing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.cjs","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/parsing.ts"],"names":[],"mappings":";;;;;;AAAA,2CAKyB;AAEzB,gEAAuC;AAIvC;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAChC,GAAoB,EACpB,QAAgB;IAEhB,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9D,MAAM,KAAK,GAAG,IAAI,sBAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AACxC,CAAC;AARD,gDAQC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAA8B;IACzD,IAAI,IAAA,yBAAiB,EAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,IAAA,qBAAa,EAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,wBAAgB,EAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAA,mBAAW,EAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AATD,oCASC","sourcesContent":["import {\n isCaipChainId,\n isStrictHexString,\n numberToHex,\n parseCaipChainId,\n} from '@metamask/utils';\nimport type { CaipChainId, Hex } from '@metamask/utils';\nimport BigNumberJS from 'bignumber.js';\n\nimport type { ChainId } from '../types';\n\n/**\n * Convert wei to human-readable amount with decimals, trim trailing zeros.\n * Uses BigNumber for precision.\n *\n * Note: `.shiftedBy(-decimals).toFixed()` (no args) rounds to DECIMAL_PLACES (0\n * by default in bignumber.js), producing integers (e.g. 1.5 ETH → \"2\").\n * We use `.toFixed(decimals)` to preserve fractional precision, then trim\n * trailing zeros so the result is e.g. \"1.5\" instead of \"1.500000000000000000\".\n *\n * @param wei - Balance in wei as bigint or decimal string.\n * @param decimals - Token decimals (e.g. 18).\n * @returns Human-readable amount string (e.g. \"1.5\").\n */\nexport function weiToHumanReadable(\n wei: string | bigint,\n decimals: number,\n): string {\n const weiStr = typeof wei === 'bigint' ? wei.toString() : wei;\n const fixed = new BigNumberJS(weiStr).shiftedBy(-decimals).toFixed(decimals);\n const trimmed = fixed.replace(/\\.?0+$/u, '');\n return trimmed === '' ? '0' : trimmed;\n}\n\n/**\n * Normalize chain ID to hex for contract lookup (e.g. eip155:1 -> 0x1).\n * Uses @metamask/utils for CAIP parsing.\n *\n * @param chainId - CAIP-2 or hex chain ID.\n * @returns Hex chain ID for contract map lookup.\n */\nexport function chainIdToHex(chainId: ChainId | CaipChainId): Hex {\n if (isStrictHexString(chainId)) {\n return chainId;\n }\n if (isCaipChainId(chainId)) {\n const { reference } = parseCaipChainId(chainId);\n return numberToHex(parseInt(reference, 10));\n }\n return chainId;\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CaipChainId, Hex } from "@metamask/utils";
|
|
2
|
+
import type { ChainId } from "../types/index.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Convert wei to human-readable amount with decimals, trim trailing zeros.
|
|
5
|
+
* Uses BigNumber for precision.
|
|
6
|
+
*
|
|
7
|
+
* Note: `.shiftedBy(-decimals).toFixed()` (no args) rounds to DECIMAL_PLACES (0
|
|
8
|
+
* by default in bignumber.js), producing integers (e.g. 1.5 ETH → "2").
|
|
9
|
+
* We use `.toFixed(decimals)` to preserve fractional precision, then trim
|
|
10
|
+
* trailing zeros so the result is e.g. "1.5" instead of "1.500000000000000000".
|
|
11
|
+
*
|
|
12
|
+
* @param wei - Balance in wei as bigint or decimal string.
|
|
13
|
+
* @param decimals - Token decimals (e.g. 18).
|
|
14
|
+
* @returns Human-readable amount string (e.g. "1.5").
|
|
15
|
+
*/
|
|
16
|
+
export declare function weiToHumanReadable(wei: string | bigint, decimals: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Normalize chain ID to hex for contract lookup (e.g. eip155:1 -> 0x1).
|
|
19
|
+
* Uses @metamask/utils for CAIP parsing.
|
|
20
|
+
*
|
|
21
|
+
* @param chainId - CAIP-2 or hex chain ID.
|
|
22
|
+
* @returns Hex chain ID for contract map lookup.
|
|
23
|
+
*/
|
|
24
|
+
export declare function chainIdToHex(chainId: ChainId | CaipChainId): Hex;
|
|
25
|
+
//# sourceMappingURL=parsing.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsing.d.cts","sourceRoot":"","sources":["../../../../src/data-sources/evm-rpc-services/utils/parsing.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,wBAAwB;AAGxD,OAAO,KAAK,EAAE,OAAO,EAAE,2BAAiB;AAExC;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,MAAM,CAKR;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,GAAG,CAShE"}
|