@keplr-wallet/stores-eth 0.12.71-rc.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.
Files changed (58) hide show
  1. package/.eslintignore +2 -0
  2. package/.prettierignore +2 -0
  3. package/LICENSE +209 -0
  4. package/build/account/base.d.ts +36 -0
  5. package/build/account/base.js +235 -0
  6. package/build/account/base.js.map +1 -0
  7. package/build/account/index.d.ts +2 -0
  8. package/build/account/index.js +19 -0
  9. package/build/account/index.js.map +1 -0
  10. package/build/account/store.d.ts +9 -0
  11. package/build/account/store.js +20 -0
  12. package/build/account/store.js.map +1 -0
  13. package/build/constants.d.ts +2 -0
  14. package/build/constants.js +275 -0
  15. package/build/constants.js.map +1 -0
  16. package/build/index.d.ts +3 -0
  17. package/build/index.js +20 -0
  18. package/build/index.js.map +1 -0
  19. package/build/queries/balance.d.ts +19 -0
  20. package/build/queries/balance.js +72 -0
  21. package/build/queries/balance.js.map +1 -0
  22. package/build/queries/block.d.ts +54 -0
  23. package/build/queries/block.js +45 -0
  24. package/build/queries/block.js.map +1 -0
  25. package/build/queries/erc20-balance.d.ts +20 -0
  26. package/build/queries/erc20-balance.js +79 -0
  27. package/build/queries/erc20-balance.js.map +1 -0
  28. package/build/queries/erc20-contract-info.d.ts +20 -0
  29. package/build/queries/erc20-contract-info.js +51 -0
  30. package/build/queries/erc20-contract-info.js.map +1 -0
  31. package/build/queries/erc20-metadata.d.ts +31 -0
  32. package/build/queries/erc20-metadata.js +142 -0
  33. package/build/queries/erc20-metadata.js.map +1 -0
  34. package/build/queries/evm-chain-json-rpc.d.ts +13 -0
  35. package/build/queries/evm-chain-json-rpc.js +27 -0
  36. package/build/queries/evm-chain-json-rpc.js.map +1 -0
  37. package/build/queries/fee-histroy.d.ts +17 -0
  38. package/build/queries/fee-histroy.js +55 -0
  39. package/build/queries/fee-histroy.js.map +1 -0
  40. package/build/queries/index.d.ts +21 -0
  41. package/build/queries/index.js +32 -0
  42. package/build/queries/index.js.map +1 -0
  43. package/jest.config.js +5 -0
  44. package/package.json +35 -0
  45. package/src/account/base.ts +302 -0
  46. package/src/account/index.ts +2 -0
  47. package/src/account/store.ts +19 -0
  48. package/src/constants.ts +272 -0
  49. package/src/index.ts +3 -0
  50. package/src/queries/balance.ts +94 -0
  51. package/src/queries/block.ts +111 -0
  52. package/src/queries/erc20-balance.ts +103 -0
  53. package/src/queries/erc20-contract-info.ts +66 -0
  54. package/src/queries/erc20-metadata.ts +184 -0
  55. package/src/queries/evm-chain-json-rpc.ts +48 -0
  56. package/src/queries/fee-histroy.ts +80 -0
  57. package/src/queries/index.ts +86 -0
  58. package/tsconfig.json +12 -0
@@ -0,0 +1,111 @@
1
+ import { ChainGetter, QuerySharedContext } from "@keplr-wallet/stores";
2
+ import { computed, makeObservable } from "mobx";
3
+ import {
4
+ ObservableEvmChainJsonRpcQuery,
5
+ ObservableEvmChainJsonRpcQueryMap,
6
+ } from "./evm-chain-json-rpc";
7
+
8
+ interface Transaction {
9
+ accessList?: string[];
10
+ blockHash: string;
11
+ blockNumber: string;
12
+ chainId: string;
13
+ from: string;
14
+ gas: string;
15
+ gasPrice: string;
16
+ hash: string;
17
+ input: string;
18
+ maxFeePerGas?: string;
19
+ maxPriorityFeePerGas?: string;
20
+ nonce: string;
21
+ r: string;
22
+ s: string;
23
+ to: string;
24
+ transactionIndex: string;
25
+ type: string;
26
+ v: string;
27
+ value: string;
28
+ }
29
+
30
+ interface EthereumBlock {
31
+ baseFeePerGas: string;
32
+ difficulty: string;
33
+ extraData: string;
34
+ gasLimit: string;
35
+ gasUsed: string;
36
+ hash: string;
37
+ logsBloom: string;
38
+ mixHash: string;
39
+ nonce: string;
40
+ number: string;
41
+ parentHash: string;
42
+ receiptsRoot: string;
43
+ sha3Uncles: string;
44
+ size: string;
45
+ stateRoot: string;
46
+ timestamp: string;
47
+ totalDifficulty: string;
48
+ transactions: Transaction[];
49
+ transactionsRoot: string;
50
+ uncles: string[];
51
+ }
52
+
53
+ export class ObservableQueryEthereumBlockInner extends ObservableEvmChainJsonRpcQuery<EthereumBlock> {
54
+ constructor(
55
+ sharedContext: QuerySharedContext,
56
+ chainId: string,
57
+ chainGetter: ChainGetter,
58
+ blockNumberOrTagParam?: string
59
+ ) {
60
+ super(sharedContext, chainId, chainGetter, "eth_getBlockByNumber", [
61
+ blockNumberOrTagParam,
62
+ true,
63
+ ]);
64
+
65
+ makeObservable(this);
66
+ }
67
+
68
+ @computed
69
+ get block(): EthereumBlock | undefined {
70
+ if (!this.response) {
71
+ return;
72
+ }
73
+
74
+ return this.response.data;
75
+ }
76
+ }
77
+
78
+ export class ObservableQueryEthereumBlock extends ObservableEvmChainJsonRpcQueryMap<EthereumBlock> {
79
+ constructor(
80
+ sharedContext: QuerySharedContext,
81
+ chainId: string,
82
+ chainGetter: ChainGetter
83
+ ) {
84
+ super(
85
+ sharedContext,
86
+ chainId,
87
+ chainGetter,
88
+ (blockNumberOrTagParam: string) => {
89
+ return new ObservableQueryEthereumBlockInner(
90
+ this.sharedContext,
91
+ this.chainId,
92
+ this.chainGetter,
93
+ blockNumberOrTagParam
94
+ );
95
+ }
96
+ );
97
+ }
98
+
99
+ getQueryByBlockNumberOrTag(
100
+ blockNumberOrTag?: number | string
101
+ ): ObservableQueryEthereumBlockInner {
102
+ const blockNumberOrTagParam =
103
+ typeof blockNumberOrTag === "number"
104
+ ? `0x${Number(blockNumberOrTag).toString(16)}`
105
+ : blockNumberOrTag;
106
+
107
+ return this.get(
108
+ blockNumberOrTagParam ?? "latest"
109
+ ) as ObservableQueryEthereumBlockInner;
110
+ }
111
+ }
@@ -0,0 +1,103 @@
1
+ import {
2
+ BalanceRegistry,
3
+ ChainGetter,
4
+ IObservableQueryBalanceImpl,
5
+ ObservableJsonRPCQuery,
6
+ QuerySharedContext,
7
+ } from "@keplr-wallet/stores";
8
+ import { AppCurrency, ChainInfo } from "@keplr-wallet/types";
9
+ import { CoinPretty, Int } from "@keplr-wallet/unit";
10
+ import { computed, makeObservable } from "mobx";
11
+ import bigInteger from "big-integer";
12
+ import { erc20ContractInterface } from "../constants";
13
+ import { DenomHelper } from "@keplr-wallet/common";
14
+ import { EthereumAccountBase } from "../account";
15
+
16
+ export class ObservableQueryEthereumERC20BalanceImpl
17
+ extends ObservableJsonRPCQuery<string>
18
+ implements IObservableQueryBalanceImpl
19
+ {
20
+ constructor(
21
+ sharedContext: QuerySharedContext,
22
+ protected readonly chainId: string,
23
+ protected readonly chainGetter: ChainGetter,
24
+ protected readonly denomHelper: DenomHelper,
25
+ protected readonly ethereumURL: string,
26
+ protected readonly ethereumHexAddress: string,
27
+ protected readonly contractAddress: string
28
+ ) {
29
+ super(sharedContext, ethereumURL, "", "eth_call", [
30
+ {
31
+ to: contractAddress,
32
+ data: erc20ContractInterface.encodeFunctionData("balanceOf", [
33
+ ethereumHexAddress,
34
+ ]),
35
+ },
36
+ "latest",
37
+ ]);
38
+
39
+ makeObservable(this);
40
+ }
41
+
42
+ @computed
43
+ get balance(): CoinPretty {
44
+ const denom = this.denomHelper.denom;
45
+
46
+ const chainInfo = this.chainGetter.getChain(this.chainId);
47
+ const currency = chainInfo.currencies.find(
48
+ (cur) => cur.coinMinimalDenom === denom
49
+ );
50
+
51
+ if (!currency) {
52
+ throw new Error(`Unknown currency: ${this.contractAddress}`);
53
+ }
54
+
55
+ if (!this.response || !this.response.data) {
56
+ return new CoinPretty(currency, new Int(0)).ready(false);
57
+ }
58
+
59
+ return new CoinPretty(
60
+ currency,
61
+ new Int(bigInteger(this.response.data.replace("0x", ""), 16).toString())
62
+ );
63
+ }
64
+
65
+ @computed
66
+ get currency(): AppCurrency {
67
+ const denom = this.denomHelper.denom;
68
+
69
+ const chainInfo = this.chainGetter.getChain(this.chainId);
70
+ return chainInfo.forceFindCurrency(denom);
71
+ }
72
+ }
73
+
74
+ export class ObservableQueryEthereumERC20BalanceRegistry
75
+ implements BalanceRegistry
76
+ {
77
+ constructor(protected readonly sharedContext: QuerySharedContext) {}
78
+
79
+ getBalanceImpl(
80
+ chainId: string,
81
+ chainGetter: ChainGetter<ChainInfo>,
82
+ address: string,
83
+ minimalDenom: string
84
+ ): IObservableQueryBalanceImpl | undefined {
85
+ const denomHelper = new DenomHelper(minimalDenom);
86
+ const chainInfo = chainGetter.getChain(chainId);
87
+ const isHexAddress =
88
+ EthereumAccountBase.isEthereumHexAddressWithChecksum(address);
89
+ if (denomHelper.type !== "erc20" || !isHexAddress || !chainInfo.evm) {
90
+ return;
91
+ }
92
+
93
+ return new ObservableQueryEthereumERC20BalanceImpl(
94
+ this.sharedContext,
95
+ chainId,
96
+ chainGetter,
97
+ denomHelper,
98
+ chainInfo.evm.rpc,
99
+ address,
100
+ denomHelper.contractAddress
101
+ );
102
+ }
103
+ }
@@ -0,0 +1,66 @@
1
+ import {
2
+ ChainGetter,
3
+ HasMapStore,
4
+ QuerySharedContext,
5
+ } from "@keplr-wallet/stores";
6
+ import { ObservableQueryEVMChainERC20MetadataInner } from "./erc20-metadata";
7
+ import { computed } from "mobx";
8
+
9
+ interface ERC20ContractInfo {
10
+ decimals: number;
11
+ symbol: string;
12
+ }
13
+
14
+ export class ObservableQueryERC20ContactInfoInner extends ObservableQueryEVMChainERC20MetadataInner {
15
+ constructor(
16
+ sharedContext: QuerySharedContext,
17
+ chainId: string,
18
+ chainGetter: ChainGetter,
19
+ contractAddress: string
20
+ ) {
21
+ super(sharedContext, chainId, chainGetter, contractAddress);
22
+ }
23
+
24
+ @computed
25
+ get tokenInfo(): ERC20ContractInfo | undefined {
26
+ if (this.symbol === undefined || this.decimals === undefined) {
27
+ return undefined;
28
+ }
29
+
30
+ return {
31
+ decimals: this.decimals,
32
+ symbol: this.symbol,
33
+ };
34
+ }
35
+
36
+ get isFetching(): boolean {
37
+ return this._querySymbol.isFetching || this._queryDecimals.isFetching;
38
+ }
39
+
40
+ get error() {
41
+ return this._querySymbol.error || this._queryDecimals.error;
42
+ }
43
+ }
44
+
45
+ export class ObservableQueryERC20ContractInfo extends HasMapStore<ObservableQueryERC20ContactInfoInner> {
46
+ constructor(
47
+ protected readonly sharedContext: QuerySharedContext,
48
+ protected readonly chainId: string,
49
+ protected readonly chainGetter: ChainGetter
50
+ ) {
51
+ super((contractAddress: string) => {
52
+ return new ObservableQueryERC20ContactInfoInner(
53
+ this.sharedContext,
54
+ this.chainId,
55
+ this.chainGetter,
56
+ contractAddress
57
+ );
58
+ });
59
+ }
60
+
61
+ getQueryContract(
62
+ contractAddress: string
63
+ ): ObservableQueryERC20ContactInfoInner {
64
+ return this.get(contractAddress) as ObservableQueryERC20ContactInfoInner;
65
+ }
66
+ }
@@ -0,0 +1,184 @@
1
+ import {
2
+ ChainGetter,
3
+ HasMapStore,
4
+ QuerySharedContext,
5
+ } from "@keplr-wallet/stores";
6
+ import { Interface } from "@ethersproject/abi";
7
+ import { computed, makeObservable } from "mobx";
8
+ import { ObservableEvmChainJsonRpcQuery } from "./evm-chain-json-rpc";
9
+
10
+ const erc20MetadataInterface: Interface = new Interface([
11
+ {
12
+ constant: true,
13
+ inputs: [],
14
+ name: "symbol",
15
+ outputs: [
16
+ {
17
+ name: "",
18
+ type: "string",
19
+ },
20
+ ],
21
+ payable: false,
22
+ stateMutability: "view",
23
+ type: "function",
24
+ },
25
+ {
26
+ constant: true,
27
+ inputs: [],
28
+ name: "decimals",
29
+ outputs: [
30
+ {
31
+ name: "",
32
+ type: "uint8",
33
+ },
34
+ ],
35
+ payable: false,
36
+ stateMutability: "view",
37
+ type: "function",
38
+ },
39
+ ]);
40
+
41
+ export class ObservableQueryEVMChainERC20MetadataSymbol extends ObservableEvmChainJsonRpcQuery<string> {
42
+ constructor(
43
+ sharedContext: QuerySharedContext,
44
+ chainId: string,
45
+ chainGetter: ChainGetter,
46
+ protected contractAddress: string
47
+ ) {
48
+ super(sharedContext, chainId, chainGetter, "eth_call", [
49
+ {
50
+ to: contractAddress,
51
+ data: erc20MetadataInterface.encodeFunctionData("symbol"),
52
+ },
53
+ "latest",
54
+ ]);
55
+
56
+ makeObservable(this);
57
+ }
58
+
59
+ protected override canFetch(): boolean {
60
+ return super.canFetch() && this.contractAddress !== "";
61
+ }
62
+
63
+ @computed
64
+ get symbol(): string | undefined {
65
+ if (!this.response) {
66
+ return undefined;
67
+ }
68
+
69
+ try {
70
+ return erc20MetadataInterface.decodeFunctionResult(
71
+ "symbol",
72
+ this.response.data
73
+ )[0];
74
+ } catch (e) {
75
+ console.log(e);
76
+ }
77
+ return undefined;
78
+ }
79
+ }
80
+
81
+ export class ObservableQueryEVMChainERC20MetadataDecimals extends ObservableEvmChainJsonRpcQuery<string> {
82
+ constructor(
83
+ sharedContext: QuerySharedContext,
84
+ chainId: string,
85
+ chainGetter: ChainGetter,
86
+ protected contractAddress: string
87
+ ) {
88
+ super(sharedContext, chainId, chainGetter, "eth_call", [
89
+ {
90
+ to: contractAddress,
91
+ data: erc20MetadataInterface.encodeFunctionData("decimals"),
92
+ },
93
+ "latest",
94
+ ]);
95
+
96
+ makeObservable(this);
97
+ }
98
+
99
+ protected override canFetch(): boolean {
100
+ return super.canFetch() && this.contractAddress !== "";
101
+ }
102
+
103
+ @computed
104
+ get decimals(): number | undefined {
105
+ if (!this.response) {
106
+ return undefined;
107
+ }
108
+
109
+ try {
110
+ return erc20MetadataInterface.decodeFunctionResult(
111
+ "decimals",
112
+ this.response.data
113
+ )[0];
114
+ } catch (e) {
115
+ console.log(e);
116
+ }
117
+ return undefined;
118
+ }
119
+ }
120
+
121
+ export class ObservableQueryEVMChainERC20MetadataInner {
122
+ protected readonly _querySymbol: ObservableQueryEVMChainERC20MetadataSymbol;
123
+ protected readonly _queryDecimals: ObservableQueryEVMChainERC20MetadataDecimals;
124
+
125
+ constructor(
126
+ protected readonly sharedContext: QuerySharedContext,
127
+ chainId: string,
128
+ chainGetter: ChainGetter,
129
+ contractAddress: string
130
+ ) {
131
+ this._querySymbol = new ObservableQueryEVMChainERC20MetadataSymbol(
132
+ sharedContext,
133
+ chainId,
134
+ chainGetter,
135
+ contractAddress
136
+ );
137
+
138
+ this._queryDecimals = new ObservableQueryEVMChainERC20MetadataDecimals(
139
+ sharedContext,
140
+ chainId,
141
+ chainGetter,
142
+ contractAddress
143
+ );
144
+ }
145
+
146
+ get querySymbol(): ObservableQueryEVMChainERC20MetadataSymbol {
147
+ return this._querySymbol;
148
+ }
149
+
150
+ get queryDecimals(): ObservableQueryEVMChainERC20MetadataDecimals {
151
+ return this._queryDecimals;
152
+ }
153
+
154
+ get symbol(): string | undefined {
155
+ return this._querySymbol.symbol;
156
+ }
157
+
158
+ get decimals(): number | undefined {
159
+ return this._queryDecimals.decimals;
160
+ }
161
+ }
162
+
163
+ export class ObservableQueryEVMChainERC20Metadata extends HasMapStore<ObservableQueryEVMChainERC20MetadataInner> {
164
+ constructor(
165
+ protected readonly sharedContext: QuerySharedContext,
166
+ protected readonly chainId: string,
167
+ protected readonly chainGetter: ChainGetter
168
+ ) {
169
+ super((contractAddress) => {
170
+ return new ObservableQueryEVMChainERC20MetadataInner(
171
+ this.sharedContext,
172
+ this.chainId,
173
+ this.chainGetter,
174
+ contractAddress
175
+ );
176
+ });
177
+ }
178
+
179
+ override get(
180
+ contractAddress: string
181
+ ): ObservableQueryEVMChainERC20MetadataInner {
182
+ return super.get(contractAddress);
183
+ }
184
+ }
@@ -0,0 +1,48 @@
1
+ import {
2
+ ChainGetter,
3
+ HasMapStore,
4
+ ObservableJsonRPCQuery,
5
+ QuerySharedContext,
6
+ } from "@keplr-wallet/stores";
7
+
8
+ export class ObservableEvmChainJsonRpcQuery<
9
+ T = unknown,
10
+ E = unknown
11
+ > extends ObservableJsonRPCQuery<T, E> {
12
+ // Chain Id should not be changed after creation.
13
+ protected readonly _chainId: string;
14
+ protected readonly chainGetter: ChainGetter;
15
+
16
+ constructor(
17
+ sharedContext: QuerySharedContext,
18
+ chainId: string,
19
+ chainGetter: ChainGetter,
20
+ method: string,
21
+ params: any[]
22
+ ) {
23
+ const chainInfo = chainGetter.getChain(chainId);
24
+
25
+ super(sharedContext, chainInfo.evm?.rpc ?? "", "", method, params);
26
+
27
+ this._chainId = chainId;
28
+ this.chainGetter = chainGetter;
29
+ }
30
+
31
+ get chainId(): string {
32
+ return this._chainId;
33
+ }
34
+ }
35
+
36
+ export class ObservableEvmChainJsonRpcQueryMap<
37
+ T = unknown,
38
+ E = unknown
39
+ > extends HasMapStore<ObservableEvmChainJsonRpcQuery<T, E>> {
40
+ constructor(
41
+ protected readonly sharedContext: QuerySharedContext,
42
+ protected readonly chainId: string,
43
+ protected readonly chainGetter: ChainGetter,
44
+ creater: (key: string) => ObservableEvmChainJsonRpcQuery<T, E>
45
+ ) {
46
+ super(creater);
47
+ }
48
+ }
@@ -0,0 +1,80 @@
1
+ import { ChainGetter, QuerySharedContext } from "@keplr-wallet/stores";
2
+ import { computed, makeObservable } from "mobx";
3
+ import {
4
+ ObservableEvmChainJsonRpcQuery,
5
+ ObservableEvmChainJsonRpcQueryMap,
6
+ } from "./evm-chain-json-rpc";
7
+
8
+ interface EthereumFeeHistory {
9
+ oldestBlock: string;
10
+ baseFeePerGas?: string[];
11
+ gasUsedRatio: number[];
12
+ reward?: string[][];
13
+ }
14
+
15
+ export class ObservableQueryEthereumFeeHistoryInner extends ObservableEvmChainJsonRpcQuery<EthereumFeeHistory> {
16
+ constructor(
17
+ sharedContext: QuerySharedContext,
18
+ chainId: string,
19
+ chainGetter: ChainGetter,
20
+ blockCount: string | number,
21
+ newestBlock: string,
22
+ rewardPercentiles: number[]
23
+ ) {
24
+ super(sharedContext, chainId, chainGetter, "eth_feeHistory", [
25
+ blockCount,
26
+ newestBlock,
27
+ rewardPercentiles,
28
+ ]);
29
+
30
+ makeObservable(this);
31
+ }
32
+
33
+ @computed
34
+ get feeHistory(): EthereumFeeHistory | undefined {
35
+ if (!this.response) {
36
+ return;
37
+ }
38
+
39
+ return this.response.data;
40
+ }
41
+ }
42
+
43
+ export class ObservableQueryEthereumFeeHistory extends ObservableEvmChainJsonRpcQueryMap<EthereumFeeHistory> {
44
+ constructor(
45
+ sharedContext: QuerySharedContext,
46
+ chainId: string,
47
+ chainGetter: ChainGetter
48
+ ) {
49
+ super(sharedContext, chainId, chainGetter, (stringifiedParams: string) => {
50
+ const params = (() => {
51
+ try {
52
+ return JSON.parse(stringifiedParams);
53
+ } catch {
54
+ throw new Error("Invalid JSON RPC params");
55
+ }
56
+ })();
57
+ const blockCount = params[0];
58
+ const newestBlock = params[1];
59
+ const rewardPercentiles = params[2];
60
+
61
+ return new ObservableQueryEthereumFeeHistoryInner(
62
+ this.sharedContext,
63
+ this.chainId,
64
+ this.chainGetter,
65
+ blockCount,
66
+ newestBlock,
67
+ rewardPercentiles
68
+ );
69
+ });
70
+ }
71
+
72
+ getQueryByFeeHistoryParams(
73
+ blockCount: string | number,
74
+ newestBlock: string,
75
+ rewardPercentiles: number[]
76
+ ): ObservableQueryEthereumFeeHistoryInner {
77
+ const key = JSON.stringify([blockCount, newestBlock, rewardPercentiles]);
78
+ return this.get(key) as ObservableQueryEthereumFeeHistoryInner;
79
+ }
80
+ }
@@ -0,0 +1,86 @@
1
+ import {
2
+ QueriesSetBase,
3
+ ChainGetter,
4
+ QuerySharedContext,
5
+ } from "@keplr-wallet/stores";
6
+ import { ObservableQueryEthAccountBalanceRegistry } from "./balance";
7
+ import { ObservableQueryEthereumERC20BalanceRegistry } from "./erc20-balance";
8
+ import { DeepReadonly } from "utility-types";
9
+ import { ObservableQueryEthereumBlock } from "./block";
10
+ import { ObservableQueryEthereumFeeHistory } from "./fee-histroy";
11
+ import { ObservableQueryEVMChainERC20Metadata } from "./erc20-metadata";
12
+ import { ObservableQueryERC20ContractInfo } from "./erc20-contract-info";
13
+
14
+ export interface EthereumQueries {
15
+ ethereum: EthereumQueriesImpl;
16
+ }
17
+
18
+ export const EthereumQueries = {
19
+ use(): (
20
+ queriesSetBase: QueriesSetBase,
21
+ sharedContext: QuerySharedContext,
22
+ chainId: string,
23
+ chainGetter: ChainGetter
24
+ ) => EthereumQueries {
25
+ return (
26
+ queriesSetBase: QueriesSetBase,
27
+ sharedContext: QuerySharedContext,
28
+ chainId: string,
29
+ chainGetter: ChainGetter
30
+ ) => {
31
+ return {
32
+ ethereum: new EthereumQueriesImpl(
33
+ queriesSetBase,
34
+ sharedContext,
35
+ chainId,
36
+ chainGetter
37
+ ),
38
+ };
39
+ };
40
+ },
41
+ };
42
+
43
+ export class EthereumQueriesImpl {
44
+ public readonly queryEthereumBlock: DeepReadonly<ObservableQueryEthereumBlock>;
45
+ public readonly queryEthereumFeeHistory: DeepReadonly<ObservableQueryEthereumFeeHistory>;
46
+ public readonly queryEthereumERC20Metadata: DeepReadonly<ObservableQueryEVMChainERC20Metadata>;
47
+ public readonly queryEthereumERC20ContractInfo: DeepReadonly<ObservableQueryERC20ContractInfo>;
48
+
49
+ constructor(
50
+ base: QueriesSetBase,
51
+ sharedContext: QuerySharedContext,
52
+ protected chainId: string,
53
+ protected chainGetter: ChainGetter
54
+ ) {
55
+ base.queryBalances.addBalanceRegistry(
56
+ new ObservableQueryEthAccountBalanceRegistry(sharedContext)
57
+ );
58
+ base.queryBalances.addBalanceRegistry(
59
+ new ObservableQueryEthereumERC20BalanceRegistry(sharedContext)
60
+ );
61
+
62
+ this.queryEthereumBlock = new ObservableQueryEthereumBlock(
63
+ sharedContext,
64
+ chainId,
65
+ chainGetter
66
+ );
67
+
68
+ this.queryEthereumFeeHistory = new ObservableQueryEthereumFeeHistory(
69
+ sharedContext,
70
+ chainId,
71
+ chainGetter
72
+ );
73
+
74
+ this.queryEthereumERC20Metadata = new ObservableQueryEVMChainERC20Metadata(
75
+ sharedContext,
76
+ chainId,
77
+ chainGetter
78
+ );
79
+
80
+ this.queryEthereumERC20ContractInfo = new ObservableQueryERC20ContractInfo(
81
+ sharedContext,
82
+ chainId,
83
+ chainGetter
84
+ );
85
+ }
86
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "outDir": "build",
6
+ "declaration": true,
7
+ "rootDir": "src"
8
+ },
9
+ "include": [
10
+ "src/**/*"
11
+ ]
12
+ }