@keplr-wallet/stores-eth 0.12.312 → 0.13.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/build/account/base.d.ts +15 -1
- package/build/account/base.js +241 -9
- package/build/account/base.js.map +1 -1
- package/build/queries/erc20-balances.d.ts +2 -1
- package/build/queries/erc20-balances.js +4 -2
- package/build/queries/erc20-balances.js.map +1 -1
- package/build/queries/index.d.ts +3 -1
- package/build/queries/index.js +4 -3
- package/build/queries/index.js.map +1 -1
- package/build/types.d.ts +25 -0
- package/package.json +8 -8
- package/src/account/base.ts +326 -9
- package/src/queries/erc20-balances.ts +11 -2
- package/src/queries/index.ts +17 -1
- package/src/types.ts +30 -0
package/build/account/base.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChainGetter } from "@keplr-wallet/stores";
|
|
2
2
|
import { AppCurrency, ERC20Currency, EthTxReceipt, Keplr } from "@keplr-wallet/types";
|
|
3
3
|
import { UnsignedTransaction } from "@ethersproject/transactions";
|
|
4
|
+
import { SimulateGasWithPendingErc20ApprovalResult, StateOverride, UnsignedEVMTransactionWithErc20Approvals } from "../types";
|
|
4
5
|
export declare class EthereumAccountBase {
|
|
5
6
|
protected readonly chainGetter: ChainGetter;
|
|
6
7
|
protected readonly chainId: string;
|
|
@@ -9,7 +10,7 @@ export declare class EthereumAccountBase {
|
|
|
9
10
|
constructor(chainGetter: ChainGetter, chainId: string, getKeplr: () => Promise<Keplr | undefined>);
|
|
10
11
|
setIsSendingTx(value: boolean): void;
|
|
11
12
|
get isSendingTx(): boolean;
|
|
12
|
-
simulateGas(sender: string, unsignedTx: UnsignedTransaction): Promise<{
|
|
13
|
+
simulateGas(sender: string, unsignedTx: UnsignedTransaction, stateOverride?: StateOverride): Promise<{
|
|
13
14
|
gasUsed: number;
|
|
14
15
|
}>;
|
|
15
16
|
simulateGasForSendTokenTx({ currency, amount, sender, recipient, }: {
|
|
@@ -20,7 +21,9 @@ export declare class EthereumAccountBase {
|
|
|
20
21
|
}): Promise<{
|
|
21
22
|
gasUsed: number;
|
|
22
23
|
}>;
|
|
24
|
+
simulateGasWithPendingErc20Approval(sender: string, unsignedTx: UnsignedEVMTransactionWithErc20Approvals): Promise<SimulateGasWithPendingErc20ApprovalResult>;
|
|
23
25
|
simulateOpStackL1Fee(unsignedTx: UnsignedTransaction): Promise<string>;
|
|
26
|
+
simulateOpStackL1FeeWithPendingErc20Approval(unsignedTx: UnsignedEVMTransactionWithErc20Approvals): Promise<string>;
|
|
24
27
|
makeSendTokenTx({ currency, amount, to, gasLimit, maxFeePerGas, maxPriorityFeePerGas, gasPrice, }: {
|
|
25
28
|
currency: AppCurrency;
|
|
26
29
|
amount: string;
|
|
@@ -32,6 +35,17 @@ export declare class EthereumAccountBase {
|
|
|
32
35
|
}): UnsignedTransaction;
|
|
33
36
|
makeErc20ApprovalTx(currency: ERC20Currency, spender: string, amount: string): UnsignedTransaction;
|
|
34
37
|
makeTx(to: string, value: string, data?: string): UnsignedTransaction;
|
|
38
|
+
/**
|
|
39
|
+
* Sign an Ethereum transaction.
|
|
40
|
+
* @param sender - The sender address.
|
|
41
|
+
* @param unsignedTx - The unsigned transaction to sign.
|
|
42
|
+
* @param options - The options for the transaction.
|
|
43
|
+
* @returns The signed transaction in serialized format.
|
|
44
|
+
*/
|
|
45
|
+
signEthereumTx(sender: string, unsignedTx: UnsignedEVMTransactionWithErc20Approvals, options?: {
|
|
46
|
+
nonceMethod?: "pending" | "latest";
|
|
47
|
+
considerRequiredErc20ApprovalsForNonce?: boolean;
|
|
48
|
+
}): Promise<string>;
|
|
35
49
|
sendEthereumTx(sender: string, unsignedTx: UnsignedTransaction, onTxEvents?: {
|
|
36
50
|
onBroadcastFailed?: (e?: Error) => void;
|
|
37
51
|
onBroadcasted?: (txHash: string) => void;
|
package/build/account/base.js
CHANGED
|
@@ -25,6 +25,7 @@ const transactions_1 = require("@ethersproject/transactions");
|
|
|
25
25
|
const address_1 = require("@ethersproject/address");
|
|
26
26
|
const mobx_1 = require("mobx");
|
|
27
27
|
const abi_1 = require("@ethersproject/abi");
|
|
28
|
+
const simple_fetch_1 = require("@keplr-wallet/simple-fetch");
|
|
28
29
|
const opStackGasPriceOracleProxyAddress = "0x420000000000000000000000000000000000000F";
|
|
29
30
|
const opStackGasPriceOracleABI = new abi_1.Interface([
|
|
30
31
|
{
|
|
@@ -35,6 +36,63 @@ const opStackGasPriceOracleABI = new abi_1.Interface([
|
|
|
35
36
|
type: "function",
|
|
36
37
|
},
|
|
37
38
|
]);
|
|
39
|
+
function traceCallWithDiff(rpcUrl, tx, blockTag = "latest") {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const response = yield (0, simple_fetch_1.simpleFetch)(rpcUrl, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: { "Content-Type": "application/json" },
|
|
44
|
+
body: JSON.stringify({
|
|
45
|
+
jsonrpc: "2.0",
|
|
46
|
+
method: "debug_traceCall",
|
|
47
|
+
params: [
|
|
48
|
+
tx,
|
|
49
|
+
blockTag,
|
|
50
|
+
{
|
|
51
|
+
tracer: "prestateTracer",
|
|
52
|
+
tracerConfig: {
|
|
53
|
+
diffMode: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
id: 1,
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
const data = response.data;
|
|
61
|
+
if (data.error) {
|
|
62
|
+
throw new Error(data.error.message);
|
|
63
|
+
}
|
|
64
|
+
if (!data.result) {
|
|
65
|
+
throw new Error("Unknown error");
|
|
66
|
+
}
|
|
67
|
+
return data.result;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function diffResultToStateOverride(diffResult, allowedAddresses, useStateDiff = false) {
|
|
71
|
+
const override = {};
|
|
72
|
+
const allowed = new Set(allowedAddresses.map((addr) => addr.toLowerCase()));
|
|
73
|
+
for (const [address, state] of Object.entries(diffResult.post)) {
|
|
74
|
+
if (!allowed.has(address.toLowerCase())) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (state.storage && Object.keys(state.storage).length > 0) {
|
|
78
|
+
if (useStateDiff) {
|
|
79
|
+
// 개별 슬롯만 패치 (stateDiff)
|
|
80
|
+
override[address] = {
|
|
81
|
+
stateDiff: state.storage,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// 전체 스토리지 override (state)
|
|
86
|
+
// 시스템 컨트랙트의 전체 상태를 덮어쓰려고 하면 오류가 발생할 수 있다.
|
|
87
|
+
// 가능한 이 기능을 사용하지 않도록 하자.
|
|
88
|
+
override[address] = {
|
|
89
|
+
state: state.storage,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return override;
|
|
95
|
+
}
|
|
38
96
|
class EthereumAccountBase {
|
|
39
97
|
constructor(chainGetter, chainId, getKeplr) {
|
|
40
98
|
this.chainGetter = chainGetter;
|
|
@@ -49,7 +107,7 @@ class EthereumAccountBase {
|
|
|
49
107
|
get isSendingTx() {
|
|
50
108
|
return this._isSendingTx;
|
|
51
109
|
}
|
|
52
|
-
simulateGas(sender, unsignedTx) {
|
|
110
|
+
simulateGas(sender, unsignedTx, stateOverride) {
|
|
53
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
112
|
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
55
113
|
const evmInfo = chainInfo.evm;
|
|
@@ -59,16 +117,20 @@ class EthereumAccountBase {
|
|
|
59
117
|
const { to, value, data } = unsignedTx;
|
|
60
118
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
61
119
|
const keplr = (yield this.getKeplr());
|
|
120
|
+
const params = [
|
|
121
|
+
{
|
|
122
|
+
from: sender,
|
|
123
|
+
to,
|
|
124
|
+
value,
|
|
125
|
+
data,
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
if (stateOverride) {
|
|
129
|
+
params.push("latest", stateOverride);
|
|
130
|
+
}
|
|
62
131
|
const gasEstimated = yield keplr.ethereum.request({
|
|
63
132
|
method: "eth_estimateGas",
|
|
64
|
-
params
|
|
65
|
-
{
|
|
66
|
-
from: sender,
|
|
67
|
-
to,
|
|
68
|
-
value,
|
|
69
|
-
data,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
133
|
+
params,
|
|
72
134
|
chainId: this.chainId,
|
|
73
135
|
});
|
|
74
136
|
if (!gasEstimated) {
|
|
@@ -108,6 +170,78 @@ class EthereumAccountBase {
|
|
|
108
170
|
return this.simulateGas(sender, unsignedTx);
|
|
109
171
|
});
|
|
110
172
|
}
|
|
173
|
+
simulateGasWithPendingErc20Approval(sender, unsignedTx) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
176
|
+
const evmInfo = chainInfo.evm;
|
|
177
|
+
if (!evmInfo) {
|
|
178
|
+
throw new Error("No EVM chain info provided");
|
|
179
|
+
}
|
|
180
|
+
const { to, value, data, requiredErc20Approvals } = unsignedTx;
|
|
181
|
+
const erc20ApprovalTxs = requiredErc20Approvals === null || requiredErc20Approvals === void 0 ? void 0 : requiredErc20Approvals.map((approval) => {
|
|
182
|
+
return {
|
|
183
|
+
to: approval.tokenAddress,
|
|
184
|
+
value: "0x0",
|
|
185
|
+
data: constants_1.erc20ContractInterface.encodeFunctionData("approve", [
|
|
186
|
+
approval.spender,
|
|
187
|
+
(0, bytes_1.hexValue)(BigInt(approval.amount)),
|
|
188
|
+
]),
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
if (!erc20ApprovalTxs || (erc20ApprovalTxs === null || erc20ApprovalTxs === void 0 ? void 0 : erc20ApprovalTxs.length) === 0) {
|
|
192
|
+
const result = yield this.simulateGas(sender, unsignedTx);
|
|
193
|
+
return {
|
|
194
|
+
outcome: types_1.EvmGasSimulationOutcome.TX_SIMULATED,
|
|
195
|
+
gasUsed: result.gasUsed,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (erc20ApprovalTxs.length > 1) {
|
|
199
|
+
throw new Error("Multiple ERC20 approvals are not supported");
|
|
200
|
+
}
|
|
201
|
+
const erc20Approval = requiredErc20Approvals === null || requiredErc20Approvals === void 0 ? void 0 : requiredErc20Approvals[0];
|
|
202
|
+
if (!erc20Approval) {
|
|
203
|
+
throw new Error("Invalid ERC20 approval");
|
|
204
|
+
}
|
|
205
|
+
const erc20ApprovalTx = erc20ApprovalTxs[0];
|
|
206
|
+
// First, estimate gas for the ERC20 approval tx itself.
|
|
207
|
+
// This result is reused whether the bundle simulation with state diff succeeds or falls back.
|
|
208
|
+
const erc20ApprovalSimResult = yield this.simulateGas(sender, erc20ApprovalTx);
|
|
209
|
+
try {
|
|
210
|
+
// State diff tracing for the ERC20 approval transaction
|
|
211
|
+
const approvalStateDiff = yield traceCallWithDiff(chainInfo.rpc, {
|
|
212
|
+
from: sender,
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
214
|
+
to: erc20ApprovalTx.to,
|
|
215
|
+
value: erc20ApprovalTx.value,
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
217
|
+
data: erc20ApprovalTx.data,
|
|
218
|
+
});
|
|
219
|
+
// estimate gas with state override with approval state diff
|
|
220
|
+
const result = yield this.simulateGas(sender, {
|
|
221
|
+
to,
|
|
222
|
+
value,
|
|
223
|
+
data,
|
|
224
|
+
}, diffResultToStateOverride(approvalStateDiff, [
|
|
225
|
+
sender,
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
227
|
+
erc20ApprovalTx.to,
|
|
228
|
+
erc20Approval.spender,
|
|
229
|
+
], true));
|
|
230
|
+
return {
|
|
231
|
+
outcome: types_1.EvmGasSimulationOutcome.TX_BUNDLE_SIMULATED,
|
|
232
|
+
gasUsed: result.gasUsed,
|
|
233
|
+
erc20ApprovalGasUsed: erc20ApprovalSimResult.gasUsed,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
console.error("Failed to simulate gas with pending ERC20 approval", e);
|
|
238
|
+
return {
|
|
239
|
+
outcome: types_1.EvmGasSimulationOutcome.APPROVAL_ONLY_SIMULATED,
|
|
240
|
+
erc20ApprovalGasUsed: erc20ApprovalSimResult.gasUsed,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
111
245
|
simulateOpStackL1Fee(unsignedTx) {
|
|
112
246
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
247
|
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
@@ -136,6 +270,69 @@ class EthereumAccountBase {
|
|
|
136
270
|
return l1Fee;
|
|
137
271
|
});
|
|
138
272
|
}
|
|
273
|
+
simulateOpStackL1FeeWithPendingErc20Approval(unsignedTx) {
|
|
274
|
+
var _a;
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
277
|
+
if (!chainInfo.features.includes("op-stack-l1-data-fee")) {
|
|
278
|
+
throw new Error("The chain isn't built with OP Stack");
|
|
279
|
+
}
|
|
280
|
+
const evmInfo = chainInfo.evm;
|
|
281
|
+
if (!evmInfo) {
|
|
282
|
+
throw new Error("No EVM chain info provided");
|
|
283
|
+
}
|
|
284
|
+
const txsToSimulate = [
|
|
285
|
+
{
|
|
286
|
+
to: unsignedTx.to,
|
|
287
|
+
gasLimit: unsignedTx.gasLimit,
|
|
288
|
+
value: unsignedTx.value,
|
|
289
|
+
data: unsignedTx.data,
|
|
290
|
+
chainId: unsignedTx.chainId,
|
|
291
|
+
},
|
|
292
|
+
];
|
|
293
|
+
// If there's a pending ERC20 approval, add it to the batch
|
|
294
|
+
const erc20Approval = (_a = unsignedTx.requiredErc20Approvals) === null || _a === void 0 ? void 0 : _a[0];
|
|
295
|
+
if (erc20Approval != null) {
|
|
296
|
+
txsToSimulate.push({
|
|
297
|
+
to: erc20Approval.tokenAddress,
|
|
298
|
+
data: constants_1.erc20ContractInterface.encodeFunctionData("approve", [
|
|
299
|
+
erc20Approval.spender,
|
|
300
|
+
(0, bytes_1.hexValue)(BigInt(erc20Approval.amount)),
|
|
301
|
+
]),
|
|
302
|
+
chainId: unsignedTx.chainId,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
const batchRequests = txsToSimulate.map((tx, index) => ({
|
|
306
|
+
jsonrpc: "2.0",
|
|
307
|
+
method: "eth_call",
|
|
308
|
+
params: [
|
|
309
|
+
{
|
|
310
|
+
to: opStackGasPriceOracleProxyAddress,
|
|
311
|
+
data: opStackGasPriceOracleABI.encodeFunctionData("getL1Fee", [
|
|
312
|
+
(0, transactions_1.serialize)(tx),
|
|
313
|
+
]),
|
|
314
|
+
},
|
|
315
|
+
"latest",
|
|
316
|
+
],
|
|
317
|
+
id: index + 1,
|
|
318
|
+
}));
|
|
319
|
+
const response = yield (0, simple_fetch_1.simpleFetch)(evmInfo.rpc, {
|
|
320
|
+
method: "POST",
|
|
321
|
+
headers: { "Content-Type": "application/json" },
|
|
322
|
+
body: JSON.stringify(batchRequests),
|
|
323
|
+
});
|
|
324
|
+
let totalL1Fee = BigInt(0);
|
|
325
|
+
for (const result of response.data) {
|
|
326
|
+
if (result.error) {
|
|
327
|
+
throw new Error(result.error.message);
|
|
328
|
+
}
|
|
329
|
+
if (result.result) {
|
|
330
|
+
totalL1Fee += BigInt(result.result);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return "0x" + totalL1Fee.toString(16);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
139
336
|
makeSendTokenTx({ currency, amount, to, gasLimit, maxFeePerGas, maxPriorityFeePerGas, gasPrice, }) {
|
|
140
337
|
const parsedAmount = (0, units_1.parseUnits)(amount, currency.coinDecimals);
|
|
141
338
|
const denomHelper = new common_1.DenomHelper(currency.coinMinimalDenom);
|
|
@@ -183,6 +380,41 @@ class EthereumAccountBase {
|
|
|
183
380
|
data,
|
|
184
381
|
};
|
|
185
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Sign an Ethereum transaction.
|
|
385
|
+
* @param sender - The sender address.
|
|
386
|
+
* @param unsignedTx - The unsigned transaction to sign.
|
|
387
|
+
* @param options - The options for the transaction.
|
|
388
|
+
* @returns The signed transaction in serialized format.
|
|
389
|
+
*/
|
|
390
|
+
signEthereumTx(sender, unsignedTx, options) {
|
|
391
|
+
var _a, _b;
|
|
392
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
393
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
394
|
+
const evmInfo = chainInfo.evm;
|
|
395
|
+
if (!evmInfo) {
|
|
396
|
+
throw new Error("No EVM info provided");
|
|
397
|
+
}
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
399
|
+
const keplr = (yield this.getKeplr());
|
|
400
|
+
const transactionCount = yield keplr.ethereum.request({
|
|
401
|
+
method: "eth_getTransactionCount",
|
|
402
|
+
params: [sender, (options === null || options === void 0 ? void 0 : options.nonceMethod) || "pending"],
|
|
403
|
+
chainId: this.chainId,
|
|
404
|
+
});
|
|
405
|
+
unsignedTx = Object.assign(Object.assign({}, unsignedTx), { nonce: parseInt(transactionCount) +
|
|
406
|
+
((options === null || options === void 0 ? void 0 : options.considerRequiredErc20ApprovalsForNonce)
|
|
407
|
+
? (_b = (_a = unsignedTx.requiredErc20Approvals) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0
|
|
408
|
+
: 0) });
|
|
409
|
+
const signEthereum = keplr.signEthereum.bind(keplr);
|
|
410
|
+
const signature = yield signEthereum(this.chainId, sender, JSON.stringify(unsignedTx), types_1.EthSignType.TRANSACTION);
|
|
411
|
+
const isEIP1559 = !!unsignedTx.maxFeePerGas || !!unsignedTx.maxPriorityFeePerGas;
|
|
412
|
+
if (isEIP1559) {
|
|
413
|
+
unsignedTx.type = transactions_1.TransactionTypes.eip1559;
|
|
414
|
+
}
|
|
415
|
+
return (0, transactions_1.serialize)(unsignedTx, signature);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
186
418
|
sendEthereumTx(sender, unsignedTx, onTxEvents, options) {
|
|
187
419
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
420
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/account/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,+CAM6B;AAC7B,iDAA0D;AAC1D,4CAAsD;AACtD,gDAAgD;AAChD,gDAAkD;AAClD,8DAIqC;AACrC,oDAAqE;AACrE,+BAA0D;AAC1D,4CAA+C;AAE/C,MAAM,iCAAiC,GACrC,4CAA4C,CAAC;AAE/C,MAAM,wBAAwB,GAAG,IAAI,eAAS,CAAC;IAC7C;QACE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACjE,IAAI,EAAE,UAAU;QAChB,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;AAEH,MAAa,mBAAmB;IAI9B,YACqB,WAAwB,EACxB,OAAe,EACf,QAA0C;QAF1C,gBAAW,GAAX,WAAW,CAAa;QACxB,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAkC;QALrD,iBAAY,GAAY,KAAK,CAAC;QAOtC,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAGD,cAAc,CAAC,KAAc;QAC3B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW;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MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,2DAAG,SAAS,CAAC,CAAC;4BACnC,OAAO,EAAE,CAAC;yBACX;wBAED,MAAM,EAAE,CAAC;oBACX,CAAC,CAAA,CAAC,CAAC;gBACL,CAAC,EACD;oBACE,UAAU,EAAE,EAAE;oBACd,gBAAgB,EAAE,GAAG;oBACrB,mBAAmB,EAAE,IAAI;iBAC1B,CACF,CAAC;gBAEF,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,iBAAiB,EAAE;oBACjC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;iBACjC;gBAED,MAAM,CAAC,CAAC;aACT;QACH,CAAC;KAAA;IAED,MAAM,CAAC,gCAAgC,CAAC,UAAkB;QACxD,MAAM,YAAY,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC5D,MAAM,iBAAiB,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAC1C,+BAA+B,CAChC,CAAC;QACF,IAAI,CAAC,YAAY,IAAI,UAAU,CAAC,MAAM,KAAK,EAAE,EAAE;YAC7C,OAAO,KAAK,CAAC;SACd;QAED,MAAM,kBAAkB,GAAG,IAAA,oBAAa,EAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;QACnE,IAAI,iBAAiB,IAAI,kBAAkB,KAAK,UAAU,EAAE;YAC1D,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AApjBW;IADT,iBAAU;yDAC6B;AAWxC;IADC,aAAM;yDAGN;AAfH,kDAsjBC"}
|
|
@@ -42,8 +42,9 @@ export declare class ObservableQueryThirdpartyERC20BalancesImpl implements IObse
|
|
|
42
42
|
}
|
|
43
43
|
export declare class ObservableQueryThirdpartyERC20BalanceRegistry implements BalanceRegistry {
|
|
44
44
|
protected readonly sharedContext: QuerySharedContext;
|
|
45
|
+
protected readonly forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean;
|
|
45
46
|
protected parentMap: Map<string, ObservableQueryThirdpartyERC20BalancesImplParent>;
|
|
46
|
-
constructor(sharedContext: QuerySharedContext);
|
|
47
|
+
constructor(sharedContext: QuerySharedContext, forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean);
|
|
47
48
|
getBalanceImpl(chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string): ObservableQueryThirdpartyERC20BalancesImpl | undefined;
|
|
48
49
|
}
|
|
49
50
|
export {};
|
|
@@ -149,8 +149,9 @@ __decorate([
|
|
|
149
149
|
], ObservableQueryThirdpartyERC20BalancesImpl.prototype, "currency", null);
|
|
150
150
|
exports.ObservableQueryThirdpartyERC20BalancesImpl = ObservableQueryThirdpartyERC20BalancesImpl;
|
|
151
151
|
class ObservableQueryThirdpartyERC20BalanceRegistry {
|
|
152
|
-
constructor(sharedContext) {
|
|
152
|
+
constructor(sharedContext, forceNativeERC20Query) {
|
|
153
153
|
this.sharedContext = sharedContext;
|
|
154
|
+
this.forceNativeERC20Query = forceNativeERC20Query;
|
|
154
155
|
this.parentMap = new Map();
|
|
155
156
|
}
|
|
156
157
|
getBalanceImpl(chainId, chainGetter, address, minimalDenom) {
|
|
@@ -160,7 +161,8 @@ class ObservableQueryThirdpartyERC20BalanceRegistry {
|
|
|
160
161
|
if (!Object.keys(thirdparySupportedChainIdMap).includes(chainId) ||
|
|
161
162
|
denomHelper.type !== "erc20" ||
|
|
162
163
|
!isHexAddress ||
|
|
163
|
-
!chainInfo.evm
|
|
164
|
+
!chainInfo.evm ||
|
|
165
|
+
this.forceNativeERC20Query(chainId, chainGetter, address, minimalDenom)) {
|
|
164
166
|
return;
|
|
165
167
|
}
|
|
166
168
|
const key = `${chainId}/${address}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20-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A0DC"}
|
package/build/queries/index.d.ts
CHANGED
|
@@ -14,9 +14,11 @@ export declare const EthereumQueries: {
|
|
|
14
14
|
use(options: {
|
|
15
15
|
coingeckoAPIBaseURL: string;
|
|
16
16
|
coingeckoAPIURI: string;
|
|
17
|
+
forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean;
|
|
17
18
|
}): (queriesSetBase: QueriesSetBase, sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter) => EthereumQueries;
|
|
18
19
|
};
|
|
19
20
|
export declare class EthereumQueriesImpl {
|
|
21
|
+
protected readonly forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean;
|
|
20
22
|
protected chainId: string;
|
|
21
23
|
protected chainGetter: ChainGetter;
|
|
22
24
|
protected coingeckoAPIBaseURL: string;
|
|
@@ -28,5 +30,5 @@ export declare class EthereumQueriesImpl {
|
|
|
28
30
|
readonly queryEthereumMaxPriorityFee: DeepReadonly<ObservableQueryEthereumMaxPriorityFee>;
|
|
29
31
|
readonly queryEthereumCoingeckoTokenInfo: DeepReadonly<ObservableQueryCoingeckoTokenInfo>;
|
|
30
32
|
readonly queryEthereumGasPrice: DeepReadonly<ObservableQueryEthereumGasPrice>;
|
|
31
|
-
constructor(base: QueriesSetBase, sharedContext: QuerySharedContext, chainId: string, chainGetter: ChainGetter, coingeckoAPIBaseURL: string, coingeckoAPIURI: string);
|
|
33
|
+
constructor(base: QueriesSetBase, sharedContext: QuerySharedContext, forceNativeERC20Query: (chainId: string, chainGetter: ChainGetter, address: string, minimalDenom: string) => boolean, chainId: string, chainGetter: ChainGetter, coingeckoAPIBaseURL: string, coingeckoAPIURI: string);
|
|
32
34
|
}
|
package/build/queries/index.js
CHANGED
|
@@ -15,19 +15,20 @@ exports.EthereumQueries = {
|
|
|
15
15
|
use(options) {
|
|
16
16
|
return (queriesSetBase, sharedContext, chainId, chainGetter) => {
|
|
17
17
|
return {
|
|
18
|
-
ethereum: new EthereumQueriesImpl(queriesSetBase, sharedContext, chainId, chainGetter, options.coingeckoAPIBaseURL, options.coingeckoAPIURI),
|
|
18
|
+
ethereum: new EthereumQueriesImpl(queriesSetBase, sharedContext, options.forceNativeERC20Query, chainId, chainGetter, options.coingeckoAPIBaseURL, options.coingeckoAPIURI),
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
class EthereumQueriesImpl {
|
|
24
|
-
constructor(base, sharedContext, chainId, chainGetter, coingeckoAPIBaseURL, coingeckoAPIURI) {
|
|
24
|
+
constructor(base, sharedContext, forceNativeERC20Query, chainId, chainGetter, coingeckoAPIBaseURL, coingeckoAPIURI) {
|
|
25
|
+
this.forceNativeERC20Query = forceNativeERC20Query;
|
|
25
26
|
this.chainId = chainId;
|
|
26
27
|
this.chainGetter = chainGetter;
|
|
27
28
|
this.coingeckoAPIBaseURL = coingeckoAPIBaseURL;
|
|
28
29
|
this.coingeckoAPIURI = coingeckoAPIURI;
|
|
29
30
|
base.queryBalances.addBalanceRegistry(new erc20_balance_1.ObservableQueryEthereumERC20BalanceRegistry(sharedContext));
|
|
30
|
-
base.queryBalances.addBalanceRegistry(new erc20_balances_1.ObservableQueryThirdpartyERC20BalanceRegistry(sharedContext));
|
|
31
|
+
base.queryBalances.addBalanceRegistry(new erc20_balances_1.ObservableQueryThirdpartyERC20BalanceRegistry(sharedContext, forceNativeERC20Query));
|
|
31
32
|
base.queryBalances.addBalanceRegistry(new balance_1.ObservableQueryEthAccountBalanceRegistry(sharedContext));
|
|
32
33
|
this.queryEthereumBlock = new block_1.ObservableQueryEthereumBlock(sharedContext, chainId, chainGetter);
|
|
33
34
|
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,uCA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;QACF,IAAI,CAAC,aAAa,CAAC,kBAAkB,CACnC,IAAI,kDAAwC,CAAC,aAAa,CAAC,CAC5D,CAAC;QAEF,IAAI,CAAC,kBAAkB,GAAG,IAAI,oCAA4B,CACxD,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,uBAAuB,GAAG,IAAI,+CAAiC,CAClE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,0BAA0B,GAAG,IAAI,qDAAoC,CACxE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,8BAA8B,GAAG,IAAI,sDAAgC,CACxE,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEF,IAAI,CAAC,2BAA2B;YAC9B,IAAI,wDAAqC,CACvC,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;QAEJ,IAAI,CAAC,+BAA+B;YAClC,IAAI,wDAAiC,CACnC,aAAa,EACb,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,eAAe,CAChB,CAAC;QAEJ,IAAI,CAAC,qBAAqB,GAAG,IAAI,2CAA+B,CAC9D,aAAa,EACb,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC;CACF;AAlFD,kDAkFC"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UnsignedTransaction } from "@ethersproject/transactions";
|
|
2
|
+
import { EvmGasSimulationOutcome } from "@keplr-wallet/types";
|
|
2
3
|
export type UnsignedEVMTransaction = UnsignedTransaction;
|
|
3
4
|
export type UnsignedEVMTransactionWithErc20Approvals = UnsignedEVMTransaction & {
|
|
4
5
|
requiredErc20Approvals?: {
|
|
@@ -7,3 +8,27 @@ export type UnsignedEVMTransactionWithErc20Approvals = UnsignedEVMTransaction &
|
|
|
7
8
|
tokenAddress: string;
|
|
8
9
|
}[];
|
|
9
10
|
};
|
|
11
|
+
export interface AccountState {
|
|
12
|
+
balance?: string;
|
|
13
|
+
code?: string;
|
|
14
|
+
nonce?: string;
|
|
15
|
+
storage?: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
export interface AccountStateDiffTracerResult {
|
|
18
|
+
pre: Record<string, AccountState>;
|
|
19
|
+
post: Record<string, AccountState>;
|
|
20
|
+
}
|
|
21
|
+
export interface SimulateGasWithPendingErc20ApprovalResult {
|
|
22
|
+
outcome: EvmGasSimulationOutcome;
|
|
23
|
+
gasUsed?: number;
|
|
24
|
+
erc20ApprovalGasUsed?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface StateOverrideAccountState {
|
|
27
|
+
balance?: string;
|
|
28
|
+
nonce?: string;
|
|
29
|
+
code?: string;
|
|
30
|
+
storage?: Record<string, string>;
|
|
31
|
+
state?: Record<string, string>;
|
|
32
|
+
stateDiff?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export type StateOverride = Record<string, StateOverrideAccountState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keplr-wallet/stores-eth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"author": "chainapsis",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@ethersproject/strings": "^5.7.0",
|
|
27
27
|
"@ethersproject/transactions": "^5.7.0",
|
|
28
28
|
"@ethersproject/units": "^5.7.0",
|
|
29
|
-
"@keplr-wallet/common": "0.
|
|
30
|
-
"@keplr-wallet/simple-fetch": "0.
|
|
31
|
-
"@keplr-wallet/stores": "0.
|
|
32
|
-
"@keplr-wallet/stores-etc": "0.
|
|
33
|
-
"@keplr-wallet/types": "0.
|
|
34
|
-
"@keplr-wallet/unit": "0.
|
|
29
|
+
"@keplr-wallet/common": "0.13.0",
|
|
30
|
+
"@keplr-wallet/simple-fetch": "0.13.0",
|
|
31
|
+
"@keplr-wallet/stores": "0.13.0",
|
|
32
|
+
"@keplr-wallet/stores-etc": "0.13.0",
|
|
33
|
+
"@keplr-wallet/types": "0.13.0",
|
|
34
|
+
"@keplr-wallet/unit": "0.13.0",
|
|
35
35
|
"big-integer": "^1.6.48",
|
|
36
36
|
"lodash.debounce": "^4.0.8",
|
|
37
37
|
"utility-types": "^3.10.0"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash.debounce": "^4"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "83c23d58e9ee42ed3b67c27033d1af11a7c575d7"
|
|
47
47
|
}
|
package/src/account/base.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { ChainGetter } from "@keplr-wallet/stores";
|
|
|
2
2
|
import {
|
|
3
3
|
AppCurrency,
|
|
4
4
|
ERC20Currency,
|
|
5
|
+
EvmGasSimulationOutcome,
|
|
5
6
|
EthSignType,
|
|
6
7
|
EthTxReceipt,
|
|
8
|
+
JsonRpcResponse,
|
|
7
9
|
Keplr,
|
|
8
10
|
} from "@keplr-wallet/types";
|
|
9
11
|
import { DenomHelper, retry } from "@keplr-wallet/common";
|
|
@@ -18,6 +20,13 @@ import {
|
|
|
18
20
|
import { getAddress as getEthAddress } from "@ethersproject/address";
|
|
19
21
|
import { action, makeObservable, observable } from "mobx";
|
|
20
22
|
import { Interface } from "@ethersproject/abi";
|
|
23
|
+
import {
|
|
24
|
+
AccountStateDiffTracerResult,
|
|
25
|
+
SimulateGasWithPendingErc20ApprovalResult,
|
|
26
|
+
StateOverride,
|
|
27
|
+
UnsignedEVMTransactionWithErc20Approvals,
|
|
28
|
+
} from "../types";
|
|
29
|
+
import { simpleFetch } from "@keplr-wallet/simple-fetch";
|
|
21
30
|
|
|
22
31
|
const opStackGasPriceOracleProxyAddress =
|
|
23
32
|
"0x420000000000000000000000000000000000000F";
|
|
@@ -32,6 +41,80 @@ const opStackGasPriceOracleABI = new Interface([
|
|
|
32
41
|
},
|
|
33
42
|
]);
|
|
34
43
|
|
|
44
|
+
async function traceCallWithDiff(
|
|
45
|
+
rpcUrl: string,
|
|
46
|
+
tx: { from: string; to: string; data: string; value?: string },
|
|
47
|
+
blockTag: string = "latest"
|
|
48
|
+
): Promise<AccountStateDiffTracerResult> {
|
|
49
|
+
const response = await simpleFetch<
|
|
50
|
+
JsonRpcResponse<AccountStateDiffTracerResult>
|
|
51
|
+
>(rpcUrl, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: { "Content-Type": "application/json" },
|
|
54
|
+
body: JSON.stringify({
|
|
55
|
+
jsonrpc: "2.0",
|
|
56
|
+
method: "debug_traceCall",
|
|
57
|
+
params: [
|
|
58
|
+
tx,
|
|
59
|
+
blockTag,
|
|
60
|
+
{
|
|
61
|
+
tracer: "prestateTracer",
|
|
62
|
+
tracerConfig: {
|
|
63
|
+
diffMode: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
id: 1,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const data = response.data;
|
|
72
|
+
|
|
73
|
+
if (data.error) {
|
|
74
|
+
throw new Error(data.error.message);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!data.result) {
|
|
78
|
+
throw new Error("Unknown error");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return data.result;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function diffResultToStateOverride(
|
|
85
|
+
diffResult: AccountStateDiffTracerResult,
|
|
86
|
+
allowedAddresses: string[],
|
|
87
|
+
useStateDiff: boolean = false
|
|
88
|
+
): StateOverride {
|
|
89
|
+
const override: StateOverride = {};
|
|
90
|
+
|
|
91
|
+
const allowed = new Set(allowedAddresses.map((addr) => addr.toLowerCase()));
|
|
92
|
+
|
|
93
|
+
for (const [address, state] of Object.entries(diffResult.post)) {
|
|
94
|
+
if (!allowed.has(address.toLowerCase())) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (state.storage && Object.keys(state.storage).length > 0) {
|
|
99
|
+
if (useStateDiff) {
|
|
100
|
+
// 개별 슬롯만 패치 (stateDiff)
|
|
101
|
+
override[address] = {
|
|
102
|
+
stateDiff: state.storage,
|
|
103
|
+
};
|
|
104
|
+
} else {
|
|
105
|
+
// 전체 스토리지 override (state)
|
|
106
|
+
// 시스템 컨트랙트의 전체 상태를 덮어쓰려고 하면 오류가 발생할 수 있다.
|
|
107
|
+
// 가능한 이 기능을 사용하지 않도록 하자.
|
|
108
|
+
override[address] = {
|
|
109
|
+
state: state.storage,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return override;
|
|
116
|
+
}
|
|
117
|
+
|
|
35
118
|
export class EthereumAccountBase {
|
|
36
119
|
@observable
|
|
37
120
|
protected _isSendingTx: boolean = false;
|
|
@@ -53,7 +136,11 @@ export class EthereumAccountBase {
|
|
|
53
136
|
return this._isSendingTx;
|
|
54
137
|
}
|
|
55
138
|
|
|
56
|
-
async simulateGas(
|
|
139
|
+
async simulateGas(
|
|
140
|
+
sender: string,
|
|
141
|
+
unsignedTx: UnsignedTransaction,
|
|
142
|
+
stateOverride?: StateOverride
|
|
143
|
+
) {
|
|
57
144
|
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
58
145
|
const evmInfo = chainInfo.evm;
|
|
59
146
|
if (!evmInfo) {
|
|
@@ -64,16 +151,23 @@ export class EthereumAccountBase {
|
|
|
64
151
|
|
|
65
152
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
66
153
|
const keplr = (await this.getKeplr())!;
|
|
154
|
+
|
|
155
|
+
const params: unknown[] = [
|
|
156
|
+
{
|
|
157
|
+
from: sender,
|
|
158
|
+
to,
|
|
159
|
+
value,
|
|
160
|
+
data,
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
if (stateOverride) {
|
|
165
|
+
params.push("latest", stateOverride);
|
|
166
|
+
}
|
|
167
|
+
|
|
67
168
|
const gasEstimated = await keplr.ethereum.request<string | undefined>({
|
|
68
169
|
method: "eth_estimateGas",
|
|
69
|
-
params
|
|
70
|
-
{
|
|
71
|
-
from: sender,
|
|
72
|
-
to,
|
|
73
|
-
value,
|
|
74
|
-
data,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
170
|
+
params,
|
|
77
171
|
chainId: this.chainId,
|
|
78
172
|
});
|
|
79
173
|
|
|
@@ -129,6 +223,101 @@ export class EthereumAccountBase {
|
|
|
129
223
|
return this.simulateGas(sender, unsignedTx);
|
|
130
224
|
}
|
|
131
225
|
|
|
226
|
+
async simulateGasWithPendingErc20Approval(
|
|
227
|
+
sender: string,
|
|
228
|
+
unsignedTx: UnsignedEVMTransactionWithErc20Approvals
|
|
229
|
+
): Promise<SimulateGasWithPendingErc20ApprovalResult> {
|
|
230
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
231
|
+
const evmInfo = chainInfo.evm;
|
|
232
|
+
if (!evmInfo) {
|
|
233
|
+
throw new Error("No EVM chain info provided");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const { to, value, data, requiredErc20Approvals } = unsignedTx;
|
|
237
|
+
|
|
238
|
+
const erc20ApprovalTxs = requiredErc20Approvals?.map((approval) => {
|
|
239
|
+
return {
|
|
240
|
+
to: approval.tokenAddress,
|
|
241
|
+
value: "0x0",
|
|
242
|
+
data: erc20ContractInterface.encodeFunctionData("approve", [
|
|
243
|
+
approval.spender,
|
|
244
|
+
hexValue(BigInt(approval.amount)),
|
|
245
|
+
]),
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
if (!erc20ApprovalTxs || erc20ApprovalTxs?.length === 0) {
|
|
250
|
+
const result = await this.simulateGas(sender, unsignedTx);
|
|
251
|
+
return {
|
|
252
|
+
outcome: EvmGasSimulationOutcome.TX_SIMULATED,
|
|
253
|
+
gasUsed: result.gasUsed,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (erc20ApprovalTxs.length > 1) {
|
|
258
|
+
throw new Error("Multiple ERC20 approvals are not supported");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const erc20Approval = requiredErc20Approvals?.[0];
|
|
262
|
+
if (!erc20Approval) {
|
|
263
|
+
throw new Error("Invalid ERC20 approval");
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const erc20ApprovalTx = erc20ApprovalTxs[0];
|
|
267
|
+
|
|
268
|
+
// First, estimate gas for the ERC20 approval tx itself.
|
|
269
|
+
// This result is reused whether the bundle simulation with state diff succeeds or falls back.
|
|
270
|
+
const erc20ApprovalSimResult = await this.simulateGas(
|
|
271
|
+
sender,
|
|
272
|
+
erc20ApprovalTx
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
try {
|
|
276
|
+
// State diff tracing for the ERC20 approval transaction
|
|
277
|
+
const approvalStateDiff = await traceCallWithDiff(chainInfo.rpc, {
|
|
278
|
+
from: sender,
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
280
|
+
to: erc20ApprovalTx.to!,
|
|
281
|
+
value: erc20ApprovalTx.value,
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
283
|
+
data: erc20ApprovalTx.data!,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// estimate gas with state override with approval state diff
|
|
287
|
+
const result = await this.simulateGas(
|
|
288
|
+
sender,
|
|
289
|
+
{
|
|
290
|
+
to,
|
|
291
|
+
value,
|
|
292
|
+
data,
|
|
293
|
+
},
|
|
294
|
+
diffResultToStateOverride(
|
|
295
|
+
approvalStateDiff,
|
|
296
|
+
[
|
|
297
|
+
sender,
|
|
298
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
299
|
+
erc20ApprovalTx.to!,
|
|
300
|
+
erc20Approval.spender,
|
|
301
|
+
],
|
|
302
|
+
true
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
outcome: EvmGasSimulationOutcome.TX_BUNDLE_SIMULATED,
|
|
308
|
+
gasUsed: result.gasUsed,
|
|
309
|
+
erc20ApprovalGasUsed: erc20ApprovalSimResult.gasUsed,
|
|
310
|
+
};
|
|
311
|
+
} catch (e) {
|
|
312
|
+
console.error("Failed to simulate gas with pending ERC20 approval", e);
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
outcome: EvmGasSimulationOutcome.APPROVAL_ONLY_SIMULATED,
|
|
316
|
+
erc20ApprovalGasUsed: erc20ApprovalSimResult.gasUsed,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
132
321
|
async simulateOpStackL1Fee(unsignedTx: UnsignedTransaction): Promise<string> {
|
|
133
322
|
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
134
323
|
if (!chainInfo.features.includes("op-stack-l1-data-fee")) {
|
|
@@ -160,6 +349,76 @@ export class EthereumAccountBase {
|
|
|
160
349
|
return l1Fee;
|
|
161
350
|
}
|
|
162
351
|
|
|
352
|
+
async simulateOpStackL1FeeWithPendingErc20Approval(
|
|
353
|
+
unsignedTx: UnsignedEVMTransactionWithErc20Approvals
|
|
354
|
+
): Promise<string> {
|
|
355
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
356
|
+
if (!chainInfo.features.includes("op-stack-l1-data-fee")) {
|
|
357
|
+
throw new Error("The chain isn't built with OP Stack");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const evmInfo = chainInfo.evm;
|
|
361
|
+
if (!evmInfo) {
|
|
362
|
+
throw new Error("No EVM chain info provided");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const txsToSimulate: UnsignedTransaction[] = [
|
|
366
|
+
{
|
|
367
|
+
to: unsignedTx.to,
|
|
368
|
+
gasLimit: unsignedTx.gasLimit,
|
|
369
|
+
value: unsignedTx.value,
|
|
370
|
+
data: unsignedTx.data,
|
|
371
|
+
chainId: unsignedTx.chainId,
|
|
372
|
+
},
|
|
373
|
+
];
|
|
374
|
+
|
|
375
|
+
// If there's a pending ERC20 approval, add it to the batch
|
|
376
|
+
const erc20Approval = unsignedTx.requiredErc20Approvals?.[0];
|
|
377
|
+
if (erc20Approval != null) {
|
|
378
|
+
txsToSimulate.push({
|
|
379
|
+
to: erc20Approval.tokenAddress,
|
|
380
|
+
data: erc20ContractInterface.encodeFunctionData("approve", [
|
|
381
|
+
erc20Approval.spender,
|
|
382
|
+
hexValue(BigInt(erc20Approval.amount)),
|
|
383
|
+
]),
|
|
384
|
+
chainId: unsignedTx.chainId,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const batchRequests = txsToSimulate.map((tx, index) => ({
|
|
389
|
+
jsonrpc: "2.0" as const,
|
|
390
|
+
method: "eth_call",
|
|
391
|
+
params: [
|
|
392
|
+
{
|
|
393
|
+
to: opStackGasPriceOracleProxyAddress,
|
|
394
|
+
data: opStackGasPriceOracleABI.encodeFunctionData("getL1Fee", [
|
|
395
|
+
serialize(tx),
|
|
396
|
+
]),
|
|
397
|
+
},
|
|
398
|
+
"latest",
|
|
399
|
+
],
|
|
400
|
+
id: index + 1,
|
|
401
|
+
}));
|
|
402
|
+
|
|
403
|
+
const response = await simpleFetch<JsonRpcResponse<string>[]>(evmInfo.rpc, {
|
|
404
|
+
method: "POST",
|
|
405
|
+
headers: { "Content-Type": "application/json" },
|
|
406
|
+
body: JSON.stringify(batchRequests),
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
let totalL1Fee = BigInt(0);
|
|
410
|
+
for (const result of response.data) {
|
|
411
|
+
if (result.error) {
|
|
412
|
+
throw new Error(result.error.message);
|
|
413
|
+
}
|
|
414
|
+
if (result.result) {
|
|
415
|
+
totalL1Fee += BigInt(result.result);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return "0x" + totalL1Fee.toString(16);
|
|
420
|
+
}
|
|
421
|
+
|
|
163
422
|
makeSendTokenTx({
|
|
164
423
|
currency,
|
|
165
424
|
amount,
|
|
@@ -249,6 +508,64 @@ export class EthereumAccountBase {
|
|
|
249
508
|
};
|
|
250
509
|
}
|
|
251
510
|
|
|
511
|
+
/**
|
|
512
|
+
* Sign an Ethereum transaction.
|
|
513
|
+
* @param sender - The sender address.
|
|
514
|
+
* @param unsignedTx - The unsigned transaction to sign.
|
|
515
|
+
* @param options - The options for the transaction.
|
|
516
|
+
* @returns The signed transaction in serialized format.
|
|
517
|
+
*/
|
|
518
|
+
async signEthereumTx(
|
|
519
|
+
sender: string,
|
|
520
|
+
unsignedTx: UnsignedEVMTransactionWithErc20Approvals,
|
|
521
|
+
options?: {
|
|
522
|
+
nonceMethod?: "pending" | "latest";
|
|
523
|
+
// Whether to offset nonce by the number of required ERC20 approvals
|
|
524
|
+
considerRequiredErc20ApprovalsForNonce?: boolean;
|
|
525
|
+
}
|
|
526
|
+
) {
|
|
527
|
+
const chainInfo = this.chainGetter.getChain(this.chainId);
|
|
528
|
+
const evmInfo = chainInfo.evm;
|
|
529
|
+
if (!evmInfo) {
|
|
530
|
+
throw new Error("No EVM info provided");
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
534
|
+
const keplr = (await this.getKeplr())!;
|
|
535
|
+
|
|
536
|
+
const transactionCount = await keplr.ethereum.request<string>({
|
|
537
|
+
method: "eth_getTransactionCount",
|
|
538
|
+
params: [sender, options?.nonceMethod || "pending"],
|
|
539
|
+
chainId: this.chainId,
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
unsignedTx = {
|
|
543
|
+
...unsignedTx,
|
|
544
|
+
nonce:
|
|
545
|
+
parseInt(transactionCount) +
|
|
546
|
+
(options?.considerRequiredErc20ApprovalsForNonce
|
|
547
|
+
? unsignedTx.requiredErc20Approvals?.length ?? 0
|
|
548
|
+
: 0),
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const signEthereum = keplr.signEthereum.bind(keplr);
|
|
552
|
+
|
|
553
|
+
const signature = await signEthereum(
|
|
554
|
+
this.chainId,
|
|
555
|
+
sender,
|
|
556
|
+
JSON.stringify(unsignedTx),
|
|
557
|
+
EthSignType.TRANSACTION
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
const isEIP1559 =
|
|
561
|
+
!!unsignedTx.maxFeePerGas || !!unsignedTx.maxPriorityFeePerGas;
|
|
562
|
+
if (isEIP1559) {
|
|
563
|
+
unsignedTx.type = TransactionTypes.eip1559;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return serialize(unsignedTx, signature);
|
|
567
|
+
}
|
|
568
|
+
|
|
252
569
|
async sendEthereumTx(
|
|
253
570
|
sender: string,
|
|
254
571
|
unsignedTx: UnsignedTransaction,
|
|
@@ -199,7 +199,15 @@ export class ObservableQueryThirdpartyERC20BalanceRegistry
|
|
|
199
199
|
ObservableQueryThirdpartyERC20BalancesImplParent
|
|
200
200
|
> = new Map();
|
|
201
201
|
|
|
202
|
-
constructor(
|
|
202
|
+
constructor(
|
|
203
|
+
protected readonly sharedContext: QuerySharedContext,
|
|
204
|
+
protected readonly forceNativeERC20Query: (
|
|
205
|
+
chainId: string,
|
|
206
|
+
chainGetter: ChainGetter,
|
|
207
|
+
address: string,
|
|
208
|
+
minimalDenom: string
|
|
209
|
+
) => boolean
|
|
210
|
+
) {}
|
|
203
211
|
|
|
204
212
|
getBalanceImpl(
|
|
205
213
|
chainId: string,
|
|
@@ -215,7 +223,8 @@ export class ObservableQueryThirdpartyERC20BalanceRegistry
|
|
|
215
223
|
!Object.keys(thirdparySupportedChainIdMap).includes(chainId) ||
|
|
216
224
|
denomHelper.type !== "erc20" ||
|
|
217
225
|
!isHexAddress ||
|
|
218
|
-
!chainInfo.evm
|
|
226
|
+
!chainInfo.evm ||
|
|
227
|
+
this.forceNativeERC20Query(chainId, chainGetter, address, minimalDenom)
|
|
219
228
|
) {
|
|
220
229
|
return;
|
|
221
230
|
}
|
package/src/queries/index.ts
CHANGED
|
@@ -23,6 +23,12 @@ export const EthereumQueries = {
|
|
|
23
23
|
use(options: {
|
|
24
24
|
coingeckoAPIBaseURL: string;
|
|
25
25
|
coingeckoAPIURI: string;
|
|
26
|
+
forceNativeERC20Query: (
|
|
27
|
+
chainId: string,
|
|
28
|
+
chainGetter: ChainGetter,
|
|
29
|
+
address: string,
|
|
30
|
+
minimalDenom: string
|
|
31
|
+
) => boolean;
|
|
26
32
|
}): (
|
|
27
33
|
queriesSetBase: QueriesSetBase,
|
|
28
34
|
sharedContext: QuerySharedContext,
|
|
@@ -39,6 +45,7 @@ export const EthereumQueries = {
|
|
|
39
45
|
ethereum: new EthereumQueriesImpl(
|
|
40
46
|
queriesSetBase,
|
|
41
47
|
sharedContext,
|
|
48
|
+
options.forceNativeERC20Query,
|
|
42
49
|
chainId,
|
|
43
50
|
chainGetter,
|
|
44
51
|
options.coingeckoAPIBaseURL,
|
|
@@ -61,6 +68,12 @@ export class EthereumQueriesImpl {
|
|
|
61
68
|
constructor(
|
|
62
69
|
base: QueriesSetBase,
|
|
63
70
|
sharedContext: QuerySharedContext,
|
|
71
|
+
protected readonly forceNativeERC20Query: (
|
|
72
|
+
chainId: string,
|
|
73
|
+
chainGetter: ChainGetter,
|
|
74
|
+
address: string,
|
|
75
|
+
minimalDenom: string
|
|
76
|
+
) => boolean,
|
|
64
77
|
protected chainId: string,
|
|
65
78
|
protected chainGetter: ChainGetter,
|
|
66
79
|
protected coingeckoAPIBaseURL: string,
|
|
@@ -70,7 +83,10 @@ export class EthereumQueriesImpl {
|
|
|
70
83
|
new ObservableQueryEthereumERC20BalanceRegistry(sharedContext)
|
|
71
84
|
);
|
|
72
85
|
base.queryBalances.addBalanceRegistry(
|
|
73
|
-
new ObservableQueryThirdpartyERC20BalanceRegistry(
|
|
86
|
+
new ObservableQueryThirdpartyERC20BalanceRegistry(
|
|
87
|
+
sharedContext,
|
|
88
|
+
forceNativeERC20Query
|
|
89
|
+
)
|
|
74
90
|
);
|
|
75
91
|
base.queryBalances.addBalanceRegistry(
|
|
76
92
|
new ObservableQueryEthAccountBalanceRegistry(sharedContext)
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UnsignedTransaction } from "@ethersproject/transactions";
|
|
2
|
+
import { EvmGasSimulationOutcome } from "@keplr-wallet/types";
|
|
2
3
|
|
|
3
4
|
export type UnsignedEVMTransaction = UnsignedTransaction;
|
|
4
5
|
|
|
@@ -10,3 +11,32 @@ export type UnsignedEVMTransactionWithErc20Approvals =
|
|
|
10
11
|
tokenAddress: string;
|
|
11
12
|
}[];
|
|
12
13
|
};
|
|
14
|
+
|
|
15
|
+
export interface AccountState {
|
|
16
|
+
balance?: string;
|
|
17
|
+
code?: string;
|
|
18
|
+
nonce?: string;
|
|
19
|
+
storage?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AccountStateDiffTracerResult {
|
|
23
|
+
pre: Record<string, AccountState>;
|
|
24
|
+
post: Record<string, AccountState>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SimulateGasWithPendingErc20ApprovalResult {
|
|
28
|
+
outcome: EvmGasSimulationOutcome;
|
|
29
|
+
gasUsed?: number;
|
|
30
|
+
erc20ApprovalGasUsed?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface StateOverrideAccountState {
|
|
34
|
+
balance?: string;
|
|
35
|
+
nonce?: string; // hex string for stateOverride
|
|
36
|
+
code?: string;
|
|
37
|
+
storage?: Record<string, string>;
|
|
38
|
+
state?: Record<string, string>;
|
|
39
|
+
stateDiff?: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type StateOverride = Record<string, StateOverrideAccountState>;
|