@keplr-wallet/stores-eth 0.13.32 → 0.13.34
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/build/queries/erc20-balance-batch.d.ts +26 -0
- package/build/queries/erc20-balance-batch.js +262 -0
- package/build/queries/erc20-balance-batch.js.map +1 -0
- package/build/queries/erc20-balance-batch.spec.d.ts +1 -0
- package/build/queries/erc20-balance-batch.spec.js +157 -0
- package/build/queries/erc20-balance-batch.spec.js.map +1 -0
- package/build/queries/erc20-balance.d.ts +21 -6
- package/build/queries/erc20-balance.js +118 -27
- package/build/queries/erc20-balance.js.map +1 -1
- package/build/queries/erc20-balance.spec.d.ts +1 -0
- package/build/queries/erc20-balance.spec.js +90 -0
- package/build/queries/erc20-balance.spec.js.map +1 -0
- package/build/queries/erc20-balances.d.ts +18 -4
- package/build/queries/erc20-balances.js +200 -25
- package/build/queries/erc20-balances.js.map +1 -1
- package/build/queries/erc20-balances.spec.d.ts +1 -0
- package/build/queries/erc20-balances.spec.js +150 -0
- package/build/queries/erc20-balances.spec.js.map +1 -0
- package/build/queries/erc20-batch-parent-store.d.ts +8 -0
- package/build/queries/erc20-batch-parent-store.js +21 -0
- package/build/queries/erc20-batch-parent-store.js.map +1 -0
- package/build/queries/index.d.ts +1 -3
- package/build/queries/index.js +6 -5
- package/build/queries/index.js.map +1 -1
- package/jest.config.js +8 -1
- package/package.json +8 -8
- package/src/queries/erc20-balance-batch.spec.ts +192 -0
- package/src/queries/erc20-balance-batch.ts +273 -0
- package/src/queries/erc20-balance.spec.ts +129 -0
- package/src/queries/erc20-balance.ts +122 -36
- package/src/queries/erc20-balances.spec.ts +194 -0
- package/src/queries/erc20-balances.ts +220 -37
- package/src/queries/erc20-batch-parent-store.ts +28 -0
- package/src/queries/index.ts +8 -15
|
@@ -14,22 +14,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.ObservableQueryThirdpartyERC20BalanceRegistry = exports.ObservableQueryThirdpartyERC20BalancesImpl = exports.ObservableQueryThirdpartyERC20BalancesImplParent = void 0;
|
|
19
22
|
const common_1 = require("@keplr-wallet/common");
|
|
20
23
|
const mobx_1 = require("mobx");
|
|
21
24
|
const unit_1 = require("@keplr-wallet/unit");
|
|
22
25
|
const stores_1 = require("@keplr-wallet/stores");
|
|
26
|
+
const big_integer_1 = __importDefault(require("big-integer"));
|
|
23
27
|
const account_1 = require("../account");
|
|
24
28
|
const thirdparySupportedChainIdMap = {
|
|
25
29
|
"eip155:1": "eth",
|
|
26
|
-
"eip155:10": "opt",
|
|
27
30
|
"eip155:137": "polygon",
|
|
28
31
|
"eip155:8453": "base",
|
|
29
32
|
"eip155:42161": "arb",
|
|
30
33
|
};
|
|
31
34
|
class ObservableQueryThirdpartyERC20BalancesImplParent extends stores_1.ObservableJsonRPCQuery {
|
|
32
|
-
constructor(sharedContext, chainId, chainGetter, ethereumHexAddress) {
|
|
35
|
+
constructor(sharedContext, chainId, chainGetter, ethereumHexAddress, batchParent) {
|
|
33
36
|
const tokenAPIURL = `https://evm-${chainId.replace("eip155:", "")}.keplr.app/api`;
|
|
34
37
|
super(sharedContext, tokenAPIURL, "", "alchemy_getTokenBalances", [
|
|
35
38
|
ethereumHexAddress,
|
|
@@ -43,6 +46,8 @@ class ObservableQueryThirdpartyERC20BalancesImplParent extends stores_1.Observab
|
|
|
43
46
|
this.chainId = chainId;
|
|
44
47
|
this.chainGetter = chainGetter;
|
|
45
48
|
this.ethereumHexAddress = ethereumHexAddress;
|
|
49
|
+
this.batchParent = batchParent;
|
|
50
|
+
this.alchemyContractSet = new Set();
|
|
46
51
|
(0, mobx_1.makeObservable)(this);
|
|
47
52
|
}
|
|
48
53
|
canFetch() {
|
|
@@ -53,15 +58,38 @@ class ObservableQueryThirdpartyERC20BalancesImplParent extends stores_1.Observab
|
|
|
53
58
|
onReceiveResponse(response) {
|
|
54
59
|
super.onReceiveResponse(response);
|
|
55
60
|
const mcInfo = this.chainGetter.getModularChain(this.chainId);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
const next = new Set();
|
|
62
|
+
const erc20Denoms = [];
|
|
63
|
+
for (const tokenBalance of response.data.tokenBalances) {
|
|
64
|
+
if (tokenBalance.tokenBalance != null) {
|
|
65
|
+
next.add(tokenBalance.contractAddress.toLowerCase());
|
|
66
|
+
if (BigInt(tokenBalance.tokenBalance) > 0) {
|
|
67
|
+
erc20Denoms.push(`erc20:${tokenBalance.contractAddress}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
(0, mobx_1.runInAction)(() => {
|
|
72
|
+
this.alchemyContractSet = next;
|
|
73
|
+
});
|
|
74
|
+
if (erc20Denoms.length > 0) {
|
|
61
75
|
mcInfo.addUnknownDenoms(...erc20Denoms);
|
|
62
76
|
}
|
|
63
77
|
}
|
|
78
|
+
hasAlchemyBalance(contract) {
|
|
79
|
+
return this.alchemyContractSet.has(contract.toLowerCase());
|
|
80
|
+
}
|
|
81
|
+
getAlchemyTokenBalance(contract) {
|
|
82
|
+
var _a;
|
|
83
|
+
return (_a = this.response) === null || _a === void 0 ? void 0 : _a.data.tokenBalances.find((bal) => bal.contractAddress.toLowerCase() === contract.toLowerCase());
|
|
84
|
+
}
|
|
85
|
+
resolvesAlchemyBalance(contract) {
|
|
86
|
+
var _a;
|
|
87
|
+
return ((_a = this.getAlchemyTokenBalance(contract)) === null || _a === void 0 ? void 0 : _a.tokenBalance) != null;
|
|
88
|
+
}
|
|
64
89
|
}
|
|
90
|
+
__decorate([
|
|
91
|
+
mobx_1.observable.shallow
|
|
92
|
+
], ObservableQueryThirdpartyERC20BalancesImplParent.prototype, "alchemyContractSet", void 0);
|
|
65
93
|
exports.ObservableQueryThirdpartyERC20BalancesImplParent = ObservableQueryThirdpartyERC20BalancesImplParent;
|
|
66
94
|
class ObservableQueryThirdpartyERC20BalancesImpl {
|
|
67
95
|
constructor(parent, chainId, chainGetter, denomHelper) {
|
|
@@ -69,19 +97,80 @@ class ObservableQueryThirdpartyERC20BalancesImpl {
|
|
|
69
97
|
this.chainId = chainId;
|
|
70
98
|
this.chainGetter = chainGetter;
|
|
71
99
|
this.denomHelper = denomHelper;
|
|
100
|
+
this.isInBatch = false;
|
|
101
|
+
this.observedProps = 0;
|
|
72
102
|
(0, mobx_1.makeObservable)(this);
|
|
103
|
+
const contract = denomHelper.contractAddress;
|
|
104
|
+
// Readiness gates in hooks-evm can early-return on `response` before
|
|
105
|
+
// reading `balance`, so track observation across both to register the
|
|
106
|
+
// contract with the batch parent when needed.
|
|
107
|
+
const installReaction = () => {
|
|
108
|
+
// Register to batch only when Alchemy can't cover the contract, to avoid
|
|
109
|
+
// duplicate eth_call against tokens Alchemy already returns.
|
|
110
|
+
this.batchReactionDisposer = (0, mobx_1.reaction)(() => {
|
|
111
|
+
// Alchemy error forces fallback even when a stale `response` still
|
|
112
|
+
// advertises the contract as covered.
|
|
113
|
+
if (parent.error)
|
|
114
|
+
return "missing";
|
|
115
|
+
if (!parent.response)
|
|
116
|
+
return "pending";
|
|
117
|
+
if (parent.resolvesAlchemyBalance(contract))
|
|
118
|
+
return "covered";
|
|
119
|
+
return "missing";
|
|
120
|
+
}, (status) => {
|
|
121
|
+
if (status === "missing" && !this.isInBatch) {
|
|
122
|
+
(0, mobx_1.runInAction)(() => {
|
|
123
|
+
this.isInBatch = true;
|
|
124
|
+
});
|
|
125
|
+
parent.batchParent.addContract(contract);
|
|
126
|
+
}
|
|
127
|
+
else if (status !== "missing" && this.isInBatch) {
|
|
128
|
+
(0, mobx_1.runInAction)(() => {
|
|
129
|
+
this.isInBatch = false;
|
|
130
|
+
});
|
|
131
|
+
parent.batchParent.removeContract(contract);
|
|
132
|
+
}
|
|
133
|
+
}, { fireImmediately: true });
|
|
134
|
+
};
|
|
135
|
+
const teardownReaction = () => {
|
|
136
|
+
var _a;
|
|
137
|
+
(_a = this.batchReactionDisposer) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
138
|
+
this.batchReactionDisposer = undefined;
|
|
139
|
+
if (this.isInBatch) {
|
|
140
|
+
(0, mobx_1.runInAction)(() => {
|
|
141
|
+
this.isInBatch = false;
|
|
142
|
+
});
|
|
143
|
+
parent.batchParent.removeContract(contract);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const attach = (prop) => {
|
|
147
|
+
(0, mobx_1.onBecomeObserved)(this, prop, () => {
|
|
148
|
+
if (this.observedProps++ === 0)
|
|
149
|
+
installReaction();
|
|
150
|
+
});
|
|
151
|
+
(0, mobx_1.onBecomeUnobserved)(this, prop, () => {
|
|
152
|
+
if (--this.observedProps === 0)
|
|
153
|
+
teardownReaction();
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
attach("balance");
|
|
157
|
+
attach("response");
|
|
158
|
+
attach("error");
|
|
73
159
|
}
|
|
74
160
|
get balance() {
|
|
75
161
|
const currency = this.currency;
|
|
76
|
-
|
|
77
|
-
|
|
162
|
+
const contract = this.denomHelper.contractAddress;
|
|
163
|
+
if (this.alchemyResolvesBalance) {
|
|
164
|
+
const tokenBalance = this.parent.getAlchemyTokenBalance(contract);
|
|
165
|
+
if ((tokenBalance === null || tokenBalance === void 0 ? void 0 : tokenBalance.tokenBalance) != null) {
|
|
166
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int(BigInt(tokenBalance.tokenBalance)));
|
|
167
|
+
}
|
|
78
168
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return new unit_1.CoinPretty(currency, new unit_1.Int(0)).ready(false);
|
|
169
|
+
const raw = this.parent.batchParent.getBalance(contract);
|
|
170
|
+
if (raw !== undefined) {
|
|
171
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int((0, big_integer_1.default)(raw.replace("0x", ""), 16).toString()));
|
|
83
172
|
}
|
|
84
|
-
return new unit_1.CoinPretty(currency, new unit_1.Int(
|
|
173
|
+
return new unit_1.CoinPretty(currency, new unit_1.Int(0)).ready(false);
|
|
85
174
|
}
|
|
86
175
|
get currency() {
|
|
87
176
|
const denom = this.denomHelper.denom;
|
|
@@ -89,10 +178,32 @@ class ObservableQueryThirdpartyERC20BalancesImpl {
|
|
|
89
178
|
.getModularChain(this.chainId)
|
|
90
179
|
.forceFindCurrency(denom);
|
|
91
180
|
}
|
|
181
|
+
// Whether the contract is currently sourced from a healthy Alchemy response.
|
|
182
|
+
// Derived from actual data/error state so imperative callers (which never
|
|
183
|
+
// flip `isInBatch`) observe the same semantics as the reaction path.
|
|
184
|
+
get alchemyResolvesBalance() {
|
|
185
|
+
return (!this.parent.error &&
|
|
186
|
+
!!this.parent.response &&
|
|
187
|
+
this.parent.resolvesAlchemyBalance(this.denomHelper.contractAddress));
|
|
188
|
+
}
|
|
92
189
|
get error() {
|
|
93
|
-
|
|
190
|
+
if (this.alchemyResolvesBalance)
|
|
191
|
+
return undefined;
|
|
192
|
+
const contract = this.denomHelper.contractAddress;
|
|
193
|
+
const batchErr = this.parent.batchParent.getError(contract);
|
|
194
|
+
if (batchErr)
|
|
195
|
+
return batchErr;
|
|
196
|
+
// Batch has valid data — suppress any lingering Alchemy error.
|
|
197
|
+
if (this.parent.batchParent.getBalance(contract) !== undefined) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
// Still loading — stay quiet until the fallback settles.
|
|
201
|
+
return undefined;
|
|
94
202
|
}
|
|
95
203
|
get isFetching() {
|
|
204
|
+
if (!this.alchemyResolvesBalance) {
|
|
205
|
+
return (this.parent.batchParent.isFetchingContract(this.denomHelper.contractAddress) || this.parent.isFetching);
|
|
206
|
+
}
|
|
96
207
|
return this.parent.isFetching;
|
|
97
208
|
}
|
|
98
209
|
get isObserved() {
|
|
@@ -102,7 +213,24 @@ class ObservableQueryThirdpartyERC20BalancesImpl {
|
|
|
102
213
|
return this.parent.isStarted;
|
|
103
214
|
}
|
|
104
215
|
get response() {
|
|
105
|
-
|
|
216
|
+
// Readiness must gate on actual data availability, not the
|
|
217
|
+
// observation-driven `isInBatch` flag, so imperative callers also see
|
|
218
|
+
// batch-backed readiness for tokens missing from Alchemy.
|
|
219
|
+
if (this.alchemyResolvesBalance)
|
|
220
|
+
return this.parent.response;
|
|
221
|
+
const raw = this.parent.batchParent.getBalance(this.denomHelper.contractAddress);
|
|
222
|
+
if (raw === undefined)
|
|
223
|
+
return undefined;
|
|
224
|
+
return {
|
|
225
|
+
data: {
|
|
226
|
+
address: "",
|
|
227
|
+
tokenBalances: [],
|
|
228
|
+
pageKey: "",
|
|
229
|
+
},
|
|
230
|
+
staled: false,
|
|
231
|
+
local: false,
|
|
232
|
+
timestamp: 0,
|
|
233
|
+
};
|
|
106
234
|
}
|
|
107
235
|
fetch() {
|
|
108
236
|
// XXX: The ERC20 balances via thirdparty token API can share the result of one endpoint.
|
|
@@ -127,32 +255,79 @@ class ObservableQueryThirdpartyERC20BalancesImpl {
|
|
|
127
255
|
}
|
|
128
256
|
}))();
|
|
129
257
|
});
|
|
130
|
-
return this.parent.duplicatedFetchResolver;
|
|
131
258
|
}
|
|
132
|
-
|
|
259
|
+
const alchemyFetch = this.parent.duplicatedFetchResolver;
|
|
260
|
+
return alchemyFetch.then(() => this.awaitFallbackIfMissing());
|
|
261
|
+
}
|
|
262
|
+
// After Alchemy resolves, check Alchemy coverage directly (not via the
|
|
263
|
+
// observation-driven reaction) so imperative callers also exercise the
|
|
264
|
+
// batch fallback for tokens missing from Alchemy.
|
|
265
|
+
awaitFallbackIfMissing() {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
// balanceImplMap doesn't evict on currency removal.
|
|
268
|
+
if (!this.isCurrencyRegistered())
|
|
269
|
+
return;
|
|
270
|
+
const contract = this.denomHelper.contractAddress;
|
|
271
|
+
// Mirror the reaction: an Alchemy error forces fallback even when a
|
|
272
|
+
// stale response still advertises the contract as covered.
|
|
273
|
+
const coveredByAlchemy = !this.parent.error &&
|
|
274
|
+
!!this.parent.response &&
|
|
275
|
+
this.parent.resolvesAlchemyBalance(contract);
|
|
276
|
+
if (coveredByAlchemy)
|
|
277
|
+
return;
|
|
278
|
+
this.parent.batchParent.addContract(contract);
|
|
279
|
+
try {
|
|
280
|
+
yield this.parent.batchParent.waitFreshResponse();
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
this.parent.batchParent.removeContract(contract);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
isCurrencyRegistered() {
|
|
288
|
+
const target = common_1.DenomHelper.normalizeDenom(this.denomHelper.denom);
|
|
289
|
+
return this.chainGetter
|
|
290
|
+
.getModularChain(this.chainId)
|
|
291
|
+
.currencies.some((c) => common_1.DenomHelper.normalizeDenom(c.coinMinimalDenom) === target);
|
|
133
292
|
}
|
|
134
293
|
waitFreshResponse() {
|
|
135
294
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
|
|
295
|
+
yield this.parent.waitFreshResponse();
|
|
296
|
+
yield this.awaitFallbackIfMissing();
|
|
297
|
+
return this.response;
|
|
137
298
|
});
|
|
138
299
|
}
|
|
139
300
|
waitResponse() {
|
|
140
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
|
|
302
|
+
yield this.parent.waitResponse();
|
|
303
|
+
yield this.awaitFallbackIfMissing();
|
|
304
|
+
return this.response;
|
|
142
305
|
});
|
|
143
306
|
}
|
|
144
307
|
}
|
|
308
|
+
__decorate([
|
|
309
|
+
mobx_1.observable
|
|
310
|
+
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "isInBatch", void 0);
|
|
145
311
|
__decorate([
|
|
146
312
|
mobx_1.computed
|
|
147
313
|
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "balance", null);
|
|
148
314
|
__decorate([
|
|
149
315
|
mobx_1.computed
|
|
150
316
|
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "currency", null);
|
|
317
|
+
__decorate([
|
|
318
|
+
mobx_1.computed
|
|
319
|
+
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "alchemyResolvesBalance", null);
|
|
320
|
+
__decorate([
|
|
321
|
+
mobx_1.computed
|
|
322
|
+
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "error", null);
|
|
323
|
+
__decorate([
|
|
324
|
+
mobx_1.computed
|
|
325
|
+
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "response", null);
|
|
151
326
|
exports.ObservableQueryThirdpartyERC20BalancesImpl = ObservableQueryThirdpartyERC20BalancesImpl;
|
|
152
327
|
class ObservableQueryThirdpartyERC20BalanceRegistry {
|
|
153
|
-
constructor(sharedContext,
|
|
328
|
+
constructor(sharedContext, batchParentStore) {
|
|
154
329
|
this.sharedContext = sharedContext;
|
|
155
|
-
this.
|
|
330
|
+
this.batchParentStore = batchParentStore;
|
|
156
331
|
this.parentMap = new Map();
|
|
157
332
|
}
|
|
158
333
|
getBalanceImpl(chainId, chainGetter, address, minimalDenom) {
|
|
@@ -162,13 +337,13 @@ class ObservableQueryThirdpartyERC20BalanceRegistry {
|
|
|
162
337
|
if (!Object.keys(thirdparySupportedChainIdMap).includes(chainId) ||
|
|
163
338
|
denomHelper.type !== "erc20" ||
|
|
164
339
|
!isHexAddress ||
|
|
165
|
-
(mcInfo.type !== "evm" && mcInfo.type !== "ethermint")
|
|
166
|
-
this.forceNativeERC20Query(chainId, chainGetter, address, minimalDenom)) {
|
|
340
|
+
(mcInfo.type !== "evm" && mcInfo.type !== "ethermint")) {
|
|
167
341
|
return;
|
|
168
342
|
}
|
|
169
343
|
const key = `${chainId}/${address}`;
|
|
170
344
|
if (!this.parentMap.has(key)) {
|
|
171
|
-
this.
|
|
345
|
+
const batchParent = this.batchParentStore.getOrCreate(chainId, chainGetter, address);
|
|
346
|
+
this.parentMap.set(key, new ObservableQueryThirdpartyERC20BalancesImplParent(this.sharedContext, chainId, chainGetter, address, batchParent));
|
|
172
347
|
}
|
|
173
348
|
return new ObservableQueryThirdpartyERC20BalancesImpl(this.parentMap.get(key), chainId, chainGetter, denomHelper);
|
|
174
349
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-balances.js","sourceRoot":"","sources":["../../src/queries/erc20-balances.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"erc20-balances.js","sourceRoot":"","sources":["../../src/queries/erc20-balances.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmD;AACnD,+BASc;AACd,6CAAqD;AAErD,iDAQ8B;AAC9B,8DAAqC;AACrC,wCAAiD;AAIjD,MAAM,4BAA4B,GAA2B;IAC3D,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,SAAS;IACvB,aAAa,EAAE,MAAM;IACrB,cAAc,EAAE,KAAK;CACtB,CAAC;AAgBF,MAAa,gDAAiD,SAAQ,+BAAmD;IAUvH,YACE,aAAiC,EACd,OAAe,EACf,WAAwB,EACxB,kBAA0B,EAC7B,WAA4D;QAE5E,MAAM,WAAW,GAAG,eAAe,OAAO,CAAC,OAAO,CAChD,SAAS,EACT,EAAE,CACH,gBAAgB,CAAC;QAClB,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE,0BAA0B,EAAE;YAChE,kBAAkB;YAClB,OAAO;YACP;gBACE,4BAA4B;gBAC5B,8CAA8C;gBAC9C,QAAQ,EAAE,GAAG;aACd;SACF,CAAC,CAAC;QAjBgB,YAAO,GAAP,OAAO,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAa;QACxB,uBAAkB,GAAlB,kBAAkB,CAAQ;QAC7B,gBAAW,GAAX,WAAW,CAAiD;QAPpE,u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S,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CACnD,OAAO,EACP,WAAW,EACX,OAAO,CACR,CAAC;YACF,IAAI,CAAC,SAAS,CAAC,GAAG,CAChB,GAAG,EACH,IAAI,gDAAgD,CAClD,IAAI,CAAC,aAAa,EAClB,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,CACZ,CACF,CAAC;SACH;QAED,OAAO,IAAI,0CAA0C,CACnD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAE,EACxB,OAAO,EACP,WAAW,EACX,WAAW,CACZ,CAAC;IACJ,CAAC;CACF;AA1DD,sGA0DC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const common_1 = require("@keplr-wallet/common");
|
|
13
|
+
const erc20_balances_1 = require("./erc20-balances");
|
|
14
|
+
jest.mock("../account", () => ({
|
|
15
|
+
EthereumAccountBase: {
|
|
16
|
+
isEthereumHexAddressWithChecksum: jest.fn(() => true),
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
jest.mock("@keplr-wallet/stores", () => {
|
|
20
|
+
const context = jest.requireActual("../../../stores/src/common/query/context");
|
|
21
|
+
const jsonRpc = jest.requireActual("../../../stores/src/common/query/json-rpc");
|
|
22
|
+
const batch = jest.requireActual("../../../stores/src/common/query/json-rpc-batch");
|
|
23
|
+
return {
|
|
24
|
+
QuerySharedContext: context.QuerySharedContext,
|
|
25
|
+
ObservableJsonRPCQuery: jsonRpc.ObservableJsonRPCQuery,
|
|
26
|
+
ObservableJsonRpcBatchQuery: batch.ObservableJsonRpcBatchQuery,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const CONTRACT = "0x0000000000000000000000000000000000000002";
|
|
30
|
+
const DENOM = `erc20:${CONTRACT}`;
|
|
31
|
+
const CURRENCY = {
|
|
32
|
+
coinMinimalDenom: DENOM,
|
|
33
|
+
coinDenom: "TEST",
|
|
34
|
+
coinDecimals: 18,
|
|
35
|
+
};
|
|
36
|
+
describe("ObservableQueryThirdpartyERC20BalancesImpl", () => {
|
|
37
|
+
it("falls back to batch eth_call for a missing token when the Alchemy response is complete", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const { parent, batchParent } = mockParent({
|
|
39
|
+
address: "0x0000000000000000000000000000000000000001",
|
|
40
|
+
tokenBalances: [],
|
|
41
|
+
});
|
|
42
|
+
batchParent.waitFreshResponse.mockImplementation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
batchParent.getBalance.mockReturnValue("0x5");
|
|
44
|
+
}));
|
|
45
|
+
const balance = createBalance(parent);
|
|
46
|
+
yield balance.fetch();
|
|
47
|
+
expect(batchParent.addContract).toHaveBeenCalledWith(CONTRACT);
|
|
48
|
+
expect(batchParent.waitFreshResponse).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(batchParent.removeContract).toHaveBeenCalledWith(CONTRACT);
|
|
50
|
+
expect(balance.response).not.toBe(parent.response);
|
|
51
|
+
expect(balance.balance.isReady).toBe(true);
|
|
52
|
+
expect(balance.balance.toCoin().amount).toBe("5");
|
|
53
|
+
}));
|
|
54
|
+
it("uses the batch parent's cached balance when complete Alchemy response omits the token", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
const { parent, batchParent } = mockParent({
|
|
56
|
+
address: "0x0000000000000000000000000000000000000001",
|
|
57
|
+
tokenBalances: [],
|
|
58
|
+
});
|
|
59
|
+
batchParent.getBalance.mockReturnValue("0x5");
|
|
60
|
+
const balance = createBalance(parent);
|
|
61
|
+
yield balance.fetch();
|
|
62
|
+
expect(batchParent.addContract).toHaveBeenCalledWith(CONTRACT);
|
|
63
|
+
expect(balance.balance.toCoin().amount).toBe("5");
|
|
64
|
+
}));
|
|
65
|
+
it("falls back to batch eth_call for a missing token when Alchemy has more pages", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const { parent, batchParent } = mockParent({
|
|
67
|
+
address: "0x0000000000000000000000000000000000000001",
|
|
68
|
+
tokenBalances: [],
|
|
69
|
+
pageKey: "next-page",
|
|
70
|
+
});
|
|
71
|
+
const balance = createBalance(parent);
|
|
72
|
+
yield balance.fetch();
|
|
73
|
+
expect(batchParent.addContract).toHaveBeenCalledWith(CONTRACT);
|
|
74
|
+
expect(batchParent.waitFreshResponse).toHaveBeenCalledTimes(1);
|
|
75
|
+
expect(batchParent.removeContract).toHaveBeenCalledWith(CONTRACT);
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
78
|
+
describe("ObservableQueryThirdpartyERC20BalanceRegistry", () => {
|
|
79
|
+
it("does not use the Keplr Alchemy proxy for Optimism", () => {
|
|
80
|
+
const batchParentStore = {
|
|
81
|
+
getOrCreate: jest.fn(),
|
|
82
|
+
};
|
|
83
|
+
const registry = new erc20_balances_1.ObservableQueryThirdpartyERC20BalanceRegistry({}, batchParentStore);
|
|
84
|
+
const impl = registry.getBalanceImpl("eip155:10", mockChainGetter(), "0x0000000000000000000000000000000000000001", DENOM);
|
|
85
|
+
expect(impl).toBeUndefined();
|
|
86
|
+
expect(batchParentStore.getOrCreate).not.toHaveBeenCalled();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
function createBalance(parent) {
|
|
90
|
+
return new erc20_balances_1.ObservableQueryThirdpartyERC20BalancesImpl(parent, "eip155:1", mockChainGetter(), new common_1.DenomHelper(DENOM));
|
|
91
|
+
}
|
|
92
|
+
function mockParent(data) {
|
|
93
|
+
const batchParent = {
|
|
94
|
+
addContract: jest.fn(),
|
|
95
|
+
removeContract: jest.fn(),
|
|
96
|
+
waitFreshResponse: jest.fn().mockResolvedValue(undefined),
|
|
97
|
+
getBalance: jest.fn(),
|
|
98
|
+
getLastKnownBalance: jest.fn(),
|
|
99
|
+
getError: jest.fn(),
|
|
100
|
+
isFetchingContract: jest.fn(() => false),
|
|
101
|
+
isFetching: false,
|
|
102
|
+
};
|
|
103
|
+
const response = {
|
|
104
|
+
data,
|
|
105
|
+
staled: false,
|
|
106
|
+
local: false,
|
|
107
|
+
timestamp: 0,
|
|
108
|
+
};
|
|
109
|
+
const parent = {
|
|
110
|
+
response,
|
|
111
|
+
error: undefined,
|
|
112
|
+
batchParent,
|
|
113
|
+
duplicatedFetchResolver: undefined,
|
|
114
|
+
fetch: jest.fn().mockResolvedValue(undefined),
|
|
115
|
+
hasAlchemyBalance(contract) {
|
|
116
|
+
return data.tokenBalances.some((bal) => bal.contractAddress.toLowerCase() === contract.toLowerCase() &&
|
|
117
|
+
bal.tokenBalance != null);
|
|
118
|
+
},
|
|
119
|
+
getAlchemyTokenBalance(contract) {
|
|
120
|
+
return data.tokenBalances.find((bal) => bal.contractAddress.toLowerCase() === contract.toLowerCase());
|
|
121
|
+
},
|
|
122
|
+
resolvesAlchemyBalance(contract) {
|
|
123
|
+
var _a;
|
|
124
|
+
return ((_a = this.getAlchemyTokenBalance(contract)) === null || _a === void 0 ? void 0 : _a.tokenBalance) != null;
|
|
125
|
+
},
|
|
126
|
+
isFetching: false,
|
|
127
|
+
isObserved: false,
|
|
128
|
+
isStarted: false,
|
|
129
|
+
};
|
|
130
|
+
return { parent, batchParent };
|
|
131
|
+
}
|
|
132
|
+
function mockChainGetter() {
|
|
133
|
+
return {
|
|
134
|
+
getModularChain() {
|
|
135
|
+
return {
|
|
136
|
+
currencies: [CURRENCY],
|
|
137
|
+
forceFindCurrency(denom) {
|
|
138
|
+
if (denom === DENOM) {
|
|
139
|
+
return CURRENCY;
|
|
140
|
+
}
|
|
141
|
+
throw new Error(`Unknown currency: ${denom}`);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
hasModularChain() {
|
|
146
|
+
return true;
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=erc20-balances.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20-balances.spec.js","sourceRoot":"","sources":["../../src/queries/erc20-balances.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAAmD;AAEnD,qDAG0B;AAE1B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,mBAAmB,EAAE;QACnB,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KACtD;CACF,CAAC,CAAC,CAAC;AAEJ,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAChC,0CAA0C,CAC3C,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAChC,2CAA2C,CAC5C,CAAC;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAC9B,iDAAiD,CAClD,CAAC;IACF,OAAO;QACL,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;QACtD,2BAA2B,EAAE,KAAK,CAAC,2BAA2B;KAC/D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,QA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,8 @@
|
|
|
1
|
+
import { ChainGetter, QuerySharedContext } from "@keplr-wallet/stores";
|
|
2
|
+
import { ObservableQueryEthereumERC20BalancesBatchParent } from "./erc20-balance-batch";
|
|
3
|
+
export declare class ERC20BalanceBatchParentStore {
|
|
4
|
+
protected readonly sharedContext: QuerySharedContext;
|
|
5
|
+
protected map: Map<string, ObservableQueryEthereumERC20BalancesBatchParent>;
|
|
6
|
+
constructor(sharedContext: QuerySharedContext);
|
|
7
|
+
getOrCreate(chainId: string, chainGetter: ChainGetter, ethereumHexAddress: string): ObservableQueryEthereumERC20BalancesBatchParent;
|
|
8
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERC20BalanceBatchParentStore = void 0;
|
|
4
|
+
const erc20_balance_batch_1 = require("./erc20-balance-batch");
|
|
5
|
+
class ERC20BalanceBatchParentStore {
|
|
6
|
+
constructor(sharedContext) {
|
|
7
|
+
this.sharedContext = sharedContext;
|
|
8
|
+
this.map = new Map();
|
|
9
|
+
}
|
|
10
|
+
getOrCreate(chainId, chainGetter, ethereumHexAddress) {
|
|
11
|
+
const key = `${chainId}/${ethereumHexAddress.toLowerCase()}`;
|
|
12
|
+
let p = this.map.get(key);
|
|
13
|
+
if (!p) {
|
|
14
|
+
p = new erc20_balance_batch_1.ObservableQueryEthereumERC20BalancesBatchParent(this.sharedContext, chainId, chainGetter, ethereumHexAddress);
|
|
15
|
+
this.map.set(key, p);
|
|
16
|
+
}
|
|
17
|
+
return p;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.ERC20BalanceBatchParentStore = ERC20BalanceBatchParentStore;
|
|
21
|
+
//# sourceMappingURL=erc20-batch-parent-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erc20-batch-parent-store.js","sourceRoot":"","sources":["../../src/queries/erc20-batch-parent-store.ts"],"names":[],"mappings":";;;AACA,+DAAwF;AAExF,MAAa,4BAA4B;IAIvC,YAA+B,aAAiC;QAAjC,kBAAa,GAAb,aAAa,CAAoB;QAHtD,QAAG,GACX,IAAI,GAAG,EAAE,CAAC;IAEuD,CAAC;IAEpE,WAAW,CACT,OAAe,EACf,WAAwB,EACxB,kBAA0B;QAE1B,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,kBAAkB,CAAC,WAAW,EAAE,EAAE,CAAC;QAC7D,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,CAAC,EAAE;YACN,CAAC,GAAG,IAAI,qEAA+C,CACrD,IAAI,CAAC,aAAa,EAClB,OAAO,EACP,WAAW,EACX,kBAAkB,CACnB,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;SACtB;QACD,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAxBD,oEAwBC"}
|
package/build/queries/index.d.ts
CHANGED
|
@@ -15,11 +15,9 @@ export declare const EthereumQueries: {
|
|
|
15
15
|
use(options: {
|
|
16
16
|
coingeckoAPIBaseURL: string;
|
|
17
17
|
coingeckoAPIURI: string;
|
|
18
|
-
forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean;
|
|
19
18
|
}): (queriesSetBase: QueriesSetBase, sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter) => EthereumQueries;
|
|
20
19
|
};
|
|
21
20
|
export declare class EthereumQueriesImpl {
|
|
22
|
-
protected readonly forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean;
|
|
23
21
|
protected chainId: string;
|
|
24
22
|
protected chainGetter: ChainGetter;
|
|
25
23
|
protected coingeckoAPIBaseURL: string;
|
|
@@ -32,5 +30,5 @@ export declare class EthereumQueriesImpl {
|
|
|
32
30
|
readonly queryEthereumCoingeckoTokenInfo: DeepReadonly<ObservableQueryCoingeckoTokenInfo>;
|
|
33
31
|
readonly queryEthereumGasPrice: DeepReadonly<ObservableQueryEthereumGasPrice>;
|
|
34
32
|
readonly queryEthereumTxReceipt: DeepReadonly<ObservableQueryEthereumTxReceipt>;
|
|
35
|
-
constructor(base: QueriesSetBase, sharedContext: QuerySharedContext,
|
|
33
|
+
constructor(base: QueriesSetBase, sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, coingeckoAPIBaseURL: string, coingeckoAPIURI: string);
|
|
36
34
|
}
|
package/build/queries/index.js
CHANGED
|
@@ -10,26 +10,27 @@ const max_priority_fee_1 = require("./max-priority-fee");
|
|
|
10
10
|
const erc20_balances_1 = require("./erc20-balances");
|
|
11
11
|
const coingecko_token_info_1 = require("./coingecko-token-info");
|
|
12
12
|
const erc20_balance_1 = require("./erc20-balance");
|
|
13
|
+
const erc20_batch_parent_store_1 = require("./erc20-batch-parent-store");
|
|
13
14
|
const gas_price_1 = require("./gas-price");
|
|
14
15
|
const tx_receipt_1 = require("./tx-receipt");
|
|
15
16
|
exports.EthereumQueries = {
|
|
16
17
|
use(options) {
|
|
17
18
|
return (queriesSetBase, sharedContext, chainId, chainGetter) => {
|
|
18
19
|
return {
|
|
19
|
-
ethereum: new EthereumQueriesImpl(queriesSetBase, sharedContext,
|
|
20
|
+
ethereum: new EthereumQueriesImpl(queriesSetBase, sharedContext, chainId, chainGetter, options.coingeckoAPIBaseURL, options.coingeckoAPIURI),
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
},
|
|
23
24
|
};
|
|
24
25
|
class EthereumQueriesImpl {
|
|
25
|
-
constructor(base, sharedContext,
|
|
26
|
-
this.forceNativeERC20Query = forceNativeERC20Query;
|
|
26
|
+
constructor(base, sharedContext, chainId, chainGetter, coingeckoAPIBaseURL, coingeckoAPIURI) {
|
|
27
27
|
this.chainId = chainId;
|
|
28
28
|
this.chainGetter = chainGetter;
|
|
29
29
|
this.coingeckoAPIBaseURL = coingeckoAPIBaseURL;
|
|
30
30
|
this.coingeckoAPIURI = coingeckoAPIURI;
|
|
31
|
-
|
|
32
|
-
base.queryBalances.addBalanceRegistry(new
|
|
31
|
+
const batchParentStore = new erc20_batch_parent_store_1.ERC20BalanceBatchParentStore(sharedContext);
|
|
32
|
+
base.queryBalances.addBalanceRegistry(new erc20_balance_1.ObservableQueryEthereumERC20BalanceRegistry(sharedContext, batchParentStore));
|
|
33
|
+
base.queryBalances.addBalanceRegistry(new erc20_balances_1.ObservableQueryThirdpartyERC20BalanceRegistry(sharedContext, batchParentStore));
|
|
33
34
|
base.queryBalances.addBalanceRegistry(new balance_1.ObservableQueryEthAccountBalanceRegistry(sharedContext));
|
|
34
35
|
this.queryEthereumBlock = new block_1.ObservableQueryEthereumBlock(sharedContext, chainId, chainGetter);
|
|
35
36
|
this.queryEthereumFeeHistory = new fee_histroy_1.ObservableQueryEthereumFeeHistory(sharedContext, chainId, chainGetter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/queries/index.ts"],"names":[],"mappings":";;;AAKA,uCAAqE;AAErE,mCAAuD;AACvD,+CAAkE;AAClE,qDAAwE;AACxE,+DAAyE;AACzE,yDAA2E;AAC3E,qDAAiF;AACjF,iEAA2E;AAC3E,mDAA8E;AAC9E,2CAA8D;AAC9D,6CAAgE;AAMnD,QAAA,eAAe,GAAG;IAC7B,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/queries/index.ts"],"names":[],"mappings":";;;AAKA,uCAAqE;AAErE,mCAAuD;AACvD,+CAAkE;AAClE,qDAAwE;AACxE,+DAAyE;AACzE,yDAA2E;AAC3E,qDAAiF;AACjF,iEAA2E;AAC3E,mDAA8E;AAC9E,yEAA0E;AAC1E,2CAA8D;AAC9D,6CAAgE;AAMnD,QAAA,eAAe,GAAG;IAC7B,GAAG,CAAC,OAGH;QAMC,OAAO,CACL,cAA8B,EAC9B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