viem 0.0.1-alpha.12 → 0.0.1-alpha.14
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/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.js +7 -3
- package/dist/actions/index.mjs +6 -2
- package/dist/chains.js +5 -5
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-PC3JNTPF.mjs → chunk-5TCPFLFT.mjs} +1 -1
- package/dist/{chunk-A3PVAH22.js → chunk-6Z62LPKB.js} +25 -10
- package/dist/{chunk-DPSKYDCG.mjs → chunk-DUNJAMH5.mjs} +172 -141
- package/dist/{chunk-A4O3JKF2.js → chunk-E7IQYTLV.js} +11 -11
- package/dist/{chunk-ERPD74AT.mjs → chunk-KB6CBNKW.mjs} +16 -1
- package/dist/{chunk-QO5C5Y2L.js → chunk-VUNR7KGG.js} +224 -193
- package/dist/clients/index.js +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -4
- package/dist/index.mjs +7 -3
- package/dist/{parseGwei-7c87ff41.d.ts → parseGwei-21f98a29.d.ts} +1 -1
- package/dist/{watchAsset-43255bfd.d.ts → stopImpersonatingAccount-fcc5a678.d.ts} +63 -44
- package/dist/{transactionRequest-08d30731.d.ts → transactionRequest-1d4e4385.d.ts} +1 -1
- package/dist/utils/index.d.ts +12 -5
- package/dist/utils/index.js +4 -2
- package/dist/utils/index.mjs +3 -1
- package/package.json +1 -1
@@ -23,7 +23,9 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
|
26
|
-
|
26
|
+
|
27
|
+
|
28
|
+
var _chunk6Z62LPKBjs = require('./chunk-6Z62LPKB.js');
|
27
29
|
|
28
30
|
// src/actions/public/call.ts
|
29
31
|
async function call(client, {
|
@@ -43,9 +45,10 @@ async function call(client, {
|
|
43
45
|
...rest
|
44
46
|
}) {
|
45
47
|
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
46
|
-
throw new (0,
|
47
|
-
const blockNumberHex = blockNumber ?
|
48
|
-
const
|
48
|
+
throw new (0, _chunk6Z62LPKBjs.InvalidGasArgumentsError)();
|
49
|
+
const blockNumberHex = blockNumber ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
50
|
+
const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
|
51
|
+
const request_ = _chunk6Z62LPKBjs.format.call(void 0,
|
49
52
|
{
|
50
53
|
from,
|
51
54
|
accessList,
|
@@ -57,10 +60,10 @@ async function call(client, {
|
|
57
60
|
nonce,
|
58
61
|
to,
|
59
62
|
value,
|
60
|
-
...rest
|
63
|
+
..._chunk6Z62LPKBjs.extract.call(void 0, rest, { formatter })
|
61
64
|
},
|
62
65
|
{
|
63
|
-
formatter:
|
66
|
+
formatter: formatter || _chunk6Z62LPKBjs.formatTransactionRequest
|
64
67
|
}
|
65
68
|
);
|
66
69
|
const response = await client.request({
|
@@ -80,7 +83,7 @@ async function callContract(client, {
|
|
80
83
|
functionName,
|
81
84
|
...callRequest
|
82
85
|
}) {
|
83
|
-
const calldata =
|
86
|
+
const calldata = _chunk6Z62LPKBjs.encodeFunctionData.call(void 0, {
|
84
87
|
abi,
|
85
88
|
args,
|
86
89
|
functionName
|
@@ -91,13 +94,13 @@ async function callContract(client, {
|
|
91
94
|
to: address,
|
92
95
|
...callRequest
|
93
96
|
});
|
94
|
-
return
|
97
|
+
return _chunk6Z62LPKBjs.decodeFunctionResult.call(void 0, {
|
95
98
|
abi,
|
96
99
|
functionName,
|
97
100
|
data: data || "0x"
|
98
101
|
});
|
99
102
|
} catch (err) {
|
100
|
-
throw
|
103
|
+
throw _chunk6Z62LPKBjs.getContractError.call(void 0, err, {
|
101
104
|
abi,
|
102
105
|
address,
|
103
106
|
args,
|
@@ -123,6 +126,148 @@ async function createBlockFilter(client) {
|
|
123
126
|
return { id, type: "block" };
|
124
127
|
}
|
125
128
|
|
129
|
+
// src/actions/wallet/addChain.ts
|
130
|
+
async function addChain(client, chain) {
|
131
|
+
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
132
|
+
await client.request({
|
133
|
+
method: "wallet_addEthereumChain",
|
134
|
+
params: [
|
135
|
+
{
|
136
|
+
chainId: _chunk6Z62LPKBjs.numberToHex.call(void 0, id),
|
137
|
+
chainName: name,
|
138
|
+
nativeCurrency,
|
139
|
+
rpcUrls: rpcUrls.default.http,
|
140
|
+
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
141
|
+
}
|
142
|
+
]
|
143
|
+
});
|
144
|
+
}
|
145
|
+
|
146
|
+
// src/actions/wallet/getAccounts.ts
|
147
|
+
async function getAccounts(client) {
|
148
|
+
const addresses = await client.request({ method: "eth_accounts" });
|
149
|
+
return addresses.map((address) => _chunk6Z62LPKBjs.checksumAddress.call(void 0, address));
|
150
|
+
}
|
151
|
+
|
152
|
+
// src/actions/wallet/getPermissions.ts
|
153
|
+
async function getPermissions(client) {
|
154
|
+
const permissions = await client.request({ method: "wallet_getPermissions" });
|
155
|
+
return permissions;
|
156
|
+
}
|
157
|
+
|
158
|
+
// src/actions/wallet/requestAccounts.ts
|
159
|
+
async function requestAccounts(client) {
|
160
|
+
const addresses = await client.request({ method: "eth_requestAccounts" });
|
161
|
+
return addresses.map((address) => _chunk6Z62LPKBjs.getAddress.call(void 0, address));
|
162
|
+
}
|
163
|
+
|
164
|
+
// src/actions/wallet/requestPermissions.ts
|
165
|
+
async function requestPermissions(client, permissions) {
|
166
|
+
return client.request({
|
167
|
+
method: "wallet_requestPermissions",
|
168
|
+
params: [permissions]
|
169
|
+
});
|
170
|
+
}
|
171
|
+
|
172
|
+
// src/actions/wallet/sendTransaction.ts
|
173
|
+
async function sendTransaction(client, {
|
174
|
+
chain,
|
175
|
+
from,
|
176
|
+
accessList,
|
177
|
+
data,
|
178
|
+
gas,
|
179
|
+
gasPrice,
|
180
|
+
maxFeePerGas,
|
181
|
+
maxPriorityFeePerGas,
|
182
|
+
nonce,
|
183
|
+
to,
|
184
|
+
value,
|
185
|
+
...rest
|
186
|
+
}) {
|
187
|
+
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
188
|
+
throw new (0, _chunk6Z62LPKBjs.InvalidGasArgumentsError)();
|
189
|
+
const formatter = _optionalChain([chain, 'optionalAccess', _3 => _3.formatters, 'optionalAccess', _4 => _4.transactionRequest]);
|
190
|
+
const request_ = _chunk6Z62LPKBjs.format.call(void 0,
|
191
|
+
{
|
192
|
+
from,
|
193
|
+
accessList,
|
194
|
+
data,
|
195
|
+
gas,
|
196
|
+
gasPrice,
|
197
|
+
maxFeePerGas,
|
198
|
+
maxPriorityFeePerGas,
|
199
|
+
nonce,
|
200
|
+
to,
|
201
|
+
value,
|
202
|
+
..._chunk6Z62LPKBjs.extract.call(void 0, rest, { formatter })
|
203
|
+
},
|
204
|
+
{
|
205
|
+
formatter: formatter || _chunk6Z62LPKBjs.formatTransactionRequest
|
206
|
+
}
|
207
|
+
);
|
208
|
+
const hash = await client.request({
|
209
|
+
method: "eth_sendTransaction",
|
210
|
+
params: [request_]
|
211
|
+
});
|
212
|
+
return hash;
|
213
|
+
}
|
214
|
+
|
215
|
+
// src/actions/wallet/signMessage.ts
|
216
|
+
async function signMessage(client, { from, data: data_ }) {
|
217
|
+
let data;
|
218
|
+
if (typeof data_ === "string") {
|
219
|
+
if (!data_.startsWith("0x"))
|
220
|
+
throw new (0, _chunk6Z62LPKBjs.BaseError)(
|
221
|
+
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
222
|
+
{
|
223
|
+
docsPath: "/TODO"
|
224
|
+
}
|
225
|
+
);
|
226
|
+
data = data_;
|
227
|
+
} else {
|
228
|
+
data = _chunk6Z62LPKBjs.encodeHex.call(void 0, data_);
|
229
|
+
}
|
230
|
+
const signed = await client.request({
|
231
|
+
method: "personal_sign",
|
232
|
+
params: [data, from]
|
233
|
+
});
|
234
|
+
return signed;
|
235
|
+
}
|
236
|
+
|
237
|
+
// src/actions/wallet/switchChain.ts
|
238
|
+
async function switchChain(client, { id }) {
|
239
|
+
await client.request({
|
240
|
+
method: "wallet_switchEthereumChain",
|
241
|
+
params: [
|
242
|
+
{
|
243
|
+
chainId: _chunk6Z62LPKBjs.numberToHex.call(void 0, id)
|
244
|
+
}
|
245
|
+
]
|
246
|
+
});
|
247
|
+
}
|
248
|
+
|
249
|
+
// src/actions/wallet/watchAsset.ts
|
250
|
+
async function watchAsset(client, params) {
|
251
|
+
const added = await client.request({
|
252
|
+
method: "wallet_watchAsset",
|
253
|
+
params: [params]
|
254
|
+
});
|
255
|
+
return added;
|
256
|
+
}
|
257
|
+
|
258
|
+
// src/actions/public/deployContract.ts
|
259
|
+
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
260
|
+
const calldata = _chunk6Z62LPKBjs.encodeDeployData.call(void 0, {
|
261
|
+
abi,
|
262
|
+
args,
|
263
|
+
bytecode
|
264
|
+
});
|
265
|
+
return sendTransaction(walletClient, {
|
266
|
+
...request,
|
267
|
+
data: calldata
|
268
|
+
});
|
269
|
+
}
|
270
|
+
|
126
271
|
// src/actions/public/estimateGas.ts
|
127
272
|
async function estimateGas(client, {
|
128
273
|
blockNumber,
|
@@ -136,16 +281,16 @@ async function estimateGas(client, {
|
|
136
281
|
to,
|
137
282
|
value
|
138
283
|
}) {
|
139
|
-
const blockNumberHex = blockNumber ?
|
284
|
+
const blockNumberHex = blockNumber ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
140
285
|
const parameters = {
|
141
286
|
data,
|
142
287
|
from,
|
143
|
-
gas: gas ?
|
144
|
-
gasPrice: gasPrice ?
|
145
|
-
maxFeePerGas: maxFeePerGas ?
|
146
|
-
maxPriorityFeePerGas: maxPriorityFeePerGas ?
|
288
|
+
gas: gas ? _chunk6Z62LPKBjs.numberToHex.call(void 0, gas) : void 0,
|
289
|
+
gasPrice: gasPrice ? _chunk6Z62LPKBjs.numberToHex.call(void 0, gasPrice) : void 0,
|
290
|
+
maxFeePerGas: maxFeePerGas ? _chunk6Z62LPKBjs.numberToHex.call(void 0, maxFeePerGas) : void 0,
|
291
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas ? _chunk6Z62LPKBjs.numberToHex.call(void 0, maxPriorityFeePerGas) : void 0,
|
147
292
|
to,
|
148
|
-
value: value ?
|
293
|
+
value: value ? _chunk6Z62LPKBjs.numberToHex.call(void 0, value) : void 0
|
149
294
|
};
|
150
295
|
const balance = await client.request({
|
151
296
|
method: "eth_estimateGas",
|
@@ -156,7 +301,7 @@ async function estimateGas(client, {
|
|
156
301
|
|
157
302
|
// src/actions/public/getBalance.ts
|
158
303
|
async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
|
159
|
-
const blockNumberHex = blockNumber ?
|
304
|
+
const blockNumberHex = blockNumber ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
160
305
|
const balance = await client.request({
|
161
306
|
method: "eth_getBalance",
|
162
307
|
params: [address, blockNumberHex || blockTag]
|
@@ -171,7 +316,7 @@ async function getBlock(client, {
|
|
171
316
|
blockTag = "latest",
|
172
317
|
includeTransactions = false
|
173
318
|
} = {}) {
|
174
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
319
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
175
320
|
let block = null;
|
176
321
|
if (blockHash) {
|
177
322
|
block = await client.request({
|
@@ -185,19 +330,19 @@ async function getBlock(client, {
|
|
185
330
|
});
|
186
331
|
}
|
187
332
|
if (!block)
|
188
|
-
throw new (0,
|
189
|
-
return
|
190
|
-
formatter: _optionalChain([client, 'access',
|
333
|
+
throw new (0, _chunk6Z62LPKBjs.BlockNotFoundError)({ blockHash, blockNumber });
|
334
|
+
return _chunk6Z62LPKBjs.format.call(void 0, block, {
|
335
|
+
formatter: _optionalChain([client, 'access', _5 => _5.chain, 'optionalAccess', _6 => _6.formatters, 'optionalAccess', _7 => _7.block]) || _chunk6Z62LPKBjs.formatBlock
|
191
336
|
});
|
192
337
|
}
|
193
338
|
|
194
339
|
// src/actions/public/getBlockNumber.ts
|
195
340
|
var cacheKey = (id) => `blockNumber.${id}`;
|
196
341
|
function getBlockNumberCache(id) {
|
197
|
-
return
|
342
|
+
return _chunk6Z62LPKBjs.getCache.call(void 0, cacheKey(id));
|
198
343
|
}
|
199
344
|
async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
|
200
|
-
const blockNumberHex = await
|
345
|
+
const blockNumberHex = await _chunk6Z62LPKBjs.withCache.call(void 0,
|
201
346
|
() => client.request({
|
202
347
|
method: "eth_blockNumber"
|
203
348
|
}),
|
@@ -212,7 +357,7 @@ async function getBlockTransactionCount(client, {
|
|
212
357
|
blockNumber,
|
213
358
|
blockTag = "latest"
|
214
359
|
} = {}) {
|
215
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
360
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
216
361
|
let count = null;
|
217
362
|
if (blockHash) {
|
218
363
|
count = await client.request({
|
@@ -225,13 +370,25 @@ async function getBlockTransactionCount(client, {
|
|
225
370
|
params: [blockNumberHex || blockTag]
|
226
371
|
});
|
227
372
|
}
|
228
|
-
return
|
373
|
+
return _chunk6Z62LPKBjs.hexToNumber.call(void 0, count);
|
374
|
+
}
|
375
|
+
|
376
|
+
// src/actions/public/getBytecode.ts
|
377
|
+
async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
|
378
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
379
|
+
const hex = await client.request({
|
380
|
+
method: "eth_getCode",
|
381
|
+
params: [address, blockNumberHex || blockTag]
|
382
|
+
});
|
383
|
+
if (hex === "0x")
|
384
|
+
return void 0;
|
385
|
+
return hex;
|
229
386
|
}
|
230
387
|
|
231
388
|
// src/actions/public/getChainId.ts
|
232
389
|
async function getChainId(client) {
|
233
390
|
const chainIdHex = await client.request({ method: "eth_chainId" });
|
234
|
-
return
|
391
|
+
return _chunk6Z62LPKBjs.hexToNumber.call(void 0, chainIdHex);
|
235
392
|
}
|
236
393
|
|
237
394
|
// src/actions/public/getFeeHistory.ts
|
@@ -241,16 +398,16 @@ async function getFeeHistory(client, {
|
|
241
398
|
blockTag = "latest",
|
242
399
|
rewardPercentiles
|
243
400
|
}) {
|
244
|
-
const blockNumberHex = blockNumber ?
|
401
|
+
const blockNumberHex = blockNumber ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
245
402
|
const feeHistory = await client.request({
|
246
403
|
method: "eth_feeHistory",
|
247
404
|
params: [
|
248
|
-
|
405
|
+
_chunk6Z62LPKBjs.numberToHex.call(void 0, blockCount),
|
249
406
|
blockNumberHex || blockTag,
|
250
407
|
rewardPercentiles
|
251
408
|
]
|
252
409
|
});
|
253
|
-
return
|
410
|
+
return _chunk6Z62LPKBjs.formatFeeHistory.call(void 0, feeHistory);
|
254
411
|
}
|
255
412
|
|
256
413
|
// src/actions/public/getFilterChanges.ts
|
@@ -260,7 +417,7 @@ async function getFilterChanges(client, { filter }) {
|
|
260
417
|
params: [filter.id]
|
261
418
|
});
|
262
419
|
return logs.map(
|
263
|
-
(log) => typeof log === "string" ? log :
|
420
|
+
(log) => typeof log === "string" ? log : _chunk6Z62LPKBjs.formatLog.call(void 0, log)
|
264
421
|
);
|
265
422
|
}
|
266
423
|
|
@@ -270,7 +427,7 @@ async function getFilterLogs(client, { filter }) {
|
|
270
427
|
method: "eth_getFilterLogs",
|
271
428
|
params: [filter.id]
|
272
429
|
});
|
273
|
-
return logs.map(
|
430
|
+
return logs.map(_chunk6Z62LPKBjs.formatLog);
|
274
431
|
}
|
275
432
|
|
276
433
|
// src/actions/public/getGasPrice.ts
|
@@ -289,7 +446,7 @@ async function getTransaction(client, {
|
|
289
446
|
hash,
|
290
447
|
index
|
291
448
|
}) {
|
292
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
449
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : void 0;
|
293
450
|
let transaction = null;
|
294
451
|
if (hash) {
|
295
452
|
transaction = await client.request({
|
@@ -299,24 +456,24 @@ async function getTransaction(client, {
|
|
299
456
|
} else if (blockHash) {
|
300
457
|
transaction = await client.request({
|
301
458
|
method: "eth_getTransactionByBlockHashAndIndex",
|
302
|
-
params: [blockHash,
|
459
|
+
params: [blockHash, _chunk6Z62LPKBjs.numberToHex.call(void 0, index)]
|
303
460
|
});
|
304
461
|
} else if (blockNumberHex || blockTag) {
|
305
462
|
transaction = await client.request({
|
306
463
|
method: "eth_getTransactionByBlockNumberAndIndex",
|
307
|
-
params: [blockNumberHex || blockTag,
|
464
|
+
params: [blockNumberHex || blockTag, _chunk6Z62LPKBjs.numberToHex.call(void 0, index)]
|
308
465
|
});
|
309
466
|
}
|
310
467
|
if (!transaction)
|
311
|
-
throw new (0,
|
468
|
+
throw new (0, _chunk6Z62LPKBjs.TransactionNotFoundError)({
|
312
469
|
blockHash,
|
313
470
|
blockNumber,
|
314
471
|
blockTag,
|
315
472
|
hash,
|
316
473
|
index
|
317
474
|
});
|
318
|
-
return
|
319
|
-
formatter: _optionalChain([client, 'access',
|
475
|
+
return _chunk6Z62LPKBjs.format.call(void 0, transaction, {
|
476
|
+
formatter: _optionalChain([client, 'access', _8 => _8.chain, 'optionalAccess', _9 => _9.formatters, 'optionalAccess', _10 => _10.transaction]) || _chunk6Z62LPKBjs.formatTransaction
|
320
477
|
});
|
321
478
|
}
|
322
479
|
|
@@ -326,7 +483,7 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
|
|
326
483
|
getBlockNumber(client),
|
327
484
|
hash ? getTransaction(client, { hash }) : void 0
|
328
485
|
]);
|
329
|
-
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess',
|
486
|
+
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess', _11 => _11.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _12 => _12.blockNumber]);
|
330
487
|
if (!transactionBlockNumber)
|
331
488
|
return 0n;
|
332
489
|
return blockNumber - transactionBlockNumber + 1n;
|
@@ -336,9 +493,9 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
|
|
336
493
|
async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
|
337
494
|
const count = await client.request({
|
338
495
|
method: "eth_getTransactionCount",
|
339
|
-
params: [address, blockNumber ?
|
496
|
+
params: [address, blockNumber ? _chunk6Z62LPKBjs.numberToHex.call(void 0, blockNumber) : blockTag]
|
340
497
|
});
|
341
|
-
return
|
498
|
+
return _chunk6Z62LPKBjs.hexToNumber.call(void 0, count);
|
342
499
|
}
|
343
500
|
|
344
501
|
// src/actions/public/getTransactionReceipt.ts
|
@@ -348,9 +505,9 @@ async function getTransactionReceipt(client, { hash }) {
|
|
348
505
|
params: [hash]
|
349
506
|
});
|
350
507
|
if (!receipt)
|
351
|
-
throw new (0,
|
352
|
-
return
|
353
|
-
formatter: _optionalChain([client, 'access',
|
508
|
+
throw new (0, _chunk6Z62LPKBjs.TransactionReceiptNotFoundError)({ hash });
|
509
|
+
return _chunk6Z62LPKBjs.format.call(void 0, receipt, {
|
510
|
+
formatter: _optionalChain([client, 'access', _13 => _13.chain, 'optionalAccess', _14 => _14.formatters, 'optionalAccess', _15 => _15.transactionReceipt]) || _chunk6Z62LPKBjs.formatTransactionReceipt
|
354
511
|
});
|
355
512
|
}
|
356
513
|
|
@@ -395,7 +552,7 @@ function observe(observerId, callbacks, fn) {
|
|
395
552
|
const listeners2 = getListeners();
|
396
553
|
if (listeners2.length === 0)
|
397
554
|
return;
|
398
|
-
listeners2.forEach((listener) => _optionalChain([listener, 'access',
|
555
|
+
listeners2.forEach((listener) => _optionalChain([listener, 'access', _16 => _16.fns, 'access', _17 => _17[key], 'optionalCall', _18 => _18(...args)]));
|
399
556
|
};
|
400
557
|
}
|
401
558
|
const cleanup = fn(emit);
|
@@ -423,7 +580,7 @@ async function waitForTransactionReceipt(client, {
|
|
423
580
|
return new Promise((resolve, reject) => {
|
424
581
|
if (timeout)
|
425
582
|
setTimeout(
|
426
|
-
() => reject(new (0,
|
583
|
+
() => reject(new (0, _chunk6Z62LPKBjs.WaitForTransactionReceiptTimeoutError)({ hash })),
|
427
584
|
timeout
|
428
585
|
);
|
429
586
|
const unobserve = observe(
|
@@ -453,7 +610,7 @@ async function waitForTransactionReceipt(client, {
|
|
453
610
|
return;
|
454
611
|
done(() => emit.resolve(receipt));
|
455
612
|
} catch (err) {
|
456
|
-
if (transaction && (err instanceof
|
613
|
+
if (transaction && (err instanceof _chunk6Z62LPKBjs.TransactionNotFoundError || err instanceof _chunk6Z62LPKBjs.TransactionReceiptNotFoundError)) {
|
457
614
|
replacedTransaction = transaction;
|
458
615
|
const block = await getBlock(client, {
|
459
616
|
blockNumber,
|
@@ -476,7 +633,7 @@ async function waitForTransactionReceipt(client, {
|
|
476
633
|
reason = "cancelled";
|
477
634
|
}
|
478
635
|
done(() => {
|
479
|
-
_optionalChain([emit, 'access',
|
636
|
+
_optionalChain([emit, 'access', _19 => _19.onReplaced, 'optionalCall', _20 => _20({
|
480
637
|
reason,
|
481
638
|
replacedTransaction,
|
482
639
|
transaction: replacementTransaction,
|
@@ -504,13 +661,13 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
504
661
|
let data;
|
505
662
|
if (emitOnBegin)
|
506
663
|
data = await fn({ unpoll: unwatch });
|
507
|
-
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall',
|
508
|
-
await
|
664
|
+
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _21 => _21(data)]), async () => ( interval));
|
665
|
+
await _chunk6Z62LPKBjs.wait.call(void 0, initialWait);
|
509
666
|
const poll2 = async () => {
|
510
667
|
if (!active)
|
511
668
|
return;
|
512
669
|
await fn({ unpoll: unwatch });
|
513
|
-
await
|
670
|
+
await _chunk6Z62LPKBjs.wait.call(void 0, interval);
|
514
671
|
poll2();
|
515
672
|
};
|
516
673
|
poll2();
|
@@ -555,7 +712,7 @@ function watchBlockNumber(client, {
|
|
555
712
|
prevBlockNumber = blockNumber;
|
556
713
|
emit.onBlockNumber(blockNumber, prevBlockNumber);
|
557
714
|
} catch (err) {
|
558
|
-
_optionalChain([emit, 'access',
|
715
|
+
_optionalChain([emit, 'access', _22 => _22.onError, 'optionalCall', _23 => _23(err)]);
|
559
716
|
}
|
560
717
|
},
|
561
718
|
{
|
@@ -595,11 +752,11 @@ function watchBlocks(client, {
|
|
595
752
|
blockTag,
|
596
753
|
includeTransactions
|
597
754
|
});
|
598
|
-
if (block.number && _optionalChain([prevBlock, 'optionalAccess',
|
755
|
+
if (block.number && _optionalChain([prevBlock, 'optionalAccess', _24 => _24.number])) {
|
599
756
|
if (block.number === prevBlock.number)
|
600
757
|
return;
|
601
758
|
if (block.number - prevBlock.number > 1 && emitMissed) {
|
602
|
-
for (let i = _optionalChain([prevBlock, 'optionalAccess',
|
759
|
+
for (let i = _optionalChain([prevBlock, 'optionalAccess', _25 => _25.number]) + 1n; i < block.number; i++) {
|
603
760
|
const block2 = await getBlock(client, {
|
604
761
|
blockNumber: i,
|
605
762
|
includeTransactions
|
@@ -612,7 +769,7 @@ function watchBlocks(client, {
|
|
612
769
|
emit.onBlock(block, prevBlock);
|
613
770
|
prevBlock = block;
|
614
771
|
} catch (err) {
|
615
|
-
_optionalChain([emit, 'access',
|
772
|
+
_optionalChain([emit, 'access', _26 => _26.onError, 'optionalCall', _27 => _27(err)]);
|
616
773
|
}
|
617
774
|
},
|
618
775
|
{
|
@@ -656,7 +813,7 @@ function watchPendingTransactions(client, {
|
|
656
813
|
else
|
657
814
|
hashes.forEach((hash) => emit.onTransactions([hash]));
|
658
815
|
} catch (err) {
|
659
|
-
_optionalChain([emit, 'access',
|
816
|
+
_optionalChain([emit, 'access', _28 => _28.onError, 'optionalCall', _29 => _29(err)]);
|
660
817
|
}
|
661
818
|
},
|
662
819
|
{
|
@@ -700,8 +857,8 @@ async function getTxpoolStatus(client) {
|
|
700
857
|
method: "txpool_status"
|
701
858
|
});
|
702
859
|
return {
|
703
|
-
pending:
|
704
|
-
queued:
|
860
|
+
pending: _chunk6Z62LPKBjs.hexToNumber.call(void 0, pending),
|
861
|
+
queued: _chunk6Z62LPKBjs.hexToNumber.call(void 0, queued)
|
705
862
|
};
|
706
863
|
}
|
707
864
|
|
@@ -717,7 +874,7 @@ async function impersonateAccount(client, { address }) {
|
|
717
874
|
async function increaseTime(client, { seconds }) {
|
718
875
|
return await client.request({
|
719
876
|
method: "evm_increaseTime",
|
720
|
-
params: [
|
877
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, seconds)]
|
721
878
|
});
|
722
879
|
}
|
723
880
|
|
@@ -732,7 +889,7 @@ async function inspectTxpool(client) {
|
|
732
889
|
async function mine(client, { blocks, interval }) {
|
733
890
|
return await client.request({
|
734
891
|
method: `${client.mode}_mine`,
|
735
|
-
params: [
|
892
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, blocks), _chunk6Z62LPKBjs.numberToHex.call(void 0, interval || 0)]
|
736
893
|
});
|
737
894
|
}
|
738
895
|
|
@@ -761,7 +918,7 @@ async function revert(client, { id }) {
|
|
761
918
|
|
762
919
|
// src/actions/test/sendUnsignedTransaction.ts
|
763
920
|
async function sendUnsignedTransaction(client, request) {
|
764
|
-
const request_ =
|
921
|
+
const request_ = _chunk6Z62LPKBjs.formatTransactionRequest.call(void 0, request);
|
765
922
|
const hash = await client.request({
|
766
923
|
method: "eth_sendUnsignedTransaction",
|
767
924
|
params: [request_]
|
@@ -781,7 +938,7 @@ async function setAutomine(client, enabled) {
|
|
781
938
|
async function setBalance(client, { address, value }) {
|
782
939
|
return await client.request({
|
783
940
|
method: `${client.mode}_setBalance`,
|
784
|
-
params: [address,
|
941
|
+
params: [address, _chunk6Z62LPKBjs.numberToHex.call(void 0, value)]
|
785
942
|
});
|
786
943
|
}
|
787
944
|
|
@@ -789,7 +946,7 @@ async function setBalance(client, { address, value }) {
|
|
789
946
|
async function setBlockGasLimit(client, { gasLimit }) {
|
790
947
|
return await client.request({
|
791
948
|
method: "evm_setBlockGasLimit",
|
792
|
-
params: [
|
949
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, gasLimit)]
|
793
950
|
});
|
794
951
|
}
|
795
952
|
|
@@ -837,7 +994,7 @@ async function setLoggingEnabled(client, enabled) {
|
|
837
994
|
async function setMinGasPrice(client, { gasPrice }) {
|
838
995
|
return await client.request({
|
839
996
|
method: `${client.mode}_setMinGasPrice`,
|
840
|
-
params: [
|
997
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, gasPrice)]
|
841
998
|
});
|
842
999
|
}
|
843
1000
|
|
@@ -845,7 +1002,7 @@ async function setMinGasPrice(client, { gasPrice }) {
|
|
845
1002
|
async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
846
1003
|
return await client.request({
|
847
1004
|
method: `${client.mode}_setNextBlockBaseFeePerGas`,
|
848
|
-
params: [
|
1005
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, baseFeePerGas)]
|
849
1006
|
});
|
850
1007
|
}
|
851
1008
|
|
@@ -853,7 +1010,7 @@ async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
|
853
1010
|
async function setNextBlockTimestamp(client, { timestamp }) {
|
854
1011
|
return await client.request({
|
855
1012
|
method: "evm_setNextBlockTimestamp",
|
856
|
-
params: [
|
1013
|
+
params: [_chunk6Z62LPKBjs.numberToHex.call(void 0, timestamp)]
|
857
1014
|
});
|
858
1015
|
}
|
859
1016
|
|
@@ -861,7 +1018,7 @@ async function setNextBlockTimestamp(client, { timestamp }) {
|
|
861
1018
|
async function setNonce(client, { address, nonce }) {
|
862
1019
|
return await client.request({
|
863
1020
|
method: `${client.mode}_setNonce`,
|
864
|
-
params: [address,
|
1021
|
+
params: [address, _chunk6Z62LPKBjs.numberToHex.call(void 0, nonce)]
|
865
1022
|
});
|
866
1023
|
}
|
867
1024
|
|
@@ -871,7 +1028,7 @@ async function setStorageAt(client, { address, index, value }) {
|
|
871
1028
|
method: `${client.mode}_setStorageAt`,
|
872
1029
|
params: [
|
873
1030
|
address,
|
874
|
-
typeof index === "number" ?
|
1031
|
+
typeof index === "number" ? _chunk6Z62LPKBjs.numberToHex.call(void 0, index) : index,
|
875
1032
|
value
|
876
1033
|
]
|
877
1034
|
});
|
@@ -892,133 +1049,7 @@ async function stopImpersonatingAccount(client, { address }) {
|
|
892
1049
|
});
|
893
1050
|
}
|
894
1051
|
|
895
|
-
// src/actions/wallet/addChain.ts
|
896
|
-
async function addChain(client, chain) {
|
897
|
-
const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
898
|
-
await client.request({
|
899
|
-
method: "wallet_addEthereumChain",
|
900
|
-
params: [
|
901
|
-
{
|
902
|
-
chainId: _chunkA3PVAH22js.numberToHex.call(void 0, id),
|
903
|
-
chainName: name,
|
904
|
-
nativeCurrency,
|
905
|
-
rpcUrls: rpcUrls.default.http,
|
906
|
-
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
907
|
-
}
|
908
|
-
]
|
909
|
-
});
|
910
|
-
}
|
911
|
-
|
912
|
-
// src/actions/wallet/getAccounts.ts
|
913
|
-
async function getAccounts(client) {
|
914
|
-
const addresses = await client.request({ method: "eth_accounts" });
|
915
|
-
return addresses.map((address) => _chunkA3PVAH22js.checksumAddress.call(void 0, address));
|
916
|
-
}
|
917
|
-
|
918
|
-
// src/actions/wallet/getPermissions.ts
|
919
|
-
async function getPermissions(client) {
|
920
|
-
const permissions = await client.request({ method: "wallet_getPermissions" });
|
921
|
-
return permissions;
|
922
|
-
}
|
923
|
-
|
924
|
-
// src/actions/wallet/requestAccounts.ts
|
925
|
-
async function requestAccounts(client) {
|
926
|
-
const addresses = await client.request({ method: "eth_requestAccounts" });
|
927
|
-
return addresses.map((address) => _chunkA3PVAH22js.getAddress.call(void 0, address));
|
928
|
-
}
|
929
|
-
|
930
|
-
// src/actions/wallet/requestPermissions.ts
|
931
|
-
async function requestPermissions(client, permissions) {
|
932
|
-
return client.request({
|
933
|
-
method: "wallet_requestPermissions",
|
934
|
-
params: [permissions]
|
935
|
-
});
|
936
|
-
}
|
937
|
-
|
938
|
-
// src/actions/wallet/sendTransaction.ts
|
939
|
-
async function sendTransaction(client, {
|
940
|
-
chain,
|
941
|
-
from,
|
942
|
-
accessList,
|
943
|
-
data,
|
944
|
-
gas,
|
945
|
-
gasPrice,
|
946
|
-
maxFeePerGas,
|
947
|
-
maxPriorityFeePerGas,
|
948
|
-
nonce,
|
949
|
-
to,
|
950
|
-
value,
|
951
|
-
...rest
|
952
|
-
}) {
|
953
|
-
if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
|
954
|
-
throw new (0, _chunkA3PVAH22js.InvalidGasArgumentsError)();
|
955
|
-
const request_ = _chunkA3PVAH22js.format.call(void 0,
|
956
|
-
{
|
957
|
-
from,
|
958
|
-
accessList,
|
959
|
-
data,
|
960
|
-
gas,
|
961
|
-
gasPrice,
|
962
|
-
maxFeePerGas,
|
963
|
-
maxPriorityFeePerGas,
|
964
|
-
nonce,
|
965
|
-
to,
|
966
|
-
value,
|
967
|
-
...rest
|
968
|
-
},
|
969
|
-
{
|
970
|
-
formatter: _optionalChain([chain, 'optionalAccess', _28 => _28.formatters, 'optionalAccess', _29 => _29.transactionRequest]) || _chunkA3PVAH22js.formatTransactionRequest
|
971
|
-
}
|
972
|
-
);
|
973
|
-
const hash = await client.request({
|
974
|
-
method: "eth_sendTransaction",
|
975
|
-
params: [request_]
|
976
|
-
});
|
977
|
-
return hash;
|
978
|
-
}
|
979
|
-
|
980
|
-
// src/actions/wallet/signMessage.ts
|
981
|
-
async function signMessage(client, { from, data: data_ }) {
|
982
|
-
let data;
|
983
|
-
if (typeof data_ === "string") {
|
984
|
-
if (!data_.startsWith("0x"))
|
985
|
-
throw new (0, _chunkA3PVAH22js.BaseError)(
|
986
|
-
`data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
|
987
|
-
{
|
988
|
-
docsPath: "/TODO"
|
989
|
-
}
|
990
|
-
);
|
991
|
-
data = data_;
|
992
|
-
} else {
|
993
|
-
data = _chunkA3PVAH22js.encodeHex.call(void 0, data_);
|
994
|
-
}
|
995
|
-
const signed = await client.request({
|
996
|
-
method: "personal_sign",
|
997
|
-
params: [data, from]
|
998
|
-
});
|
999
|
-
return signed;
|
1000
|
-
}
|
1001
|
-
|
1002
|
-
// src/actions/wallet/switchChain.ts
|
1003
|
-
async function switchChain(client, { id }) {
|
1004
|
-
await client.request({
|
1005
|
-
method: "wallet_switchEthereumChain",
|
1006
|
-
params: [
|
1007
|
-
{
|
1008
|
-
chainId: _chunkA3PVAH22js.numberToHex.call(void 0, id)
|
1009
|
-
}
|
1010
|
-
]
|
1011
|
-
});
|
1012
|
-
}
|
1013
1052
|
|
1014
|
-
// src/actions/wallet/watchAsset.ts
|
1015
|
-
async function watchAsset(client, params) {
|
1016
|
-
const added = await client.request({
|
1017
|
-
method: "wallet_watchAsset",
|
1018
|
-
params: [params]
|
1019
|
-
});
|
1020
|
-
return added;
|
1021
|
-
}
|
1022
1053
|
|
1023
1054
|
|
1024
1055
|
|
@@ -1081,4 +1112,4 @@ async function watchAsset(client, params) {
|
|
1081
1112
|
|
1082
1113
|
|
1083
1114
|
|
1084
|
-
exports.call = call; exports.callContract = callContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.estimateGas = estimateGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchPendingTransactions = watchPendingTransactions; exports.dropTransaction = dropTransaction; exports.getAutomine = getAutomine; exports.getTxpoolContent = getTxpoolContent; exports.getTxpoolStatus = getTxpoolStatus; exports.impersonateAccount = impersonateAccount; exports.increaseTime = increaseTime; exports.inspectTxpool = inspectTxpool; exports.mine = mine; exports.removeBlockTimestampInterval = removeBlockTimestampInterval; exports.reset = reset; exports.revert = revert; exports.sendUnsignedTransaction = sendUnsignedTransaction; exports.setAutomine = setAutomine; exports.setBalance = setBalance; exports.setBlockGasLimit = setBlockGasLimit; exports.setBlockTimestampInterval = setBlockTimestampInterval; exports.setCode = setCode; exports.setCoinbase = setCoinbase; exports.setIntervalMining = setIntervalMining; exports.setLoggingEnabled = setLoggingEnabled; exports.setMinGasPrice = setMinGasPrice; exports.setNextBlockBaseFeePerGas = setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = setNextBlockTimestamp; exports.setNonce = setNonce; exports.setStorageAt = setStorageAt; exports.snapshot = snapshot; exports.stopImpersonatingAccount = stopImpersonatingAccount;
|
1115
|
+
exports.call = call; exports.callContract = callContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.addChain = addChain; exports.getAccounts = getAccounts; exports.getPermissions = getPermissions; exports.requestAccounts = requestAccounts; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.deployContract = deployContract; exports.estimateGas = estimateGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchPendingTransactions = watchPendingTransactions; exports.dropTransaction = dropTransaction; exports.getAutomine = getAutomine; exports.getTxpoolContent = getTxpoolContent; exports.getTxpoolStatus = getTxpoolStatus; exports.impersonateAccount = impersonateAccount; exports.increaseTime = increaseTime; exports.inspectTxpool = inspectTxpool; exports.mine = mine; exports.removeBlockTimestampInterval = removeBlockTimestampInterval; exports.reset = reset; exports.revert = revert; exports.sendUnsignedTransaction = sendUnsignedTransaction; exports.setAutomine = setAutomine; exports.setBalance = setBalance; exports.setBlockGasLimit = setBlockGasLimit; exports.setBlockTimestampInterval = setBlockTimestampInterval; exports.setCode = setCode; exports.setCoinbase = setCoinbase; exports.setIntervalMining = setIntervalMining; exports.setLoggingEnabled = setLoggingEnabled; exports.setMinGasPrice = setMinGasPrice; exports.setNextBlockBaseFeePerGas = setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = setNextBlockTimestamp; exports.setNonce = setNonce; exports.setStorageAt = setStorageAt; exports.snapshot = snapshot; exports.stopImpersonatingAccount = stopImpersonatingAccount;
|