viem 0.0.1-alpha.35 → 0.0.1-alpha.37
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/README.md +132 -0
- package/dist/abi.d.ts +2 -2
- package/dist/abi.js +2 -2
- package/dist/abi.mjs +1 -1
- package/dist/{chain-7b7ac245.d.ts → chain-a34aa9a2.d.ts} +65 -63
- package/dist/{chain-145cfaf3.d.ts → chain-b1229232.d.ts} +1 -1
- package/dist/chains.d.ts +3 -3
- package/dist/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/{chunk-HQCSH22G.js → chunk-534U2FZG.js} +1824 -129
- package/dist/chunk-534U2FZG.js.map +1 -0
- package/dist/{chunk-5NDMORWZ.mjs → chunk-AS2YWIFN.mjs} +3 -5
- package/dist/{chunk-5NDMORWZ.mjs.map → chunk-AS2YWIFN.mjs.map} +1 -1
- package/dist/{chunk-57YM6E7I.js → chunk-JXFHSHM6.js} +21 -23
- package/dist/chunk-JXFHSHM6.js.map +1 -0
- package/dist/{chunk-PBW4YL37.mjs → chunk-WVZFIDQ5.mjs} +1844 -149
- package/dist/chunk-WVZFIDQ5.mjs.map +1 -0
- package/dist/contract.d.ts +7 -7
- package/dist/contract.js +2 -6
- package/dist/contract.mjs +11 -15
- package/dist/{createClient-7c715e2c.d.ts → createClient-8024655d.d.ts} +3 -11
- package/dist/{createPublicClient-4d24afb2.d.ts → createPublicClient-f283b09d.d.ts} +62 -59
- package/dist/{eip1193-d538ae6d.d.ts → eip1193-a4f254d2.d.ts} +2 -2
- package/dist/{encodeFunctionResult-f59f4cfe.d.ts → encodeFunctionResult-c3d6c7ea.d.ts} +1 -1
- package/dist/ens.d.ts +4 -4
- package/dist/ens.js +3 -4
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +2 -3
- package/dist/ens.mjs.map +1 -1
- package/dist/{formatAbiItem-89d97367.d.ts → formatAbiItem-d79cb207.d.ts} +1 -1
- package/dist/{getAbiItem-c9cbc8b8.d.ts → getAbiItem-48e793da.d.ts} +1 -1
- package/dist/index.d.ts +27 -16
- package/dist/index.js +89 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -86
- package/dist/index.mjs.map +1 -1
- package/dist/{parseGwei-ad6d1914.d.ts → parseGwei-a8c67c77.d.ts} +11 -22
- package/dist/public.d.ts +6 -6
- package/dist/public.js +2 -3
- package/dist/public.mjs +1 -2
- package/dist/{test-8646fb50.d.ts → test-f8bc2fa7.d.ts} +3 -11
- package/dist/test.d.ts +5 -5
- package/dist/test.js +2 -3
- package/dist/test.mjs +1 -2
- package/dist/utils/index.d.ts +27 -16
- package/dist/utils/index.js +2 -4
- package/dist/utils/index.mjs +11 -13
- package/dist/wallet.d.ts +4 -4
- package/dist/wallet.js +2 -4
- package/dist/wallet.mjs +5 -7
- package/dist/window.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-3FT7UKPT.js +0 -1216
- package/dist/chunk-3FT7UKPT.js.map +0 -1
- package/dist/chunk-57YM6E7I.js.map +0 -1
- package/dist/chunk-A665BF7O.js +0 -205
- package/dist/chunk-A665BF7O.js.map +0 -1
- package/dist/chunk-HQCSH22G.js.map +0 -1
- package/dist/chunk-PBW4YL37.mjs.map +0 -1
- package/dist/chunk-PH5LCMME.mjs +0 -205
- package/dist/chunk-PH5LCMME.mjs.map +0 -1
- package/dist/chunk-TJK6AFBM.js +0 -265
- package/dist/chunk-TJK6AFBM.js.map +0 -1
- package/dist/chunk-WQDVW7EJ.mjs +0 -1216
- package/dist/chunk-WQDVW7EJ.mjs.map +0 -1
- package/dist/chunk-YEVW7GK5.mjs +0 -265
- package/dist/chunk-YEVW7GK5.mjs.map +0 -1
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
|
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
11
|
description: "TypeScript Interface for Ethereum",
|
12
|
-
version: "0.0.1-alpha.
|
12
|
+
version: "0.0.1-alpha.37",
|
13
13
|
scripts: {
|
14
14
|
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
15
|
bench: "vitest bench --no-threads",
|
@@ -602,6 +602,20 @@ var solidityPanic = {
|
|
602
602
|
type: "error"
|
603
603
|
};
|
604
604
|
|
605
|
+
// src/constants/unit.ts
|
606
|
+
var etherUnits = {
|
607
|
+
gwei: 9,
|
608
|
+
wei: 18
|
609
|
+
};
|
610
|
+
var gweiUnits = {
|
611
|
+
ether: -9,
|
612
|
+
wei: 9
|
613
|
+
};
|
614
|
+
var weiUnits = {
|
615
|
+
ether: -18,
|
616
|
+
gwei: -9
|
617
|
+
};
|
618
|
+
|
605
619
|
// src/errors/transaction.ts
|
606
620
|
function prettyPrint(args) {
|
607
621
|
const entries = Object.entries(args).map(([key, value]) => {
|
@@ -612,10 +626,21 @@ function prettyPrint(args) {
|
|
612
626
|
const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
|
613
627
|
return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
|
614
628
|
}
|
629
|
+
var FeeConflictError = class extends BaseError {
|
630
|
+
constructor() {
|
631
|
+
super(
|
632
|
+
[
|
633
|
+
"Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
|
634
|
+
"Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
|
635
|
+
].join("\n")
|
636
|
+
);
|
637
|
+
__publicField(this, "name", "FeeConflictError");
|
638
|
+
}
|
639
|
+
};
|
615
640
|
var TransactionExecutionError = class extends BaseError {
|
616
641
|
constructor(cause, {
|
642
|
+
account,
|
617
643
|
docsPath: docsPath5,
|
618
|
-
from,
|
619
644
|
chain,
|
620
645
|
data,
|
621
646
|
gas,
|
@@ -628,7 +653,7 @@ var TransactionExecutionError = class extends BaseError {
|
|
628
653
|
}) {
|
629
654
|
const prettyArgs = prettyPrint({
|
630
655
|
chain: chain && `${chain?.name} (id: ${chain?.id})`,
|
631
|
-
from,
|
656
|
+
from: account.address,
|
632
657
|
to,
|
633
658
|
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
634
659
|
data,
|
@@ -693,8 +718,8 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
|
693
718
|
// src/errors/contract.ts
|
694
719
|
var CallExecutionError = class extends BaseError {
|
695
720
|
constructor(cause, {
|
721
|
+
account,
|
696
722
|
docsPath: docsPath5,
|
697
|
-
from,
|
698
723
|
chain,
|
699
724
|
data,
|
700
725
|
gas,
|
@@ -706,7 +731,7 @@ var CallExecutionError = class extends BaseError {
|
|
706
731
|
value
|
707
732
|
}) {
|
708
733
|
const prettyArgs = prettyPrint({
|
709
|
-
from,
|
734
|
+
from: account?.address,
|
710
735
|
to,
|
711
736
|
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
712
737
|
data,
|
@@ -920,8 +945,8 @@ var OffsetOutOfBoundsError = class extends BaseError {
|
|
920
945
|
// src/errors/estimateGas.ts
|
921
946
|
var EstimateGasExecutionError = class extends BaseError {
|
922
947
|
constructor(cause, {
|
948
|
+
account,
|
923
949
|
docsPath: docsPath5,
|
924
|
-
from,
|
925
950
|
chain,
|
926
951
|
data,
|
927
952
|
gas,
|
@@ -933,7 +958,7 @@ var EstimateGasExecutionError = class extends BaseError {
|
|
933
958
|
value
|
934
959
|
}) {
|
935
960
|
const prettyArgs = prettyPrint({
|
936
|
-
from,
|
961
|
+
from: account.address,
|
937
962
|
to,
|
938
963
|
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
939
964
|
data,
|
@@ -2623,18 +2648,33 @@ function formatAbiItemWithArgs({
|
|
2623
2648
|
).join(", ")})`;
|
2624
2649
|
}
|
2625
2650
|
|
2651
|
+
// src/utils/account.ts
|
2652
|
+
function getAccount(account) {
|
2653
|
+
if (typeof account === "string") {
|
2654
|
+
if (!isAddress(account))
|
2655
|
+
throw new InvalidAddressError({ address: account });
|
2656
|
+
return { address: account, type: "json-rpc" };
|
2657
|
+
}
|
2658
|
+
if (!isAddress(account.address))
|
2659
|
+
throw new InvalidAddressError({ address: account.address });
|
2660
|
+
return {
|
2661
|
+
...account,
|
2662
|
+
type: "externally-owned"
|
2663
|
+
};
|
2664
|
+
}
|
2665
|
+
|
2626
2666
|
// src/utils/promise/withCache.ts
|
2627
2667
|
var promiseCache = /* @__PURE__ */ new Map();
|
2628
2668
|
var responseCache = /* @__PURE__ */ new Map();
|
2629
|
-
function getCache(
|
2630
|
-
const buildCache = (
|
2631
|
-
clear: () => cache.delete(
|
2632
|
-
get: () => cache.get(
|
2633
|
-
set: (data) => cache.set(
|
2669
|
+
function getCache(cacheKey2) {
|
2670
|
+
const buildCache = (cacheKey3, cache) => ({
|
2671
|
+
clear: () => cache.delete(cacheKey3),
|
2672
|
+
get: () => cache.get(cacheKey3),
|
2673
|
+
set: (data) => cache.set(cacheKey3, data)
|
2634
2674
|
});
|
2635
|
-
const promise = buildCache(
|
2675
|
+
const promise = buildCache(cacheKey2, promiseCache);
|
2636
2676
|
const response = buildCache(
|
2637
|
-
|
2677
|
+
cacheKey2,
|
2638
2678
|
responseCache
|
2639
2679
|
);
|
2640
2680
|
return {
|
@@ -2646,8 +2686,8 @@ function getCache(cacheKey) {
|
|
2646
2686
|
response
|
2647
2687
|
};
|
2648
2688
|
}
|
2649
|
-
async function withCache(fn, { cacheKey, maxAge = Infinity }) {
|
2650
|
-
const cache = getCache(
|
2689
|
+
async function withCache(fn, { cacheKey: cacheKey2, maxAge = Infinity }) {
|
2690
|
+
const cache = getCache(cacheKey2);
|
2651
2691
|
const response = cache.response.get();
|
2652
2692
|
if (response && maxAge > 0) {
|
2653
2693
|
const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
|
@@ -2835,6 +2875,7 @@ function formatTransaction(transaction) {
|
|
2835
2875
|
const transaction_ = {
|
2836
2876
|
...transaction,
|
2837
2877
|
blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
|
2878
|
+
chainId: transaction.chainId ? hexToNumber(transaction.chainId) : void 0,
|
2838
2879
|
gas: transaction.gas ? BigInt(transaction.gas) : void 0,
|
2839
2880
|
gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
|
2840
2881
|
maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
|
@@ -2955,24 +2996,11 @@ var defineTransactionRequest = defineFormatter({
|
|
2955
2996
|
format: formatTransactionRequest
|
2956
2997
|
});
|
2957
2998
|
|
2958
|
-
// src/utils/errors/assertRequest.ts
|
2959
|
-
function assertRequest(args) {
|
2960
|
-
const { from, maxFeePerGas, maxPriorityFeePerGas, to } = args;
|
2961
|
-
if (from && !isAddress(from))
|
2962
|
-
throw new InvalidAddressError({ address: from });
|
2963
|
-
if (to && !isAddress(to))
|
2964
|
-
throw new InvalidAddressError({ address: to });
|
2965
|
-
if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
|
2966
|
-
throw new FeeCapTooHighError({ maxFeePerGas });
|
2967
|
-
if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
|
2968
|
-
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
2969
|
-
}
|
2970
|
-
|
2971
2999
|
// src/utils/errors/getNodeError.ts
|
2972
3000
|
function containsNodeError(err) {
|
2973
3001
|
return err instanceof TransactionRejectedRpcError || err instanceof InvalidInputRpcError || err instanceof RpcError && err.code === ExecutionRevertedError.code;
|
2974
3002
|
}
|
2975
|
-
function getNodeError(err, args
|
3003
|
+
function getNodeError(err, args) {
|
2976
3004
|
const message = err.details.toLowerCase();
|
2977
3005
|
if (FeeCapTooHighError.nodeMessage.test(message))
|
2978
3006
|
return new FeeCapTooHighError({
|
@@ -3258,124 +3286,1726 @@ var rpc = {
|
|
3258
3286
|
webSocketAsync
|
3259
3287
|
};
|
3260
3288
|
|
3261
|
-
// src/utils/
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
};
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
};
|
3289
|
+
// src/utils/transaction/assertRequest.ts
|
3290
|
+
function assertRequest(args) {
|
3291
|
+
const { account, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
|
3292
|
+
if (account && !isAddress(account.address))
|
3293
|
+
throw new InvalidAddressError({ address: account.address });
|
3294
|
+
if (to && !isAddress(to))
|
3295
|
+
throw new InvalidAddressError({ address: to });
|
3296
|
+
if (typeof gasPrice !== "undefined" && (typeof maxFeePerGas !== "undefined" || typeof maxPriorityFeePerGas !== "undefined"))
|
3297
|
+
throw new FeeConflictError();
|
3298
|
+
if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
|
3299
|
+
throw new FeeCapTooHighError({ maxFeePerGas });
|
3300
|
+
if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
|
3301
|
+
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
3302
|
+
}
|
3274
3303
|
|
3275
|
-
// src/
|
3276
|
-
function
|
3277
|
-
|
3278
|
-
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3304
|
+
// src/actions/public/call.ts
|
3305
|
+
async function call(client, args) {
|
3306
|
+
const {
|
3307
|
+
account,
|
3308
|
+
blockNumber,
|
3309
|
+
blockTag = "latest",
|
3310
|
+
accessList,
|
3311
|
+
data,
|
3312
|
+
gas,
|
3313
|
+
gasPrice,
|
3314
|
+
maxFeePerGas,
|
3315
|
+
maxPriorityFeePerGas,
|
3316
|
+
nonce,
|
3317
|
+
to,
|
3318
|
+
value,
|
3319
|
+
...rest
|
3320
|
+
} = args;
|
3321
|
+
try {
|
3322
|
+
assertRequest(args);
|
3323
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3324
|
+
const formatter = client.chain?.formatters?.transactionRequest;
|
3325
|
+
const request_ = format3(
|
3326
|
+
{
|
3327
|
+
from: account?.address,
|
3328
|
+
accessList,
|
3329
|
+
data,
|
3330
|
+
gas,
|
3331
|
+
gasPrice,
|
3332
|
+
maxFeePerGas,
|
3333
|
+
maxPriorityFeePerGas,
|
3334
|
+
nonce,
|
3335
|
+
to,
|
3336
|
+
value,
|
3337
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
3338
|
+
...extract(rest, { formatter })
|
3339
|
+
},
|
3340
|
+
{
|
3341
|
+
formatter: formatter || formatTransactionRequest
|
3342
|
+
}
|
3343
|
+
);
|
3344
|
+
const response = await client.request({
|
3345
|
+
method: "eth_call",
|
3346
|
+
params: [request_, blockNumberHex || blockTag]
|
3347
|
+
});
|
3348
|
+
if (response === "0x")
|
3349
|
+
return { data: void 0 };
|
3350
|
+
return { data: response };
|
3351
|
+
} catch (err) {
|
3352
|
+
throw getCallError(err, {
|
3353
|
+
...args,
|
3354
|
+
chain: client.chain
|
3355
|
+
});
|
3356
|
+
}
|
3288
3357
|
}
|
3289
3358
|
|
3290
|
-
// src/
|
3291
|
-
function
|
3292
|
-
|
3359
|
+
// src/actions/public/simulateContract.ts
|
3360
|
+
async function simulateContract(client, {
|
3361
|
+
abi,
|
3362
|
+
address,
|
3363
|
+
args,
|
3364
|
+
functionName,
|
3365
|
+
...callRequest
|
3366
|
+
}) {
|
3367
|
+
const calldata = encodeFunctionData({
|
3368
|
+
abi,
|
3369
|
+
args,
|
3370
|
+
functionName
|
3371
|
+
});
|
3372
|
+
try {
|
3373
|
+
const { data } = await call(client, {
|
3374
|
+
data: calldata,
|
3375
|
+
to: address,
|
3376
|
+
...callRequest
|
3377
|
+
});
|
3378
|
+
const result = decodeFunctionResult({
|
3379
|
+
abi,
|
3380
|
+
args,
|
3381
|
+
functionName,
|
3382
|
+
data: data || "0x"
|
3383
|
+
});
|
3384
|
+
return {
|
3385
|
+
result,
|
3386
|
+
request: {
|
3387
|
+
abi,
|
3388
|
+
address,
|
3389
|
+
args,
|
3390
|
+
functionName,
|
3391
|
+
...callRequest
|
3392
|
+
}
|
3393
|
+
};
|
3394
|
+
} catch (err) {
|
3395
|
+
throw getContractError(err, {
|
3396
|
+
abi,
|
3397
|
+
address,
|
3398
|
+
args,
|
3399
|
+
docsPath: "/docs/contract/simulateContract",
|
3400
|
+
functionName,
|
3401
|
+
sender: callRequest.account?.address
|
3402
|
+
});
|
3403
|
+
}
|
3293
3404
|
}
|
3294
3405
|
|
3295
|
-
// src/
|
3296
|
-
function
|
3297
|
-
|
3406
|
+
// src/actions/public/createPendingTransactionFilter.ts
|
3407
|
+
async function createPendingTransactionFilter(client) {
|
3408
|
+
const id2 = await client.request({
|
3409
|
+
method: "eth_newPendingTransactionFilter"
|
3410
|
+
});
|
3411
|
+
return { id: id2, type: "transaction" };
|
3298
3412
|
}
|
3299
3413
|
|
3300
|
-
// src/
|
3301
|
-
function
|
3302
|
-
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3414
|
+
// src/actions/public/createBlockFilter.ts
|
3415
|
+
async function createBlockFilter(client) {
|
3416
|
+
const id2 = await client.request({
|
3417
|
+
method: "eth_newBlockFilter"
|
3418
|
+
});
|
3419
|
+
return { id: id2, type: "block" };
|
3420
|
+
}
|
3421
|
+
|
3422
|
+
// src/actions/public/createEventFilter.ts
|
3423
|
+
async function createEventFilter(client, {
|
3424
|
+
address,
|
3425
|
+
args,
|
3426
|
+
event,
|
3427
|
+
fromBlock,
|
3428
|
+
toBlock
|
3429
|
+
} = {}) {
|
3430
|
+
let topics = [];
|
3431
|
+
if (event)
|
3432
|
+
topics = encodeEventTopics({
|
3433
|
+
abi: [event],
|
3434
|
+
eventName: event.name,
|
3435
|
+
args
|
3436
|
+
});
|
3437
|
+
const id2 = await client.request({
|
3438
|
+
method: "eth_newFilter",
|
3439
|
+
params: [
|
3440
|
+
{
|
3441
|
+
address,
|
3442
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3443
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
3444
|
+
...topics.length ? { topics } : {}
|
3445
|
+
}
|
3446
|
+
]
|
3447
|
+
});
|
3448
|
+
return {
|
3449
|
+
abi: event ? [event] : void 0,
|
3450
|
+
args,
|
3451
|
+
eventName: event ? event.name : void 0,
|
3452
|
+
id: id2,
|
3453
|
+
type: "event"
|
3454
|
+
};
|
3455
|
+
}
|
3456
|
+
|
3457
|
+
// src/actions/public/createContractEventFilter.ts
|
3458
|
+
async function createContractEventFilter(client, {
|
3459
|
+
address,
|
3460
|
+
abi,
|
3461
|
+
args,
|
3462
|
+
eventName,
|
3463
|
+
fromBlock,
|
3464
|
+
toBlock
|
3465
|
+
}) {
|
3466
|
+
const topics = eventName ? encodeEventTopics({
|
3467
|
+
abi,
|
3468
|
+
args,
|
3469
|
+
eventName
|
3470
|
+
}) : void 0;
|
3471
|
+
const id2 = await client.request({
|
3472
|
+
method: "eth_newFilter",
|
3473
|
+
params: [
|
3474
|
+
{
|
3475
|
+
address,
|
3476
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3477
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
3478
|
+
topics
|
3479
|
+
}
|
3480
|
+
]
|
3481
|
+
});
|
3482
|
+
return {
|
3483
|
+
abi,
|
3484
|
+
args,
|
3485
|
+
eventName,
|
3486
|
+
id: id2,
|
3487
|
+
type: "event"
|
3488
|
+
};
|
3489
|
+
}
|
3490
|
+
|
3491
|
+
// src/actions/public/estimateGas.ts
|
3492
|
+
async function estimateGas(client, args) {
|
3493
|
+
try {
|
3494
|
+
const {
|
3495
|
+
account,
|
3496
|
+
accessList,
|
3497
|
+
blockNumber,
|
3498
|
+
blockTag = "latest",
|
3499
|
+
data,
|
3500
|
+
gas,
|
3501
|
+
gasPrice,
|
3502
|
+
maxFeePerGas,
|
3503
|
+
maxPriorityFeePerGas,
|
3504
|
+
nonce,
|
3505
|
+
to,
|
3506
|
+
value,
|
3507
|
+
...rest
|
3508
|
+
} = args.account.type === "externally-owned" ? await prepareRequest(client, args) : args;
|
3509
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3510
|
+
assertRequest(args);
|
3511
|
+
const formatter = client.chain?.formatters?.transactionRequest;
|
3512
|
+
const request = format3(
|
3513
|
+
{
|
3514
|
+
from: account.address,
|
3515
|
+
accessList,
|
3516
|
+
data,
|
3517
|
+
gas,
|
3518
|
+
gasPrice,
|
3519
|
+
maxFeePerGas,
|
3520
|
+
maxPriorityFeePerGas,
|
3521
|
+
nonce,
|
3522
|
+
to,
|
3523
|
+
value,
|
3524
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
3525
|
+
...extract(rest, { formatter })
|
3526
|
+
},
|
3527
|
+
{
|
3528
|
+
formatter: formatter || formatTransactionRequest
|
3529
|
+
}
|
3530
|
+
);
|
3531
|
+
const balance = await client.request({
|
3532
|
+
method: "eth_estimateGas",
|
3533
|
+
params: [request, blockNumberHex || blockTag]
|
3534
|
+
});
|
3535
|
+
return BigInt(balance);
|
3536
|
+
} catch (err) {
|
3537
|
+
throw getEstimateGasError(err, {
|
3538
|
+
...args,
|
3539
|
+
chain: client.chain
|
3540
|
+
});
|
3541
|
+
}
|
3542
|
+
}
|
3543
|
+
|
3544
|
+
// src/actions/public/estimateContractGas.ts
|
3545
|
+
async function estimateContractGas(client, {
|
3546
|
+
abi,
|
3547
|
+
address,
|
3548
|
+
args,
|
3549
|
+
functionName,
|
3550
|
+
...request
|
3551
|
+
}) {
|
3552
|
+
const data = encodeFunctionData({
|
3553
|
+
abi,
|
3554
|
+
args,
|
3555
|
+
functionName
|
3556
|
+
});
|
3557
|
+
try {
|
3558
|
+
const gas = await estimateGas(client, {
|
3559
|
+
data,
|
3560
|
+
to: address,
|
3561
|
+
...request
|
3562
|
+
});
|
3563
|
+
return gas;
|
3564
|
+
} catch (err) {
|
3565
|
+
throw getContractError(err, {
|
3566
|
+
abi,
|
3567
|
+
address,
|
3568
|
+
args,
|
3569
|
+
docsPath: "/docs/contract/simulateContract",
|
3570
|
+
functionName,
|
3571
|
+
sender: request.account?.address
|
3572
|
+
});
|
3573
|
+
}
|
3574
|
+
}
|
3575
|
+
|
3576
|
+
// src/actions/public/getBalance.ts
|
3577
|
+
async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
|
3578
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3579
|
+
const balance = await client.request({
|
3580
|
+
method: "eth_getBalance",
|
3581
|
+
params: [address, blockNumberHex || blockTag]
|
3582
|
+
});
|
3583
|
+
return BigInt(balance);
|
3584
|
+
}
|
3585
|
+
|
3586
|
+
// src/actions/public/getBlock.ts
|
3587
|
+
async function getBlock(client, {
|
3588
|
+
blockHash,
|
3589
|
+
blockNumber,
|
3590
|
+
blockTag = "latest",
|
3591
|
+
includeTransactions = false
|
3592
|
+
} = {}) {
|
3593
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3594
|
+
let block = null;
|
3595
|
+
if (blockHash) {
|
3596
|
+
block = await client.request({
|
3597
|
+
method: "eth_getBlockByHash",
|
3598
|
+
params: [blockHash, includeTransactions]
|
3599
|
+
});
|
3316
3600
|
} else {
|
3317
|
-
|
3601
|
+
block = await client.request({
|
3602
|
+
method: "eth_getBlockByNumber",
|
3603
|
+
params: [blockNumberHex || blockTag, includeTransactions]
|
3604
|
+
});
|
3318
3605
|
}
|
3319
|
-
|
3606
|
+
if (!block)
|
3607
|
+
throw new BlockNotFoundError({ blockHash, blockNumber });
|
3608
|
+
return format3(block, {
|
3609
|
+
formatter: client.chain?.formatters?.block || formatBlock
|
3610
|
+
});
|
3320
3611
|
}
|
3321
3612
|
|
3322
|
-
// src/
|
3323
|
-
|
3324
|
-
|
3613
|
+
// src/actions/public/getBlockNumber.ts
|
3614
|
+
var cacheKey = (id2) => `blockNumber.${id2}`;
|
3615
|
+
function getBlockNumberCache(id2) {
|
3616
|
+
return getCache(cacheKey(id2));
|
3617
|
+
}
|
3618
|
+
async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
|
3619
|
+
const blockNumberHex = await withCache(
|
3620
|
+
() => client.request({
|
3621
|
+
method: "eth_blockNumber"
|
3622
|
+
}),
|
3623
|
+
{ cacheKey: cacheKey(client.uid), maxAge }
|
3624
|
+
);
|
3625
|
+
return BigInt(blockNumberHex);
|
3325
3626
|
}
|
3326
3627
|
|
3327
|
-
// src/
|
3328
|
-
function
|
3329
|
-
|
3628
|
+
// src/actions/public/getBlockTransactionCount.ts
|
3629
|
+
async function getBlockTransactionCount(client, {
|
3630
|
+
blockHash,
|
3631
|
+
blockNumber,
|
3632
|
+
blockTag = "latest"
|
3633
|
+
} = {}) {
|
3634
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3635
|
+
let count = null;
|
3636
|
+
if (blockHash) {
|
3637
|
+
count = await client.request({
|
3638
|
+
method: "eth_getBlockTransactionCountByHash",
|
3639
|
+
params: [blockHash]
|
3640
|
+
});
|
3641
|
+
} else {
|
3642
|
+
count = await client.request({
|
3643
|
+
method: "eth_getBlockTransactionCountByNumber",
|
3644
|
+
params: [blockNumberHex || blockTag]
|
3645
|
+
});
|
3646
|
+
}
|
3647
|
+
return hexToNumber(count);
|
3330
3648
|
}
|
3331
3649
|
|
3332
|
-
|
3333
|
-
|
3334
|
-
|
3335
|
-
|
3336
|
-
|
3337
|
-
|
3338
|
-
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
3345
|
-
|
3346
|
-
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3370
|
-
|
3371
|
-
|
3372
|
-
|
3373
|
-
|
3374
|
-
|
3375
|
-
|
3376
|
-
|
3377
|
-
|
3378
|
-
|
3650
|
+
// src/actions/public/getBytecode.ts
|
3651
|
+
async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
|
3652
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3653
|
+
const hex = await client.request({
|
3654
|
+
method: "eth_getCode",
|
3655
|
+
params: [address, blockNumberHex || blockTag]
|
3656
|
+
});
|
3657
|
+
if (hex === "0x")
|
3658
|
+
return void 0;
|
3659
|
+
return hex;
|
3660
|
+
}
|
3661
|
+
|
3662
|
+
// src/actions/public/getChainId.ts
|
3663
|
+
async function getChainId(client) {
|
3664
|
+
const chainIdHex = await client.request({ method: "eth_chainId" });
|
3665
|
+
return hexToNumber(chainIdHex);
|
3666
|
+
}
|
3667
|
+
|
3668
|
+
// src/actions/public/getFeeHistory.ts
|
3669
|
+
async function getFeeHistory(client, {
|
3670
|
+
blockCount,
|
3671
|
+
blockNumber,
|
3672
|
+
blockTag = "latest",
|
3673
|
+
rewardPercentiles
|
3674
|
+
}) {
|
3675
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3676
|
+
const feeHistory = await client.request({
|
3677
|
+
method: "eth_feeHistory",
|
3678
|
+
params: [
|
3679
|
+
numberToHex(blockCount),
|
3680
|
+
blockNumberHex || blockTag,
|
3681
|
+
rewardPercentiles
|
3682
|
+
]
|
3683
|
+
});
|
3684
|
+
return formatFeeHistory(feeHistory);
|
3685
|
+
}
|
3686
|
+
|
3687
|
+
// src/actions/public/getFilterChanges.ts
|
3688
|
+
async function getFilterChanges(client, { filter }) {
|
3689
|
+
const logs = await client.request({
|
3690
|
+
method: "eth_getFilterChanges",
|
3691
|
+
params: [filter.id]
|
3692
|
+
});
|
3693
|
+
return logs.map((log) => {
|
3694
|
+
if (typeof log === "string")
|
3695
|
+
return log;
|
3696
|
+
const { eventName, args } = "abi" in filter && filter.abi ? decodeEventLog({
|
3697
|
+
abi: filter.abi,
|
3698
|
+
data: log.data,
|
3699
|
+
topics: log.topics
|
3700
|
+
}) : { eventName: void 0, args: void 0 };
|
3701
|
+
return formatLog(log, { args, eventName });
|
3702
|
+
});
|
3703
|
+
}
|
3704
|
+
|
3705
|
+
// src/actions/public/getFilterLogs.ts
|
3706
|
+
async function getFilterLogs(client, { filter }) {
|
3707
|
+
const logs = await client.request({
|
3708
|
+
method: "eth_getFilterLogs",
|
3709
|
+
params: [filter.id]
|
3710
|
+
});
|
3711
|
+
return logs.map((log) => {
|
3712
|
+
const { eventName, args } = "abi" in filter && filter.abi ? decodeEventLog({
|
3713
|
+
abi: filter.abi,
|
3714
|
+
data: log.data,
|
3715
|
+
topics: log.topics
|
3716
|
+
}) : { eventName: void 0, args: void 0 };
|
3717
|
+
return formatLog(log, { args, eventName });
|
3718
|
+
});
|
3719
|
+
}
|
3720
|
+
|
3721
|
+
// src/actions/public/getGasPrice.ts
|
3722
|
+
async function getGasPrice(client) {
|
3723
|
+
const gasPrice = await client.request({
|
3724
|
+
method: "eth_gasPrice"
|
3725
|
+
});
|
3726
|
+
return BigInt(gasPrice);
|
3727
|
+
}
|
3728
|
+
|
3729
|
+
// src/actions/public/getLogs.ts
|
3730
|
+
async function getLogs(client, {
|
3731
|
+
address,
|
3732
|
+
blockHash,
|
3733
|
+
fromBlock,
|
3734
|
+
toBlock,
|
3735
|
+
event,
|
3736
|
+
args
|
3737
|
+
} = {}) {
|
3738
|
+
let topics = [];
|
3739
|
+
if (event)
|
3740
|
+
topics = encodeEventTopics({
|
3741
|
+
abi: [event],
|
3742
|
+
eventName: event.name,
|
3743
|
+
args
|
3744
|
+
});
|
3745
|
+
let logs;
|
3746
|
+
if (blockHash) {
|
3747
|
+
logs = await client.request({
|
3748
|
+
method: "eth_getLogs",
|
3749
|
+
params: [{ address, topics, blockHash }]
|
3750
|
+
});
|
3751
|
+
} else {
|
3752
|
+
logs = await client.request({
|
3753
|
+
method: "eth_getLogs",
|
3754
|
+
params: [
|
3755
|
+
{
|
3756
|
+
address,
|
3757
|
+
topics,
|
3758
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3759
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
|
3760
|
+
}
|
3761
|
+
]
|
3762
|
+
});
|
3763
|
+
}
|
3764
|
+
return logs.map((log) => {
|
3765
|
+
const { eventName, args: args2 } = event ? decodeEventLog({
|
3766
|
+
abi: [event],
|
3767
|
+
data: log.data,
|
3768
|
+
topics: log.topics
|
3769
|
+
}) : { eventName: void 0, args: void 0 };
|
3770
|
+
return formatLog(log, { args: args2, eventName });
|
3771
|
+
});
|
3772
|
+
}
|
3773
|
+
|
3774
|
+
// src/actions/public/getStorageAt.ts
|
3775
|
+
async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
|
3776
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3777
|
+
const data = await client.request({
|
3778
|
+
method: "eth_getStorageAt",
|
3779
|
+
params: [address, slot, blockNumberHex || blockTag]
|
3780
|
+
});
|
3781
|
+
return data;
|
3782
|
+
}
|
3783
|
+
|
3784
|
+
// src/actions/public/getTransaction.ts
|
3785
|
+
async function getTransaction(client, {
|
3786
|
+
blockHash,
|
3787
|
+
blockNumber,
|
3788
|
+
blockTag = "latest",
|
3789
|
+
hash: hash2,
|
3790
|
+
index
|
3791
|
+
}) {
|
3792
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3793
|
+
let transaction = null;
|
3794
|
+
if (hash2) {
|
3795
|
+
transaction = await client.request({
|
3796
|
+
method: "eth_getTransactionByHash",
|
3797
|
+
params: [hash2]
|
3798
|
+
});
|
3799
|
+
} else if (blockHash) {
|
3800
|
+
transaction = await client.request({
|
3801
|
+
method: "eth_getTransactionByBlockHashAndIndex",
|
3802
|
+
params: [blockHash, numberToHex(index)]
|
3803
|
+
});
|
3804
|
+
} else if (blockNumberHex || blockTag) {
|
3805
|
+
transaction = await client.request({
|
3806
|
+
method: "eth_getTransactionByBlockNumberAndIndex",
|
3807
|
+
params: [blockNumberHex || blockTag, numberToHex(index)]
|
3808
|
+
});
|
3809
|
+
}
|
3810
|
+
if (!transaction)
|
3811
|
+
throw new TransactionNotFoundError({
|
3812
|
+
blockHash,
|
3813
|
+
blockNumber,
|
3814
|
+
blockTag,
|
3815
|
+
hash: hash2,
|
3816
|
+
index
|
3817
|
+
});
|
3818
|
+
return format3(transaction, {
|
3819
|
+
formatter: client.chain?.formatters?.transaction || formatTransaction
|
3820
|
+
});
|
3821
|
+
}
|
3822
|
+
|
3823
|
+
// src/actions/public/getTransactionConfirmations.ts
|
3824
|
+
async function getTransactionConfirmations(client, { hash: hash2, transactionReceipt }) {
|
3825
|
+
const [blockNumber, transaction] = await Promise.all([
|
3826
|
+
getBlockNumber(client),
|
3827
|
+
hash2 ? getTransaction(client, { hash: hash2 }) : void 0
|
3828
|
+
]);
|
3829
|
+
const transactionBlockNumber = transactionReceipt?.blockNumber || transaction?.blockNumber;
|
3830
|
+
if (!transactionBlockNumber)
|
3831
|
+
return 0n;
|
3832
|
+
return blockNumber - transactionBlockNumber + 1n;
|
3833
|
+
}
|
3834
|
+
|
3835
|
+
// src/actions/public/getTransactionCount.ts
|
3836
|
+
async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
|
3837
|
+
const count = await client.request({
|
3838
|
+
method: "eth_getTransactionCount",
|
3839
|
+
params: [address, blockNumber ? numberToHex(blockNumber) : blockTag]
|
3840
|
+
});
|
3841
|
+
return hexToNumber(count);
|
3842
|
+
}
|
3843
|
+
|
3844
|
+
// src/actions/public/getTransactionReceipt.ts
|
3845
|
+
async function getTransactionReceipt(client, { hash: hash2 }) {
|
3846
|
+
const receipt = await client.request({
|
3847
|
+
method: "eth_getTransactionReceipt",
|
3848
|
+
params: [hash2]
|
3849
|
+
});
|
3850
|
+
if (!receipt)
|
3851
|
+
throw new TransactionReceiptNotFoundError({ hash: hash2 });
|
3852
|
+
return format3(receipt, {
|
3853
|
+
formatter: client.chain?.formatters?.transactionReceipt || formatTransactionReceipt
|
3854
|
+
});
|
3855
|
+
}
|
3856
|
+
|
3857
|
+
// src/actions/public/readContract.ts
|
3858
|
+
async function readContract(client, {
|
3859
|
+
abi,
|
3860
|
+
address,
|
3861
|
+
args,
|
3862
|
+
functionName,
|
3863
|
+
...callRequest
|
3864
|
+
}) {
|
3865
|
+
const calldata = encodeFunctionData({
|
3866
|
+
abi,
|
3867
|
+
args,
|
3868
|
+
functionName
|
3869
|
+
});
|
3870
|
+
try {
|
3871
|
+
const { data } = await call(client, {
|
3872
|
+
data: calldata,
|
3873
|
+
to: address,
|
3874
|
+
...callRequest
|
3875
|
+
});
|
3876
|
+
return decodeFunctionResult({
|
3877
|
+
abi,
|
3878
|
+
args,
|
3879
|
+
functionName,
|
3880
|
+
data: data || "0x"
|
3881
|
+
});
|
3882
|
+
} catch (err) {
|
3883
|
+
throw getContractError(err, {
|
3884
|
+
abi,
|
3885
|
+
address,
|
3886
|
+
args,
|
3887
|
+
docsPath: "/docs/contract/readContract",
|
3888
|
+
functionName
|
3889
|
+
});
|
3890
|
+
}
|
3891
|
+
}
|
3892
|
+
|
3893
|
+
// src/actions/public/multicall.ts
|
3894
|
+
async function multicall(client, args) {
|
3895
|
+
const {
|
3896
|
+
allowFailure = true,
|
3897
|
+
blockNumber,
|
3898
|
+
blockTag,
|
3899
|
+
contracts,
|
3900
|
+
multicallAddress
|
3901
|
+
} = args;
|
3902
|
+
const calls = contracts.map(({ abi, address, args: args2, functionName }) => {
|
3903
|
+
try {
|
3904
|
+
const callData = encodeFunctionData({
|
3905
|
+
abi,
|
3906
|
+
args: args2,
|
3907
|
+
functionName
|
3908
|
+
});
|
3909
|
+
return {
|
3910
|
+
allowFailure: true,
|
3911
|
+
callData,
|
3912
|
+
target: address
|
3913
|
+
};
|
3914
|
+
} catch (err) {
|
3915
|
+
const error = getContractError(err, {
|
3916
|
+
abi,
|
3917
|
+
address,
|
3918
|
+
args: args2,
|
3919
|
+
docsPath: "/docs/contract/multicall",
|
3920
|
+
functionName
|
3921
|
+
});
|
3922
|
+
if (!allowFailure)
|
3923
|
+
throw error;
|
3924
|
+
return {
|
3925
|
+
allowFailure: true,
|
3926
|
+
callData: "0x",
|
3927
|
+
target: address
|
3928
|
+
};
|
3929
|
+
}
|
3930
|
+
});
|
3931
|
+
const results = await readContract(client, {
|
3932
|
+
abi: multicall3Abi,
|
3933
|
+
address: multicallAddress,
|
3934
|
+
args: [calls],
|
3935
|
+
blockNumber,
|
3936
|
+
blockTag,
|
3937
|
+
functionName: "aggregate3"
|
3938
|
+
});
|
3939
|
+
return results.map(({ returnData, success }, i) => {
|
3940
|
+
const { callData } = calls[i];
|
3941
|
+
const { abi, address, functionName, args: args2 } = contracts[i];
|
3942
|
+
try {
|
3943
|
+
if (callData === "0x")
|
3944
|
+
throw new AbiDecodingZeroDataError();
|
3945
|
+
if (!success)
|
3946
|
+
throw new RawContractError({ data: returnData });
|
3947
|
+
const result = decodeFunctionResult({
|
3948
|
+
abi,
|
3949
|
+
data: returnData,
|
3950
|
+
functionName
|
3951
|
+
});
|
3952
|
+
return { result, status: "success" };
|
3953
|
+
} catch (err) {
|
3954
|
+
const error = getContractError(err, {
|
3955
|
+
abi,
|
3956
|
+
address,
|
3957
|
+
args: args2,
|
3958
|
+
docsPath: "/docs/contract/multicall",
|
3959
|
+
functionName
|
3960
|
+
});
|
3961
|
+
if (!allowFailure)
|
3962
|
+
throw error;
|
3963
|
+
return { error, result: void 0, status: "failure" };
|
3964
|
+
}
|
3965
|
+
});
|
3966
|
+
}
|
3967
|
+
|
3968
|
+
// src/actions/public/uninstallFilter.ts
|
3969
|
+
async function uninstallFilter(client, { filter }) {
|
3970
|
+
return client.request({
|
3971
|
+
method: "eth_uninstallFilter",
|
3972
|
+
params: [filter.id]
|
3973
|
+
});
|
3974
|
+
}
|
3975
|
+
|
3976
|
+
// src/utils/observe.ts
|
3977
|
+
var listenersCache = /* @__PURE__ */ new Map();
|
3978
|
+
var cleanupCache = /* @__PURE__ */ new Map();
|
3979
|
+
var callbackCount = 0;
|
3980
|
+
function observe(observerId, callbacks, fn) {
|
3981
|
+
const callbackId = ++callbackCount;
|
3982
|
+
const getListeners = () => listenersCache.get(observerId) || [];
|
3983
|
+
const unsubscribe = () => {
|
3984
|
+
const listeners2 = getListeners();
|
3985
|
+
listenersCache.set(
|
3986
|
+
observerId,
|
3987
|
+
listeners2.filter((cb) => cb.id !== callbackId)
|
3988
|
+
);
|
3989
|
+
};
|
3990
|
+
const unwatch = () => {
|
3991
|
+
const cleanup2 = cleanupCache.get(observerId);
|
3992
|
+
if (getListeners().length === 1 && cleanup2)
|
3993
|
+
cleanup2();
|
3994
|
+
unsubscribe();
|
3995
|
+
};
|
3996
|
+
const listeners = getListeners();
|
3997
|
+
listenersCache.set(observerId, [
|
3998
|
+
...listeners,
|
3999
|
+
{ id: callbackId, fns: callbacks }
|
4000
|
+
]);
|
4001
|
+
if (listeners && listeners.length > 0)
|
4002
|
+
return unwatch;
|
4003
|
+
let emit = {};
|
4004
|
+
for (const key in callbacks) {
|
4005
|
+
emit[key] = (...args) => {
|
4006
|
+
const listeners2 = getListeners();
|
4007
|
+
if (listeners2.length === 0)
|
4008
|
+
return;
|
4009
|
+
listeners2.forEach((listener) => listener.fns[key]?.(...args));
|
4010
|
+
};
|
4011
|
+
}
|
4012
|
+
const cleanup = fn(emit);
|
4013
|
+
if (typeof cleanup === "function")
|
4014
|
+
cleanupCache.set(observerId, cleanup);
|
4015
|
+
return unwatch;
|
4016
|
+
}
|
4017
|
+
|
4018
|
+
// src/actions/public/waitForTransactionReceipt.ts
|
4019
|
+
async function waitForTransactionReceipt(client, {
|
4020
|
+
confirmations = 1,
|
4021
|
+
hash: hash2,
|
4022
|
+
onReplaced,
|
4023
|
+
pollingInterval = client.pollingInterval,
|
4024
|
+
timeout
|
4025
|
+
}) {
|
4026
|
+
const observerId = JSON.stringify([
|
4027
|
+
"waitForTransactionReceipt",
|
4028
|
+
client.uid,
|
4029
|
+
hash2
|
4030
|
+
]);
|
4031
|
+
let transaction;
|
4032
|
+
let replacedTransaction;
|
4033
|
+
let receipt;
|
4034
|
+
return new Promise((resolve, reject) => {
|
4035
|
+
if (timeout)
|
4036
|
+
setTimeout(
|
4037
|
+
() => reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 })),
|
4038
|
+
timeout
|
4039
|
+
);
|
4040
|
+
const unobserve = observe(
|
4041
|
+
observerId,
|
4042
|
+
{ onReplaced, resolve, reject },
|
4043
|
+
(emit) => {
|
4044
|
+
const unwatch = watchBlockNumber(client, {
|
4045
|
+
emitMissed: true,
|
4046
|
+
emitOnBegin: true,
|
4047
|
+
pollingInterval,
|
4048
|
+
async onBlockNumber(blockNumber) {
|
4049
|
+
const done = async (fn) => {
|
4050
|
+
unwatch();
|
4051
|
+
fn();
|
4052
|
+
unobserve();
|
4053
|
+
};
|
4054
|
+
try {
|
4055
|
+
if (receipt) {
|
4056
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4057
|
+
return;
|
4058
|
+
done(() => emit.resolve(receipt));
|
4059
|
+
return;
|
4060
|
+
}
|
4061
|
+
transaction = await getTransaction(client, { hash: hash2 });
|
4062
|
+
receipt = await getTransactionReceipt(client, { hash: hash2 });
|
4063
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4064
|
+
return;
|
4065
|
+
done(() => emit.resolve(receipt));
|
4066
|
+
} catch (err) {
|
4067
|
+
if (transaction && (err instanceof TransactionNotFoundError || err instanceof TransactionReceiptNotFoundError)) {
|
4068
|
+
replacedTransaction = transaction;
|
4069
|
+
const block = await getBlock(client, {
|
4070
|
+
blockNumber,
|
4071
|
+
includeTransactions: true
|
4072
|
+
});
|
4073
|
+
const replacementTransaction = block.transactions.find(
|
4074
|
+
({ from, nonce }) => from === replacedTransaction.from && nonce === replacedTransaction.nonce
|
4075
|
+
);
|
4076
|
+
if (!replacementTransaction)
|
4077
|
+
return;
|
4078
|
+
receipt = await getTransactionReceipt(client, {
|
4079
|
+
hash: replacementTransaction.hash
|
4080
|
+
});
|
4081
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4082
|
+
return;
|
4083
|
+
let reason = "replaced";
|
4084
|
+
if (replacementTransaction.to === replacedTransaction.to && replacementTransaction.value === replacedTransaction.value) {
|
4085
|
+
reason = "repriced";
|
4086
|
+
} else if (replacementTransaction.from === replacementTransaction.to && replacementTransaction.value === 0n) {
|
4087
|
+
reason = "cancelled";
|
4088
|
+
}
|
4089
|
+
done(() => {
|
4090
|
+
emit.onReplaced?.({
|
4091
|
+
reason,
|
4092
|
+
replacedTransaction,
|
4093
|
+
transaction: replacementTransaction,
|
4094
|
+
transactionReceipt: receipt
|
4095
|
+
});
|
4096
|
+
emit.resolve(receipt);
|
4097
|
+
});
|
4098
|
+
} else {
|
4099
|
+
done(() => emit.reject(err));
|
4100
|
+
}
|
4101
|
+
}
|
4102
|
+
}
|
4103
|
+
});
|
4104
|
+
return unwatch;
|
4105
|
+
}
|
4106
|
+
);
|
4107
|
+
});
|
4108
|
+
}
|
4109
|
+
|
4110
|
+
// src/utils/poll.ts
|
4111
|
+
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
4112
|
+
let active = true;
|
4113
|
+
const unwatch = () => active = false;
|
4114
|
+
const watch = async () => {
|
4115
|
+
let data;
|
4116
|
+
if (emitOnBegin)
|
4117
|
+
data = await fn({ unpoll: unwatch });
|
4118
|
+
const initialWait = await initialWaitTime?.(data) ?? interval;
|
4119
|
+
await wait(initialWait);
|
4120
|
+
const poll2 = async () => {
|
4121
|
+
if (!active)
|
4122
|
+
return;
|
4123
|
+
await fn({ unpoll: unwatch });
|
4124
|
+
await wait(interval);
|
4125
|
+
poll2();
|
4126
|
+
};
|
4127
|
+
poll2();
|
4128
|
+
};
|
4129
|
+
watch();
|
4130
|
+
return unwatch;
|
4131
|
+
}
|
4132
|
+
|
4133
|
+
// src/actions/public/watchBlockNumber.ts
|
4134
|
+
function watchBlockNumber(client, {
|
4135
|
+
emitOnBegin = false,
|
4136
|
+
emitMissed = false,
|
4137
|
+
onBlockNumber,
|
4138
|
+
onError,
|
4139
|
+
pollingInterval = client.pollingInterval
|
4140
|
+
}) {
|
4141
|
+
const observerId = JSON.stringify([
|
4142
|
+
"watchBlockNumber",
|
4143
|
+
client.uid,
|
4144
|
+
emitOnBegin,
|
4145
|
+
emitMissed,
|
4146
|
+
pollingInterval
|
4147
|
+
]);
|
4148
|
+
let prevBlockNumber;
|
4149
|
+
return observe(
|
4150
|
+
observerId,
|
4151
|
+
{ onBlockNumber, onError },
|
4152
|
+
(emit) => poll(
|
4153
|
+
async () => {
|
4154
|
+
try {
|
4155
|
+
const blockNumber = await getBlockNumber(client, { maxAge: 0 });
|
4156
|
+
if (prevBlockNumber) {
|
4157
|
+
if (blockNumber === prevBlockNumber)
|
4158
|
+
return;
|
4159
|
+
if (blockNumber - prevBlockNumber > 1 && emitMissed) {
|
4160
|
+
for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {
|
4161
|
+
emit.onBlockNumber(i, prevBlockNumber);
|
4162
|
+
prevBlockNumber = i;
|
4163
|
+
}
|
4164
|
+
}
|
4165
|
+
}
|
4166
|
+
prevBlockNumber = blockNumber;
|
4167
|
+
emit.onBlockNumber(blockNumber, prevBlockNumber);
|
4168
|
+
} catch (err) {
|
4169
|
+
emit.onError?.(err);
|
4170
|
+
}
|
4171
|
+
},
|
4172
|
+
{
|
4173
|
+
emitOnBegin,
|
4174
|
+
interval: pollingInterval
|
4175
|
+
}
|
4176
|
+
)
|
4177
|
+
);
|
4178
|
+
}
|
4179
|
+
|
4180
|
+
// src/actions/public/watchBlocks.ts
|
4181
|
+
function watchBlocks(client, {
|
4182
|
+
blockTag = "latest",
|
4183
|
+
emitMissed = false,
|
4184
|
+
emitOnBegin = false,
|
4185
|
+
onBlock,
|
4186
|
+
onError,
|
4187
|
+
includeTransactions = false,
|
4188
|
+
pollingInterval = client.pollingInterval
|
4189
|
+
}) {
|
4190
|
+
const observerId = JSON.stringify([
|
4191
|
+
"watchBlocks",
|
4192
|
+
client.uid,
|
4193
|
+
emitMissed,
|
4194
|
+
emitOnBegin,
|
4195
|
+
includeTransactions,
|
4196
|
+
pollingInterval
|
4197
|
+
]);
|
4198
|
+
let prevBlock;
|
4199
|
+
return observe(
|
4200
|
+
observerId,
|
4201
|
+
{ onBlock, onError },
|
4202
|
+
(emit) => poll(
|
4203
|
+
async () => {
|
4204
|
+
try {
|
4205
|
+
const block = await getBlock(client, {
|
4206
|
+
blockTag,
|
4207
|
+
includeTransactions
|
4208
|
+
});
|
4209
|
+
if (block.number && prevBlock?.number) {
|
4210
|
+
if (block.number === prevBlock.number)
|
4211
|
+
return;
|
4212
|
+
if (block.number - prevBlock.number > 1 && emitMissed) {
|
4213
|
+
for (let i = prevBlock?.number + 1n; i < block.number; i++) {
|
4214
|
+
const block2 = await getBlock(client, {
|
4215
|
+
blockNumber: i,
|
4216
|
+
includeTransactions
|
4217
|
+
});
|
4218
|
+
emit.onBlock(block2, prevBlock);
|
4219
|
+
prevBlock = block2;
|
4220
|
+
}
|
4221
|
+
}
|
4222
|
+
}
|
4223
|
+
emit.onBlock(block, prevBlock);
|
4224
|
+
prevBlock = block;
|
4225
|
+
} catch (err) {
|
4226
|
+
emit.onError?.(err);
|
4227
|
+
}
|
4228
|
+
},
|
4229
|
+
{
|
4230
|
+
emitOnBegin,
|
4231
|
+
interval: pollingInterval
|
4232
|
+
}
|
4233
|
+
)
|
4234
|
+
);
|
4235
|
+
}
|
4236
|
+
|
4237
|
+
// src/actions/public/watchContractEvent.ts
|
4238
|
+
function watchContractEvent(client, {
|
4239
|
+
abi,
|
4240
|
+
address,
|
4241
|
+
args,
|
4242
|
+
batch = true,
|
4243
|
+
eventName,
|
4244
|
+
onError,
|
4245
|
+
onLogs,
|
4246
|
+
pollingInterval = client.pollingInterval
|
4247
|
+
}) {
|
4248
|
+
const observerId = JSON.stringify([
|
4249
|
+
"watchContractEvent",
|
4250
|
+
address,
|
4251
|
+
args,
|
4252
|
+
batch,
|
4253
|
+
client.uid,
|
4254
|
+
eventName,
|
4255
|
+
pollingInterval
|
4256
|
+
]);
|
4257
|
+
return observe(observerId, { onLogs, onError }, (emit) => {
|
4258
|
+
let currentBlockNumber;
|
4259
|
+
let filter;
|
4260
|
+
let initialized = false;
|
4261
|
+
const unwatch = poll(
|
4262
|
+
async () => {
|
4263
|
+
if (!initialized) {
|
4264
|
+
try {
|
4265
|
+
filter = await createContractEventFilter(client, {
|
4266
|
+
abi,
|
4267
|
+
address,
|
4268
|
+
args,
|
4269
|
+
eventName
|
4270
|
+
});
|
4271
|
+
} catch {
|
4272
|
+
}
|
4273
|
+
initialized = true;
|
4274
|
+
return;
|
4275
|
+
}
|
4276
|
+
try {
|
4277
|
+
let logs;
|
4278
|
+
if (filter) {
|
4279
|
+
logs = await getFilterChanges(client, { filter });
|
4280
|
+
} else {
|
4281
|
+
const blockNumber = await getBlockNumber(client);
|
4282
|
+
if (currentBlockNumber && currentBlockNumber !== blockNumber) {
|
4283
|
+
logs = await getLogs(client, {
|
4284
|
+
address,
|
4285
|
+
args,
|
4286
|
+
fromBlock: blockNumber,
|
4287
|
+
toBlock: blockNumber,
|
4288
|
+
event: getAbiItem({
|
4289
|
+
abi,
|
4290
|
+
name: eventName
|
4291
|
+
})
|
4292
|
+
});
|
4293
|
+
} else {
|
4294
|
+
logs = [];
|
4295
|
+
}
|
4296
|
+
currentBlockNumber = blockNumber;
|
4297
|
+
}
|
4298
|
+
if (logs.length === 0)
|
4299
|
+
return;
|
4300
|
+
if (batch)
|
4301
|
+
emit.onLogs(logs);
|
4302
|
+
else
|
4303
|
+
logs.forEach((log) => emit.onLogs([log]));
|
4304
|
+
} catch (err) {
|
4305
|
+
emit.onError?.(err);
|
4306
|
+
}
|
4307
|
+
},
|
4308
|
+
{
|
4309
|
+
emitOnBegin: true,
|
4310
|
+
interval: pollingInterval
|
4311
|
+
}
|
4312
|
+
);
|
4313
|
+
return async () => {
|
4314
|
+
if (filter)
|
4315
|
+
await uninstallFilter(client, { filter });
|
4316
|
+
unwatch();
|
4317
|
+
};
|
4318
|
+
});
|
4319
|
+
}
|
4320
|
+
|
4321
|
+
// src/actions/public/watchEvent.ts
|
4322
|
+
function watchEvent(client, {
|
4323
|
+
address,
|
4324
|
+
args,
|
4325
|
+
batch = true,
|
4326
|
+
event,
|
4327
|
+
onError,
|
4328
|
+
onLogs,
|
4329
|
+
pollingInterval = client.pollingInterval
|
4330
|
+
}) {
|
4331
|
+
const observerId = JSON.stringify([
|
4332
|
+
"watchEvent",
|
4333
|
+
address,
|
4334
|
+
args,
|
4335
|
+
batch,
|
4336
|
+
client.uid,
|
4337
|
+
event,
|
4338
|
+
pollingInterval
|
4339
|
+
]);
|
4340
|
+
return observe(observerId, { onLogs, onError }, (emit) => {
|
4341
|
+
let currentBlockNumber;
|
4342
|
+
let filter;
|
4343
|
+
let initialized = false;
|
4344
|
+
const unwatch = poll(
|
4345
|
+
async () => {
|
4346
|
+
if (!initialized) {
|
4347
|
+
try {
|
4348
|
+
filter = await createEventFilter(client, {
|
4349
|
+
address,
|
4350
|
+
args,
|
4351
|
+
event
|
4352
|
+
});
|
4353
|
+
} catch {
|
4354
|
+
}
|
4355
|
+
initialized = true;
|
4356
|
+
return;
|
4357
|
+
}
|
4358
|
+
try {
|
4359
|
+
let logs;
|
4360
|
+
if (filter) {
|
4361
|
+
logs = await getFilterChanges(client, { filter });
|
4362
|
+
} else {
|
4363
|
+
const blockNumber = await getBlockNumber(client);
|
4364
|
+
if (currentBlockNumber && currentBlockNumber !== blockNumber) {
|
4365
|
+
logs = await getLogs(client, {
|
4366
|
+
address,
|
4367
|
+
args,
|
4368
|
+
fromBlock: blockNumber,
|
4369
|
+
toBlock: blockNumber,
|
4370
|
+
event
|
4371
|
+
});
|
4372
|
+
} else {
|
4373
|
+
logs = [];
|
4374
|
+
}
|
4375
|
+
currentBlockNumber = blockNumber;
|
4376
|
+
}
|
4377
|
+
if (logs.length === 0)
|
4378
|
+
return;
|
4379
|
+
if (batch)
|
4380
|
+
emit.onLogs(logs);
|
4381
|
+
else
|
4382
|
+
logs.forEach((log) => emit.onLogs([log]));
|
4383
|
+
} catch (err) {
|
4384
|
+
emit.onError?.(err);
|
4385
|
+
}
|
4386
|
+
},
|
4387
|
+
{
|
4388
|
+
emitOnBegin: true,
|
4389
|
+
interval: pollingInterval
|
4390
|
+
}
|
4391
|
+
);
|
4392
|
+
return async () => {
|
4393
|
+
if (filter)
|
4394
|
+
await uninstallFilter(client, { filter });
|
4395
|
+
unwatch();
|
4396
|
+
};
|
4397
|
+
});
|
4398
|
+
}
|
4399
|
+
|
4400
|
+
// src/actions/public/watchPendingTransactions.ts
|
4401
|
+
function watchPendingTransactions(client, {
|
4402
|
+
batch = true,
|
4403
|
+
onError,
|
4404
|
+
onTransactions,
|
4405
|
+
pollingInterval = client.pollingInterval
|
4406
|
+
}) {
|
4407
|
+
const observerId = JSON.stringify([
|
4408
|
+
"watchPendingTransactions",
|
4409
|
+
client.uid,
|
4410
|
+
batch,
|
4411
|
+
pollingInterval
|
4412
|
+
]);
|
4413
|
+
return observe(observerId, { onTransactions, onError }, (emit) => {
|
4414
|
+
let filter;
|
4415
|
+
const unwatch = poll(
|
4416
|
+
async () => {
|
4417
|
+
try {
|
4418
|
+
if (!filter) {
|
4419
|
+
try {
|
4420
|
+
filter = await createPendingTransactionFilter(client);
|
4421
|
+
return;
|
4422
|
+
} catch (err) {
|
4423
|
+
unwatch();
|
4424
|
+
throw err;
|
4425
|
+
}
|
4426
|
+
}
|
4427
|
+
const hashes = await getFilterChanges(client, { filter });
|
4428
|
+
if (hashes.length === 0)
|
4429
|
+
return;
|
4430
|
+
if (batch)
|
4431
|
+
emit.onTransactions(hashes);
|
4432
|
+
else
|
4433
|
+
hashes.forEach((hash2) => emit.onTransactions([hash2]));
|
4434
|
+
} catch (err) {
|
4435
|
+
emit.onError?.(err);
|
4436
|
+
}
|
4437
|
+
},
|
4438
|
+
{
|
4439
|
+
emitOnBegin: true,
|
4440
|
+
interval: pollingInterval
|
4441
|
+
}
|
4442
|
+
);
|
4443
|
+
return async () => {
|
4444
|
+
if (filter)
|
4445
|
+
await uninstallFilter(client, { filter });
|
4446
|
+
unwatch();
|
4447
|
+
};
|
4448
|
+
});
|
4449
|
+
}
|
4450
|
+
|
4451
|
+
// src/actions/test/dropTransaction.ts
|
4452
|
+
async function dropTransaction(client, { hash: hash2 }) {
|
4453
|
+
return await client.request({
|
4454
|
+
method: `${client.mode}_dropTransaction`,
|
4455
|
+
params: [hash2]
|
4456
|
+
});
|
4457
|
+
}
|
4458
|
+
|
4459
|
+
// src/actions/test/getAutomine.ts
|
4460
|
+
async function getAutomine(client) {
|
4461
|
+
return await client.request({
|
4462
|
+
method: `${client.mode}_getAutomine`
|
4463
|
+
});
|
4464
|
+
}
|
4465
|
+
|
4466
|
+
// src/actions/test/getTxpoolContent.ts
|
4467
|
+
async function getTxpoolContent(client) {
|
4468
|
+
return await client.request({
|
4469
|
+
method: "txpool_content"
|
4470
|
+
});
|
4471
|
+
}
|
4472
|
+
|
4473
|
+
// src/actions/test/getTxpoolStatus.ts
|
4474
|
+
async function getTxpoolStatus(client) {
|
4475
|
+
const { pending, queued } = await client.request({
|
4476
|
+
method: "txpool_status"
|
4477
|
+
});
|
4478
|
+
return {
|
4479
|
+
pending: hexToNumber(pending),
|
4480
|
+
queued: hexToNumber(queued)
|
4481
|
+
};
|
4482
|
+
}
|
4483
|
+
|
4484
|
+
// src/actions/test/impersonateAccount.ts
|
4485
|
+
async function impersonateAccount(client, { address }) {
|
4486
|
+
return await client.request({
|
4487
|
+
method: `${client.mode}_impersonateAccount`,
|
4488
|
+
params: [address]
|
4489
|
+
});
|
4490
|
+
}
|
4491
|
+
|
4492
|
+
// src/actions/test/increaseTime.ts
|
4493
|
+
async function increaseTime(client, { seconds }) {
|
4494
|
+
return await client.request({
|
4495
|
+
method: "evm_increaseTime",
|
4496
|
+
params: [numberToHex(seconds)]
|
4497
|
+
});
|
4498
|
+
}
|
4499
|
+
|
4500
|
+
// src/actions/test/inspectTxpool.ts
|
4501
|
+
async function inspectTxpool(client) {
|
4502
|
+
return await client.request({
|
4503
|
+
method: "txpool_inspect"
|
4504
|
+
});
|
4505
|
+
}
|
4506
|
+
|
4507
|
+
// src/actions/test/mine.ts
|
4508
|
+
async function mine(client, { blocks, interval }) {
|
4509
|
+
return await client.request({
|
4510
|
+
method: `${client.mode}_mine`,
|
4511
|
+
params: [numberToHex(blocks), numberToHex(interval || 0)]
|
4512
|
+
});
|
4513
|
+
}
|
4514
|
+
|
4515
|
+
// src/actions/test/removeBlockTimestampInterval.ts
|
4516
|
+
async function removeBlockTimestampInterval(client) {
|
4517
|
+
return await client.request({
|
4518
|
+
method: `${client.mode}_removeBlockTimestampInterval`
|
4519
|
+
});
|
4520
|
+
}
|
4521
|
+
|
4522
|
+
// src/actions/test/reset.ts
|
4523
|
+
async function reset(client, { blockNumber, jsonRpcUrl } = {}) {
|
4524
|
+
return await client.request({
|
4525
|
+
method: `${client.mode}_reset`,
|
4526
|
+
params: [{ forking: { blockNumber: Number(blockNumber), jsonRpcUrl } }]
|
4527
|
+
});
|
4528
|
+
}
|
4529
|
+
|
4530
|
+
// src/actions/test/revert.ts
|
4531
|
+
async function revert(client, { id: id2 }) {
|
4532
|
+
return await client.request({
|
4533
|
+
method: "evm_revert",
|
4534
|
+
params: [id2]
|
4535
|
+
});
|
4536
|
+
}
|
4537
|
+
|
4538
|
+
// src/actions/test/sendUnsignedTransaction.ts
|
4539
|
+
async function sendUnsignedTransaction(client, request) {
|
4540
|
+
const request_ = formatTransactionRequest(request);
|
4541
|
+
const hash2 = await client.request({
|
4542
|
+
method: "eth_sendUnsignedTransaction",
|
4543
|
+
params: [request_]
|
4544
|
+
});
|
4545
|
+
return hash2;
|
4546
|
+
}
|
4547
|
+
|
4548
|
+
// src/actions/test/setAutomine.ts
|
4549
|
+
async function setAutomine(client, enabled) {
|
4550
|
+
return await client.request({
|
4551
|
+
method: "evm_setAutomine",
|
4552
|
+
params: [enabled]
|
4553
|
+
});
|
4554
|
+
}
|
4555
|
+
|
4556
|
+
// src/actions/test/setBalance.ts
|
4557
|
+
async function setBalance(client, { address, value }) {
|
4558
|
+
return await client.request({
|
4559
|
+
method: `${client.mode}_setBalance`,
|
4560
|
+
params: [address, numberToHex(value)]
|
4561
|
+
});
|
4562
|
+
}
|
4563
|
+
|
4564
|
+
// src/actions/test/setBlockGasLimit.ts
|
4565
|
+
async function setBlockGasLimit(client, { gasLimit }) {
|
4566
|
+
return await client.request({
|
4567
|
+
method: "evm_setBlockGasLimit",
|
4568
|
+
params: [numberToHex(gasLimit)]
|
4569
|
+
});
|
4570
|
+
}
|
4571
|
+
|
4572
|
+
// src/actions/test/setBlockTimestampInterval.ts
|
4573
|
+
async function setBlockTimestampInterval(client, { interval }) {
|
4574
|
+
return await client.request({
|
4575
|
+
method: `${client.mode}_setBlockTimestampInterval`,
|
4576
|
+
params: [interval]
|
4577
|
+
});
|
4578
|
+
}
|
4579
|
+
|
4580
|
+
// src/actions/test/setCode.ts
|
4581
|
+
async function setCode(client, { address, bytecode }) {
|
4582
|
+
return await client.request({
|
4583
|
+
method: `${client.mode}_setCode`,
|
4584
|
+
params: [address, bytecode]
|
4585
|
+
});
|
4586
|
+
}
|
4587
|
+
|
4588
|
+
// src/actions/test/setCoinbase.ts
|
4589
|
+
async function setCoinbase(client, { address }) {
|
4590
|
+
return await client.request({
|
4591
|
+
method: `${client.mode}_setCoinbase`,
|
4592
|
+
params: [address]
|
4593
|
+
});
|
4594
|
+
}
|
4595
|
+
|
4596
|
+
// src/actions/test/setIntervalMining.ts
|
4597
|
+
async function setIntervalMining(client, { interval }) {
|
4598
|
+
return await client.request({
|
4599
|
+
method: "evm_setIntervalMining",
|
4600
|
+
params: [interval]
|
4601
|
+
});
|
4602
|
+
}
|
4603
|
+
|
4604
|
+
// src/actions/test/setLoggingEnabled.ts
|
4605
|
+
async function setLoggingEnabled(client, enabled) {
|
4606
|
+
return await client.request({
|
4607
|
+
method: `${client.mode}_setLoggingEnabled`,
|
4608
|
+
params: [enabled]
|
4609
|
+
});
|
4610
|
+
}
|
4611
|
+
|
4612
|
+
// src/actions/test/setMinGasPrice.ts
|
4613
|
+
async function setMinGasPrice(client, { gasPrice }) {
|
4614
|
+
return await client.request({
|
4615
|
+
method: `${client.mode}_setMinGasPrice`,
|
4616
|
+
params: [numberToHex(gasPrice)]
|
4617
|
+
});
|
4618
|
+
}
|
4619
|
+
|
4620
|
+
// src/actions/test/setNextBlockBaseFeePerGas.ts
|
4621
|
+
async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
4622
|
+
return await client.request({
|
4623
|
+
method: `${client.mode}_setNextBlockBaseFeePerGas`,
|
4624
|
+
params: [numberToHex(baseFeePerGas)]
|
4625
|
+
});
|
4626
|
+
}
|
4627
|
+
|
4628
|
+
// src/actions/test/setNextBlockTimestamp.ts
|
4629
|
+
async function setNextBlockTimestamp(client, { timestamp }) {
|
4630
|
+
return await client.request({
|
4631
|
+
method: "evm_setNextBlockTimestamp",
|
4632
|
+
params: [numberToHex(timestamp)]
|
4633
|
+
});
|
4634
|
+
}
|
4635
|
+
|
4636
|
+
// src/actions/test/setNonce.ts
|
4637
|
+
async function setNonce(client, { address, nonce }) {
|
4638
|
+
return await client.request({
|
4639
|
+
method: `${client.mode}_setNonce`,
|
4640
|
+
params: [address, numberToHex(nonce)]
|
4641
|
+
});
|
4642
|
+
}
|
4643
|
+
|
4644
|
+
// src/actions/test/setRpcUrl.ts
|
4645
|
+
async function setRpcUrl(client, jsonRpcUrl) {
|
4646
|
+
return await client.request({
|
4647
|
+
method: `${client.mode}_setRpcUrl`,
|
4648
|
+
params: [jsonRpcUrl]
|
4649
|
+
});
|
4650
|
+
}
|
4651
|
+
|
4652
|
+
// src/actions/test/setStorageAt.ts
|
4653
|
+
async function setStorageAt(client, { address, index, value }) {
|
4654
|
+
return await client.request({
|
4655
|
+
method: `${client.mode}_setStorageAt`,
|
4656
|
+
params: [
|
4657
|
+
address,
|
4658
|
+
typeof index === "number" ? numberToHex(index) : index,
|
4659
|
+
value
|
4660
|
+
]
|
4661
|
+
});
|
4662
|
+
}
|
4663
|
+
|
4664
|
+
// src/actions/test/snapshot.ts
|
4665
|
+
async function snapshot(client) {
|
4666
|
+
return await client.request({
|
4667
|
+
method: "evm_snapshot"
|
4668
|
+
});
|
4669
|
+
}
|
4670
|
+
|
4671
|
+
// src/actions/test/stopImpersonatingAccount.ts
|
4672
|
+
async function stopImpersonatingAccount(client, { address }) {
|
4673
|
+
return await client.request({
|
4674
|
+
method: `${client.mode}_stopImpersonatingAccount`,
|
4675
|
+
params: [address]
|
4676
|
+
});
|
4677
|
+
}
|
4678
|
+
|
4679
|
+
// src/actions/wallet/addChain.ts
|
4680
|
+
async function addChain(client, { chain }) {
|
4681
|
+
const { id: id2, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
4682
|
+
await client.request({
|
4683
|
+
method: "wallet_addEthereumChain",
|
4684
|
+
params: [
|
4685
|
+
{
|
4686
|
+
chainId: numberToHex(id2),
|
4687
|
+
chainName: name,
|
4688
|
+
nativeCurrency,
|
4689
|
+
rpcUrls: rpcUrls.default.http,
|
4690
|
+
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
4691
|
+
}
|
4692
|
+
]
|
4693
|
+
});
|
4694
|
+
}
|
4695
|
+
|
4696
|
+
// src/actions/wallet/deployContract.ts
|
4697
|
+
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
4698
|
+
const calldata = encodeDeployData({
|
4699
|
+
abi,
|
4700
|
+
args,
|
4701
|
+
bytecode
|
4702
|
+
});
|
4703
|
+
return sendTransaction(walletClient, {
|
4704
|
+
...request,
|
4705
|
+
data: calldata
|
4706
|
+
});
|
4707
|
+
}
|
4708
|
+
|
4709
|
+
// src/actions/wallet/getAddresses.ts
|
4710
|
+
async function getAddresses(client) {
|
4711
|
+
const addresses = await client.request({ method: "eth_accounts" });
|
4712
|
+
return addresses.map((address) => checksumAddress(address));
|
4713
|
+
}
|
4714
|
+
|
4715
|
+
// src/actions/wallet/getPermissions.ts
|
4716
|
+
async function getPermissions(client) {
|
4717
|
+
const permissions = await client.request({ method: "wallet_getPermissions" });
|
4718
|
+
return permissions;
|
4719
|
+
}
|
4720
|
+
|
4721
|
+
// src/actions/wallet/requestAddresses.ts
|
4722
|
+
async function requestAddresses(client) {
|
4723
|
+
const addresses = await client.request({ method: "eth_requestAccounts" });
|
4724
|
+
return addresses.map((address) => getAddress(address));
|
4725
|
+
}
|
4726
|
+
|
4727
|
+
// src/actions/wallet/requestPermissions.ts
|
4728
|
+
async function requestPermissions(client, permissions) {
|
4729
|
+
return client.request({
|
4730
|
+
method: "wallet_requestPermissions",
|
4731
|
+
params: [permissions]
|
4732
|
+
});
|
4733
|
+
}
|
4734
|
+
|
4735
|
+
// src/actions/wallet/sendTransaction.ts
|
4736
|
+
async function sendTransaction(client, args) {
|
4737
|
+
const {
|
4738
|
+
account,
|
4739
|
+
chain,
|
4740
|
+
accessList,
|
4741
|
+
assertChain = true,
|
4742
|
+
data,
|
4743
|
+
gas,
|
4744
|
+
gasPrice,
|
4745
|
+
maxFeePerGas,
|
4746
|
+
maxPriorityFeePerGas,
|
4747
|
+
nonce,
|
4748
|
+
to,
|
4749
|
+
value,
|
4750
|
+
...rest
|
4751
|
+
} = args;
|
4752
|
+
try {
|
4753
|
+
assertRequest(args);
|
4754
|
+
const currentChainId = await getChainId(client);
|
4755
|
+
if (assertChain && chain && currentChainId !== chain?.id)
|
4756
|
+
throw new ChainMismatchError({ chain, currentChainId });
|
4757
|
+
if (account.type === "externally-owned") {
|
4758
|
+
const chainId = chain?.id ?? currentChainId;
|
4759
|
+
const request2 = await prepareRequest(client, {
|
4760
|
+
account,
|
4761
|
+
accessList,
|
4762
|
+
chain,
|
4763
|
+
data,
|
4764
|
+
gas,
|
4765
|
+
gasPrice,
|
4766
|
+
maxFeePerGas,
|
4767
|
+
maxPriorityFeePerGas,
|
4768
|
+
nonce,
|
4769
|
+
to,
|
4770
|
+
value,
|
4771
|
+
...rest
|
4772
|
+
});
|
4773
|
+
const signedRequest = await account.signTransaction({
|
4774
|
+
chainId,
|
4775
|
+
...request2
|
4776
|
+
});
|
4777
|
+
return await client.request({
|
4778
|
+
method: "eth_sendRawTransaction",
|
4779
|
+
params: [signedRequest]
|
4780
|
+
});
|
4781
|
+
}
|
4782
|
+
const formatter = chain?.formatters?.transactionRequest;
|
4783
|
+
const request = format3(
|
4784
|
+
{
|
4785
|
+
accessList,
|
4786
|
+
data,
|
4787
|
+
from: account.address,
|
4788
|
+
gas,
|
4789
|
+
gasPrice,
|
4790
|
+
maxFeePerGas,
|
4791
|
+
maxPriorityFeePerGas,
|
4792
|
+
nonce,
|
4793
|
+
to,
|
4794
|
+
value,
|
4795
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
4796
|
+
...extract(rest, { formatter })
|
4797
|
+
},
|
4798
|
+
{
|
4799
|
+
formatter: formatter || formatTransactionRequest
|
4800
|
+
}
|
4801
|
+
);
|
4802
|
+
return await client.request({
|
4803
|
+
method: "eth_sendTransaction",
|
4804
|
+
params: [request]
|
4805
|
+
});
|
4806
|
+
} catch (err) {
|
4807
|
+
throw getTransactionError(err, args);
|
4808
|
+
}
|
4809
|
+
}
|
4810
|
+
|
4811
|
+
// src/actions/wallet/signMessage.ts
|
4812
|
+
async function signMessage(client, { account, data }) {
|
4813
|
+
if (account.type === "externally-owned")
|
4814
|
+
return account.signMessage(data);
|
4815
|
+
return client.request({
|
4816
|
+
method: "personal_sign",
|
4817
|
+
params: [toHex(data), account.address]
|
4818
|
+
});
|
4819
|
+
}
|
4820
|
+
|
4821
|
+
// src/actions/wallet/switchChain.ts
|
4822
|
+
async function switchChain(client, { id: id2 }) {
|
4823
|
+
await client.request({
|
4824
|
+
method: "wallet_switchEthereumChain",
|
4825
|
+
params: [
|
4826
|
+
{
|
4827
|
+
chainId: numberToHex(id2)
|
4828
|
+
}
|
4829
|
+
]
|
4830
|
+
});
|
4831
|
+
}
|
4832
|
+
|
4833
|
+
// src/actions/wallet/watchAsset.ts
|
4834
|
+
async function watchAsset(client, params) {
|
4835
|
+
const added = await client.request({
|
4836
|
+
method: "wallet_watchAsset",
|
4837
|
+
params: [params]
|
4838
|
+
});
|
4839
|
+
return added;
|
4840
|
+
}
|
4841
|
+
|
4842
|
+
// src/actions/wallet/writeContract.ts
|
4843
|
+
async function writeContract(client, {
|
4844
|
+
abi,
|
4845
|
+
address,
|
4846
|
+
args,
|
4847
|
+
functionName,
|
4848
|
+
...request
|
4849
|
+
}) {
|
4850
|
+
const data = encodeFunctionData({
|
4851
|
+
abi,
|
4852
|
+
args,
|
4853
|
+
functionName
|
4854
|
+
});
|
4855
|
+
const hash2 = await sendTransaction(client, {
|
4856
|
+
data,
|
4857
|
+
to: address,
|
4858
|
+
...request
|
4859
|
+
});
|
4860
|
+
return hash2;
|
4861
|
+
}
|
4862
|
+
|
4863
|
+
// src/utils/unit/parseUnits.ts
|
4864
|
+
function parseUnits(value, decimals) {
|
4865
|
+
let [integer, fraction = "0"] = value.split(".");
|
4866
|
+
const negative = integer.startsWith("-");
|
4867
|
+
if (negative)
|
4868
|
+
integer = integer.slice(1);
|
4869
|
+
fraction = fraction.replace(/(0+)$/, "");
|
4870
|
+
if (decimals === 0) {
|
4871
|
+
integer = `${Math.round(Number(`${integer}.${fraction}`))}`;
|
4872
|
+
fraction = "";
|
4873
|
+
} else if (fraction.length > decimals) {
|
4874
|
+
const [before, after] = [
|
4875
|
+
fraction.slice(0, decimals),
|
4876
|
+
fraction.slice(decimals)
|
4877
|
+
];
|
4878
|
+
fraction = `${/^0+$/.test(before) ? before.slice(0, before.length - 1) : ""}${Math.round(Number(`${before}.${after}`))}`;
|
4879
|
+
} else {
|
4880
|
+
fraction = fraction.padEnd(decimals, "0");
|
4881
|
+
}
|
4882
|
+
return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
|
4883
|
+
}
|
4884
|
+
|
4885
|
+
// src/utils/unit/parseGwei.ts
|
4886
|
+
function parseGwei(ether, unit = "wei") {
|
4887
|
+
return parseUnits(ether, gweiUnits[unit]);
|
4888
|
+
}
|
4889
|
+
|
4890
|
+
// src/utils/transaction/prepareRequest.ts
|
4891
|
+
var defaultTip = parseGwei("1.5");
|
4892
|
+
async function prepareRequest(client, args) {
|
4893
|
+
const { account, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce } = args;
|
4894
|
+
const block = await getBlock(client, { blockTag: "latest" });
|
4895
|
+
const request = { ...args, from: account.address };
|
4896
|
+
if (typeof nonce === "undefined")
|
4897
|
+
request.nonce = await getTransactionCount(client, {
|
4898
|
+
address: account.address,
|
4899
|
+
blockTag: "pending"
|
4900
|
+
});
|
4901
|
+
if (block.baseFeePerGas) {
|
4902
|
+
if (typeof gasPrice !== "undefined")
|
4903
|
+
throw new BaseError("Chain does not support legacy `gasPrice`.");
|
4904
|
+
if (typeof maxFeePerGas === "undefined") {
|
4905
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip;
|
4906
|
+
request.maxFeePerGas = block.baseFeePerGas * 120n / 100n + request.maxPriorityFeePerGas;
|
4907
|
+
} else {
|
4908
|
+
if (typeof maxPriorityFeePerGas === "undefined" && maxFeePerGas < defaultTip)
|
4909
|
+
throw new BaseError(
|
4910
|
+
"`maxFeePerGas` cannot be less than the default `maxPriorityFeePerGas` (1.5 gwei)."
|
4911
|
+
);
|
4912
|
+
request.maxFeePerGas = maxFeePerGas;
|
4913
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip;
|
4914
|
+
}
|
4915
|
+
} else {
|
4916
|
+
if (typeof maxFeePerGas !== "undefined" || typeof maxPriorityFeePerGas !== "undefined")
|
4917
|
+
throw new BaseError("Chain does not support EIP-1559 fees.");
|
4918
|
+
if (typeof gasPrice === "undefined")
|
4919
|
+
request.gasPrice = await getGasPrice(client) * 120n / 100n;
|
4920
|
+
}
|
4921
|
+
if (typeof gas === "undefined")
|
4922
|
+
request.gas = await estimateGas(client, {
|
4923
|
+
...request,
|
4924
|
+
account: { address: account.address, type: "json-rpc" }
|
4925
|
+
});
|
4926
|
+
assertRequest(request);
|
4927
|
+
return request;
|
4928
|
+
}
|
4929
|
+
|
4930
|
+
// src/utils/unit/formatUnits.ts
|
4931
|
+
function formatUnits(value, decimals) {
|
4932
|
+
let display = value.toString();
|
4933
|
+
const negative = display.startsWith("-");
|
4934
|
+
if (negative)
|
4935
|
+
display = display.slice(1);
|
4936
|
+
display = display.padStart(decimals, "0");
|
4937
|
+
let [integer, fraction] = [
|
4938
|
+
display.slice(0, display.length - decimals),
|
4939
|
+
display.slice(display.length - decimals)
|
4940
|
+
];
|
4941
|
+
fraction = fraction.replace(/(0+)$/, "");
|
4942
|
+
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
4943
|
+
}
|
4944
|
+
|
4945
|
+
// src/utils/unit/formatEther.ts
|
4946
|
+
function formatEther(wei, unit = "wei") {
|
4947
|
+
return formatUnits(wei, etherUnits[unit]);
|
4948
|
+
}
|
4949
|
+
|
4950
|
+
// src/utils/unit/formatGwei.ts
|
4951
|
+
function formatGwei(wei, unit = "wei") {
|
4952
|
+
return formatUnits(wei, gweiUnits[unit]);
|
4953
|
+
}
|
4954
|
+
|
4955
|
+
// src/utils/unit/parseEther.ts
|
4956
|
+
function parseEther(ether, unit = "wei") {
|
4957
|
+
return parseUnits(ether, etherUnits[unit]);
|
4958
|
+
}
|
4959
|
+
|
4960
|
+
export {
|
4961
|
+
BaseError,
|
4962
|
+
AbiConstructorNotFoundError,
|
4963
|
+
AbiConstructorParamsNotFoundError,
|
4964
|
+
AbiDecodingDataSizeInvalidError,
|
4965
|
+
AbiDecodingZeroDataError,
|
4966
|
+
AbiEncodingArrayLengthMismatchError,
|
4967
|
+
AbiEncodingLengthMismatchError,
|
4968
|
+
AbiErrorInputsNotFoundError,
|
4969
|
+
AbiErrorNotFoundError,
|
4970
|
+
AbiErrorSignatureNotFoundError,
|
4971
|
+
AbiEventSignatureNotFoundError,
|
4972
|
+
AbiEventNotFoundError,
|
4973
|
+
AbiFunctionNotFoundError,
|
4974
|
+
AbiFunctionOutputsNotFoundError,
|
4975
|
+
AbiFunctionSignatureNotFoundError,
|
4976
|
+
InvalidAbiEncodingTypeError,
|
4977
|
+
InvalidAbiDecodingTypeError,
|
4978
|
+
InvalidArrayError,
|
4979
|
+
InvalidDefinitionTypeError,
|
4980
|
+
InvalidAddressError,
|
4981
|
+
BlockNotFoundError,
|
4982
|
+
ChainDoesNotSupportContract,
|
4983
|
+
multicall3Abi,
|
4984
|
+
panicReasons,
|
4985
|
+
etherUnits,
|
4986
|
+
gweiUnits,
|
4987
|
+
weiUnits,
|
4988
|
+
TransactionExecutionError,
|
4989
|
+
TransactionNotFoundError,
|
4990
|
+
TransactionReceiptNotFoundError,
|
4991
|
+
WaitForTransactionReceiptTimeoutError,
|
4992
|
+
CallExecutionError,
|
4993
|
+
ContractFunctionExecutionError,
|
4994
|
+
ContractFunctionRevertedError,
|
4995
|
+
ContractFunctionZeroDataError,
|
4996
|
+
RawContractError,
|
4997
|
+
SizeExceedsPaddingSizeError,
|
4998
|
+
DataLengthTooLongError,
|
4999
|
+
DataLengthTooShortError,
|
5000
|
+
InvalidBytesBooleanError,
|
5001
|
+
InvalidHexBooleanError,
|
5002
|
+
InvalidHexValueError,
|
5003
|
+
OffsetOutOfBoundsError,
|
5004
|
+
EstimateGasExecutionError,
|
5005
|
+
FilterTypeNotSupportedError,
|
5006
|
+
ExecutionRevertedError,
|
5007
|
+
FeeCapTooHighError,
|
5008
|
+
FeeCapTooLowError,
|
3379
5009
|
NonceTooHighError,
|
3380
5010
|
NonceTooLowError,
|
3381
5011
|
NonceMaxValueError,
|
@@ -3448,7 +5078,6 @@ export {
|
|
3448
5078
|
getEventSelector,
|
3449
5079
|
getFunctionSelector,
|
3450
5080
|
isAddress,
|
3451
|
-
checksumAddress,
|
3452
5081
|
getAddress,
|
3453
5082
|
getContractAddress2 as getContractAddress,
|
3454
5083
|
getCreateAddress,
|
@@ -3468,9 +5097,7 @@ export {
|
|
3468
5097
|
encodeFunctionData,
|
3469
5098
|
encodeFunctionResult,
|
3470
5099
|
formatAbiItemWithArgs,
|
3471
|
-
|
3472
|
-
withCache,
|
3473
|
-
wait,
|
5100
|
+
getAccount,
|
3474
5101
|
isDeterministicError,
|
3475
5102
|
buildRequest,
|
3476
5103
|
defineChain,
|
@@ -3482,13 +5109,9 @@ export {
|
|
3482
5109
|
formatBlock,
|
3483
5110
|
defineBlock,
|
3484
5111
|
extract,
|
3485
|
-
formatFeeHistory,
|
3486
|
-
formatLog,
|
3487
|
-
formatTransactionReceipt,
|
3488
5112
|
defineTransactionReceipt,
|
3489
5113
|
formatTransactionRequest,
|
3490
5114
|
defineTransactionRequest,
|
3491
|
-
assertRequest,
|
3492
5115
|
containsNodeError,
|
3493
5116
|
getNodeError,
|
3494
5117
|
getCallError,
|
@@ -3498,14 +5121,86 @@ export {
|
|
3498
5121
|
stringify,
|
3499
5122
|
getSocket,
|
3500
5123
|
rpc,
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
5124
|
+
assertRequest,
|
5125
|
+
call,
|
5126
|
+
simulateContract,
|
5127
|
+
createPendingTransactionFilter,
|
5128
|
+
createBlockFilter,
|
5129
|
+
createEventFilter,
|
5130
|
+
createContractEventFilter,
|
5131
|
+
estimateGas,
|
5132
|
+
estimateContractGas,
|
5133
|
+
getBalance,
|
5134
|
+
getBlock,
|
5135
|
+
getBlockNumberCache,
|
5136
|
+
getBlockNumber,
|
5137
|
+
getBlockTransactionCount,
|
5138
|
+
getBytecode,
|
5139
|
+
getChainId,
|
5140
|
+
getFeeHistory,
|
5141
|
+
getFilterChanges,
|
5142
|
+
getFilterLogs,
|
5143
|
+
getGasPrice,
|
5144
|
+
getLogs,
|
5145
|
+
getStorageAt,
|
5146
|
+
getTransaction,
|
5147
|
+
getTransactionConfirmations,
|
5148
|
+
getTransactionCount,
|
5149
|
+
getTransactionReceipt,
|
5150
|
+
readContract,
|
5151
|
+
multicall,
|
5152
|
+
uninstallFilter,
|
5153
|
+
waitForTransactionReceipt,
|
5154
|
+
watchBlockNumber,
|
5155
|
+
watchBlocks,
|
5156
|
+
watchContractEvent,
|
5157
|
+
watchEvent,
|
5158
|
+
watchPendingTransactions,
|
5159
|
+
dropTransaction,
|
5160
|
+
getAutomine,
|
5161
|
+
getTxpoolContent,
|
5162
|
+
getTxpoolStatus,
|
5163
|
+
impersonateAccount,
|
5164
|
+
increaseTime,
|
5165
|
+
inspectTxpool,
|
5166
|
+
mine,
|
5167
|
+
removeBlockTimestampInterval,
|
5168
|
+
reset,
|
5169
|
+
revert,
|
5170
|
+
sendUnsignedTransaction,
|
5171
|
+
setAutomine,
|
5172
|
+
setBalance,
|
5173
|
+
setBlockGasLimit,
|
5174
|
+
setBlockTimestampInterval,
|
5175
|
+
setCode,
|
5176
|
+
setCoinbase,
|
5177
|
+
setIntervalMining,
|
5178
|
+
setLoggingEnabled,
|
5179
|
+
setMinGasPrice,
|
5180
|
+
setNextBlockBaseFeePerGas,
|
5181
|
+
setNextBlockTimestamp,
|
5182
|
+
setNonce,
|
5183
|
+
setRpcUrl,
|
5184
|
+
setStorageAt,
|
5185
|
+
snapshot,
|
5186
|
+
stopImpersonatingAccount,
|
5187
|
+
addChain,
|
5188
|
+
deployContract,
|
5189
|
+
getAddresses,
|
5190
|
+
getPermissions,
|
5191
|
+
requestAddresses,
|
5192
|
+
requestPermissions,
|
5193
|
+
sendTransaction,
|
5194
|
+
signMessage,
|
5195
|
+
switchChain,
|
5196
|
+
watchAsset,
|
5197
|
+
writeContract,
|
5198
|
+
parseUnits,
|
5199
|
+
parseGwei,
|
5200
|
+
prepareRequest,
|
5201
|
+
formatUnits,
|
3505
5202
|
formatEther,
|
3506
5203
|
formatGwei,
|
3507
|
-
|
3508
|
-
parseEther,
|
3509
|
-
parseGwei
|
5204
|
+
parseEther
|
3510
5205
|
};
|
3511
|
-
//# sourceMappingURL=chunk-
|
5206
|
+
//# sourceMappingURL=chunk-WVZFIDQ5.mjs.map
|