@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.
- package/.eslintignore +2 -0
- package/.prettierignore +2 -0
- package/LICENSE +209 -0
- package/build/account/base.d.ts +36 -0
- package/build/account/base.js +235 -0
- package/build/account/base.js.map +1 -0
- package/build/account/index.d.ts +2 -0
- package/build/account/index.js +19 -0
- package/build/account/index.js.map +1 -0
- package/build/account/store.d.ts +9 -0
- package/build/account/store.js +20 -0
- package/build/account/store.js.map +1 -0
- package/build/constants.d.ts +2 -0
- package/build/constants.js +275 -0
- package/build/constants.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +20 -0
- package/build/index.js.map +1 -0
- package/build/queries/balance.d.ts +19 -0
- package/build/queries/balance.js +72 -0
- package/build/queries/balance.js.map +1 -0
- package/build/queries/block.d.ts +54 -0
- package/build/queries/block.js +45 -0
- package/build/queries/block.js.map +1 -0
- package/build/queries/erc20-balance.d.ts +20 -0
- package/build/queries/erc20-balance.js +79 -0
- package/build/queries/erc20-balance.js.map +1 -0
- package/build/queries/erc20-contract-info.d.ts +20 -0
- package/build/queries/erc20-contract-info.js +51 -0
- package/build/queries/erc20-contract-info.js.map +1 -0
- package/build/queries/erc20-metadata.d.ts +31 -0
- package/build/queries/erc20-metadata.js +142 -0
- package/build/queries/erc20-metadata.js.map +1 -0
- package/build/queries/evm-chain-json-rpc.d.ts +13 -0
- package/build/queries/evm-chain-json-rpc.js +27 -0
- package/build/queries/evm-chain-json-rpc.js.map +1 -0
- package/build/queries/fee-histroy.d.ts +17 -0
- package/build/queries/fee-histroy.js +55 -0
- package/build/queries/fee-histroy.js.map +1 -0
- package/build/queries/index.d.ts +21 -0
- package/build/queries/index.js +32 -0
- package/build/queries/index.js.map +1 -0
- package/jest.config.js +5 -0
- package/package.json +35 -0
- package/src/account/base.ts +302 -0
- package/src/account/index.ts +2 -0
- package/src/account/store.ts +19 -0
- package/src/constants.ts +272 -0
- package/src/index.ts +3 -0
- package/src/queries/balance.ts +94 -0
- package/src/queries/block.ts +111 -0
- package/src/queries/erc20-balance.ts +103 -0
- package/src/queries/erc20-contract-info.ts +66 -0
- package/src/queries/erc20-metadata.ts +184 -0
- package/src/queries/evm-chain-json-rpc.ts +48 -0
- package/src/queries/fee-histroy.ts +80 -0
- package/src/queries/index.ts +86 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.erc20ContractInterface = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
exports.erc20ContractInterface = new abi_1.Interface([
|
|
6
|
+
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
7
|
+
{
|
|
8
|
+
anonymous: false,
|
|
9
|
+
inputs: [
|
|
10
|
+
{
|
|
11
|
+
indexed: true,
|
|
12
|
+
internalType: "address",
|
|
13
|
+
name: "owner",
|
|
14
|
+
type: "address",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
indexed: true,
|
|
18
|
+
internalType: "address",
|
|
19
|
+
name: "spender",
|
|
20
|
+
type: "address",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
indexed: false,
|
|
24
|
+
internalType: "uint256",
|
|
25
|
+
name: "value",
|
|
26
|
+
type: "uint256",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
name: "Approval",
|
|
30
|
+
type: "event",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
anonymous: false,
|
|
34
|
+
inputs: [
|
|
35
|
+
{
|
|
36
|
+
indexed: true,
|
|
37
|
+
internalType: "address",
|
|
38
|
+
name: "usr",
|
|
39
|
+
type: "address",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
name: "Deny",
|
|
43
|
+
type: "event",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
anonymous: false,
|
|
47
|
+
inputs: [
|
|
48
|
+
{
|
|
49
|
+
indexed: true,
|
|
50
|
+
internalType: "address",
|
|
51
|
+
name: "usr",
|
|
52
|
+
type: "address",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
name: "Rely",
|
|
56
|
+
type: "event",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
anonymous: false,
|
|
60
|
+
inputs: [
|
|
61
|
+
{
|
|
62
|
+
indexed: true,
|
|
63
|
+
internalType: "address",
|
|
64
|
+
name: "from",
|
|
65
|
+
type: "address",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
indexed: true,
|
|
69
|
+
internalType: "address",
|
|
70
|
+
name: "to",
|
|
71
|
+
type: "address",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
indexed: false,
|
|
75
|
+
internalType: "uint256",
|
|
76
|
+
name: "value",
|
|
77
|
+
type: "uint256",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
name: "Transfer",
|
|
81
|
+
type: "event",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
inputs: [],
|
|
85
|
+
name: "DOMAIN_SEPARATOR",
|
|
86
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
87
|
+
stateMutability: "view",
|
|
88
|
+
type: "function",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
inputs: [],
|
|
92
|
+
name: "PERMIT_TYPEHASH",
|
|
93
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
94
|
+
stateMutability: "view",
|
|
95
|
+
type: "function",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
inputs: [
|
|
99
|
+
{ internalType: "address", name: "", type: "address" },
|
|
100
|
+
{ internalType: "address", name: "", type: "address" },
|
|
101
|
+
],
|
|
102
|
+
name: "allowance",
|
|
103
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
104
|
+
stateMutability: "view",
|
|
105
|
+
type: "function",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
inputs: [
|
|
109
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
110
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
111
|
+
],
|
|
112
|
+
name: "approve",
|
|
113
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
114
|
+
stateMutability: "nonpayable",
|
|
115
|
+
type: "function",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
119
|
+
name: "balanceOf",
|
|
120
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
121
|
+
stateMutability: "view",
|
|
122
|
+
type: "function",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
inputs: [
|
|
126
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
127
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
128
|
+
],
|
|
129
|
+
name: "burn",
|
|
130
|
+
outputs: [],
|
|
131
|
+
stateMutability: "nonpayable",
|
|
132
|
+
type: "function",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
inputs: [],
|
|
136
|
+
name: "decimals",
|
|
137
|
+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
138
|
+
stateMutability: "view",
|
|
139
|
+
type: "function",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
inputs: [
|
|
143
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
144
|
+
{
|
|
145
|
+
internalType: "uint256",
|
|
146
|
+
name: "subtractedValue",
|
|
147
|
+
type: "uint256",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
name: "decreaseAllowance",
|
|
151
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
152
|
+
stateMutability: "nonpayable",
|
|
153
|
+
type: "function",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
inputs: [{ internalType: "address", name: "usr", type: "address" }],
|
|
157
|
+
name: "deny",
|
|
158
|
+
outputs: [],
|
|
159
|
+
stateMutability: "nonpayable",
|
|
160
|
+
type: "function",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
inputs: [],
|
|
164
|
+
name: "deploymentChainId",
|
|
165
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
166
|
+
stateMutability: "view",
|
|
167
|
+
type: "function",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
inputs: [
|
|
171
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
172
|
+
{ internalType: "uint256", name: "addedValue", type: "uint256" },
|
|
173
|
+
],
|
|
174
|
+
name: "increaseAllowance",
|
|
175
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
176
|
+
stateMutability: "nonpayable",
|
|
177
|
+
type: "function",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
inputs: [
|
|
181
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
182
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
183
|
+
],
|
|
184
|
+
name: "mint",
|
|
185
|
+
outputs: [],
|
|
186
|
+
stateMutability: "nonpayable",
|
|
187
|
+
type: "function",
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
inputs: [],
|
|
191
|
+
name: "name",
|
|
192
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
193
|
+
stateMutability: "view",
|
|
194
|
+
type: "function",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
198
|
+
name: "nonces",
|
|
199
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
200
|
+
stateMutability: "view",
|
|
201
|
+
type: "function",
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
inputs: [
|
|
205
|
+
{ internalType: "address", name: "owner", type: "address" },
|
|
206
|
+
{ internalType: "address", name: "spender", type: "address" },
|
|
207
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
208
|
+
{ internalType: "uint256", name: "deadline", type: "uint256" },
|
|
209
|
+
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
210
|
+
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
211
|
+
{ internalType: "bytes32", name: "s", type: "bytes32" },
|
|
212
|
+
],
|
|
213
|
+
name: "permit",
|
|
214
|
+
outputs: [],
|
|
215
|
+
stateMutability: "nonpayable",
|
|
216
|
+
type: "function",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
inputs: [{ internalType: "address", name: "usr", type: "address" }],
|
|
220
|
+
name: "rely",
|
|
221
|
+
outputs: [],
|
|
222
|
+
stateMutability: "nonpayable",
|
|
223
|
+
type: "function",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
inputs: [],
|
|
227
|
+
name: "symbol",
|
|
228
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
229
|
+
stateMutability: "view",
|
|
230
|
+
type: "function",
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
inputs: [],
|
|
234
|
+
name: "totalSupply",
|
|
235
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
236
|
+
stateMutability: "view",
|
|
237
|
+
type: "function",
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
inputs: [
|
|
241
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
242
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
243
|
+
],
|
|
244
|
+
name: "transfer",
|
|
245
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
246
|
+
stateMutability: "nonpayable",
|
|
247
|
+
type: "function",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
inputs: [
|
|
251
|
+
{ internalType: "address", name: "from", type: "address" },
|
|
252
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
253
|
+
{ internalType: "uint256", name: "value", type: "uint256" },
|
|
254
|
+
],
|
|
255
|
+
name: "transferFrom",
|
|
256
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
257
|
+
stateMutability: "nonpayable",
|
|
258
|
+
type: "function",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
inputs: [],
|
|
262
|
+
name: "version",
|
|
263
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
264
|
+
stateMutability: "view",
|
|
265
|
+
type: "function",
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
269
|
+
name: "wards",
|
|
270
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
271
|
+
stateMutability: "view",
|
|
272
|
+
type: "function",
|
|
273
|
+
},
|
|
274
|
+
]);
|
|
275
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,4CAA+C;AAElC,QAAA,sBAAsB,GAAc,IAAI,eAAS,CAAC;IAC7D,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE;IAClE;QACE,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE;YACN;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,OAAO;KACd;IACD;QACE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SAAS,EAAE,CAAC;QAChE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACF,CAAC,CAAC"}
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./queries"), exports);
|
|
18
|
+
__exportStar(require("./account"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B;AAC1B,8CAA4B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DenomHelper } from "@keplr-wallet/common";
|
|
2
|
+
import { BalanceRegistry, ChainGetter, IObservableQueryBalanceImpl, ObservableJsonRPCQuery, QuerySharedContext } from "@keplr-wallet/stores";
|
|
3
|
+
import { AppCurrency, ChainInfo } from "@keplr-wallet/types";
|
|
4
|
+
import { CoinPretty } from "@keplr-wallet/unit";
|
|
5
|
+
export declare class ObservableQueryEthAccountBalanceImpl extends ObservableJsonRPCQuery<string> implements IObservableQueryBalanceImpl {
|
|
6
|
+
protected readonly chainId: string;
|
|
7
|
+
protected readonly chainGetter: ChainGetter;
|
|
8
|
+
protected readonly denomHelper: DenomHelper;
|
|
9
|
+
protected readonly ethereumURL: string;
|
|
10
|
+
protected readonly ethereumeHexAddress: string;
|
|
11
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, denomHelper: DenomHelper, ethereumURL: string, ethereumeHexAddress: string);
|
|
12
|
+
get balance(): CoinPretty;
|
|
13
|
+
get currency(): AppCurrency;
|
|
14
|
+
}
|
|
15
|
+
export declare class ObservableQueryEthAccountBalanceRegistry implements BalanceRegistry {
|
|
16
|
+
protected readonly sharedContext: QuerySharedContext;
|
|
17
|
+
constructor(sharedContext: QuerySharedContext);
|
|
18
|
+
getBalanceImpl(chainId: string, chainGetter: ChainGetter<ChainInfo>, address: string, minimalDenom: string): IObservableQueryBalanceImpl | undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ObservableQueryEthAccountBalanceRegistry = exports.ObservableQueryEthAccountBalanceImpl = void 0;
|
|
13
|
+
const common_1 = require("@keplr-wallet/common");
|
|
14
|
+
const stores_1 = require("@keplr-wallet/stores");
|
|
15
|
+
const unit_1 = require("@keplr-wallet/unit");
|
|
16
|
+
const mobx_1 = require("mobx");
|
|
17
|
+
const big_integer_1 = __importDefault(require("big-integer"));
|
|
18
|
+
const account_1 = require("../account");
|
|
19
|
+
class ObservableQueryEthAccountBalanceImpl extends stores_1.ObservableJsonRPCQuery {
|
|
20
|
+
constructor(sharedContext, chainId, chainGetter, denomHelper, ethereumURL, ethereumeHexAddress) {
|
|
21
|
+
super(sharedContext, ethereumURL, "", "eth_getBalance", [
|
|
22
|
+
ethereumeHexAddress,
|
|
23
|
+
"latest",
|
|
24
|
+
]);
|
|
25
|
+
this.chainId = chainId;
|
|
26
|
+
this.chainGetter = chainGetter;
|
|
27
|
+
this.denomHelper = denomHelper;
|
|
28
|
+
this.ethereumURL = ethereumURL;
|
|
29
|
+
this.ethereumeHexAddress = ethereumeHexAddress;
|
|
30
|
+
(0, mobx_1.makeObservable)(this);
|
|
31
|
+
}
|
|
32
|
+
get balance() {
|
|
33
|
+
const denom = this.denomHelper.denom;
|
|
34
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
35
|
+
const currency = chainInfo.currencies.find((cur) => cur.coinMinimalDenom === denom);
|
|
36
|
+
if (!currency) {
|
|
37
|
+
throw new Error(`Unknown currency: ${denom}`);
|
|
38
|
+
}
|
|
39
|
+
if (!this.response || !this.response.data) {
|
|
40
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int(0)).ready(false);
|
|
41
|
+
}
|
|
42
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int((0, big_integer_1.default)(this.response.data.replace("0x", ""), 16).toString()));
|
|
43
|
+
}
|
|
44
|
+
get currency() {
|
|
45
|
+
const denom = this.denomHelper.denom;
|
|
46
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
47
|
+
return chainInfo.forceFindCurrency(denom);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
__decorate([
|
|
51
|
+
mobx_1.computed
|
|
52
|
+
], ObservableQueryEthAccountBalanceImpl.prototype, "balance", null);
|
|
53
|
+
__decorate([
|
|
54
|
+
mobx_1.computed
|
|
55
|
+
], ObservableQueryEthAccountBalanceImpl.prototype, "currency", null);
|
|
56
|
+
exports.ObservableQueryEthAccountBalanceImpl = ObservableQueryEthAccountBalanceImpl;
|
|
57
|
+
class ObservableQueryEthAccountBalanceRegistry {
|
|
58
|
+
constructor(sharedContext) {
|
|
59
|
+
this.sharedContext = sharedContext;
|
|
60
|
+
}
|
|
61
|
+
getBalanceImpl(chainId, chainGetter, address, minimalDenom) {
|
|
62
|
+
const denomHelper = new common_1.DenomHelper(minimalDenom);
|
|
63
|
+
const chainInfo = chainGetter.getChain(chainId);
|
|
64
|
+
const isHexAddress = account_1.EthereumAccountBase.isEthereumHexAddressWithChecksum(address);
|
|
65
|
+
if (denomHelper.type !== "native" || !isHexAddress || !chainInfo.evm) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
return new ObservableQueryEthAccountBalanceImpl(this.sharedContext, chainId, chainGetter, denomHelper, chainInfo.evm.rpc, address);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ObservableQueryEthAccountBalanceRegistry = ObservableQueryEthAccountBalanceRegistry;
|
|
72
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/queries/balance.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAmD;AACnD,i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AAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CACzE,CAAC;IACJ,CAAC;IAGD,IAAI,QAAQ;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAErC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AA7BC;IADC,eAAQ;mEAqBR;AAGD;IADC,eAAQ;oEAMR;AAhDH,oFAiDC;AAED,MAAa,wCAAwC;IAGnD,YAA+B,aAAiC;QAAjC,kBAAa,GAAb,aAAa,CAAoB;IAAG,CAAC;IAEpE,cAAc,CACZ,OAAe,EACf,WAAmC,EACnC,OAAe,EACf,YAAoB;QAEpB,MAAM,WAAW,GAAG,IAAI,oBAAW,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,YAAY,GAChB,6BAAmB,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;QAChE,IAAI,WAAW,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;YACpE,OAAO;SACR;QAED,OAAO,IAAI,oCAAoC,CAC7C,IAAI,CAAC,aAAa,EAClB,OAAO,EACP,WAAW,EACX,WAAW,EACX,SAAS,CAAC,GAAG,CAAC,GAAG,EACjB,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AA5BD,4FA4BC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ChainGetter, QuerySharedContext } from "@keplr-wallet/stores";
|
|
2
|
+
import { ObservableEvmChainJsonRpcQuery, ObservableEvmChainJsonRpcQueryMap } from "./evm-chain-json-rpc";
|
|
3
|
+
interface Transaction {
|
|
4
|
+
accessList?: string[];
|
|
5
|
+
blockHash: string;
|
|
6
|
+
blockNumber: string;
|
|
7
|
+
chainId: string;
|
|
8
|
+
from: string;
|
|
9
|
+
gas: string;
|
|
10
|
+
gasPrice: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
input: string;
|
|
13
|
+
maxFeePerGas?: string;
|
|
14
|
+
maxPriorityFeePerGas?: string;
|
|
15
|
+
nonce: string;
|
|
16
|
+
r: string;
|
|
17
|
+
s: string;
|
|
18
|
+
to: string;
|
|
19
|
+
transactionIndex: string;
|
|
20
|
+
type: string;
|
|
21
|
+
v: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
interface EthereumBlock {
|
|
25
|
+
baseFeePerGas: string;
|
|
26
|
+
difficulty: string;
|
|
27
|
+
extraData: string;
|
|
28
|
+
gasLimit: string;
|
|
29
|
+
gasUsed: string;
|
|
30
|
+
hash: string;
|
|
31
|
+
logsBloom: string;
|
|
32
|
+
mixHash: string;
|
|
33
|
+
nonce: string;
|
|
34
|
+
number: string;
|
|
35
|
+
parentHash: string;
|
|
36
|
+
receiptsRoot: string;
|
|
37
|
+
sha3Uncles: string;
|
|
38
|
+
size: string;
|
|
39
|
+
stateRoot: string;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
totalDifficulty: string;
|
|
42
|
+
transactions: Transaction[];
|
|
43
|
+
transactionsRoot: string;
|
|
44
|
+
uncles: string[];
|
|
45
|
+
}
|
|
46
|
+
export declare class ObservableQueryEthereumBlockInner extends ObservableEvmChainJsonRpcQuery<EthereumBlock> {
|
|
47
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, blockNumberOrTagParam?: string);
|
|
48
|
+
get block(): EthereumBlock | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare class ObservableQueryEthereumBlock extends ObservableEvmChainJsonRpcQueryMap<EthereumBlock> {
|
|
51
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
52
|
+
getQueryByBlockNumberOrTag(blockNumberOrTag?: number | string): ObservableQueryEthereumBlockInner;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ObservableQueryEthereumBlock = exports.ObservableQueryEthereumBlockInner = void 0;
|
|
10
|
+
const mobx_1 = require("mobx");
|
|
11
|
+
const evm_chain_json_rpc_1 = require("./evm-chain-json-rpc");
|
|
12
|
+
class ObservableQueryEthereumBlockInner extends evm_chain_json_rpc_1.ObservableEvmChainJsonRpcQuery {
|
|
13
|
+
constructor(sharedContext, chainId, chainGetter, blockNumberOrTagParam) {
|
|
14
|
+
super(sharedContext, chainId, chainGetter, "eth_getBlockByNumber", [
|
|
15
|
+
blockNumberOrTagParam,
|
|
16
|
+
true,
|
|
17
|
+
]);
|
|
18
|
+
(0, mobx_1.makeObservable)(this);
|
|
19
|
+
}
|
|
20
|
+
get block() {
|
|
21
|
+
if (!this.response) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return this.response.data;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
__decorate([
|
|
28
|
+
mobx_1.computed
|
|
29
|
+
], ObservableQueryEthereumBlockInner.prototype, "block", null);
|
|
30
|
+
exports.ObservableQueryEthereumBlockInner = ObservableQueryEthereumBlockInner;
|
|
31
|
+
class ObservableQueryEthereumBlock extends evm_chain_json_rpc_1.ObservableEvmChainJsonRpcQueryMap {
|
|
32
|
+
constructor(sharedContext, chainId, chainGetter) {
|
|
33
|
+
super(sharedContext, chainId, chainGetter, (blockNumberOrTagParam) => {
|
|
34
|
+
return new ObservableQueryEthereumBlockInner(this.sharedContext, this.chainId, this.chainGetter, blockNumberOrTagParam);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getQueryByBlockNumberOrTag(blockNumberOrTag) {
|
|
38
|
+
const blockNumberOrTagParam = typeof blockNumberOrTag === "number"
|
|
39
|
+
? `0x${Number(blockNumberOrTag).toString(16)}`
|
|
40
|
+
: blockNumberOrTag;
|
|
41
|
+
return this.get(blockNumberOrTagParam !== null && blockNumberOrTagParam !== void 0 ? blockNumberOrTagParam : "latest");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ObservableQueryEthereumBlock = ObservableQueryEthereumBlock;
|
|
45
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.js","sourceRoot":"","sources":["../../src/queries/block.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAAgD;AAChD,6DAG8B;AA+C9B,MAAa,iCAAkC,SAAQ,mDAA6C;IAClG,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB,EACxB,qBAA8B;QAE9B,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE;YACjE,qBAAqB;YACrB,IAAI;SACL,CAAC,CAAC;QAEH,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACR;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;CACF;AAPC;IADC,eAAQ;8DAOR;AAtBH,8EAuBC;AAED,MAAa,4BAA6B,SAAQ,sDAAgD;IAChG,YACE,aAAiC,EACjC,OAAe,EACf,WAAwB;QAExB,KAAK,CACH,aAAa,EACb,OAAO,EACP,WAAW,EACX,CAAC,qBAA6B,EAAE,EAAE;YAChC,OAAO,IAAI,iCAAiC,CAC1C,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,WAAW,EAChB,qBAAqB,CACtB,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED,0BAA0B,CACxB,gBAAkC;QAElC,MAAM,qBAAqB,GACzB,OAAO,gBAAgB,KAAK,QAAQ;YAClC,CAAC,CAAC,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;YAC9C,CAAC,CAAC,gBAAgB,CAAC;QAEvB,OAAO,IAAI,CAAC,GAAG,CACb,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,QAAQ,CACG,CAAC;IACzC,CAAC;CACF;AAjCD,oEAiCC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BalanceRegistry, ChainGetter, IObservableQueryBalanceImpl, ObservableJsonRPCQuery, QuerySharedContext } from "@keplr-wallet/stores";
|
|
2
|
+
import { AppCurrency, ChainInfo } from "@keplr-wallet/types";
|
|
3
|
+
import { CoinPretty } from "@keplr-wallet/unit";
|
|
4
|
+
import { DenomHelper } from "@keplr-wallet/common";
|
|
5
|
+
export declare class ObservableQueryEthereumERC20BalanceImpl extends ObservableJsonRPCQuery<string> implements IObservableQueryBalanceImpl {
|
|
6
|
+
protected readonly chainId: string;
|
|
7
|
+
protected readonly chainGetter: ChainGetter;
|
|
8
|
+
protected readonly denomHelper: DenomHelper;
|
|
9
|
+
protected readonly ethereumURL: string;
|
|
10
|
+
protected readonly ethereumHexAddress: string;
|
|
11
|
+
protected readonly contractAddress: string;
|
|
12
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, denomHelper: DenomHelper, ethereumURL: string, ethereumHexAddress: string, contractAddress: string);
|
|
13
|
+
get balance(): CoinPretty;
|
|
14
|
+
get currency(): AppCurrency;
|
|
15
|
+
}
|
|
16
|
+
export declare class ObservableQueryEthereumERC20BalanceRegistry implements BalanceRegistry {
|
|
17
|
+
protected readonly sharedContext: QuerySharedContext;
|
|
18
|
+
constructor(sharedContext: QuerySharedContext);
|
|
19
|
+
getBalanceImpl(chainId: string, chainGetter: ChainGetter<ChainInfo>, address: string, minimalDenom: string): IObservableQueryBalanceImpl | undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ObservableQueryEthereumERC20BalanceRegistry = exports.ObservableQueryEthereumERC20BalanceImpl = void 0;
|
|
13
|
+
const stores_1 = require("@keplr-wallet/stores");
|
|
14
|
+
const unit_1 = require("@keplr-wallet/unit");
|
|
15
|
+
const mobx_1 = require("mobx");
|
|
16
|
+
const big_integer_1 = __importDefault(require("big-integer"));
|
|
17
|
+
const constants_1 = require("../constants");
|
|
18
|
+
const common_1 = require("@keplr-wallet/common");
|
|
19
|
+
const account_1 = require("../account");
|
|
20
|
+
class ObservableQueryEthereumERC20BalanceImpl extends stores_1.ObservableJsonRPCQuery {
|
|
21
|
+
constructor(sharedContext, chainId, chainGetter, denomHelper, ethereumURL, ethereumHexAddress, contractAddress) {
|
|
22
|
+
super(sharedContext, ethereumURL, "", "eth_call", [
|
|
23
|
+
{
|
|
24
|
+
to: contractAddress,
|
|
25
|
+
data: constants_1.erc20ContractInterface.encodeFunctionData("balanceOf", [
|
|
26
|
+
ethereumHexAddress,
|
|
27
|
+
]),
|
|
28
|
+
},
|
|
29
|
+
"latest",
|
|
30
|
+
]);
|
|
31
|
+
this.chainId = chainId;
|
|
32
|
+
this.chainGetter = chainGetter;
|
|
33
|
+
this.denomHelper = denomHelper;
|
|
34
|
+
this.ethereumURL = ethereumURL;
|
|
35
|
+
this.ethereumHexAddress = ethereumHexAddress;
|
|
36
|
+
this.contractAddress = contractAddress;
|
|
37
|
+
(0, mobx_1.makeObservable)(this);
|
|
38
|
+
}
|
|
39
|
+
get balance() {
|
|
40
|
+
const denom = this.denomHelper.denom;
|
|
41
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
42
|
+
const currency = chainInfo.currencies.find((cur) => cur.coinMinimalDenom === denom);
|
|
43
|
+
if (!currency) {
|
|
44
|
+
throw new Error(`Unknown currency: ${this.contractAddress}`);
|
|
45
|
+
}
|
|
46
|
+
if (!this.response || !this.response.data) {
|
|
47
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int(0)).ready(false);
|
|
48
|
+
}
|
|
49
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int((0, big_integer_1.default)(this.response.data.replace("0x", ""), 16).toString()));
|
|
50
|
+
}
|
|
51
|
+
get currency() {
|
|
52
|
+
const denom = this.denomHelper.denom;
|
|
53
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
54
|
+
return chainInfo.forceFindCurrency(denom);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
__decorate([
|
|
58
|
+
mobx_1.computed
|
|
59
|
+
], ObservableQueryEthereumERC20BalanceImpl.prototype, "balance", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
mobx_1.computed
|
|
62
|
+
], ObservableQueryEthereumERC20BalanceImpl.prototype, "currency", null);
|
|
63
|
+
exports.ObservableQueryEthereumERC20BalanceImpl = ObservableQueryEthereumERC20BalanceImpl;
|
|
64
|
+
class ObservableQueryEthereumERC20BalanceRegistry {
|
|
65
|
+
constructor(sharedContext) {
|
|
66
|
+
this.sharedContext = sharedContext;
|
|
67
|
+
}
|
|
68
|
+
getBalanceImpl(chainId, chainGetter, address, minimalDenom) {
|
|
69
|
+
const denomHelper = new common_1.DenomHelper(minimalDenom);
|
|
70
|
+
const chainInfo = chainGetter.getChain(chainId);
|
|
71
|
+
const isHexAddress = account_1.EthereumAccountBase.isEthereumHexAddressWithChecksum(address);
|
|
72
|
+
if (denomHelper.type !== "erc20" || !isHexAddress || !chainInfo.evm) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
return new ObservableQueryEthereumERC20BalanceImpl(this.sharedContext, chainId, chainGetter, denomHelper, chainInfo.evm.rpc, address, denomHelper.contractAddress);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.ObservableQueryEthereumERC20BalanceRegistry = ObservableQueryEthereumERC20BalanceRegistry;
|
|
79
|
+
//# sourceMappingURL=erc20-balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20-balance.js","sourceRoot":"","sources":["../../src/queries/erc20-balance.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAM8B;AAE9B,6CAAqD;AACrD,+BAAgD;AAChD,8DAAqC;AACrC,4CAAsD;AACtD,iDAAmD;AACnD,wCAAiD;AAEjD,MAAa,uCACX,SAAQ,+BAA8B;IAGtC,YACE,aAAiC,EACd,OAAe,EACf,WAAwB,EACxB,WAAwB,EACxB,WAAmB,EACnB,kBAA0B,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,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CACzE,CAAC;IACJ,CAAC;IAGD,IAAI,QAAQ;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAErC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1D,OAAO,SAAS,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AA7BC;IADC,eAAQ;sEAqBR;AAGD;IADC,eAAQ;uEAMR;AAvDH,0FAwDC;AAED,MAAa,2CAA2C;IAGtD,YAA+B,aAAiC;QAAjC,kBAAa,GAAb,aAAa,CAAoB;IAAG,CAAC;IAEpE,cAAc,CACZ,OAAe,EACf,WAAmC,EACnC,OAAe,EACf,YAAoB;QAEpB,MAAM,WAAW,GAAG,IAAI,oBAAW,CAAC,YAAY,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,YAAY,GAChB,6BAAmB,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;QAChE,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;YACnE,OAAO;SACR;QAED,OAAO,IAAI,uCAAuC,CAChD,IAAI,CAAC,aAAa,EAClB,OAAO,EACP,WAAW,EACX,WAAW,EACX,SAAS,CAAC,GAAG,CAAC,GAAG,EACjB,OAAO,EACP,WAAW,CAAC,eAAe,CAC5B,CAAC;IACJ,CAAC;CACF;AA7BD,kGA6BC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChainGetter, HasMapStore, QuerySharedContext } from "@keplr-wallet/stores";
|
|
2
|
+
import { ObservableQueryEVMChainERC20MetadataInner } from "./erc20-metadata";
|
|
3
|
+
interface ERC20ContractInfo {
|
|
4
|
+
decimals: number;
|
|
5
|
+
symbol: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ObservableQueryERC20ContactInfoInner extends ObservableQueryEVMChainERC20MetadataInner {
|
|
8
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, contractAddress: string);
|
|
9
|
+
get tokenInfo(): ERC20ContractInfo | undefined;
|
|
10
|
+
get isFetching(): boolean;
|
|
11
|
+
get error(): Readonly<import("@keplr-wallet/stores").QueryError<unknown>> | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare class ObservableQueryERC20ContractInfo extends HasMapStore<ObservableQueryERC20ContactInfoInner> {
|
|
14
|
+
protected readonly sharedContext: QuerySharedContext;
|
|
15
|
+
protected readonly chainId: string;
|
|
16
|
+
protected readonly chainGetter: ChainGetter;
|
|
17
|
+
constructor(sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter);
|
|
18
|
+
getQueryContract(contractAddress: string): ObservableQueryERC20ContactInfoInner;
|
|
19
|
+
}
|
|
20
|
+
export {};
|