viem 0.0.1-alpha.11 → 0.0.1-alpha.13
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 +5 -3
- package/dist/actions/index.mjs +4 -2
- package/dist/chains.js +5 -5
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-DY4MSK2M.mjs → chunk-4XV4JRFM.mjs} +16 -2
- package/dist/{chunk-35OJIFIW.js → chunk-AGF7GU6G.js} +25 -11
- package/dist/{chunk-TP542F7H.mjs → chunk-KZVBHS2T.mjs} +1 -1
- package/dist/{chunk-JXGK2LUM.mjs → chunk-NJ5NFIT4.mjs} +159 -141
- package/dist/{chunk-GXCYE2PD.js → chunk-O3XABJRL.js} +11 -11
- package/dist/{chunk-PEAG3TIC.js → chunk-OHOJCVQD.js} +212 -194
- 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 +6 -4
- package/dist/index.mjs +5 -3
- package/dist/{parseGwei-7c87ff41.d.ts → parseGwei-21f98a29.d.ts} +1 -1
- package/dist/{watchAsset-43255bfd.d.ts → stopImpersonatingAccount-70c4a70c.d.ts} +51 -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 +6 -1
@@ -23,7 +23,9 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
|
26
|
-
|
26
|
+
|
27
|
+
|
28
|
+
var _chunkAGF7GU6Gjs = require('./chunk-AGF7GU6G.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, _chunkAGF7GU6Gjs.InvalidGasArgumentsError)();
|
49
|
+
const blockNumberHex = blockNumber ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, blockNumber) : void 0;
|
50
|
+
const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
|
51
|
+
const request_ = _chunkAGF7GU6Gjs.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
|
+
..._chunkAGF7GU6Gjs.extract.call(void 0, rest, { formatter })
|
61
64
|
},
|
62
65
|
{
|
63
|
-
formatter:
|
66
|
+
formatter: formatter || _chunkAGF7GU6Gjs.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 = _chunkAGF7GU6Gjs.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 _chunkAGF7GU6Gjs.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 _chunkAGF7GU6Gjs.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: _chunkAGF7GU6Gjs.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) => _chunkAGF7GU6Gjs.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) => _chunkAGF7GU6Gjs.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, _chunkAGF7GU6Gjs.InvalidGasArgumentsError)();
|
189
|
+
const formatter = _optionalChain([chain, 'optionalAccess', _3 => _3.formatters, 'optionalAccess', _4 => _4.transactionRequest]);
|
190
|
+
const request_ = _chunkAGF7GU6Gjs.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
|
+
..._chunkAGF7GU6Gjs.extract.call(void 0, rest, { formatter })
|
203
|
+
},
|
204
|
+
{
|
205
|
+
formatter: formatter || _chunkAGF7GU6Gjs.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, _chunkAGF7GU6Gjs.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 = _chunkAGF7GU6Gjs.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: _chunkAGF7GU6Gjs.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 = _chunkAGF7GU6Gjs.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 ? _chunkAGF7GU6Gjs.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 ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, gas) : void 0,
|
289
|
+
gasPrice: gasPrice ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, gasPrice) : void 0,
|
290
|
+
maxFeePerGas: maxFeePerGas ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, maxFeePerGas) : void 0,
|
291
|
+
maxPriorityFeePerGas: maxPriorityFeePerGas ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, maxPriorityFeePerGas) : void 0,
|
147
292
|
to,
|
148
|
-
value: value ?
|
293
|
+
value: value ? _chunkAGF7GU6Gjs.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 ? _chunkAGF7GU6Gjs.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 ? _chunkAGF7GU6Gjs.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, _chunkAGF7GU6Gjs.BlockNotFoundError)({ blockHash, blockNumber });
|
334
|
+
return _chunkAGF7GU6Gjs.format.call(void 0, block, {
|
335
|
+
formatter: _optionalChain([client, 'access', _5 => _5.chain, 'optionalAccess', _6 => _6.formatters, 'optionalAccess', _7 => _7.block]) || _chunkAGF7GU6Gjs.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 _chunkAGF7GU6Gjs.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 _chunkAGF7GU6Gjs.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 ? _chunkAGF7GU6Gjs.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,13 @@ async function getBlockTransactionCount(client, {
|
|
225
370
|
params: [blockNumberHex || blockTag]
|
226
371
|
});
|
227
372
|
}
|
228
|
-
return
|
373
|
+
return _chunkAGF7GU6Gjs.hexToNumber.call(void 0, count);
|
229
374
|
}
|
230
375
|
|
231
376
|
// src/actions/public/getChainId.ts
|
232
377
|
async function getChainId(client) {
|
233
378
|
const chainIdHex = await client.request({ method: "eth_chainId" });
|
234
|
-
return
|
379
|
+
return _chunkAGF7GU6Gjs.hexToNumber.call(void 0, chainIdHex);
|
235
380
|
}
|
236
381
|
|
237
382
|
// src/actions/public/getFeeHistory.ts
|
@@ -241,16 +386,16 @@ async function getFeeHistory(client, {
|
|
241
386
|
blockTag = "latest",
|
242
387
|
rewardPercentiles
|
243
388
|
}) {
|
244
|
-
const blockNumberHex = blockNumber ?
|
389
|
+
const blockNumberHex = blockNumber ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, blockNumber) : void 0;
|
245
390
|
const feeHistory = await client.request({
|
246
391
|
method: "eth_feeHistory",
|
247
392
|
params: [
|
248
|
-
|
393
|
+
_chunkAGF7GU6Gjs.numberToHex.call(void 0, blockCount),
|
249
394
|
blockNumberHex || blockTag,
|
250
395
|
rewardPercentiles
|
251
396
|
]
|
252
397
|
});
|
253
|
-
return
|
398
|
+
return _chunkAGF7GU6Gjs.formatFeeHistory.call(void 0, feeHistory);
|
254
399
|
}
|
255
400
|
|
256
401
|
// src/actions/public/getFilterChanges.ts
|
@@ -260,7 +405,7 @@ async function getFilterChanges(client, { filter }) {
|
|
260
405
|
params: [filter.id]
|
261
406
|
});
|
262
407
|
return logs.map(
|
263
|
-
(log) => typeof log === "string" ? log :
|
408
|
+
(log) => typeof log === "string" ? log : _chunkAGF7GU6Gjs.formatLog.call(void 0, log)
|
264
409
|
);
|
265
410
|
}
|
266
411
|
|
@@ -270,7 +415,7 @@ async function getFilterLogs(client, { filter }) {
|
|
270
415
|
method: "eth_getFilterLogs",
|
271
416
|
params: [filter.id]
|
272
417
|
});
|
273
|
-
return logs.map(
|
418
|
+
return logs.map(_chunkAGF7GU6Gjs.formatLog);
|
274
419
|
}
|
275
420
|
|
276
421
|
// src/actions/public/getGasPrice.ts
|
@@ -289,7 +434,7 @@ async function getTransaction(client, {
|
|
289
434
|
hash,
|
290
435
|
index
|
291
436
|
}) {
|
292
|
-
const blockNumberHex = blockNumber !== void 0 ?
|
437
|
+
const blockNumberHex = blockNumber !== void 0 ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, blockNumber) : void 0;
|
293
438
|
let transaction = null;
|
294
439
|
if (hash) {
|
295
440
|
transaction = await client.request({
|
@@ -299,24 +444,24 @@ async function getTransaction(client, {
|
|
299
444
|
} else if (blockHash) {
|
300
445
|
transaction = await client.request({
|
301
446
|
method: "eth_getTransactionByBlockHashAndIndex",
|
302
|
-
params: [blockHash,
|
447
|
+
params: [blockHash, _chunkAGF7GU6Gjs.numberToHex.call(void 0, index)]
|
303
448
|
});
|
304
449
|
} else if (blockNumberHex || blockTag) {
|
305
450
|
transaction = await client.request({
|
306
451
|
method: "eth_getTransactionByBlockNumberAndIndex",
|
307
|
-
params: [blockNumberHex || blockTag,
|
452
|
+
params: [blockNumberHex || blockTag, _chunkAGF7GU6Gjs.numberToHex.call(void 0, index)]
|
308
453
|
});
|
309
454
|
}
|
310
455
|
if (!transaction)
|
311
|
-
throw new (0,
|
456
|
+
throw new (0, _chunkAGF7GU6Gjs.TransactionNotFoundError)({
|
312
457
|
blockHash,
|
313
458
|
blockNumber,
|
314
459
|
blockTag,
|
315
460
|
hash,
|
316
461
|
index
|
317
462
|
});
|
318
|
-
return
|
319
|
-
formatter: _optionalChain([client, 'access',
|
463
|
+
return _chunkAGF7GU6Gjs.format.call(void 0, transaction, {
|
464
|
+
formatter: _optionalChain([client, 'access', _8 => _8.chain, 'optionalAccess', _9 => _9.formatters, 'optionalAccess', _10 => _10.transaction]) || _chunkAGF7GU6Gjs.formatTransaction
|
320
465
|
});
|
321
466
|
}
|
322
467
|
|
@@ -326,7 +471,7 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
|
|
326
471
|
getBlockNumber(client),
|
327
472
|
hash ? getTransaction(client, { hash }) : void 0
|
328
473
|
]);
|
329
|
-
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess',
|
474
|
+
const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess', _11 => _11.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _12 => _12.blockNumber]);
|
330
475
|
if (!transactionBlockNumber)
|
331
476
|
return 0n;
|
332
477
|
return blockNumber - transactionBlockNumber + 1n;
|
@@ -336,9 +481,9 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
|
|
336
481
|
async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
|
337
482
|
const count = await client.request({
|
338
483
|
method: "eth_getTransactionCount",
|
339
|
-
params: [address, blockNumber ?
|
484
|
+
params: [address, blockNumber ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, blockNumber) : blockTag]
|
340
485
|
});
|
341
|
-
return
|
486
|
+
return _chunkAGF7GU6Gjs.hexToNumber.call(void 0, count);
|
342
487
|
}
|
343
488
|
|
344
489
|
// src/actions/public/getTransactionReceipt.ts
|
@@ -348,9 +493,9 @@ async function getTransactionReceipt(client, { hash }) {
|
|
348
493
|
params: [hash]
|
349
494
|
});
|
350
495
|
if (!receipt)
|
351
|
-
throw new (0,
|
352
|
-
return
|
353
|
-
formatter: _optionalChain([client, 'access',
|
496
|
+
throw new (0, _chunkAGF7GU6Gjs.TransactionReceiptNotFoundError)({ hash });
|
497
|
+
return _chunkAGF7GU6Gjs.format.call(void 0, receipt, {
|
498
|
+
formatter: _optionalChain([client, 'access', _13 => _13.chain, 'optionalAccess', _14 => _14.formatters, 'optionalAccess', _15 => _15.transactionReceipt]) || _chunkAGF7GU6Gjs.formatTransactionReceipt
|
354
499
|
});
|
355
500
|
}
|
356
501
|
|
@@ -395,7 +540,7 @@ function observe(observerId, callbacks, fn) {
|
|
395
540
|
const listeners2 = getListeners();
|
396
541
|
if (listeners2.length === 0)
|
397
542
|
return;
|
398
|
-
listeners2.forEach((listener) => _optionalChain([listener, 'access',
|
543
|
+
listeners2.forEach((listener) => _optionalChain([listener, 'access', _16 => _16.fns, 'access', _17 => _17[key], 'optionalCall', _18 => _18(...args)]));
|
399
544
|
};
|
400
545
|
}
|
401
546
|
const cleanup = fn(emit);
|
@@ -423,7 +568,7 @@ async function waitForTransactionReceipt(client, {
|
|
423
568
|
return new Promise((resolve, reject) => {
|
424
569
|
if (timeout)
|
425
570
|
setTimeout(
|
426
|
-
() => reject(new (0,
|
571
|
+
() => reject(new (0, _chunkAGF7GU6Gjs.WaitForTransactionReceiptTimeoutError)({ hash })),
|
427
572
|
timeout
|
428
573
|
);
|
429
574
|
const unobserve = observe(
|
@@ -453,7 +598,7 @@ async function waitForTransactionReceipt(client, {
|
|
453
598
|
return;
|
454
599
|
done(() => emit.resolve(receipt));
|
455
600
|
} catch (err) {
|
456
|
-
if (transaction && (err instanceof
|
601
|
+
if (transaction && (err instanceof _chunkAGF7GU6Gjs.TransactionNotFoundError || err instanceof _chunkAGF7GU6Gjs.TransactionReceiptNotFoundError)) {
|
457
602
|
replacedTransaction = transaction;
|
458
603
|
const block = await getBlock(client, {
|
459
604
|
blockNumber,
|
@@ -476,7 +621,7 @@ async function waitForTransactionReceipt(client, {
|
|
476
621
|
reason = "cancelled";
|
477
622
|
}
|
478
623
|
done(() => {
|
479
|
-
_optionalChain([emit, 'access',
|
624
|
+
_optionalChain([emit, 'access', _19 => _19.onReplaced, 'optionalCall', _20 => _20({
|
480
625
|
reason,
|
481
626
|
replacedTransaction,
|
482
627
|
transaction: replacementTransaction,
|
@@ -504,13 +649,13 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
|
504
649
|
let data;
|
505
650
|
if (emitOnBegin)
|
506
651
|
data = await fn({ unpoll: unwatch });
|
507
|
-
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall',
|
508
|
-
await
|
652
|
+
const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _21 => _21(data)]), async () => ( interval));
|
653
|
+
await _chunkAGF7GU6Gjs.wait.call(void 0, initialWait);
|
509
654
|
const poll2 = async () => {
|
510
655
|
if (!active)
|
511
656
|
return;
|
512
657
|
await fn({ unpoll: unwatch });
|
513
|
-
await
|
658
|
+
await _chunkAGF7GU6Gjs.wait.call(void 0, interval);
|
514
659
|
poll2();
|
515
660
|
};
|
516
661
|
poll2();
|
@@ -555,7 +700,7 @@ function watchBlockNumber(client, {
|
|
555
700
|
prevBlockNumber = blockNumber;
|
556
701
|
emit.onBlockNumber(blockNumber, prevBlockNumber);
|
557
702
|
} catch (err) {
|
558
|
-
_optionalChain([emit, 'access',
|
703
|
+
_optionalChain([emit, 'access', _22 => _22.onError, 'optionalCall', _23 => _23(err)]);
|
559
704
|
}
|
560
705
|
},
|
561
706
|
{
|
@@ -595,11 +740,11 @@ function watchBlocks(client, {
|
|
595
740
|
blockTag,
|
596
741
|
includeTransactions
|
597
742
|
});
|
598
|
-
if (block.number && _optionalChain([prevBlock, 'optionalAccess',
|
743
|
+
if (block.number && _optionalChain([prevBlock, 'optionalAccess', _24 => _24.number])) {
|
599
744
|
if (block.number === prevBlock.number)
|
600
745
|
return;
|
601
746
|
if (block.number - prevBlock.number > 1 && emitMissed) {
|
602
|
-
for (let i = _optionalChain([prevBlock, 'optionalAccess',
|
747
|
+
for (let i = _optionalChain([prevBlock, 'optionalAccess', _25 => _25.number]) + 1n; i < block.number; i++) {
|
603
748
|
const block2 = await getBlock(client, {
|
604
749
|
blockNumber: i,
|
605
750
|
includeTransactions
|
@@ -612,7 +757,7 @@ function watchBlocks(client, {
|
|
612
757
|
emit.onBlock(block, prevBlock);
|
613
758
|
prevBlock = block;
|
614
759
|
} catch (err) {
|
615
|
-
_optionalChain([emit, 'access',
|
760
|
+
_optionalChain([emit, 'access', _26 => _26.onError, 'optionalCall', _27 => _27(err)]);
|
616
761
|
}
|
617
762
|
},
|
618
763
|
{
|
@@ -656,7 +801,7 @@ function watchPendingTransactions(client, {
|
|
656
801
|
else
|
657
802
|
hashes.forEach((hash) => emit.onTransactions([hash]));
|
658
803
|
} catch (err) {
|
659
|
-
_optionalChain([emit, 'access',
|
804
|
+
_optionalChain([emit, 'access', _28 => _28.onError, 'optionalCall', _29 => _29(err)]);
|
660
805
|
}
|
661
806
|
},
|
662
807
|
{
|
@@ -700,8 +845,8 @@ async function getTxpoolStatus(client) {
|
|
700
845
|
method: "txpool_status"
|
701
846
|
});
|
702
847
|
return {
|
703
|
-
pending:
|
704
|
-
queued:
|
848
|
+
pending: _chunkAGF7GU6Gjs.hexToNumber.call(void 0, pending),
|
849
|
+
queued: _chunkAGF7GU6Gjs.hexToNumber.call(void 0, queued)
|
705
850
|
};
|
706
851
|
}
|
707
852
|
|
@@ -717,7 +862,7 @@ async function impersonateAccount(client, { address }) {
|
|
717
862
|
async function increaseTime(client, { seconds }) {
|
718
863
|
return await client.request({
|
719
864
|
method: "evm_increaseTime",
|
720
|
-
params: [
|
865
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, seconds)]
|
721
866
|
});
|
722
867
|
}
|
723
868
|
|
@@ -732,7 +877,7 @@ async function inspectTxpool(client) {
|
|
732
877
|
async function mine(client, { blocks, interval }) {
|
733
878
|
return await client.request({
|
734
879
|
method: `${client.mode}_mine`,
|
735
|
-
params: [
|
880
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, blocks), _chunkAGF7GU6Gjs.numberToHex.call(void 0, interval || 0)]
|
736
881
|
});
|
737
882
|
}
|
738
883
|
|
@@ -761,7 +906,7 @@ async function revert(client, { id }) {
|
|
761
906
|
|
762
907
|
// src/actions/test/sendUnsignedTransaction.ts
|
763
908
|
async function sendUnsignedTransaction(client, request) {
|
764
|
-
const request_ =
|
909
|
+
const request_ = _chunkAGF7GU6Gjs.formatTransactionRequest.call(void 0, request);
|
765
910
|
const hash = await client.request({
|
766
911
|
method: "eth_sendUnsignedTransaction",
|
767
912
|
params: [request_]
|
@@ -781,7 +926,7 @@ async function setAutomine(client, enabled) {
|
|
781
926
|
async function setBalance(client, { address, value }) {
|
782
927
|
return await client.request({
|
783
928
|
method: `${client.mode}_setBalance`,
|
784
|
-
params: [address,
|
929
|
+
params: [address, _chunkAGF7GU6Gjs.numberToHex.call(void 0, value)]
|
785
930
|
});
|
786
931
|
}
|
787
932
|
|
@@ -789,7 +934,7 @@ async function setBalance(client, { address, value }) {
|
|
789
934
|
async function setBlockGasLimit(client, { gasLimit }) {
|
790
935
|
return await client.request({
|
791
936
|
method: "evm_setBlockGasLimit",
|
792
|
-
params: [
|
937
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, gasLimit)]
|
793
938
|
});
|
794
939
|
}
|
795
940
|
|
@@ -837,7 +982,7 @@ async function setLoggingEnabled(client, enabled) {
|
|
837
982
|
async function setMinGasPrice(client, { gasPrice }) {
|
838
983
|
return await client.request({
|
839
984
|
method: `${client.mode}_setMinGasPrice`,
|
840
|
-
params: [
|
985
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, gasPrice)]
|
841
986
|
});
|
842
987
|
}
|
843
988
|
|
@@ -845,7 +990,7 @@ async function setMinGasPrice(client, { gasPrice }) {
|
|
845
990
|
async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
846
991
|
return await client.request({
|
847
992
|
method: `${client.mode}_setNextBlockBaseFeePerGas`,
|
848
|
-
params: [
|
993
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, baseFeePerGas)]
|
849
994
|
});
|
850
995
|
}
|
851
996
|
|
@@ -853,7 +998,7 @@ async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
|
853
998
|
async function setNextBlockTimestamp(client, { timestamp }) {
|
854
999
|
return await client.request({
|
855
1000
|
method: "evm_setNextBlockTimestamp",
|
856
|
-
params: [
|
1001
|
+
params: [_chunkAGF7GU6Gjs.numberToHex.call(void 0, timestamp)]
|
857
1002
|
});
|
858
1003
|
}
|
859
1004
|
|
@@ -861,7 +1006,7 @@ async function setNextBlockTimestamp(client, { timestamp }) {
|
|
861
1006
|
async function setNonce(client, { address, nonce }) {
|
862
1007
|
return await client.request({
|
863
1008
|
method: `${client.mode}_setNonce`,
|
864
|
-
params: [address,
|
1009
|
+
params: [address, _chunkAGF7GU6Gjs.numberToHex.call(void 0, nonce)]
|
865
1010
|
});
|
866
1011
|
}
|
867
1012
|
|
@@ -871,7 +1016,7 @@ async function setStorageAt(client, { address, index, value }) {
|
|
871
1016
|
method: `${client.mode}_setStorageAt`,
|
872
1017
|
params: [
|
873
1018
|
address,
|
874
|
-
typeof index === "number" ?
|
1019
|
+
typeof index === "number" ? _chunkAGF7GU6Gjs.numberToHex.call(void 0, index) : index,
|
875
1020
|
value
|
876
1021
|
]
|
877
1022
|
});
|
@@ -892,133 +1037,6 @@ async function stopImpersonatingAccount(client, { address }) {
|
|
892
1037
|
});
|
893
1038
|
}
|
894
1039
|
|
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: _chunk35OJIFIWjs.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) => _chunk35OJIFIWjs.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) => _chunk35OJIFIWjs.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, _chunk35OJIFIWjs.InvalidGasArgumentsError)();
|
955
|
-
const request_ = _chunk35OJIFIWjs.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]) || _chunk35OJIFIWjs.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, _chunk35OJIFIWjs.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 = _chunk35OJIFIWjs.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: _chunk35OJIFIWjs.numberToHex.call(void 0, id)
|
1009
|
-
}
|
1010
|
-
]
|
1011
|
-
});
|
1012
|
-
}
|
1013
|
-
|
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
1040
|
|
1023
1041
|
|
1024
1042
|
|
@@ -1081,4 +1099,4 @@ async function watchAsset(client, params) {
|
|
1081
1099
|
|
1082
1100
|
|
1083
1101
|
|
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;
|
1102
|
+
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.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;
|