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
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
3
|
var __publicField = (obj, key, value) => {
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
@@ -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 && `${_optionalChain([chain, 'optionalAccess', _4 => _4.name])} (id: ${_optionalChain([chain, 'optionalAccess', _5 => _5.id])})`,
|
631
|
-
from,
|
656
|
+
from: account.address,
|
632
657
|
to,
|
633
658
|
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _6 => _6.nativeCurrency, 'access', _7 => _7.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,9 +731,9 @@ var CallExecutionError = class extends BaseError {
|
|
706
731
|
value
|
707
732
|
}) {
|
708
733
|
const prettyArgs = prettyPrint({
|
709
|
-
from,
|
734
|
+
from: _optionalChain([account, 'optionalAccess', _8 => _8.address]),
|
710
735
|
to,
|
711
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess',
|
736
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _9 => _9.nativeCurrency, 'access', _10 => _10.symbol]) || "ETH"}`,
|
712
737
|
data,
|
713
738
|
gas,
|
714
739
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
@@ -750,7 +775,7 @@ var ContractFunctionExecutionError = class extends BaseError {
|
|
750
775
|
const prettyArgs = prettyPrint({
|
751
776
|
address: contractAddress && getContractAddress(contractAddress),
|
752
777
|
function: functionWithParams,
|
753
|
-
args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess',
|
778
|
+
args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _11 => _11.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
|
754
779
|
sender
|
755
780
|
});
|
756
781
|
super(
|
@@ -809,7 +834,7 @@ var ContractFunctionRevertedError = class extends BaseError {
|
|
809
834
|
}) : void 0;
|
810
835
|
metaMessages = [
|
811
836
|
errorWithParams ? `Error: ${errorWithParams}` : "",
|
812
|
-
formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess',
|
837
|
+
formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _12 => _12.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
|
813
838
|
];
|
814
839
|
}
|
815
840
|
} else if (message)
|
@@ -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,9 +958,9 @@ 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
|
-
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess',
|
963
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _13 => _13.nativeCurrency, 'access', _14 => _14.symbol]) || "ETH"}`,
|
939
964
|
data,
|
940
965
|
gas,
|
941
966
|
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
@@ -972,7 +997,7 @@ var ExecutionRevertedError = class extends BaseError {
|
|
972
997
|
cause,
|
973
998
|
message
|
974
999
|
} = {}) {
|
975
|
-
const reason = _optionalChain([message, 'optionalAccess',
|
1000
|
+
const reason = _optionalChain([message, 'optionalAccess', _15 => _15.replace, 'call', _16 => _16("execution reverted: ", ""), 'optionalAccess', _17 => _17.replace, 'call', _18 => _18("execution reverted", "")]);
|
976
1001
|
super(
|
977
1002
|
`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
|
978
1003
|
{
|
@@ -1124,7 +1149,7 @@ var TipAboveFeeCapError = class extends BaseError {
|
|
1124
1149
|
__publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
|
1125
1150
|
var UnknownNodeError = class extends BaseError {
|
1126
1151
|
constructor({ cause }) {
|
1127
|
-
super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess',
|
1152
|
+
super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _19 => _19.message])}`, {
|
1128
1153
|
cause
|
1129
1154
|
});
|
1130
1155
|
__publicField(this, "name", "UnknownNodeError");
|
@@ -1769,9 +1794,9 @@ function rlpToBytes(bytes, offset = 0) {
|
|
1769
1794
|
var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
|
1770
1795
|
function extractFunctionParts(def) {
|
1771
1796
|
const parts = def.match(paramsRegex);
|
1772
|
-
const type = _optionalChain([parts, 'optionalAccess',
|
1773
|
-
const name = _optionalChain([parts, 'optionalAccess',
|
1774
|
-
const params = _optionalChain([parts, 'optionalAccess',
|
1797
|
+
const type = _optionalChain([parts, 'optionalAccess', _20 => _20[2]]) || void 0;
|
1798
|
+
const name = _optionalChain([parts, 'optionalAccess', _21 => _21[3]]);
|
1799
|
+
const params = _optionalChain([parts, 'optionalAccess', _22 => _22[5]]) || void 0;
|
1775
1800
|
return { type, name, params };
|
1776
1801
|
}
|
1777
1802
|
function extractFunctionName(def) {
|
@@ -1779,8 +1804,8 @@ function extractFunctionName(def) {
|
|
1779
1804
|
}
|
1780
1805
|
function extractFunctionParams(def) {
|
1781
1806
|
const params = extractFunctionParts(def).params;
|
1782
|
-
const splitParams = _optionalChain([params, 'optionalAccess',
|
1783
|
-
return _optionalChain([splitParams, 'optionalAccess',
|
1807
|
+
const splitParams = _optionalChain([params, 'optionalAccess', _23 => _23.split, 'call', _24 => _24(","), 'access', _25 => _25.map, 'call', _26 => _26((x) => x.trim().split(" "))]);
|
1808
|
+
return _optionalChain([splitParams, 'optionalAccess', _27 => _27.map, 'call', _28 => _28((param) => ({
|
1784
1809
|
type: param[0],
|
1785
1810
|
name: param[1] === "indexed" ? param[2] : param[1],
|
1786
1811
|
...param[1] === "indexed" ? { indexed: true } : {}
|
@@ -2172,7 +2197,7 @@ function decodeArray(data, {
|
|
2172
2197
|
}
|
2173
2198
|
if (hasDynamicChild(param)) {
|
2174
2199
|
const arrayComponents = getArrayComponents(param.type);
|
2175
|
-
const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess',
|
2200
|
+
const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _29 => _29[0]]);
|
2176
2201
|
let consumed2 = 0;
|
2177
2202
|
let value2 = [];
|
2178
2203
|
for (let i = 0; i < length; ++i) {
|
@@ -2244,7 +2269,7 @@ function decodeTuple(data, { param, position }) {
|
|
2244
2269
|
position: consumed
|
2245
2270
|
});
|
2246
2271
|
consumed += decodedChild.consumed;
|
2247
|
-
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess',
|
2272
|
+
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _30 => _30.name])] = decodedChild.value;
|
2248
2273
|
}
|
2249
2274
|
return { consumed: 32, value };
|
2250
2275
|
}
|
@@ -2256,7 +2281,7 @@ function decodeTuple(data, { param, position }) {
|
|
2256
2281
|
position: position + consumed
|
2257
2282
|
});
|
2258
2283
|
consumed += decodedChild.consumed;
|
2259
|
-
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess',
|
2284
|
+
value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _31 => _31.name])] = decodedChild.value;
|
2260
2285
|
}
|
2261
2286
|
return { consumed, value };
|
2262
2287
|
}
|
@@ -2269,7 +2294,7 @@ function hasDynamicChild(param) {
|
|
2269
2294
|
if (type.endsWith("[]"))
|
2270
2295
|
return true;
|
2271
2296
|
if (type === "tuple")
|
2272
|
-
return _optionalChain([param, 'access',
|
2297
|
+
return _optionalChain([param, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.some, 'call', _34 => _34(hasDynamicChild)]);
|
2273
2298
|
const arrayComponents = getArrayComponents(param.type);
|
2274
2299
|
if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
|
2275
2300
|
return true;
|
@@ -2335,7 +2360,7 @@ function decodeEventLog({
|
|
2335
2360
|
docsPath: "/docs/contract/decodeEventLog"
|
2336
2361
|
});
|
2337
2362
|
const { name, inputs } = abiItem;
|
2338
|
-
const isUnnamed = _optionalChain([inputs, 'optionalAccess',
|
2363
|
+
const isUnnamed = _optionalChain([inputs, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((x) => !("name" in x && x.name))]);
|
2339
2364
|
let args = isUnnamed ? [] : {};
|
2340
2365
|
for (let i = 0; i < inputs.length; i++) {
|
2341
2366
|
const param = inputs[i];
|
@@ -2545,8 +2570,8 @@ function encodeEventTopics({ abi, eventName, args }) {
|
|
2545
2570
|
const signature = getEventSelector(definition);
|
2546
2571
|
let topics = [];
|
2547
2572
|
if (args && "inputs" in abiItem) {
|
2548
|
-
const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access',
|
2549
|
-
topics = _nullishCoalesce(_optionalChain([abiItem, 'access',
|
2573
|
+
const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _37 => _37.inputs, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((x) => args[x.name])]), () => ( []));
|
2574
|
+
topics = _nullishCoalesce(_optionalChain([abiItem, 'access', _40 => _40.inputs, 'optionalAccess', _41 => _41.filter, 'call', _42 => _42((param) => "indexed" in param && param.indexed), 'access', _43 => _43.map, 'call', _44 => _44(
|
2550
2575
|
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
2551
2576
|
(_, j) => encodeArg({ param, value: args_[i][j] })
|
2552
2577
|
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
@@ -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();
|
@@ -2718,7 +2758,7 @@ function withTimeout(fn, {
|
|
2718
2758
|
}
|
2719
2759
|
}, timeout);
|
2720
2760
|
}
|
2721
|
-
resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess',
|
2761
|
+
resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _45 => _45.signal]) }));
|
2722
2762
|
} catch (err) {
|
2723
2763
|
if (err.name === "AbortError")
|
2724
2764
|
reject(errorInstance);
|
@@ -2784,8 +2824,8 @@ function buildRequest(request, {
|
|
2784
2824
|
{
|
2785
2825
|
delay: ({ count, error }) => {
|
2786
2826
|
if (error && error instanceof HttpRequestError) {
|
2787
|
-
const retryAfter = _optionalChain([error, 'optionalAccess',
|
2788
|
-
if (_optionalChain([retryAfter, 'optionalAccess',
|
2827
|
+
const retryAfter = _optionalChain([error, 'optionalAccess', _46 => _46.headers, 'optionalAccess', _47 => _47.get, 'call', _48 => _48("Retry-After")]);
|
2828
|
+
if (_optionalChain([retryAfter, 'optionalAccess', _49 => _49.match, 'call', _50 => _50(/\d/)]))
|
2789
2829
|
return parseInt(retryAfter) * 1e3;
|
2790
2830
|
}
|
2791
2831
|
return ~~(1 << count) * retryDelay;
|
@@ -2820,7 +2860,7 @@ function defineFormatter({
|
|
2820
2860
|
}
|
2821
2861
|
return {
|
2822
2862
|
...formatted,
|
2823
|
-
..._optionalChain([formatOverride, 'optionalCall',
|
2863
|
+
..._optionalChain([formatOverride, 'optionalCall', _51 => _51(data)])
|
2824
2864
|
};
|
2825
2865
|
};
|
2826
2866
|
}
|
@@ -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,
|
@@ -2860,7 +2901,7 @@ var defineTransaction = defineFormatter({ format: formatTransaction });
|
|
2860
2901
|
|
2861
2902
|
// src/utils/formatters/block.ts
|
2862
2903
|
function formatBlock(block) {
|
2863
|
-
const transactions = _optionalChain([block, 'access',
|
2904
|
+
const transactions = _optionalChain([block, 'access', _52 => _52.transactions, 'optionalAccess', _53 => _53.map, 'call', _54 => _54((transaction) => {
|
2864
2905
|
if (typeof transaction === "string")
|
2865
2906
|
return transaction;
|
2866
2907
|
return formatTransaction(transaction);
|
@@ -2886,7 +2927,7 @@ function extract(value, { formatter }) {
|
|
2886
2927
|
return {};
|
2887
2928
|
const keys = Object.keys(formatter({}));
|
2888
2929
|
return keys.reduce((data, key) => {
|
2889
|
-
if (_optionalChain([value, 'optionalAccess',
|
2930
|
+
if (_optionalChain([value, 'optionalAccess', _55 => _55.hasOwnProperty, 'call', _56 => _56(key)])) {
|
2890
2931
|
;
|
2891
2932
|
data[key] = value[key];
|
2892
2933
|
}
|
@@ -2900,7 +2941,7 @@ function formatFeeHistory(feeHistory) {
|
|
2900
2941
|
baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
|
2901
2942
|
gasUsedRatio: feeHistory.gasUsedRatio,
|
2902
2943
|
oldestBlock: BigInt(feeHistory.oldestBlock),
|
2903
|
-
reward: _optionalChain([feeHistory, 'access',
|
2944
|
+
reward: _optionalChain([feeHistory, 'access', _57 => _57.reward, 'optionalAccess', _58 => _58.map, 'call', _59 => _59(
|
2904
2945
|
(reward) => reward.map((value) => BigInt(value))
|
2905
2946
|
)])
|
2906
2947
|
};
|
@@ -2955,56 +2996,43 @@ 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({
|
2979
3007
|
cause: err,
|
2980
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3008
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _60 => _60.maxFeePerGas])
|
2981
3009
|
});
|
2982
3010
|
else if (FeeCapTooLowError.nodeMessage.test(message))
|
2983
3011
|
return new FeeCapTooLowError({
|
2984
3012
|
cause: err,
|
2985
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3013
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _61 => _61.maxFeePerGas])
|
2986
3014
|
});
|
2987
3015
|
else if (NonceTooHighError.nodeMessage.test(message))
|
2988
|
-
return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3016
|
+
return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _62 => _62.nonce]) });
|
2989
3017
|
else if (NonceTooLowError.nodeMessage.test(message))
|
2990
|
-
return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3018
|
+
return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _63 => _63.nonce]) });
|
2991
3019
|
else if (NonceMaxValueError.nodeMessage.test(message))
|
2992
|
-
return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess',
|
3020
|
+
return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _64 => _64.nonce]) });
|
2993
3021
|
else if (InsufficientFundsError.nodeMessage.test(message))
|
2994
3022
|
return new InsufficientFundsError({ cause: err });
|
2995
3023
|
else if (IntrinsicGasTooHighError.nodeMessage.test(message))
|
2996
|
-
return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess',
|
3024
|
+
return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _65 => _65.gas]) });
|
2997
3025
|
else if (IntrinsicGasTooLowError.nodeMessage.test(message))
|
2998
|
-
return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess',
|
3026
|
+
return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _66 => _66.gas]) });
|
2999
3027
|
else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
|
3000
3028
|
return new TransactionTypeNotSupportedError({ cause: err });
|
3001
3029
|
else if (TipAboveFeeCapError.nodeMessage.test(message))
|
3002
3030
|
return new TipAboveFeeCapError({
|
3003
3031
|
cause: err,
|
3004
|
-
maxFeePerGas: _optionalChain([args, 'optionalAccess',
|
3005
|
-
maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess',
|
3032
|
+
maxFeePerGas: _optionalChain([args, 'optionalAccess', _67 => _67.maxFeePerGas]),
|
3033
|
+
maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _68 => _68.maxPriorityFeePerGas])
|
3006
3034
|
});
|
3007
|
-
else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access',
|
3035
|
+
else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _69 => _69.cause, 'optionalAccess', _70 => _70.code]) === ExecutionRevertedError.code)
|
3008
3036
|
return new ExecutionRevertedError({
|
3009
3037
|
cause: err,
|
3010
3038
|
message: err.cause.details
|
@@ -3038,7 +3066,7 @@ function getContractError(err, {
|
|
3038
3066
|
functionName,
|
3039
3067
|
sender
|
3040
3068
|
}) {
|
3041
|
-
const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access',
|
3069
|
+
const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access', _71 => _71.cause, 'optionalAccess', _72 => _72.cause, 'optionalAccess', _73 => _73.cause]) || {} : err.cause || {};
|
3042
3070
|
let cause = err;
|
3043
3071
|
if (err instanceof AbiDecodingZeroDataError) {
|
3044
3072
|
cause = new ContractFunctionZeroDataError({ functionName });
|
@@ -3127,7 +3155,7 @@ async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
|
|
3127
3155
|
}
|
3128
3156
|
);
|
3129
3157
|
let data;
|
3130
|
-
if (_optionalChain([response, 'access',
|
3158
|
+
if (_optionalChain([response, 'access', _74 => _74.headers, 'access', _75 => _75.get, 'call', _76 => _76("Content-Type"), 'optionalAccess', _77 => _77.startsWith, 'call', _78 => _78("application/json")])) {
|
3131
3159
|
data = await response.json();
|
3132
3160
|
} else {
|
3133
3161
|
data = await response.text();
|
@@ -3219,15 +3247,15 @@ function webSocket(socket, {
|
|
3219
3247
|
if (typeof message.id === "number" && id_ !== message.id)
|
3220
3248
|
return;
|
3221
3249
|
if (message.error) {
|
3222
|
-
_optionalChain([onError, 'optionalCall',
|
3250
|
+
_optionalChain([onError, 'optionalCall', _79 => _79(new RpcError({ body, error: message.error, url: socket.url }))]);
|
3223
3251
|
} else {
|
3224
|
-
_optionalChain([onData, 'optionalCall',
|
3252
|
+
_optionalChain([onData, 'optionalCall', _80 => _80(message)]);
|
3225
3253
|
}
|
3226
3254
|
if (body.method === "eth_subscribe" && typeof message.result === "string") {
|
3227
3255
|
socket.subscriptions.set(message.result, callback);
|
3228
3256
|
}
|
3229
3257
|
if (body.method === "eth_unsubscribe") {
|
3230
|
-
socket.subscriptions.delete(_optionalChain([body, 'access',
|
3258
|
+
socket.subscriptions.delete(_optionalChain([body, 'access', _81 => _81.params, 'optionalAccess', _82 => _82[0]]));
|
3231
3259
|
}
|
3232
3260
|
};
|
3233
3261
|
socket.requests.set(id_, callback);
|
@@ -3258,77 +3286,1744 @@ 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 = _optionalChain([client, 'access', _83 => _83.chain, 'optionalAccess', _84 => _84.formatters, 'optionalAccess', _85 => _85.transactionRequest]);
|
3325
|
+
const request_ = format3(
|
3326
|
+
{
|
3327
|
+
from: _optionalChain([account, 'optionalAccess', _86 => _86.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: _optionalChain([callRequest, 'access', _87 => _87.account, 'optionalAccess', _88 => _88.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 = _optionalChain([client, 'access', _89 => _89.chain, 'optionalAccess', _90 => _90.formatters, 'optionalAccess', _91 => _91.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: _optionalChain([request, 'access', _92 => _92.account, 'optionalAccess', _93 => _93.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: _optionalChain([client, 'access', _94 => _94.chain, 'optionalAccess', _95 => _95.formatters, 'optionalAccess', _96 => _96.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);
|
3648
|
+
}
|
3649
|
+
|
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;
|
3330
3782
|
}
|
3331
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: _optionalChain([client, 'access', _97 => _97.chain, 'optionalAccess', _98 => _98.formatters, 'optionalAccess', _99 => _99.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 = _optionalChain([transactionReceipt, 'optionalAccess', _100 => _100.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _101 => _101.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: _optionalChain([client, 'access', _102 => _102.chain, 'optionalAccess', _103 => _103.formatters, 'optionalAccess', _104 => _104.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) => _optionalChain([listener, 'access', _105 => _105.fns, 'access', _106 => _106[key], 'optionalCall', _107 => _107(...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
|
+
_optionalChain([emit, 'access', _108 => _108.onReplaced, 'optionalCall', _109 => _109({
|
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 _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _110 => _110(data)]), async () => ( 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
|
+
_optionalChain([emit, 'access', _111 => _111.onError, 'optionalCall', _112 => _112(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 && _optionalChain([prevBlock, 'optionalAccess', _113 => _113.number])) {
|
4210
|
+
if (block.number === prevBlock.number)
|
4211
|
+
return;
|
4212
|
+
if (block.number - prevBlock.number > 1 && emitMissed) {
|
4213
|
+
for (let i = _optionalChain([prevBlock, 'optionalAccess', _114 => _114.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
|
+
_optionalChain([emit, 'access', _115 => _115.onError, 'optionalCall', _116 => _116(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 (e) {
|
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
|
+
_optionalChain([emit, 'access', _117 => _117.onError, 'optionalCall', _118 => _118(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 (e2) {
|
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
|
+
_optionalChain([emit, 'access', _119 => _119.onError, 'optionalCall', _120 => _120(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
|
+
_optionalChain([emit, 'access', _121 => _121.onError, 'optionalCall', _122 => _122(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 !== _optionalChain([chain, 'optionalAccess', _123 => _123.id]))
|
4756
|
+
throw new ChainMismatchError({ chain, currentChainId });
|
4757
|
+
if (account.type === "externally-owned") {
|
4758
|
+
const chainId = _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _124 => _124.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 = _optionalChain([chain, 'optionalAccess', _125 => _125.formatters, 'optionalAccess', _126 => _126.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 = _nullishCoalesce(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 = _nullishCoalesce(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
|
+
|
4961
|
+
|
4962
|
+
|
4963
|
+
|
4964
|
+
|
4965
|
+
|
4966
|
+
|
4967
|
+
|
4968
|
+
|
4969
|
+
|
4970
|
+
|
4971
|
+
|
4972
|
+
|
4973
|
+
|
4974
|
+
|
4975
|
+
|
4976
|
+
|
4977
|
+
|
4978
|
+
|
4979
|
+
|
4980
|
+
|
4981
|
+
|
4982
|
+
|
4983
|
+
|
4984
|
+
|
4985
|
+
|
4986
|
+
|
4987
|
+
|
4988
|
+
|
4989
|
+
|
4990
|
+
|
4991
|
+
|
4992
|
+
|
4993
|
+
|
4994
|
+
|
4995
|
+
|
4996
|
+
|
4997
|
+
|
4998
|
+
|
4999
|
+
|
5000
|
+
|
5001
|
+
|
5002
|
+
|
5003
|
+
|
5004
|
+
|
5005
|
+
|
5006
|
+
|
5007
|
+
|
5008
|
+
|
5009
|
+
|
5010
|
+
|
5011
|
+
|
5012
|
+
|
5013
|
+
|
5014
|
+
|
5015
|
+
|
5016
|
+
|
5017
|
+
|
5018
|
+
|
5019
|
+
|
5020
|
+
|
5021
|
+
|
5022
|
+
|
5023
|
+
|
5024
|
+
|
5025
|
+
|
5026
|
+
|
3332
5027
|
|
3333
5028
|
|
3334
5029
|
|
@@ -3507,5 +5202,5 @@ function parseGwei(ether, unit = "wei") {
|
|
3507
5202
|
|
3508
5203
|
|
3509
5204
|
|
3510
|
-
exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.ChainMismatchError = ChainMismatchError; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.TransactionExecutionError = TransactionExecutionError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.CallExecutionError = CallExecutionError; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.EstimateGasExecutionError = EstimateGasExecutionError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.ExecutionRevertedError = ExecutionRevertedError; exports.FeeCapTooHighError = FeeCapTooHighError; exports.FeeCapTooLowError = FeeCapTooLowError; exports.NonceTooHighError = NonceTooHighError; exports.NonceTooLowError = NonceTooLowError; exports.NonceMaxValueError = NonceMaxValueError; exports.InsufficientFundsError = InsufficientFundsError; exports.IntrinsicGasTooHighError = IntrinsicGasTooHighError; exports.IntrinsicGasTooLowError = IntrinsicGasTooLowError; exports.TransactionTypeNotSupportedError = TransactionTypeNotSupportedError; exports.TipAboveFeeCapError = TipAboveFeeCapError; exports.UnknownNodeError = UnknownNodeError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.SwitchChainError = SwitchChainError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.UrlRequiredError = UrlRequiredError; exports.concat = concat; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.toHex = toHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.toBytes = toBytes; exports.boolToBytes = boolToBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.toRlp = toRlp; exports.fromHex = fromHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.fromBytes = fromBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.fromRlp = fromRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.keccak256 = keccak256; exports.getEventSelector = getEventSelector; exports.getFunctionSelector = getFunctionSelector; exports.isAddress = isAddress; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddressEqual = isAddressEqual; exports.encodeAbiParameters = encodeAbiParameters; exports.decodeAbiParameters = decodeAbiParameters; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.formatFeeHistory = formatFeeHistory; exports.formatLog = formatLog; exports.formatTransactionReceipt = formatTransactionReceipt; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.assertRequest = assertRequest; exports.containsNodeError = containsNodeError; exports.getNodeError = getNodeError; exports.getCallError = getCallError; exports.getContractError = getContractError; exports.getEstimateGasError = getEstimateGasError; exports.getTransactionError = getTransactionError; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseUnit = parseUnit; exports.parseEther = parseEther; exports.parseGwei = parseGwei;
|
3511
|
-
//# sourceMappingURL=chunk-
|
5205
|
+
exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiDecodingZeroDataError = AbiDecodingZeroDataError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.TransactionExecutionError = TransactionExecutionError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.CallExecutionError = CallExecutionError; exports.ContractFunctionExecutionError = ContractFunctionExecutionError; exports.ContractFunctionRevertedError = ContractFunctionRevertedError; exports.ContractFunctionZeroDataError = ContractFunctionZeroDataError; exports.RawContractError = RawContractError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.EstimateGasExecutionError = EstimateGasExecutionError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.ExecutionRevertedError = ExecutionRevertedError; exports.FeeCapTooHighError = FeeCapTooHighError; exports.FeeCapTooLowError = FeeCapTooLowError; exports.NonceTooHighError = NonceTooHighError; exports.NonceTooLowError = NonceTooLowError; exports.NonceMaxValueError = NonceMaxValueError; exports.InsufficientFundsError = InsufficientFundsError; exports.IntrinsicGasTooHighError = IntrinsicGasTooHighError; exports.IntrinsicGasTooLowError = IntrinsicGasTooLowError; exports.TransactionTypeNotSupportedError = TransactionTypeNotSupportedError; exports.TipAboveFeeCapError = TipAboveFeeCapError; exports.UnknownNodeError = UnknownNodeError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UserRejectedRequestError = UserRejectedRequestError; exports.SwitchChainError = SwitchChainError; exports.UnknownRpcError = UnknownRpcError; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.UrlRequiredError = UrlRequiredError; exports.concat = concat; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.toHex = toHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.toBytes = toBytes; exports.boolToBytes = boolToBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.toRlp = toRlp; exports.fromHex = fromHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.fromBytes = fromBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.fromRlp = fromRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.keccak256 = keccak256; exports.getEventSelector = getEventSelector; exports.getFunctionSelector = getFunctionSelector; exports.isAddress = isAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddressEqual = isAddressEqual; exports.encodeAbiParameters = encodeAbiParameters; exports.decodeAbiParameters = decodeAbiParameters; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.getAccount = getAccount; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.format = format3; exports.defineFormatter = defineFormatter; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.defineTransaction = defineTransaction; exports.formatBlock = formatBlock; exports.defineBlock = defineBlock; exports.extract = extract; exports.defineTransactionReceipt = defineTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.defineTransactionRequest = defineTransactionRequest; exports.containsNodeError = containsNodeError; exports.getNodeError = getNodeError; exports.getCallError = getCallError; exports.getContractError = getContractError; exports.getEstimateGasError = getEstimateGasError; exports.getTransactionError = getTransactionError; exports.stringify = stringify; exports.getSocket = getSocket; exports.rpc = rpc; exports.assertRequest = assertRequest; exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.estimateGas = estimateGas; exports.estimateContractGas = estimateContractGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.multicall = multicall; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchContractEvent = watchContractEvent; exports.watchEvent = watchEvent; 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.setRpcUrl = setRpcUrl; exports.setStorageAt = setStorageAt; exports.snapshot = snapshot; exports.stopImpersonatingAccount = stopImpersonatingAccount; exports.addChain = addChain; exports.deployContract = deployContract; exports.getAddresses = getAddresses; exports.getPermissions = getPermissions; exports.requestAddresses = requestAddresses; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract; exports.parseUnits = parseUnits; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.formatUnits = formatUnits; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther;
|
5206
|
+
//# sourceMappingURL=chunk-534U2FZG.js.map
|