viem 0.0.1-alpha.34 → 0.0.1-alpha.36

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.
Files changed (71) hide show
  1. package/README.md +132 -0
  2. package/abi/package.json +4 -0
  3. package/dist/abi.d.ts +5 -0
  4. package/dist/abi.js +11 -0
  5. package/dist/abi.js.map +1 -0
  6. package/dist/abi.mjs +11 -0
  7. package/dist/abi.mjs.map +1 -0
  8. package/dist/{chain-4a0d4164.d.ts → chain-a34aa9a2.d.ts} +65 -63
  9. package/dist/{chain-ce6e149c.d.ts → chain-b1229232.d.ts} +1 -1
  10. package/dist/chains.d.ts +3 -3
  11. package/dist/chains.js +46 -46
  12. package/dist/chains.mjs +1 -1
  13. package/dist/{chunk-EJEZIHXK.js → chunk-4AEFOF5R.js} +21 -23
  14. package/dist/chunk-4AEFOF5R.js.map +1 -0
  15. package/dist/{chunk-VP57P6CD.mjs → chunk-AXATFOBJ.mjs} +1885 -146
  16. package/dist/chunk-AXATFOBJ.mjs.map +1 -0
  17. package/dist/{chunk-KQQLLKZV.mjs → chunk-CUT73KXY.mjs} +3 -5
  18. package/dist/{chunk-KQQLLKZV.mjs.map → chunk-CUT73KXY.mjs.map} +1 -1
  19. package/dist/{chunk-F76TECTY.js → chunk-KXGQFW2R.js} +1907 -168
  20. package/dist/chunk-KXGQFW2R.js.map +1 -0
  21. package/dist/contract.d.ts +7 -8
  22. package/dist/contract.js +2 -6
  23. package/dist/contract.mjs +15 -19
  24. package/dist/{createClient-8a8b4bf4.d.ts → createClient-8024655d.d.ts} +3 -11
  25. package/dist/{createPublicClient-b5afe6b8.d.ts → createPublicClient-f283b09d.d.ts} +155 -39
  26. package/dist/{eip1193-8c021438.d.ts → eip1193-a4f254d2.d.ts} +12 -2
  27. package/dist/{getAbiItem-d7aa40b1.d.ts → encodeFunctionResult-c3d6c7ea.d.ts} +3 -25
  28. package/dist/ens.d.ts +4 -5
  29. package/dist/ens.js +3 -4
  30. package/dist/ens.js.map +1 -1
  31. package/dist/ens.mjs +2 -3
  32. package/dist/ens.mjs.map +1 -1
  33. package/dist/{formatAbiItem-6e00e5e6.d.ts → formatAbiItem-d79cb207.d.ts} +1 -1
  34. package/dist/getAbiItem-48e793da.d.ts +22 -0
  35. package/dist/index.d.ts +27 -17
  36. package/dist/index.js +89 -92
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +85 -88
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/{parseGwei-ce3a9dfa.d.ts → parseGwei-5dc2744d.d.ts} +11 -23
  41. package/dist/public.d.ts +6 -7
  42. package/dist/public.js +2 -3
  43. package/dist/public.mjs +1 -2
  44. package/dist/{test-5d5828c9.d.ts → test-f8bc2fa7.d.ts} +9 -17
  45. package/dist/test.d.ts +5 -5
  46. package/dist/test.js +2 -3
  47. package/dist/test.mjs +1 -2
  48. package/dist/utils/index.d.ts +27 -18
  49. package/dist/utils/index.js +2 -4
  50. package/dist/utils/index.mjs +11 -13
  51. package/dist/wallet.d.ts +5 -5
  52. package/dist/wallet.js +2 -3
  53. package/dist/wallet.mjs +5 -6
  54. package/dist/window.d.ts +2 -2
  55. package/package.json +8 -2
  56. package/dist/chunk-7ALCXZ5K.js +0 -1216
  57. package/dist/chunk-7ALCXZ5K.js.map +0 -1
  58. package/dist/chunk-EBLS4P77.js +0 -265
  59. package/dist/chunk-EBLS4P77.js.map +0 -1
  60. package/dist/chunk-EJEZIHXK.js.map +0 -1
  61. package/dist/chunk-F76TECTY.js.map +0 -1
  62. package/dist/chunk-IUCGWGPX.js +0 -197
  63. package/dist/chunk-IUCGWGPX.js.map +0 -1
  64. package/dist/chunk-NMET3ZHG.mjs +0 -265
  65. package/dist/chunk-NMET3ZHG.mjs.map +0 -1
  66. package/dist/chunk-TNN5X44H.mjs +0 -197
  67. package/dist/chunk-TNN5X44H.mjs.map +0 -1
  68. package/dist/chunk-VHZHROXW.mjs +0 -1216
  69. package/dist/chunk-VHZHROXW.mjs.map +0 -1
  70. package/dist/chunk-VP57P6CD.mjs.map +0 -1
  71. package/dist/wallet-5ab86528.d.ts +0 -115
@@ -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.34",
12
+ version: "0.0.1-alpha.36",
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",
@@ -40,6 +40,7 @@ var package_default = {
40
40
  tsup: {
41
41
  entry: [
42
42
  "src/index.ts",
43
+ "src/abi.ts",
43
44
  "src/chains.ts",
44
45
  "src/contract.ts",
45
46
  "src/ens.ts",
@@ -51,6 +52,7 @@ var package_default = {
51
52
  ]
52
53
  },
53
54
  files: [
55
+ "/abi",
54
56
  "/dist",
55
57
  "/chains",
56
58
  "/contract",
@@ -67,6 +69,11 @@ var package_default = {
67
69
  module: "./dist/index.mts",
68
70
  default: "./dist/index.js"
69
71
  },
72
+ "./abi": {
73
+ types: "./dist/abi.d.ts",
74
+ module: "./dist/abi.mts",
75
+ default: "./dist/abi.js"
76
+ },
70
77
  "./chains": {
71
78
  types: "./dist/chains.d.ts",
72
79
  module: "./dist/chains.mts",
@@ -116,7 +123,7 @@ var package_default = {
116
123
  dependencies: {
117
124
  "@noble/hashes": "^1.1.2",
118
125
  "@wagmi/chains": "~0.2.8",
119
- abitype: "~0.3.0",
126
+ abitype: "~0.5.0",
120
127
  "idna-uts46-hx": "^4.1.2",
121
128
  "isomorphic-ws": "^5.0.0",
122
129
  ws: "^8.12.0"
@@ -268,6 +275,16 @@ var AbiEncodingArrayLengthMismatchError = class extends BaseError {
268
275
  __publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
269
276
  }
270
277
  };
278
+ var AbiEncodingBytesSizeMismatchError = class extends BaseError {
279
+ constructor({ expectedSize, value }) {
280
+ super(
281
+ `Size of bytes "${value}" (bytes${size(
282
+ value
283
+ )}) does not match expected size (bytes${expectedSize}).`
284
+ );
285
+ __publicField(this, "name", "AbiEncodingBytesSizeMismatchError");
286
+ }
287
+ };
271
288
  var AbiEncodingLengthMismatchError = class extends BaseError {
272
289
  constructor({
273
290
  expectedLength,
@@ -489,6 +506,23 @@ var ChainDoesNotSupportContract = class extends BaseError {
489
506
  __publicField(this, "name", "ChainDoesNotSupportContract");
490
507
  }
491
508
  };
509
+ var ChainMismatchError = class extends BaseError {
510
+ constructor({
511
+ chain,
512
+ currentChainId
513
+ }) {
514
+ super(
515
+ `The current chain (id: ${currentChainId}) does not match the chain passed to the request (id: ${chain.id} \u2013 ${chain.name}).`,
516
+ {
517
+ metaMessages: [
518
+ `Current Chain ID: ${currentChainId}`,
519
+ `Expected Chain ID: ${chain.id} \u2013 ${chain.name}`
520
+ ]
521
+ }
522
+ );
523
+ __publicField(this, "name", "ChainMismatchError");
524
+ }
525
+ };
492
526
 
493
527
  // src/constants/abis.ts
494
528
  var multicall3Abi = [
@@ -568,6 +602,20 @@ var solidityPanic = {
568
602
  type: "error"
569
603
  };
570
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
+
571
619
  // src/errors/transaction.ts
572
620
  function prettyPrint(args) {
573
621
  const entries = Object.entries(args).map(([key, value]) => {
@@ -578,10 +626,21 @@ function prettyPrint(args) {
578
626
  const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
579
627
  return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
580
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
+ };
581
640
  var TransactionExecutionError = class extends BaseError {
582
641
  constructor(cause, {
642
+ account,
583
643
  docsPath: docsPath5,
584
- from,
585
644
  chain,
586
645
  data,
587
646
  gas,
@@ -593,9 +652,10 @@ var TransactionExecutionError = class extends BaseError {
593
652
  value
594
653
  }) {
595
654
  const prettyArgs = prettyPrint({
596
- from,
655
+ chain: chain && `${_optionalChain([chain, 'optionalAccess', _4 => _4.name])} (id: ${_optionalChain([chain, 'optionalAccess', _5 => _5.id])})`,
656
+ from: account.address,
597
657
  to,
598
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _4 => _4.nativeCurrency, 'access', _5 => _5.symbol]) || "ETH"}`,
658
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _6 => _6.nativeCurrency, 'access', _7 => _7.symbol]) || "ETH"}`,
599
659
  data,
600
660
  gas,
601
661
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -658,8 +718,8 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
658
718
  // src/errors/contract.ts
659
719
  var CallExecutionError = class extends BaseError {
660
720
  constructor(cause, {
721
+ account,
661
722
  docsPath: docsPath5,
662
- from,
663
723
  chain,
664
724
  data,
665
725
  gas,
@@ -671,9 +731,9 @@ var CallExecutionError = class extends BaseError {
671
731
  value
672
732
  }) {
673
733
  const prettyArgs = prettyPrint({
674
- from,
734
+ from: _optionalChain([account, 'optionalAccess', _8 => _8.address]),
675
735
  to,
676
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _6 => _6.nativeCurrency, 'access', _7 => _7.symbol]) || "ETH"}`,
736
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _9 => _9.nativeCurrency, 'access', _10 => _10.symbol]) || "ETH"}`,
677
737
  data,
678
738
  gas,
679
739
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -715,7 +775,7 @@ var ContractFunctionExecutionError = class extends BaseError {
715
775
  const prettyArgs = prettyPrint({
716
776
  address: contractAddress && getContractAddress(contractAddress),
717
777
  function: functionWithParams,
718
- args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _8 => _8.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
778
+ args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _11 => _11.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
719
779
  sender
720
780
  });
721
781
  super(
@@ -774,7 +834,7 @@ var ContractFunctionRevertedError = class extends BaseError {
774
834
  }) : void 0;
775
835
  metaMessages = [
776
836
  errorWithParams ? `Error: ${errorWithParams}` : "",
777
- formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _9 => _9.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
837
+ formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _12 => _12.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
778
838
  ];
779
839
  }
780
840
  } else if (message)
@@ -885,8 +945,8 @@ var OffsetOutOfBoundsError = class extends BaseError {
885
945
  // src/errors/estimateGas.ts
886
946
  var EstimateGasExecutionError = class extends BaseError {
887
947
  constructor(cause, {
948
+ account,
888
949
  docsPath: docsPath5,
889
- from,
890
950
  chain,
891
951
  data,
892
952
  gas,
@@ -898,9 +958,9 @@ var EstimateGasExecutionError = class extends BaseError {
898
958
  value
899
959
  }) {
900
960
  const prettyArgs = prettyPrint({
901
- from,
961
+ from: account.address,
902
962
  to,
903
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _10 => _10.nativeCurrency, 'access', _11 => _11.symbol]) || "ETH"}`,
963
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _13 => _13.nativeCurrency, 'access', _14 => _14.symbol]) || "ETH"}`,
904
964
  data,
905
965
  gas,
906
966
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -937,7 +997,7 @@ var ExecutionRevertedError = class extends BaseError {
937
997
  cause,
938
998
  message
939
999
  } = {}) {
940
- const reason = _optionalChain([message, 'optionalAccess', _12 => _12.replace, 'call', _13 => _13("execution reverted: ", ""), 'optionalAccess', _14 => _14.replace, 'call', _15 => _15("execution reverted", "")]);
1000
+ const reason = _optionalChain([message, 'optionalAccess', _15 => _15.replace, 'call', _16 => _16("execution reverted: ", ""), 'optionalAccess', _17 => _17.replace, 'call', _18 => _18("execution reverted", "")]);
941
1001
  super(
942
1002
  `Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
943
1003
  {
@@ -1089,7 +1149,7 @@ var TipAboveFeeCapError = class extends BaseError {
1089
1149
  __publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
1090
1150
  var UnknownNodeError = class extends BaseError {
1091
1151
  constructor({ cause }) {
1092
- super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _16 => _16.message])}`, {
1152
+ super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _19 => _19.message])}`, {
1093
1153
  cause
1094
1154
  });
1095
1155
  __publicField(this, "name", "UnknownNodeError");
@@ -1517,11 +1577,6 @@ function stringToHex(value) {
1517
1577
 
1518
1578
  // src/utils/encoding/toBytes.ts
1519
1579
  var encoder = new TextEncoder();
1520
- function boolToBytes(value) {
1521
- const bytes = new Uint8Array(1);
1522
- bytes[0] = Number(value);
1523
- return bytes;
1524
- }
1525
1580
  function toBytes(value) {
1526
1581
  if (typeof value === "number" || typeof value === "bigint")
1527
1582
  return numberToBytes(value);
@@ -1531,6 +1586,11 @@ function toBytes(value) {
1531
1586
  return hexToBytes(value);
1532
1587
  return stringToBytes(value);
1533
1588
  }
1589
+ function boolToBytes(value) {
1590
+ const bytes = new Uint8Array(1);
1591
+ bytes[0] = Number(value);
1592
+ return bytes;
1593
+ }
1534
1594
  function hexToBytes(hex_) {
1535
1595
  let hex = hex_.slice(2);
1536
1596
  if (hex.length % 2)
@@ -1541,7 +1601,7 @@ function hexToBytes(hex_) {
1541
1601
  const hexByte = hex.slice(start, start + 2);
1542
1602
  const byte = Number.parseInt(hexByte, 16);
1543
1603
  if (Number.isNaN(byte) || byte < 0)
1544
- throw new Error("Invalid byte sequence");
1604
+ throw new BaseError(`Invalid byte sequence ("${hexByte}" in "${hex}").`);
1545
1605
  bytes[index] = byte;
1546
1606
  }
1547
1607
  return bytes;
@@ -1734,9 +1794,9 @@ function rlpToBytes(bytes, offset = 0) {
1734
1794
  var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
1735
1795
  function extractFunctionParts(def) {
1736
1796
  const parts = def.match(paramsRegex);
1737
- const type = _optionalChain([parts, 'optionalAccess', _17 => _17[2]]) || void 0;
1738
- const name = _optionalChain([parts, 'optionalAccess', _18 => _18[3]]);
1739
- const params = _optionalChain([parts, 'optionalAccess', _19 => _19[5]]) || void 0;
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;
1740
1800
  return { type, name, params };
1741
1801
  }
1742
1802
  function extractFunctionName(def) {
@@ -1744,8 +1804,8 @@ function extractFunctionName(def) {
1744
1804
  }
1745
1805
  function extractFunctionParams(def) {
1746
1806
  const params = extractFunctionParts(def).params;
1747
- const splitParams = _optionalChain([params, 'optionalAccess', _20 => _20.split, 'call', _21 => _21(","), 'access', _22 => _22.map, 'call', _23 => _23((x) => x.trim().split(" "))]);
1748
- return _optionalChain([splitParams, 'optionalAccess', _24 => _24.map, 'call', _25 => _25((param) => ({
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) => ({
1749
1809
  type: param[0],
1750
1810
  name: param[1] === "indexed" ? param[2] : param[1],
1751
1811
  ...param[1] === "indexed" ? { indexed: true } : {}
@@ -1847,8 +1907,8 @@ function isAddressEqual(a, b) {
1847
1907
  return a.toLowerCase() === b.toLowerCase();
1848
1908
  }
1849
1909
 
1850
- // src/utils/abi/encodeAbi.ts
1851
- function encodeAbi({ params, values }) {
1910
+ // src/utils/abi/encodeAbiParameters.ts
1911
+ function encodeAbiParameters(params, values) {
1852
1912
  if (params.length !== values.length)
1853
1913
  throw new AbiEncodingLengthMismatchError({
1854
1914
  expectedLength: params.length,
@@ -1898,13 +1958,13 @@ function prepareParam({
1898
1958
  return encodeNumber(value, { signed });
1899
1959
  }
1900
1960
  if (param.type.startsWith("bytes")) {
1901
- return toBytes2(value, { param });
1961
+ return encodeBytes(value, { param });
1902
1962
  }
1903
1963
  if (param.type === "string") {
1904
1964
  return encodeString(value);
1905
1965
  }
1906
1966
  throw new InvalidAbiEncodingTypeError(param.type, {
1907
- docsPath: "/docs/contract/encodeAbi"
1967
+ docsPath: "/docs/contract/encodeAbiParameters"
1908
1968
  });
1909
1969
  }
1910
1970
  function encodeParams(preparedParams) {
@@ -1932,6 +1992,8 @@ function encodeParams(preparedParams) {
1932
1992
  return concat([...staticParams, ...dynamicParams]);
1933
1993
  }
1934
1994
  function encodeAddress(value) {
1995
+ if (!isAddress(value))
1996
+ throw new InvalidAddressError({ address: value });
1935
1997
  return { dynamic: false, encoded: padHex(value.toLowerCase()) };
1936
1998
  }
1937
1999
  function encodeArray(value, {
@@ -1972,13 +2034,17 @@ function encodeArray(value, {
1972
2034
  encoded: concat(preparedParams.map(({ encoded }) => encoded))
1973
2035
  };
1974
2036
  }
1975
- function toBytes2(value, { param }) {
2037
+ function encodeBytes(value, { param }) {
1976
2038
  const [_, size_] = param.type.split("bytes");
1977
2039
  if (!size_) {
1978
2040
  const partsLength = Math.floor(size(value) / 32);
1979
2041
  const parts = [];
1980
2042
  for (let i = 0; i < partsLength + 1; i++) {
1981
- parts.push(padHex(slice(value, i * 32, (i + 1) * 32), { dir: "right" }));
2043
+ parts.push(
2044
+ padHex(slice(value, i * 32, (i + 1) * 32), {
2045
+ dir: "right"
2046
+ })
2047
+ );
1982
2048
  }
1983
2049
  return {
1984
2050
  dynamic: true,
@@ -1988,6 +2054,11 @@ function toBytes2(value, { param }) {
1988
2054
  ])
1989
2055
  };
1990
2056
  }
2057
+ if (size(value) !== parseInt(size_))
2058
+ throw new AbiEncodingBytesSizeMismatchError({
2059
+ expectedSize: parseInt(size_),
2060
+ value
2061
+ });
1991
2062
  return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
1992
2063
  }
1993
2064
  function encodeBool(value) {
@@ -2038,19 +2109,16 @@ function getArrayComponents(type) {
2038
2109
  ) : void 0;
2039
2110
  }
2040
2111
 
2041
- // src/utils/abi/decodeAbi.ts
2042
- function decodeAbi({ data, params }) {
2112
+ // src/utils/abi/decodeAbiParameters.ts
2113
+ function decodeAbiParameters(params, data) {
2043
2114
  if (data === "0x" && params.length > 0)
2044
2115
  throw new AbiDecodingZeroDataError();
2045
2116
  if (size(data) % 32 !== 0)
2046
2117
  throw new AbiDecodingDataSizeInvalidError(size(data));
2047
- const values = decodeParams({
2118
+ return decodeParams({
2048
2119
  data,
2049
2120
  params
2050
2121
  });
2051
- if (values.length === 0)
2052
- return void 0;
2053
- return values;
2054
2122
  }
2055
2123
  function decodeParams({
2056
2124
  data,
@@ -2087,7 +2155,7 @@ function decodeParam({
2087
2155
  return decodeString(data, { position });
2088
2156
  }
2089
2157
  if (param.type.startsWith("bytes")) {
2090
- return fromBytes2(data, { param, position });
2158
+ return decodeBytes(data, { param, position });
2091
2159
  }
2092
2160
  let value = slice(data, position, position + 32);
2093
2161
  if (param.type.startsWith("uint") || param.type.startsWith("int")) {
@@ -2100,7 +2168,7 @@ function decodeParam({
2100
2168
  return decodeBool(value);
2101
2169
  }
2102
2170
  throw new InvalidAbiDecodingTypeError(param.type, {
2103
- docsPath: "/docs/contract/decodeAbi"
2171
+ docsPath: "/docs/contract/decodeAbiParameters"
2104
2172
  });
2105
2173
  }
2106
2174
  function decodeAddress(value) {
@@ -2129,7 +2197,7 @@ function decodeArray(data, {
2129
2197
  }
2130
2198
  if (hasDynamicChild(param)) {
2131
2199
  const arrayComponents = getArrayComponents(param.type);
2132
- const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _26 => _26[0]]);
2200
+ const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _29 => _29[0]]);
2133
2201
  let consumed2 = 0;
2134
2202
  let value2 = [];
2135
2203
  for (let i = 0; i < length; ++i) {
@@ -2160,7 +2228,7 @@ function decodeArray(data, {
2160
2228
  function decodeBool(value) {
2161
2229
  return { consumed: 32, value: hexToBool(value) };
2162
2230
  }
2163
- function fromBytes2(data, { param, position }) {
2231
+ function decodeBytes(data, { param, position }) {
2164
2232
  const [_, size2] = param.type.split("bytes");
2165
2233
  if (!size2) {
2166
2234
  const offset = hexToNumber(slice(data, position, position + 32));
@@ -2201,7 +2269,7 @@ function decodeTuple(data, { param, position }) {
2201
2269
  position: consumed
2202
2270
  });
2203
2271
  consumed += decodedChild.consumed;
2204
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _27 => _27.name])] = decodedChild.value;
2272
+ value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _30 => _30.name])] = decodedChild.value;
2205
2273
  }
2206
2274
  return { consumed: 32, value };
2207
2275
  }
@@ -2213,7 +2281,7 @@ function decodeTuple(data, { param, position }) {
2213
2281
  position: position + consumed
2214
2282
  });
2215
2283
  consumed += decodedChild.consumed;
2216
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _28 => _28.name])] = decodedChild.value;
2284
+ value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _31 => _31.name])] = decodedChild.value;
2217
2285
  }
2218
2286
  return { consumed, value };
2219
2287
  }
@@ -2226,7 +2294,7 @@ function hasDynamicChild(param) {
2226
2294
  if (type.endsWith("[]"))
2227
2295
  return true;
2228
2296
  if (type === "tuple")
2229
- return _optionalChain([param, 'access', _29 => _29.components, 'optionalAccess', _30 => _30.some, 'call', _31 => _31(hasDynamicChild)]);
2297
+ return _optionalChain([param, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.some, 'call', _34 => _34(hasDynamicChild)]);
2230
2298
  const arrayComponents = getArrayComponents(param.type);
2231
2299
  if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
2232
2300
  return true;
@@ -2272,7 +2340,7 @@ function decodeErrorResult({
2272
2340
  });
2273
2341
  return {
2274
2342
  abiItem,
2275
- args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: abiItem.inputs }) : void 0,
2343
+ args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbiParameters(abiItem.inputs, slice(data, 4)) : void 0,
2276
2344
  errorName: abiItem.name
2277
2345
  };
2278
2346
  }
@@ -2292,7 +2360,7 @@ function decodeEventLog({
2292
2360
  docsPath: "/docs/contract/decodeEventLog"
2293
2361
  });
2294
2362
  const { name, inputs } = abiItem;
2295
- const isUnnamed = _optionalChain([inputs, 'optionalAccess', _32 => _32.some, 'call', _33 => _33((x) => !("name" in x && x.name))]);
2363
+ const isUnnamed = _optionalChain([inputs, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((x) => !("name" in x && x.name))]);
2296
2364
  let args = isUnnamed ? [] : {};
2297
2365
  for (let i = 0; i < inputs.length; i++) {
2298
2366
  const param = inputs[i];
@@ -2309,7 +2377,7 @@ function decodeEventLog({
2309
2377
  }
2310
2378
  if (data && data !== "0x") {
2311
2379
  const params = inputs.filter((x) => !("indexed" in x && x.indexed));
2312
- const decodedData = decodeAbi({ params, data });
2380
+ const decodedData = decodeAbiParameters(params, data);
2313
2381
  if (decodedData) {
2314
2382
  if (isUnnamed)
2315
2383
  args = [...args, ...decodedData];
@@ -2328,7 +2396,7 @@ function decodeEventLog({
2328
2396
  function decodeTopic({ param, value }) {
2329
2397
  if (param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2330
2398
  return value;
2331
- const decodedArg = decodeAbi({ params: [param], data: value }) || [];
2399
+ const decodedArg = decodeAbiParameters([param], value) || [];
2332
2400
  return decodedArg[0];
2333
2401
  }
2334
2402
 
@@ -2344,7 +2412,7 @@ function decodeFunctionData({ abi, data }) {
2344
2412
  });
2345
2413
  return {
2346
2414
  functionName: description.name,
2347
- args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
2415
+ args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbiParameters(description.inputs, slice(data, 4)) : void 0
2348
2416
  };
2349
2417
  }
2350
2418
 
@@ -2437,7 +2505,7 @@ function decodeFunctionResult({
2437
2505
  throw new AbiFunctionNotFoundError(functionName, { docsPath });
2438
2506
  if (!("outputs" in description))
2439
2507
  throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
2440
- const values = decodeAbi({ data, params: description.outputs });
2508
+ const values = decodeAbiParameters(description.outputs, data);
2441
2509
  if (values && values.length > 1)
2442
2510
  return values;
2443
2511
  if (values && values.length === 1)
@@ -2463,10 +2531,10 @@ function encodeDeployData({
2463
2531
  throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2464
2532
  if (!description.inputs || description.inputs.length === 0)
2465
2533
  throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
2466
- const data = encodeAbi({
2467
- params: description.inputs,
2468
- values: args
2469
- });
2534
+ const data = encodeAbiParameters(
2535
+ description.inputs,
2536
+ args
2537
+ );
2470
2538
  return concatHex([bytecode, data]);
2471
2539
  }
2472
2540
 
@@ -2486,7 +2554,7 @@ function encodeErrorResult({ abi, errorName, args }) {
2486
2554
  if (args && args.length > 0) {
2487
2555
  if (!("inputs" in description && description.inputs))
2488
2556
  throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
2489
- data = encodeAbi({ params: description.inputs, values: args });
2557
+ data = encodeAbiParameters(description.inputs, args);
2490
2558
  }
2491
2559
  return concatHex([signature, data]);
2492
2560
  }
@@ -2502,8 +2570,8 @@ function encodeEventTopics({ abi, eventName, args }) {
2502
2570
  const signature = getEventSelector(definition);
2503
2571
  let topics = [];
2504
2572
  if (args && "inputs" in abiItem) {
2505
- const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _34 => _34.inputs, 'optionalAccess', _35 => _35.map, 'call', _36 => _36((x) => args[x.name])]), () => ( []));
2506
- topics = _nullishCoalesce(_optionalChain([abiItem, 'access', _37 => _37.inputs, 'optionalAccess', _38 => _38.filter, 'call', _39 => _39((param) => "indexed" in param && param.indexed), 'access', _40 => _40.map, 'call', _41 => _41(
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(
2507
2575
  (param, i) => Array.isArray(args_[i]) ? args_[i].map(
2508
2576
  (_, j) => encodeArg({ param, value: args_[i][j] })
2509
2577
  ) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
@@ -2519,7 +2587,7 @@ function encodeArg({
2519
2587
  return keccak256(toBytes(value));
2520
2588
  if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
2521
2589
  throw new FilterTypeNotSupportedError(param.type);
2522
- return encodeAbi({ params: [param], values: [value] });
2590
+ return encodeAbiParameters([param], [value]);
2523
2591
  }
2524
2592
 
2525
2593
  // src/utils/abi/encodeFunctionData.ts
@@ -2535,10 +2603,10 @@ function encodeFunctionData({ abi, args, functionName }) {
2535
2603
  });
2536
2604
  const definition = formatAbiItem(description);
2537
2605
  const signature = getFunctionSelector(definition);
2538
- const data = "inputs" in description && description.inputs ? encodeAbi({
2539
- params: description.inputs,
2540
- values: _nullishCoalesce(args, () => ( []))
2541
- }) : void 0;
2606
+ const data = "inputs" in description && description.inputs ? encodeAbiParameters(
2607
+ description.inputs,
2608
+ _nullishCoalesce(args, () => ( []))
2609
+ ) : void 0;
2542
2610
  return concatHex([signature, _nullishCoalesce(data, () => ( "0x"))]);
2543
2611
  }
2544
2612
 
@@ -2559,7 +2627,7 @@ function encodeFunctionResult({
2559
2627
  let values = Array.isArray(result) ? result : [result];
2560
2628
  if (description.outputs.length === 0 && !values[0])
2561
2629
  values = [];
2562
- return encodeAbi({ params: description.outputs, values });
2630
+ return encodeAbiParameters(description.outputs, values);
2563
2631
  }
2564
2632
 
2565
2633
  // src/utils/abi/formatAbiItemWithArgs.ts
@@ -2580,18 +2648,33 @@ function formatAbiItemWithArgs({
2580
2648
  ).join(", ")})`;
2581
2649
  }
2582
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
+
2583
2666
  // src/utils/promise/withCache.ts
2584
2667
  var promiseCache = /* @__PURE__ */ new Map();
2585
2668
  var responseCache = /* @__PURE__ */ new Map();
2586
- function getCache(cacheKey) {
2587
- const buildCache = (cacheKey2, cache) => ({
2588
- clear: () => cache.delete(cacheKey2),
2589
- get: () => cache.get(cacheKey2),
2590
- set: (data) => cache.set(cacheKey2, data)
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)
2591
2674
  });
2592
- const promise = buildCache(cacheKey, promiseCache);
2675
+ const promise = buildCache(cacheKey2, promiseCache);
2593
2676
  const response = buildCache(
2594
- cacheKey,
2677
+ cacheKey2,
2595
2678
  responseCache
2596
2679
  );
2597
2680
  return {
@@ -2603,8 +2686,8 @@ function getCache(cacheKey) {
2603
2686
  response
2604
2687
  };
2605
2688
  }
2606
- async function withCache(fn, { cacheKey, maxAge = Infinity }) {
2607
- const cache = getCache(cacheKey);
2689
+ async function withCache(fn, { cacheKey: cacheKey2, maxAge = Infinity }) {
2690
+ const cache = getCache(cacheKey2);
2608
2691
  const response = cache.response.get();
2609
2692
  if (response && maxAge > 0) {
2610
2693
  const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
@@ -2675,7 +2758,7 @@ function withTimeout(fn, {
2675
2758
  }
2676
2759
  }, timeout);
2677
2760
  }
2678
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _42 => _42.signal]) }));
2761
+ resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _45 => _45.signal]) }));
2679
2762
  } catch (err) {
2680
2763
  if (err.name === "AbortError")
2681
2764
  reject(errorInstance);
@@ -2741,8 +2824,8 @@ function buildRequest(request, {
2741
2824
  {
2742
2825
  delay: ({ count, error }) => {
2743
2826
  if (error && error instanceof HttpRequestError) {
2744
- const retryAfter = _optionalChain([error, 'optionalAccess', _43 => _43.headers, 'optionalAccess', _44 => _44.get, 'call', _45 => _45("Retry-After")]);
2745
- if (_optionalChain([retryAfter, 'optionalAccess', _46 => _46.match, 'call', _47 => _47(/\d/)]))
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/)]))
2746
2829
  return parseInt(retryAfter) * 1e3;
2747
2830
  }
2748
2831
  return ~~(1 << count) * retryDelay;
@@ -2777,7 +2860,7 @@ function defineFormatter({
2777
2860
  }
2778
2861
  return {
2779
2862
  ...formatted,
2780
- ..._optionalChain([formatOverride, 'optionalCall', _48 => _48(data)])
2863
+ ..._optionalChain([formatOverride, 'optionalCall', _51 => _51(data)])
2781
2864
  };
2782
2865
  };
2783
2866
  }
@@ -2792,6 +2875,7 @@ function formatTransaction(transaction) {
2792
2875
  const transaction_ = {
2793
2876
  ...transaction,
2794
2877
  blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
2878
+ chainId: transaction.chainId ? hexToNumber(transaction.chainId) : void 0,
2795
2879
  gas: transaction.gas ? BigInt(transaction.gas) : void 0,
2796
2880
  gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
2797
2881
  maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
@@ -2817,7 +2901,7 @@ var defineTransaction = defineFormatter({ format: formatTransaction });
2817
2901
 
2818
2902
  // src/utils/formatters/block.ts
2819
2903
  function formatBlock(block) {
2820
- const transactions = _optionalChain([block, 'access', _49 => _49.transactions, 'optionalAccess', _50 => _50.map, 'call', _51 => _51((transaction) => {
2904
+ const transactions = _optionalChain([block, 'access', _52 => _52.transactions, 'optionalAccess', _53 => _53.map, 'call', _54 => _54((transaction) => {
2821
2905
  if (typeof transaction === "string")
2822
2906
  return transaction;
2823
2907
  return formatTransaction(transaction);
@@ -2843,7 +2927,7 @@ function extract(value, { formatter }) {
2843
2927
  return {};
2844
2928
  const keys = Object.keys(formatter({}));
2845
2929
  return keys.reduce((data, key) => {
2846
- if (_optionalChain([value, 'optionalAccess', _52 => _52.hasOwnProperty, 'call', _53 => _53(key)])) {
2930
+ if (_optionalChain([value, 'optionalAccess', _55 => _55.hasOwnProperty, 'call', _56 => _56(key)])) {
2847
2931
  ;
2848
2932
  data[key] = value[key];
2849
2933
  }
@@ -2857,7 +2941,7 @@ function formatFeeHistory(feeHistory) {
2857
2941
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
2858
2942
  gasUsedRatio: feeHistory.gasUsedRatio,
2859
2943
  oldestBlock: BigInt(feeHistory.oldestBlock),
2860
- reward: _optionalChain([feeHistory, 'access', _54 => _54.reward, 'optionalAccess', _55 => _55.map, 'call', _56 => _56(
2944
+ reward: _optionalChain([feeHistory, 'access', _57 => _57.reward, 'optionalAccess', _58 => _58.map, 'call', _59 => _59(
2861
2945
  (reward) => reward.map((value) => BigInt(value))
2862
2946
  )])
2863
2947
  };
@@ -2912,56 +2996,43 @@ var defineTransactionRequest = defineFormatter({
2912
2996
  format: formatTransactionRequest
2913
2997
  });
2914
2998
 
2915
- // src/utils/errors/assertRequest.ts
2916
- function assertRequest(args) {
2917
- const { from, maxFeePerGas, maxPriorityFeePerGas, to } = args;
2918
- if (from && !isAddress(from))
2919
- throw new InvalidAddressError({ address: from });
2920
- if (to && !isAddress(to))
2921
- throw new InvalidAddressError({ address: to });
2922
- if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
2923
- throw new FeeCapTooHighError({ maxFeePerGas });
2924
- if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
2925
- throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
2926
- }
2927
-
2928
2999
  // src/utils/errors/getNodeError.ts
2929
3000
  function containsNodeError(err) {
2930
3001
  return err instanceof TransactionRejectedRpcError || err instanceof InvalidInputRpcError || err instanceof RpcError && err.code === ExecutionRevertedError.code;
2931
3002
  }
2932
- function getNodeError(err, args = {}) {
3003
+ function getNodeError(err, args) {
2933
3004
  const message = err.details.toLowerCase();
2934
3005
  if (FeeCapTooHighError.nodeMessage.test(message))
2935
3006
  return new FeeCapTooHighError({
2936
3007
  cause: err,
2937
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _57 => _57.maxFeePerGas])
3008
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _60 => _60.maxFeePerGas])
2938
3009
  });
2939
3010
  else if (FeeCapTooLowError.nodeMessage.test(message))
2940
3011
  return new FeeCapTooLowError({
2941
3012
  cause: err,
2942
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _58 => _58.maxFeePerGas])
3013
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _61 => _61.maxFeePerGas])
2943
3014
  });
2944
3015
  else if (NonceTooHighError.nodeMessage.test(message))
2945
- return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _59 => _59.nonce]) });
3016
+ return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _62 => _62.nonce]) });
2946
3017
  else if (NonceTooLowError.nodeMessage.test(message))
2947
- return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _60 => _60.nonce]) });
3018
+ return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _63 => _63.nonce]) });
2948
3019
  else if (NonceMaxValueError.nodeMessage.test(message))
2949
- return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _61 => _61.nonce]) });
3020
+ return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _64 => _64.nonce]) });
2950
3021
  else if (InsufficientFundsError.nodeMessage.test(message))
2951
3022
  return new InsufficientFundsError({ cause: err });
2952
3023
  else if (IntrinsicGasTooHighError.nodeMessage.test(message))
2953
- return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _62 => _62.gas]) });
3024
+ return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _65 => _65.gas]) });
2954
3025
  else if (IntrinsicGasTooLowError.nodeMessage.test(message))
2955
- return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _63 => _63.gas]) });
3026
+ return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _66 => _66.gas]) });
2956
3027
  else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
2957
3028
  return new TransactionTypeNotSupportedError({ cause: err });
2958
3029
  else if (TipAboveFeeCapError.nodeMessage.test(message))
2959
3030
  return new TipAboveFeeCapError({
2960
3031
  cause: err,
2961
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _64 => _64.maxFeePerGas]),
2962
- maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _65 => _65.maxPriorityFeePerGas])
3032
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _67 => _67.maxFeePerGas]),
3033
+ maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _68 => _68.maxPriorityFeePerGas])
2963
3034
  });
2964
- else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _66 => _66.cause, 'optionalAccess', _67 => _67.code]) === ExecutionRevertedError.code)
3035
+ else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _69 => _69.cause, 'optionalAccess', _70 => _70.code]) === ExecutionRevertedError.code)
2965
3036
  return new ExecutionRevertedError({
2966
3037
  cause: err,
2967
3038
  message: err.cause.details
@@ -2995,7 +3066,7 @@ function getContractError(err, {
2995
3066
  functionName,
2996
3067
  sender
2997
3068
  }) {
2998
- const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access', _68 => _68.cause, 'optionalAccess', _69 => _69.cause, 'optionalAccess', _70 => _70.cause]) || {} : err.cause || {};
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 || {};
2999
3070
  let cause = err;
3000
3071
  if (err instanceof AbiDecodingZeroDataError) {
3001
3072
  cause = new ContractFunctionZeroDataError({ functionName });
@@ -3084,7 +3155,7 @@ async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
3084
3155
  }
3085
3156
  );
3086
3157
  let data;
3087
- if (_optionalChain([response, 'access', _71 => _71.headers, 'access', _72 => _72.get, 'call', _73 => _73("Content-Type"), 'optionalAccess', _74 => _74.startsWith, 'call', _75 => _75("application/json")])) {
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")])) {
3088
3159
  data = await response.json();
3089
3160
  } else {
3090
3161
  data = await response.text();
@@ -3176,15 +3247,15 @@ function webSocket(socket, {
3176
3247
  if (typeof message.id === "number" && id_ !== message.id)
3177
3248
  return;
3178
3249
  if (message.error) {
3179
- _optionalChain([onError, 'optionalCall', _76 => _76(new RpcError({ body, error: message.error, url: socket.url }))]);
3250
+ _optionalChain([onError, 'optionalCall', _79 => _79(new RpcError({ body, error: message.error, url: socket.url }))]);
3180
3251
  } else {
3181
- _optionalChain([onData, 'optionalCall', _77 => _77(message)]);
3252
+ _optionalChain([onData, 'optionalCall', _80 => _80(message)]);
3182
3253
  }
3183
3254
  if (body.method === "eth_subscribe" && typeof message.result === "string") {
3184
3255
  socket.subscriptions.set(message.result, callback);
3185
3256
  }
3186
3257
  if (body.method === "eth_unsubscribe") {
3187
- socket.subscriptions.delete(_optionalChain([body, 'access', _78 => _78.params, 'optionalAccess', _79 => _79[0]]));
3258
+ socket.subscriptions.delete(_optionalChain([body, 'access', _81 => _81.params, 'optionalAccess', _82 => _82[0]]));
3188
3259
  }
3189
3260
  };
3190
3261
  socket.requests.set(id_, callback);
@@ -3215,77 +3286,1745 @@ var rpc = {
3215
3286
  webSocketAsync
3216
3287
  };
3217
3288
 
3218
- // src/utils/unit/constants.ts
3219
- var etherUnits = {
3220
- gwei: 9,
3221
- wei: 18
3222
- };
3223
- var gweiUnits = {
3224
- ether: -9,
3225
- wei: 9
3226
- };
3227
- var weiUnits = {
3228
- ether: -18,
3229
- gwei: -9
3230
- };
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
+ }
3231
3303
 
3232
- // src/utils/unit/formatUnit.ts
3233
- function formatUnit(value, decimals) {
3234
- let display = value.toString();
3235
- const negative = display.startsWith("-");
3236
- if (negative)
3237
- display = display.slice(1);
3238
- display = display.padStart(decimals, "0");
3239
- let [integer, fraction] = [
3240
- display.slice(0, display.length - decimals),
3241
- display.slice(display.length - decimals)
3242
- ];
3243
- fraction = fraction.replace(/(0+)$/, "");
3244
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
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
+ }
3245
3357
  }
3246
3358
 
3247
- // src/utils/unit/formatEther.ts
3248
- function formatEther(wei, unit = "wei") {
3249
- return formatUnit(wei, etherUnits[unit]);
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
+ }
3250
3404
  }
3251
3405
 
3252
- // src/utils/unit/formatGwei.ts
3253
- function formatGwei(wei, unit = "wei") {
3254
- return formatUnit(wei, gweiUnits[unit]);
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" };
3255
3412
  }
3256
3413
 
3257
- // src/utils/unit/parseUnit.ts
3258
- function parseUnit(value, decimals) {
3259
- let [integer, fraction = "0"] = value.split(".");
3260
- const negative = integer.startsWith("-");
3261
- if (negative)
3262
- integer = integer.slice(1);
3263
- fraction = fraction.replace(/(0+)$/, "");
3264
- if (decimals === 0) {
3265
- integer = `${Math.round(Number(`${integer}.${fraction}`))}`;
3266
- fraction = "";
3267
- } else if (fraction.length > decimals) {
3268
- const [before, after] = [
3269
- fraction.slice(0, decimals),
3270
- fraction.slice(decimals)
3271
- ];
3272
- fraction = `${/^0+$/.test(before) ? before.slice(0, before.length - 1) : ""}${Math.round(Number(`${before}.${after}`))}`;
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
+ });
3273
3600
  } else {
3274
- fraction = fraction.padEnd(decimals, "0");
3601
+ block = await client.request({
3602
+ method: "eth_getBlockByNumber",
3603
+ params: [blockNumberHex || blockTag, includeTransactions]
3604
+ });
3275
3605
  }
3276
- return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
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
+ });
3277
3611
  }
3278
3612
 
3279
- // src/utils/unit/parseEther.ts
3280
- function parseEther(ether, unit = "wei") {
3281
- return parseUnit(ether, etherUnits[unit]);
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);
3282
3626
  }
3283
3627
 
3284
- // src/utils/unit/parseGwei.ts
3285
- function parseGwei(ether, unit = "wei") {
3286
- return parseUnit(ether, gweiUnits[unit]);
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);
3287
3648
  }
3288
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;
3782
+ }
3783
+
3784
+ // src/actions/public/getTransaction.ts
3785
+ async function getTransaction(client, {
3786
+ blockHash,
3787
+ blockNumber,
3788
+ blockTag = "latest",
3789
+ hash: hash2,
3790
+ index
3791
+ }) {
3792
+ const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
3793
+ let transaction = null;
3794
+ if (hash2) {
3795
+ transaction = await client.request({
3796
+ method: "eth_getTransactionByHash",
3797
+ params: [hash2]
3798
+ });
3799
+ } else if (blockHash) {
3800
+ transaction = await client.request({
3801
+ method: "eth_getTransactionByBlockHashAndIndex",
3802
+ params: [blockHash, numberToHex(index)]
3803
+ });
3804
+ } else if (blockNumberHex || blockTag) {
3805
+ transaction = await client.request({
3806
+ method: "eth_getTransactionByBlockNumberAndIndex",
3807
+ params: [blockNumberHex || blockTag, numberToHex(index)]
3808
+ });
3809
+ }
3810
+ if (!transaction)
3811
+ throw new TransactionNotFoundError({
3812
+ blockHash,
3813
+ blockNumber,
3814
+ blockTag,
3815
+ hash: hash2,
3816
+ index
3817
+ });
3818
+ return format3(transaction, {
3819
+ formatter: _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/parseUnit.ts
4864
+ function parseUnit(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 parseUnit(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/formatUnit.ts
4931
+ function formatUnit(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 formatUnit(wei, etherUnits[unit]);
4948
+ }
4949
+
4950
+ // src/utils/unit/formatGwei.ts
4951
+ function formatGwei(wei, unit = "wei") {
4952
+ return formatUnit(wei, gweiUnits[unit]);
4953
+ }
4954
+
4955
+ // src/utils/unit/parseEther.ts
4956
+ function parseEther(ether, unit = "wei") {
4957
+ return parseUnit(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
+
5027
+
3289
5028
 
3290
5029
 
3291
5030
 
@@ -3463,5 +5202,5 @@ function parseGwei(ether, unit = "wei") {
3463
5202
 
3464
5203
 
3465
5204
 
3466
- 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.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.boolToBytes = boolToBytes; exports.toBytes = toBytes; 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.encodeAbi = encodeAbi; exports.decodeAbi = decodeAbi; 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;
3467
- //# sourceMappingURL=chunk-F76TECTY.js.map
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.parseUnit = parseUnit; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther;
5206
+ //# sourceMappingURL=chunk-KXGQFW2R.js.map