viem 0.1.23 → 0.2.0-0-2-0.20230328T054201

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 (72) hide show
  1. package/accounts/package.json +4 -0
  2. package/dist/abi.d.ts +3 -3
  3. package/dist/abi.js +2 -2
  4. package/dist/abi.mjs +1 -1
  5. package/dist/accounts/index.d.ts +90 -0
  6. package/dist/accounts/index.js +152 -0
  7. package/dist/accounts/index.js.map +1 -0
  8. package/dist/accounts/index.mjs +152 -0
  9. package/dist/accounts/index.mjs.map +1 -0
  10. package/dist/{chain-ec8c485d.d.ts → chain-40443542.d.ts} +1 -1
  11. package/dist/{chain-1b53ef88.d.ts → chain-4af995bf.d.ts} +77 -36
  12. package/dist/chains.d.ts +3 -3
  13. package/dist/chains.js +63 -63
  14. package/dist/chains.mjs +1 -1
  15. package/dist/chunk-43HQD3IL.js +31 -0
  16. package/dist/chunk-43HQD3IL.js.map +1 -0
  17. package/dist/{chunk-HRVPAYH7.mjs → chunk-DFMQLPHS.mjs} +2 -2
  18. package/dist/chunk-DFMQLPHS.mjs.map +1 -0
  19. package/dist/{chunk-66PXETQB.js → chunk-FZPFAAOJ.js} +19 -19
  20. package/dist/chunk-FZPFAAOJ.js.map +1 -0
  21. package/dist/{chunk-JG6MI5ZV.mjs → chunk-HYEOQX7O.mjs} +1106 -199
  22. package/dist/chunk-HYEOQX7O.mjs.map +1 -0
  23. package/dist/{chunk-Z54YSSBJ.js → chunk-OW7TKT7L.js} +1168 -261
  24. package/dist/chunk-OW7TKT7L.js.map +1 -0
  25. package/dist/chunk-UK6FAD4V.mjs +31 -0
  26. package/dist/chunk-UK6FAD4V.mjs.map +1 -0
  27. package/dist/contract.d.ts +9 -7
  28. package/dist/contract.js +2 -2
  29. package/dist/contract.mjs +1 -1
  30. package/dist/{createClient-a28317a9.d.ts → createClient-1f19be8d.d.ts} +24 -10
  31. package/dist/{createPublicClient-b250a534.d.ts → createPublicClient-fd8b1349.d.ts} +229 -242
  32. package/dist/{eip1193-4f4e240c.d.ts → eip1193-210ab776.d.ts} +1 -1
  33. package/dist/{encodeFunctionResult-1f324375.d.ts → encodeFunctionResult-a252fba1.d.ts} +1 -1
  34. package/dist/{encodePacked-d5d5264a.d.ts → encodePacked-a9464e97.d.ts} +1 -1
  35. package/dist/ens.d.ts +6 -4
  36. package/dist/ens.js +3 -3
  37. package/dist/ens.mjs +2 -2
  38. package/dist/ethers.d.ts +5 -6
  39. package/dist/ethers.js +7 -5
  40. package/dist/ethers.js.map +1 -1
  41. package/dist/ethers.mjs +7 -5
  42. package/dist/ethers.mjs.map +1 -1
  43. package/dist/{formatAbiItem-15e8817d.d.ts → formatAbiItem-6ed70dbd.d.ts} +1 -1
  44. package/dist/{getAbiItem-3e809ff9.d.ts → getAbiItem-1ff0f41a.d.ts} +1 -1
  45. package/dist/index.d.ts +22 -14
  46. package/dist/index.js +136 -101
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +78 -43
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/parseAccount-8e131c73.d.ts +6 -0
  51. package/dist/{parseGwei-bd0eea6c.d.ts → parseGwei-5e2a8e87.d.ts} +95 -15
  52. package/dist/public.d.ts +6 -4
  53. package/dist/public.js +2 -2
  54. package/dist/public.mjs +1 -1
  55. package/dist/test-e28db435.d.ts +198 -0
  56. package/dist/test.d.ts +11 -11
  57. package/dist/test.js +2 -2
  58. package/dist/test.mjs +1 -1
  59. package/dist/typedData-848139b1.d.ts +93 -0
  60. package/dist/utils/index.d.ts +22 -30
  61. package/dist/utils/index.js +26 -2
  62. package/dist/utils/index.mjs +29 -5
  63. package/dist/wallet.d.ts +6 -4
  64. package/dist/wallet.js +2 -2
  65. package/dist/wallet.mjs +1 -1
  66. package/dist/window.d.ts +2 -2
  67. package/package.json +10 -2
  68. package/dist/chunk-66PXETQB.js.map +0 -1
  69. package/dist/chunk-HRVPAYH7.mjs.map +0 -1
  70. package/dist/chunk-JG6MI5ZV.mjs.map +0 -1
  71. package/dist/chunk-Z54YSSBJ.js.map +0 -1
  72. package/dist/test-2bd23d7e.d.ts +0 -205
@@ -25,7 +25,7 @@ var package_default = {
25
25
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
26
26
  bench: "vitest bench --no-threads",
27
27
  "bench:ci": "CI=true vitest bench --no-threads",
28
- build: "tsup",
28
+ build: "tsup && size-limit",
29
29
  changeset: "changeset",
30
30
  "changeset:release": "pnpm build && changeset publish",
31
31
  "changeset:version": "changeset version && pnpm install --lockfile-only",
@@ -53,6 +53,7 @@ var package_default = {
53
53
  entry: [
54
54
  "src/index.ts",
55
55
  "src/abi.ts",
56
+ "src/accounts/index.ts",
56
57
  "src/chains.ts",
57
58
  "src/contract.ts",
58
59
  "src/ens.ts",
@@ -66,6 +67,7 @@ var package_default = {
66
67
  },
67
68
  files: [
68
69
  "/abi",
70
+ "/accounts",
69
71
  "/dist",
70
72
  "/chains",
71
73
  "/contract",
@@ -88,6 +90,11 @@ var package_default = {
88
90
  module: "./dist/abi.mts",
89
91
  default: "./dist/abi.js"
90
92
  },
93
+ "./accounts": {
94
+ types: "./dist/accounts/index.d.ts",
95
+ module: "./dist/accounts/index.mts",
96
+ default: "./dist/accounts/index.js"
97
+ },
91
98
  "./chains": {
92
99
  types: "./dist/chains.d.ts",
93
100
  module: "./dist/chains.mts",
@@ -142,6 +149,8 @@ var package_default = {
142
149
  dependencies: {
143
150
  "@noble/hashes": "^1.1.2",
144
151
  "@noble/secp256k1": "^1.7.1",
152
+ "@scure/bip32": "^1.2.0",
153
+ "@scure/bip39": "^1.1.1",
145
154
  "@wagmi/chains": "~0.2.11",
146
155
  abitype: "~0.7.1",
147
156
  "idna-uts46-hx": "^4.1.2",
@@ -154,6 +163,7 @@ var package_default = {
154
163
  "@adraffy/ens-normalize": "^1.8.9",
155
164
  "@changesets/changelog-github": "^0.4.5",
156
165
  "@changesets/cli": "^2.23.2",
166
+ "@size-limit/preset-big-lib": "^8.2.4",
157
167
  "@types/dedent": "^0.7.0",
158
168
  "@types/fs-extra": "^9.0.13",
159
169
  "@types/node": "^17.0.45",
@@ -171,6 +181,7 @@ var package_default = {
171
181
  rimraf: "^4.1.2",
172
182
  rome: "^11.0.0",
173
183
  "simple-git-hooks": "^2.8.1",
184
+ "size-limit": "^8.2.4",
174
185
  tsup: "^6.6.0",
175
186
  typescript: "^4.9.4",
176
187
  vite: "^4.1.4",
@@ -189,6 +200,11 @@ var package_default = {
189
200
  "wallet",
190
201
  "web3"
191
202
  ],
203
+ "size-limit": [
204
+ {
205
+ path: "dist/index.js"
206
+ }
207
+ ],
192
208
  "simple-git-hooks": {
193
209
  "pre-commit": "pnpm format && pnpm lint:fix"
194
210
  },
@@ -218,7 +234,9 @@ var BaseError = class extends Error {
218
234
  shortMessage || "An error occurred.",
219
235
  "",
220
236
  ...args.metaMessages ? [...args.metaMessages, ""] : [],
221
- ...docsPath6 ? [`Docs: https://viem.sh${docsPath6}.html`] : [],
237
+ ...docsPath6 ? [
238
+ `Docs: https://viem.sh${docsPath6}.html${args.docsSlug ? `#${args.docsSlug}` : ""}`
239
+ ] : [],
222
240
  ...details ? [`Details: ${details}`] : [],
223
241
  `Version: ${getVersion()}`
224
242
  ].join("\n");
@@ -519,6 +537,23 @@ var UnsupportedPackedAbiType = class extends BaseError {
519
537
  }
520
538
  };
521
539
 
540
+ // src/errors/account.ts
541
+ var AccountNotFoundError = class extends BaseError {
542
+ constructor({ docsPath: docsPath6 } = {}) {
543
+ super(
544
+ [
545
+ "Could not find an Account to execute with this Action.",
546
+ "Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the WalletClient."
547
+ ].join("\n"),
548
+ {
549
+ docsPath: docsPath6,
550
+ docsSlug: "account"
551
+ }
552
+ );
553
+ __publicField(this, "name", "AccountNotFoundError");
554
+ }
555
+ };
556
+
522
557
  // src/errors/address.ts
523
558
  var InvalidAddressError = class extends BaseError {
524
559
  constructor({ address }) {
@@ -583,6 +618,23 @@ var ChainMismatchError = class extends BaseError {
583
618
  __publicField(this, "name", "ChainMismatchError");
584
619
  }
585
620
  };
621
+ var ChainNotFoundError = class extends BaseError {
622
+ constructor() {
623
+ super(
624
+ [
625
+ "No chain was provided to the request.",
626
+ "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."
627
+ ].join("\n")
628
+ );
629
+ __publicField(this, "name", "ChainNotFoundError");
630
+ }
631
+ };
632
+ var InvalidChainIdError = class extends BaseError {
633
+ constructor({ chainId }) {
634
+ super(`Chain ID "${chainId}" is invalid.`);
635
+ __publicField(this, "name", "InvalidChainIdError");
636
+ }
637
+ };
586
638
 
587
639
  // src/constants/abis.ts
588
640
  var multicall3Abi = [
@@ -697,6 +749,69 @@ var FeeConflictError = class extends BaseError {
697
749
  __publicField(this, "name", "FeeConflictError");
698
750
  }
699
751
  };
752
+ var InvalidLegacyVError = class extends BaseError {
753
+ constructor({ v }) {
754
+ super(`Invalid \`v\` value "${v}". Expected 27 or 28.`);
755
+ __publicField(this, "name", "InvalidLegacyVError");
756
+ }
757
+ };
758
+ var InvalidSerializableTransactionError = class extends BaseError {
759
+ constructor({ transaction }) {
760
+ super("Cannot infer a transaction type from provided transaction.", {
761
+ metaMessages: [
762
+ "Provided Transaction:",
763
+ "{",
764
+ prettyPrint(transaction),
765
+ "}",
766
+ "",
767
+ "To infer the type, either provide:",
768
+ "- a `type` to the Transaction, or",
769
+ "- an EIP-1559 Transaction with `maxFeePerGas`, or",
770
+ "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
771
+ "- a Legacy Transaction with `gasPrice`"
772
+ ]
773
+ });
774
+ __publicField(this, "name", "InvalidSerializableTransactionError");
775
+ }
776
+ };
777
+ var InvalidSerializedTransactionTypeError = class extends BaseError {
778
+ constructor({ serializedType }) {
779
+ super(`Serialized transaction type "${serializedType}" is invalid.`);
780
+ __publicField(this, "name", "InvalidSerializedTransactionType");
781
+ __publicField(this, "serializedType");
782
+ this.serializedType = serializedType;
783
+ }
784
+ };
785
+ var InvalidSerializedTransactionError = class extends BaseError {
786
+ constructor({
787
+ attributes,
788
+ serializedTransaction,
789
+ type
790
+ }) {
791
+ const missing = Object.entries(attributes).map(([key, value]) => typeof value === "undefined" ? key : void 0).filter(Boolean);
792
+ super(`Invalid serialized transaction of type "${type}" was provided.`, {
793
+ metaMessages: [
794
+ `Serialized Transaction: "${serializedTransaction}"`,
795
+ missing.length > 0 ? `Missing Attributes: ${missing.join(", ")}` : ""
796
+ ].filter(Boolean)
797
+ });
798
+ __publicField(this, "name", "InvalidSerializedTransactionError");
799
+ __publicField(this, "serializedTransaction");
800
+ __publicField(this, "type");
801
+ this.serializedTransaction = serializedTransaction;
802
+ this.type = type;
803
+ }
804
+ };
805
+ var InvalidStorageKeySizeError = class extends BaseError {
806
+ constructor({ storageKey }) {
807
+ super(
808
+ `Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor(
809
+ (storageKey.length - 2) / 2
810
+ )} bytes.`
811
+ );
812
+ __publicField(this, "name", "InvalidStorageKeySizeError");
813
+ }
814
+ };
700
815
  var TransactionExecutionError = class extends BaseError {
701
816
  constructor(cause, {
702
817
  account,
@@ -713,9 +828,9 @@ var TransactionExecutionError = class extends BaseError {
713
828
  }) {
714
829
  const prettyArgs = prettyPrint({
715
830
  chain: chain && `${_optionalChain([chain, 'optionalAccess', _4 => _4.name])} (id: ${_optionalChain([chain, 'optionalAccess', _5 => _5.id])})`,
716
- from: account.address,
831
+ from: _optionalChain([account, 'optionalAccess', _6 => _6.address]),
717
832
  to,
718
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _6 => _6.nativeCurrency, 'access', _7 => _7.symbol]) || "ETH"}`,
833
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _7 => _7.nativeCurrency, 'access', _8 => _8.symbol]) || "ETH"}`,
719
834
  data,
720
835
  gas,
721
836
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -778,7 +893,7 @@ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
778
893
  // src/errors/contract.ts
779
894
  var CallExecutionError = class extends BaseError {
780
895
  constructor(cause, {
781
- account,
896
+ account: account_,
782
897
  docsPath: docsPath6,
783
898
  chain,
784
899
  data,
@@ -790,10 +905,11 @@ var CallExecutionError = class extends BaseError {
790
905
  to,
791
906
  value
792
907
  }) {
908
+ const account = account_ ? parseAccount(account_) : void 0;
793
909
  const prettyArgs = prettyPrint({
794
- from: _optionalChain([account, 'optionalAccess', _8 => _8.address]),
910
+ from: _optionalChain([account, 'optionalAccess', _9 => _9.address]),
795
911
  to,
796
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _9 => _9.nativeCurrency, 'access', _10 => _10.symbol]) || "ETH"}`,
912
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _10 => _10.nativeCurrency, 'access', _11 => _11.symbol]) || "ETH"}`,
797
913
  data,
798
914
  gas,
799
915
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -835,7 +951,7 @@ var ContractFunctionExecutionError = class extends BaseError {
835
951
  const prettyArgs = prettyPrint({
836
952
  address: contractAddress && getContractAddress(contractAddress),
837
953
  function: functionWithParams,
838
- args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _11 => _11.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
954
+ args: formattedArgs && formattedArgs !== "()" && `${[...Array(_nullishCoalesce(_optionalChain([functionName, 'optionalAccess', _12 => _12.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}`,
839
955
  sender
840
956
  });
841
957
  super(
@@ -894,7 +1010,7 @@ var ContractFunctionRevertedError = class extends BaseError {
894
1010
  }) : void 0;
895
1011
  metaMessages = [
896
1012
  errorWithParams ? `Error: ${errorWithParams}` : "",
897
- formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _12 => _12.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
1013
+ formattedArgs && formattedArgs !== "()" ? ` ${[...Array(_nullishCoalesce(_optionalChain([errorName, 'optionalAccess', _13 => _13.length]), () => ( 0))).keys()].map(() => " ").join("")}${formattedArgs}` : ""
898
1014
  ];
899
1015
  }
900
1016
  } else if (message)
@@ -1032,9 +1148,9 @@ var EstimateGasExecutionError = class extends BaseError {
1032
1148
  value
1033
1149
  }) {
1034
1150
  const prettyArgs = prettyPrint({
1035
- from: account.address,
1151
+ from: _optionalChain([account, 'optionalAccess', _14 => _14.address]),
1036
1152
  to,
1037
- value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _13 => _13.nativeCurrency, 'access', _14 => _14.symbol]) || "ETH"}`,
1153
+ value: typeof value !== "undefined" && `${formatEther(value)} ${_optionalChain([chain, 'optionalAccess', _15 => _15.nativeCurrency, 'access', _16 => _16.symbol]) || "ETH"}`,
1038
1154
  data,
1039
1155
  gas,
1040
1156
  gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
@@ -1071,7 +1187,7 @@ var ExecutionRevertedError = class extends BaseError {
1071
1187
  cause,
1072
1188
  message
1073
1189
  } = {}) {
1074
- const reason = _optionalChain([message, 'optionalAccess', _15 => _15.replace, 'call', _16 => _16("execution reverted: ", ""), 'optionalAccess', _17 => _17.replace, 'call', _18 => _18("execution reverted", "")]);
1190
+ const reason = _optionalChain([message, 'optionalAccess', _17 => _17.replace, 'call', _18 => _18("execution reverted: ", ""), 'optionalAccess', _19 => _19.replace, 'call', _20 => _20("execution reverted", "")]);
1075
1191
  super(
1076
1192
  `Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
1077
1193
  {
@@ -1223,7 +1339,7 @@ var TipAboveFeeCapError = class extends BaseError {
1223
1339
  __publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
1224
1340
  var UnknownNodeError = class extends BaseError {
1225
1341
  constructor({ cause }) {
1226
- super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _19 => _19.message])}`, {
1342
+ super(`An error occurred while executing: ${_optionalChain([cause, 'optionalAccess', _21 => _21.message])}`, {
1227
1343
  cause
1228
1344
  });
1229
1345
  __publicField(this, "name", "UnknownNodeError");
@@ -1874,9 +1990,9 @@ function rlpToBytes(bytes, offset = 0) {
1874
1990
  var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
1875
1991
  function extractFunctionParts(def) {
1876
1992
  const parts = def.match(paramsRegex);
1877
- const type = _optionalChain([parts, 'optionalAccess', _20 => _20[2]]) || void 0;
1878
- const name = _optionalChain([parts, 'optionalAccess', _21 => _21[3]]);
1879
- const params = _optionalChain([parts, 'optionalAccess', _22 => _22[5]]) || void 0;
1993
+ const type = _optionalChain([parts, 'optionalAccess', _22 => _22[2]]) || void 0;
1994
+ const name = _optionalChain([parts, 'optionalAccess', _23 => _23[3]]);
1995
+ const params = _optionalChain([parts, 'optionalAccess', _24 => _24[5]]) || void 0;
1880
1996
  return { type, name, params };
1881
1997
  }
1882
1998
  function extractFunctionName(def) {
@@ -1884,8 +2000,8 @@ function extractFunctionName(def) {
1884
2000
  }
1885
2001
  function extractFunctionParams(def) {
1886
2002
  const params = extractFunctionParts(def).params;
1887
- const splitParams = _optionalChain([params, 'optionalAccess', _23 => _23.split, 'call', _24 => _24(","), 'access', _25 => _25.map, 'call', _26 => _26((x) => x.trim().split(" "))]);
1888
- return _optionalChain([splitParams, 'optionalAccess', _27 => _27.map, 'call', _28 => _28((param) => ({
2003
+ const splitParams = _optionalChain([params, 'optionalAccess', _25 => _25.split, 'call', _26 => _26(","), 'access', _27 => _27.map, 'call', _28 => _28((x) => x.trim().split(" "))]);
2004
+ return _optionalChain([splitParams, 'optionalAccess', _29 => _29.map, 'call', _30 => _30((param) => ({
1889
2005
  type: param[0],
1890
2006
  name: param[1] === "indexed" ? param[2] : param[1],
1891
2007
  ...param[1] === "indexed" ? { indexed: true } : {}
@@ -1921,6 +2037,11 @@ var getEventSelector = (event) => hashFunction(event);
1921
2037
  // src/utils/hash/getFunctionSelector.ts
1922
2038
  var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
1923
2039
 
2040
+ // src/utils/hash/isHash.ts
2041
+ function isHash(hash2) {
2042
+ return hash2.startsWith("0x") && size(hash2) === 32;
2043
+ }
2044
+
1924
2045
  // src/utils/address/isAddress.ts
1925
2046
  var addressRegex = /^0x[a-fA-F0-9]{40}$/;
1926
2047
  function isAddress(address) {
@@ -2287,7 +2408,7 @@ function decodeArray(data, {
2287
2408
  }
2288
2409
  if (hasDynamicChild(param)) {
2289
2410
  const arrayComponents = getArrayComponents(param.type);
2290
- const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _29 => _29[0]]);
2411
+ const dynamicChild = !_optionalChain([arrayComponents, 'optionalAccess', _31 => _31[0]]);
2291
2412
  let consumed2 = 0;
2292
2413
  let value2 = [];
2293
2414
  for (let i = 0; i < length; ++i) {
@@ -2363,7 +2484,7 @@ function decodeTuple(data, { param, position }) {
2363
2484
  position: consumed
2364
2485
  });
2365
2486
  consumed += decodedChild.consumed;
2366
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _30 => _30.name])] = decodedChild.value;
2487
+ value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _32 => _32.name])] = decodedChild.value;
2367
2488
  }
2368
2489
  return { consumed: 32, value };
2369
2490
  }
@@ -2375,7 +2496,7 @@ function decodeTuple(data, { param, position }) {
2375
2496
  position: position + consumed
2376
2497
  });
2377
2498
  consumed += decodedChild.consumed;
2378
- value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _31 => _31.name])] = decodedChild.value;
2499
+ value[hasUnnamedChild ? i : _optionalChain([component, 'optionalAccess', _33 => _33.name])] = decodedChild.value;
2379
2500
  }
2380
2501
  return { consumed, value };
2381
2502
  }
@@ -2388,7 +2509,7 @@ function hasDynamicChild(param) {
2388
2509
  if (type.endsWith("[]"))
2389
2510
  return true;
2390
2511
  if (type === "tuple")
2391
- return _optionalChain([param, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.some, 'call', _34 => _34(hasDynamicChild)]);
2512
+ return _optionalChain([param, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.some, 'call', _36 => _36(hasDynamicChild)]);
2392
2513
  const arrayComponents = getArrayComponents(param.type);
2393
2514
  if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
2394
2515
  return true;
@@ -2459,7 +2580,7 @@ function decodeEventLog({
2459
2580
  docsPath
2460
2581
  });
2461
2582
  const { name, inputs } = abiItem;
2462
- const isUnnamed = _optionalChain([inputs, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((x) => !("name" in x && x.name))]);
2583
+ const isUnnamed = _optionalChain([inputs, 'optionalAccess', _37 => _37.some, 'call', _38 => _38((x) => !("name" in x && x.name))]);
2463
2584
  let args = isUnnamed ? [] : {};
2464
2585
  if (argTopics.length > 0) {
2465
2586
  const indexedInputs = inputs.filter((x) => "indexed" in x && x.indexed);
@@ -2680,8 +2801,8 @@ function encodeEventTopics({ abi, eventName, args }) {
2680
2801
  const signature = getEventSelector(definition);
2681
2802
  let topics = [];
2682
2803
  if (args && "inputs" in abiItem) {
2683
- const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _37 => _37.inputs, 'optionalAccess', _38 => _38.map, 'call', _39 => _39((x) => args[x.name])]), () => ( []));
2684
- 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(
2804
+ const args_ = Array.isArray(args) ? args : _nullishCoalesce(_optionalChain([abiItem, 'access', _39 => _39.inputs, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((x) => args[x.name])]), () => ( []));
2805
+ topics = _nullishCoalesce(_optionalChain([abiItem, 'access', _42 => _42.inputs, 'optionalAccess', _43 => _43.filter, 'call', _44 => _44((param) => "indexed" in param && param.indexed), 'access', _45 => _45.map, 'call', _46 => _46(
2685
2806
  (param, i) => Array.isArray(args_[i]) ? args_[i].map(
2686
2807
  (_, j) => encodeArg({ param, value: args_[i][j] })
2687
2808
  ) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
@@ -2828,19 +2949,11 @@ function formatAbiItemWithArgs({
2828
2949
  ).join(", ")})`;
2829
2950
  }
2830
2951
 
2831
- // src/utils/account.ts
2832
- function getAccount(account) {
2833
- if (typeof account === "string") {
2834
- if (!isAddress(account))
2835
- throw new InvalidAddressError({ address: account });
2952
+ // src/accounts/utils/parseAccount.ts
2953
+ function parseAccount(account) {
2954
+ if (typeof account === "string")
2836
2955
  return { address: account, type: "json-rpc" };
2837
- }
2838
- if (!isAddress(account.address))
2839
- throw new InvalidAddressError({ address: account.address });
2840
- return {
2841
- ...account,
2842
- type: "local"
2843
- };
2956
+ return account;
2844
2957
  }
2845
2958
 
2846
2959
  // src/utils/promise/withCache.ts
@@ -2938,7 +3051,7 @@ function withTimeout(fn, {
2938
3051
  }
2939
3052
  }, timeout);
2940
3053
  }
2941
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _45 => _45.signal]) }));
3054
+ resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _47 => _47.signal]) }));
2942
3055
  } catch (err) {
2943
3056
  if (err.name === "AbortError")
2944
3057
  reject(errorInstance);
@@ -3004,8 +3117,8 @@ function buildRequest(request, {
3004
3117
  {
3005
3118
  delay: ({ count, error }) => {
3006
3119
  if (error && error instanceof HttpRequestError) {
3007
- const retryAfter = _optionalChain([error, 'optionalAccess', _46 => _46.headers, 'optionalAccess', _47 => _47.get, 'call', _48 => _48("Retry-After")]);
3008
- if (_optionalChain([retryAfter, 'optionalAccess', _49 => _49.match, 'call', _50 => _50(/\d/)]))
3120
+ const retryAfter = _optionalChain([error, 'optionalAccess', _48 => _48.headers, 'optionalAccess', _49 => _49.get, 'call', _50 => _50("Retry-After")]);
3121
+ if (_optionalChain([retryAfter, 'optionalAccess', _51 => _51.match, 'call', _52 => _52(/\d/)]))
3009
3122
  return parseInt(retryAfter) * 1e3;
3010
3123
  }
3011
3124
  return ~~(1 << count) * retryDelay;
@@ -3025,7 +3138,7 @@ function getChainContractAddress({
3025
3138
  chain,
3026
3139
  contract: name
3027
3140
  }) {
3028
- const contract = _optionalChain([chain, 'optionalAccess', _51 => _51.contracts, 'optionalAccess', _52 => _52[name]]);
3141
+ const contract = _optionalChain([chain, 'optionalAccess', _53 => _53.contracts, 'optionalAccess', _54 => _54[name]]);
3029
3142
  if (!contract)
3030
3143
  throw new ChainDoesNotSupportContract({
3031
3144
  chain,
@@ -3062,7 +3175,7 @@ function defineFormatter({
3062
3175
  }
3063
3176
  return {
3064
3177
  ...formatted,
3065
- ..._optionalChain([formatOverride, 'optionalCall', _53 => _53(data)])
3178
+ ..._optionalChain([formatOverride, 'optionalCall', _55 => _55(data)])
3066
3179
  };
3067
3180
  };
3068
3181
  }
@@ -3105,7 +3218,7 @@ var defineTransaction = defineFormatter({ format: formatTransaction });
3105
3218
 
3106
3219
  // src/utils/formatters/block.ts
3107
3220
  function formatBlock(block) {
3108
- const transactions = _optionalChain([block, 'access', _54 => _54.transactions, 'optionalAccess', _55 => _55.map, 'call', _56 => _56((transaction) => {
3221
+ const transactions = _optionalChain([block, 'access', _56 => _56.transactions, 'optionalAccess', _57 => _57.map, 'call', _58 => _58((transaction) => {
3109
3222
  if (typeof transaction === "string")
3110
3223
  return transaction;
3111
3224
  return formatTransaction(transaction);
@@ -3134,7 +3247,7 @@ function extract(value, { formatter }) {
3134
3247
  return {};
3135
3248
  const keys = Object.keys(formatter({}));
3136
3249
  return keys.reduce((data, key) => {
3137
- if (_optionalChain([value, 'optionalAccess', _57 => _57.hasOwnProperty, 'call', _58 => _58(key)])) {
3250
+ if (_optionalChain([value, 'optionalAccess', _59 => _59.hasOwnProperty, 'call', _60 => _60(key)])) {
3138
3251
  ;
3139
3252
  data[key] = value[key];
3140
3253
  }
@@ -3148,7 +3261,7 @@ function formatFeeHistory(feeHistory) {
3148
3261
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
3149
3262
  gasUsedRatio: feeHistory.gasUsedRatio,
3150
3263
  oldestBlock: BigInt(feeHistory.oldestBlock),
3151
- reward: _optionalChain([feeHistory, 'access', _59 => _59.reward, 'optionalAccess', _60 => _60.map, 'call', _61 => _61(
3264
+ reward: _optionalChain([feeHistory, 'access', _61 => _61.reward, 'optionalAccess', _62 => _62.map, 'call', _63 => _63(
3152
3265
  (reward) => reward.map((value) => BigInt(value))
3153
3266
  )])
3154
3267
  };
@@ -3216,34 +3329,34 @@ function getNodeError(err, args) {
3216
3329
  if (FeeCapTooHighError.nodeMessage.test(message))
3217
3330
  return new FeeCapTooHighError({
3218
3331
  cause: err,
3219
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _62 => _62.maxFeePerGas])
3332
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _64 => _64.maxFeePerGas])
3220
3333
  });
3221
3334
  else if (FeeCapTooLowError.nodeMessage.test(message))
3222
3335
  return new FeeCapTooLowError({
3223
3336
  cause: err,
3224
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _63 => _63.maxFeePerGas])
3337
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _65 => _65.maxFeePerGas])
3225
3338
  });
3226
3339
  else if (NonceTooHighError.nodeMessage.test(message))
3227
- return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _64 => _64.nonce]) });
3340
+ return new NonceTooHighError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _66 => _66.nonce]) });
3228
3341
  else if (NonceTooLowError.nodeMessage.test(message))
3229
- return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _65 => _65.nonce]) });
3342
+ return new NonceTooLowError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _67 => _67.nonce]) });
3230
3343
  else if (NonceMaxValueError.nodeMessage.test(message))
3231
- return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _66 => _66.nonce]) });
3344
+ return new NonceMaxValueError({ cause: err, nonce: _optionalChain([args, 'optionalAccess', _68 => _68.nonce]) });
3232
3345
  else if (InsufficientFundsError.nodeMessage.test(message))
3233
3346
  return new InsufficientFundsError({ cause: err });
3234
3347
  else if (IntrinsicGasTooHighError.nodeMessage.test(message))
3235
- return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _67 => _67.gas]) });
3348
+ return new IntrinsicGasTooHighError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _69 => _69.gas]) });
3236
3349
  else if (IntrinsicGasTooLowError.nodeMessage.test(message))
3237
- return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _68 => _68.gas]) });
3350
+ return new IntrinsicGasTooLowError({ cause: err, gas: _optionalChain([args, 'optionalAccess', _70 => _70.gas]) });
3238
3351
  else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
3239
3352
  return new TransactionTypeNotSupportedError({ cause: err });
3240
3353
  else if (TipAboveFeeCapError.nodeMessage.test(message))
3241
3354
  return new TipAboveFeeCapError({
3242
3355
  cause: err,
3243
- maxFeePerGas: _optionalChain([args, 'optionalAccess', _69 => _69.maxFeePerGas]),
3244
- maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _70 => _70.maxPriorityFeePerGas])
3356
+ maxFeePerGas: _optionalChain([args, 'optionalAccess', _71 => _71.maxFeePerGas]),
3357
+ maxPriorityFeePerGas: _optionalChain([args, 'optionalAccess', _72 => _72.maxPriorityFeePerGas])
3245
3358
  });
3246
- else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _71 => _71.cause, 'optionalAccess', _72 => _72.code]) === ExecutionRevertedError.code)
3359
+ else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && _optionalChain([err, 'access', _73 => _73.cause, 'optionalAccess', _74 => _74.code]) === ExecutionRevertedError.code)
3247
3360
  return new ExecutionRevertedError({
3248
3361
  cause: err,
3249
3362
  message: err.cause.details
@@ -3277,7 +3390,7 @@ function getContractError(err, {
3277
3390
  functionName,
3278
3391
  sender
3279
3392
  }) {
3280
- const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access', _73 => _73.cause, 'optionalAccess', _74 => _74.cause, 'optionalAccess', _75 => _75.cause]) || {} : err.cause || {};
3393
+ const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? _optionalChain([err, 'access', _75 => _75.cause, 'optionalAccess', _76 => _76.cause, 'optionalAccess', _77 => _77.cause]) || {} : err.cause || {};
3281
3394
  let cause = err;
3282
3395
  if (err instanceof AbiDecodingZeroDataError) {
3283
3396
  cause = new ContractFunctionZeroDataError({ functionName });
@@ -3366,7 +3479,7 @@ async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
3366
3479
  }
3367
3480
  );
3368
3481
  let data;
3369
- if (_optionalChain([response, 'access', _76 => _76.headers, 'access', _77 => _77.get, 'call', _78 => _78("Content-Type"), 'optionalAccess', _79 => _79.startsWith, 'call', _80 => _80("application/json")])) {
3482
+ if (_optionalChain([response, 'access', _78 => _78.headers, 'access', _79 => _79.get, 'call', _80 => _80("Content-Type"), 'optionalAccess', _81 => _81.startsWith, 'call', _82 => _82("application/json")])) {
3370
3483
  data = await response.json();
3371
3484
  } else {
3372
3485
  data = await response.text();
@@ -3458,15 +3571,15 @@ function webSocket(socket, {
3458
3571
  if (typeof message.id === "number" && id_ !== message.id)
3459
3572
  return;
3460
3573
  if (message.error) {
3461
- _optionalChain([onError, 'optionalCall', _81 => _81(new RpcError({ body, error: message.error, url: socket.url }))]);
3574
+ _optionalChain([onError, 'optionalCall', _83 => _83(new RpcError({ body, error: message.error, url: socket.url }))]);
3462
3575
  } else {
3463
- _optionalChain([onData, 'optionalCall', _82 => _82(message)]);
3576
+ _optionalChain([onData, 'optionalCall', _84 => _84(message)]);
3464
3577
  }
3465
3578
  if (body.method === "eth_subscribe" && typeof message.result === "string") {
3466
3579
  socket.subscriptions.set(message.result, callback);
3467
3580
  }
3468
3581
  if (body.method === "eth_unsubscribe") {
3469
- socket.subscriptions.delete(_optionalChain([body, 'access', _83 => _83.params, 'optionalAccess', _84 => _84[0]]));
3582
+ socket.subscriptions.delete(_optionalChain([body, 'access', _85 => _85.params, 'optionalAccess', _86 => _86[0]]));
3470
3583
  }
3471
3584
  };
3472
3585
  socket.requests.set(id_, callback);
@@ -3507,17 +3620,226 @@ ${messageBytes.length}`
3507
3620
  return keccak256(concat([prefixBytes, messageBytes]), to_);
3508
3621
  }
3509
3622
 
3623
+ // src/utils/typedData.ts
3624
+ function validateTypedData({
3625
+ domain,
3626
+ message,
3627
+ primaryType,
3628
+ types: types_
3629
+ }) {
3630
+ const types = types_;
3631
+ const validateData = (struct, value_) => {
3632
+ for (const param of struct) {
3633
+ const { name, type: type_ } = param;
3634
+ const type = type_;
3635
+ const value = value_[name];
3636
+ const integerMatch = type.match(integerRegex);
3637
+ if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
3638
+ const [_type, base, size_] = integerMatch;
3639
+ numberToHex(value, {
3640
+ signed: base === "int",
3641
+ size: parseInt(size_) / 8
3642
+ });
3643
+ }
3644
+ if (type === "address" && typeof value === "string" && !isAddress(value))
3645
+ throw new InvalidAddressError({ address: value });
3646
+ const bytesMatch = type.match(bytesRegex);
3647
+ if (bytesMatch) {
3648
+ const [_type, size_] = bytesMatch;
3649
+ if (size_ && size(value) !== parseInt(size_))
3650
+ throw new BytesSizeMismatchError({
3651
+ expectedSize: parseInt(size_),
3652
+ givenSize: size(value)
3653
+ });
3654
+ }
3655
+ const struct2 = types[type];
3656
+ if (struct2)
3657
+ validateData(struct2, value);
3658
+ }
3659
+ };
3660
+ if (types["EIP712Domain"] && domain)
3661
+ validateData(types["EIP712Domain"], domain);
3662
+ if (primaryType !== "EIP712Domain") {
3663
+ const type = types[primaryType];
3664
+ validateData(type, message);
3665
+ }
3666
+ }
3667
+
3668
+ // src/utils/signature/hashTypedData.ts
3669
+ function hashTypedData({
3670
+ domain: domain_,
3671
+ message,
3672
+ primaryType,
3673
+ types: types_
3674
+ }) {
3675
+ const domain = typeof domain_ === "undefined" ? {} : domain_;
3676
+ const types = {
3677
+ EIP712Domain: [
3678
+ _optionalChain([domain, 'optionalAccess', _87 => _87.name]) && { name: "name", type: "string" },
3679
+ _optionalChain([domain, 'optionalAccess', _88 => _88.version]) && { name: "version", type: "string" },
3680
+ _optionalChain([domain, 'optionalAccess', _89 => _89.chainId]) && { name: "chainId", type: "uint256" },
3681
+ _optionalChain([domain, 'optionalAccess', _90 => _90.verifyingContract]) && {
3682
+ name: "verifyingContract",
3683
+ type: "address"
3684
+ },
3685
+ _optionalChain([domain, 'optionalAccess', _91 => _91.salt]) && { name: "salt", type: "bytes32" }
3686
+ ].filter(Boolean),
3687
+ ...types_
3688
+ };
3689
+ validateTypedData({
3690
+ domain,
3691
+ message,
3692
+ primaryType,
3693
+ types
3694
+ });
3695
+ let parts = ["0x1901"];
3696
+ if (domain)
3697
+ parts.push(
3698
+ hashDomain({
3699
+ domain,
3700
+ types
3701
+ })
3702
+ );
3703
+ if (primaryType !== "EIP712Domain") {
3704
+ parts.push(
3705
+ hashStruct({
3706
+ data: message,
3707
+ primaryType,
3708
+ types
3709
+ })
3710
+ );
3711
+ }
3712
+ return keccak256(concat(parts));
3713
+ }
3714
+ function hashDomain({
3715
+ domain,
3716
+ types
3717
+ }) {
3718
+ return hashStruct({
3719
+ data: domain,
3720
+ primaryType: "EIP712Domain",
3721
+ types
3722
+ });
3723
+ }
3724
+ function hashStruct({
3725
+ data,
3726
+ primaryType,
3727
+ types
3728
+ }) {
3729
+ const encoded = encodeData({
3730
+ data,
3731
+ primaryType,
3732
+ types
3733
+ });
3734
+ return keccak256(encoded);
3735
+ }
3736
+ function encodeData({
3737
+ data,
3738
+ primaryType,
3739
+ types
3740
+ }) {
3741
+ let encodedTypes = [{ type: "bytes32" }];
3742
+ const encodedValues = [hashType({ primaryType, types })];
3743
+ for (const field of types[primaryType]) {
3744
+ const [type, value] = encodeField({
3745
+ types,
3746
+ name: field.name,
3747
+ type: field.type,
3748
+ value: data[field.name]
3749
+ });
3750
+ encodedTypes.push(type);
3751
+ encodedValues.push(value);
3752
+ }
3753
+ return encodeAbiParameters(encodedTypes, encodedValues);
3754
+ }
3755
+ function hashType({
3756
+ primaryType,
3757
+ types
3758
+ }) {
3759
+ const encodedHashType = toHex(encodeType({ primaryType, types }));
3760
+ return keccak256(encodedHashType);
3761
+ }
3762
+ function encodeType({
3763
+ primaryType,
3764
+ types
3765
+ }) {
3766
+ let result = "";
3767
+ const unsortedDeps = findTypeDependencies({ primaryType, types });
3768
+ unsortedDeps.delete(primaryType);
3769
+ const deps = [primaryType, ...Array.from(unsortedDeps).sort()];
3770
+ for (const type of deps) {
3771
+ result += `${type}(${types[type].map(({ name, type: t }) => `${t} ${name}`).join(",")})`;
3772
+ }
3773
+ return result;
3774
+ }
3775
+ function findTypeDependencies({
3776
+ primaryType: primaryType_,
3777
+ types
3778
+ }, results = /* @__PURE__ */ new Set()) {
3779
+ const match = primaryType_.match(/^\w*/u);
3780
+ const primaryType = _optionalChain([match, 'optionalAccess', _92 => _92[0]]);
3781
+ if (results.has(primaryType) || types[primaryType] === void 0) {
3782
+ return results;
3783
+ }
3784
+ results.add(primaryType);
3785
+ for (const field of types[primaryType]) {
3786
+ findTypeDependencies({ primaryType: field.type, types }, results);
3787
+ }
3788
+ return results;
3789
+ }
3790
+ function encodeField({
3791
+ types,
3792
+ name,
3793
+ type,
3794
+ value
3795
+ }) {
3796
+ if (types[type] !== void 0) {
3797
+ return [
3798
+ { type: "bytes32" },
3799
+ keccak256(encodeData({ data: value, primaryType: type, types }))
3800
+ ];
3801
+ }
3802
+ if (type === "bytes") {
3803
+ const prepend = value.length % 2 ? "0" : "";
3804
+ value = `0x${prepend + value.slice(2)}`;
3805
+ return [{ type: "bytes32" }, keccak256(value)];
3806
+ }
3807
+ if (type === "string")
3808
+ return [{ type: "bytes32" }, keccak256(toHex(value))];
3809
+ if (type.lastIndexOf("]") === type.length - 1) {
3810
+ const parsedType = type.slice(0, type.lastIndexOf("["));
3811
+ const typeValuePairs = value.map(
3812
+ (item) => encodeField({
3813
+ name,
3814
+ type: parsedType,
3815
+ types,
3816
+ value: item
3817
+ })
3818
+ );
3819
+ return [
3820
+ { type: "bytes32" },
3821
+ keccak256(
3822
+ encodeAbiParameters(
3823
+ typeValuePairs.map(([t]) => t),
3824
+ typeValuePairs.map(([, v]) => v)
3825
+ )
3826
+ )
3827
+ ];
3828
+ }
3829
+ return [{ type }, value];
3830
+ }
3831
+
3510
3832
  // src/utils/signature/recoverAddress.ts
3511
- var _secp256k1 = require('@noble/secp256k1');
3512
- function recoverAddress({
3833
+ async function recoverAddress({
3513
3834
  hash: hash2,
3514
3835
  signature
3515
3836
  }) {
3516
3837
  const signatureHex = isHex(signature) ? signature : toHex(signature);
3517
3838
  const hashHex = isHex(hash2) ? hash2 : toHex(hash2);
3518
3839
  const v = hexToNumber(`0x${signatureHex.slice(130)}`);
3840
+ const { recoverPublicKey } = await Promise.resolve().then(() => require("@noble/secp256k1"));
3519
3841
  const publicKey = toHex(
3520
- _secp256k1.recoverPublicKey.call(void 0,
3842
+ recoverPublicKey(
3521
3843
  hashHex.substring(2),
3522
3844
  signatureHex.substring(2, 130),
3523
3845
  v - 27
@@ -3528,28 +3850,75 @@ function recoverAddress({
3528
3850
  }
3529
3851
 
3530
3852
  // src/utils/signature/recoverMessageAddress.ts
3531
- function recoverMessageAddress({
3853
+ async function recoverMessageAddress({
3532
3854
  message,
3533
3855
  signature
3534
3856
  }) {
3535
3857
  return recoverAddress({ hash: hashMessage(message), signature });
3536
3858
  }
3537
3859
 
3860
+ // src/utils/signature/recoverTypedDataAddress.ts
3861
+ async function recoverTypedDataAddress({
3862
+ domain,
3863
+ message,
3864
+ primaryType,
3865
+ signature,
3866
+ types
3867
+ }) {
3868
+ return recoverAddress({
3869
+ hash: hashTypedData({
3870
+ domain,
3871
+ message,
3872
+ primaryType,
3873
+ types
3874
+ }),
3875
+ signature
3876
+ });
3877
+ }
3878
+
3538
3879
  // src/utils/signature/verifyMessage.ts
3539
- function verifyMessage({
3880
+ async function verifyMessage({
3540
3881
  address,
3541
3882
  message,
3542
3883
  signature
3543
3884
  }) {
3544
3885
  return isAddressEqual(
3545
3886
  getAddress(address),
3546
- recoverMessageAddress({ message, signature })
3887
+ await recoverMessageAddress({ message, signature })
3888
+ );
3889
+ }
3890
+
3891
+ // src/utils/signature/verifyTypedData.ts
3892
+ async function verifyTypedData({
3893
+ address,
3894
+ domain,
3895
+ message,
3896
+ primaryType,
3897
+ signature,
3898
+ types
3899
+ }) {
3900
+ return isAddressEqual(
3901
+ getAddress(address),
3902
+ await recoverTypedDataAddress({
3903
+ domain,
3904
+ message,
3905
+ primaryType,
3906
+ signature,
3907
+ types
3908
+ })
3547
3909
  );
3548
3910
  }
3549
3911
 
3550
3912
  // src/utils/transaction/assertRequest.ts
3551
3913
  function assertRequest(args) {
3552
- const { account, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
3914
+ const {
3915
+ account: account_,
3916
+ gasPrice,
3917
+ maxFeePerGas,
3918
+ maxPriorityFeePerGas,
3919
+ to
3920
+ } = args;
3921
+ const account = account_ ? parseAccount(account_) : void 0;
3553
3922
  if (account && !isAddress(account.address))
3554
3923
  throw new InvalidAddressError({ address: account.address });
3555
3924
  if (to && !isAddress(to))
@@ -3562,10 +3931,36 @@ function assertRequest(args) {
3562
3931
  throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
3563
3932
  }
3564
3933
 
3934
+ // src/utils/transaction/getSerializedTransactionType.ts
3935
+ function getSerializedTransactionType(serializedTransaction) {
3936
+ const serializedType = sliceHex(serializedTransaction, 0, 1);
3937
+ if (serializedType === "0x02")
3938
+ return "eip1559";
3939
+ if (serializedType === "0x01")
3940
+ return "eip2930";
3941
+ if (serializedType !== "0x" && hexToNumber(serializedType) >= 192)
3942
+ return "legacy";
3943
+ throw new InvalidSerializedTransactionTypeError({ serializedType });
3944
+ }
3945
+
3946
+ // src/utils/transaction/getTransactionType.ts
3947
+ function getTransactionType(transaction) {
3948
+ if (transaction.type)
3949
+ return transaction.type;
3950
+ if ("maxFeePerGas" in transaction || "maxPriorityFeePerGas" in transaction)
3951
+ return "eip1559";
3952
+ if ("gasPrice" in transaction) {
3953
+ if ("accessList" in transaction)
3954
+ return "eip2930";
3955
+ return "legacy";
3956
+ }
3957
+ throw new InvalidSerializableTransactionError({ transaction });
3958
+ }
3959
+
3565
3960
  // src/actions/public/call.ts
3566
3961
  async function call(client, args) {
3567
3962
  const {
3568
- account,
3963
+ account: account_,
3569
3964
  blockNumber,
3570
3965
  blockTag = "latest",
3571
3966
  accessList,
@@ -3579,13 +3974,14 @@ async function call(client, args) {
3579
3974
  value,
3580
3975
  ...rest
3581
3976
  } = args;
3977
+ const account = account_ ? parseAccount(account_) : void 0;
3582
3978
  try {
3583
3979
  assertRequest(args);
3584
3980
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
3585
- const formatter = _optionalChain([client, 'access', _85 => _85.chain, 'optionalAccess', _86 => _86.formatters, 'optionalAccess', _87 => _87.transactionRequest]);
3981
+ const formatter = _optionalChain([client, 'access', _93 => _93.chain, 'optionalAccess', _94 => _94.formatters, 'optionalAccess', _95 => _95.transactionRequest]);
3586
3982
  const request_ = format3(
3587
3983
  {
3588
- from: _optionalChain([account, 'optionalAccess', _88 => _88.address]),
3984
+ from: _optionalChain([account, 'optionalAccess', _96 => _96.address]),
3589
3985
  accessList,
3590
3986
  data,
3591
3987
  gas,
@@ -3612,6 +4008,7 @@ async function call(client, args) {
3612
4008
  } catch (err) {
3613
4009
  throw getCallError(err, {
3614
4010
  ...args,
4011
+ account,
3615
4012
  chain: client.chain
3616
4013
  });
3617
4014
  }
@@ -3625,6 +4022,7 @@ async function simulateContract(client, {
3625
4022
  functionName,
3626
4023
  ...callRequest
3627
4024
  }) {
4025
+ const account = callRequest.account ? parseAccount(callRequest.account) : void 0;
3628
4026
  const calldata = encodeFunctionData({
3629
4027
  abi,
3630
4028
  args,
@@ -3659,7 +4057,7 @@ async function simulateContract(client, {
3659
4057
  args,
3660
4058
  docsPath: "/docs/contract/simulateContract",
3661
4059
  functionName,
3662
- sender: _optionalChain([callRequest, 'access', _89 => _89.account, 'optionalAccess', _90 => _90.address])
4060
+ sender: _optionalChain([account, 'optionalAccess', _97 => _97.address])
3663
4061
  });
3664
4062
  }
3665
4063
  }
@@ -3751,9 +4149,13 @@ async function createContractEventFilter(client, {
3751
4149
 
3752
4150
  // src/actions/public/estimateGas.ts
3753
4151
  async function estimateGas(client, args) {
4152
+ if (!args.account)
4153
+ throw new AccountNotFoundError({
4154
+ docsPath: "/docs/actions/public/estimateGas"
4155
+ });
4156
+ const account = parseAccount(args.account);
3754
4157
  try {
3755
4158
  const {
3756
- account,
3757
4159
  accessList,
3758
4160
  blockNumber,
3759
4161
  blockTag = "latest",
@@ -3766,10 +4168,10 @@ async function estimateGas(client, args) {
3766
4168
  to,
3767
4169
  value,
3768
4170
  ...rest
3769
- } = args.account.type === "local" ? await prepareRequest(client, args) : args;
4171
+ } = account.type === "local" ? await prepareRequest(client, args) : args;
3770
4172
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
3771
4173
  assertRequest(args);
3772
- const formatter = _optionalChain([client, 'access', _91 => _91.chain, 'optionalAccess', _92 => _92.formatters, 'optionalAccess', _93 => _93.transactionRequest]);
4174
+ const formatter = _optionalChain([client, 'access', _98 => _98.chain, 'optionalAccess', _99 => _99.formatters, 'optionalAccess', _100 => _100.transactionRequest]);
3773
4175
  const request = format3(
3774
4176
  {
3775
4177
  from: account.address,
@@ -3797,6 +4199,7 @@ async function estimateGas(client, args) {
3797
4199
  } catch (err) {
3798
4200
  throw getEstimateGasError(err, {
3799
4201
  ...args,
4202
+ account,
3800
4203
  chain: client.chain
3801
4204
  });
3802
4205
  }
@@ -3810,6 +4213,7 @@ async function estimateContractGas(client, {
3810
4213
  functionName,
3811
4214
  ...request
3812
4215
  }) {
4216
+ const account = parseAccount(request.account);
3813
4217
  const data = encodeFunctionData({
3814
4218
  abi,
3815
4219
  args,
@@ -3829,7 +4233,7 @@ async function estimateContractGas(client, {
3829
4233
  args,
3830
4234
  docsPath: "/docs/contract/simulateContract",
3831
4235
  functionName,
3832
- sender: _optionalChain([request, 'access', _94 => _94.account, 'optionalAccess', _95 => _95.address])
4236
+ sender: _optionalChain([account, 'optionalAccess', _101 => _101.address])
3833
4237
  });
3834
4238
  }
3835
4239
  }
@@ -3867,7 +4271,7 @@ async function getBlock(client, {
3867
4271
  if (!block)
3868
4272
  throw new BlockNotFoundError({ blockHash, blockNumber });
3869
4273
  return format3(block, {
3870
- formatter: _optionalChain([client, 'access', _96 => _96.chain, 'optionalAccess', _97 => _97.formatters, 'optionalAccess', _98 => _98.block]) || formatBlock
4274
+ formatter: _optionalChain([client, 'access', _102 => _102.chain, 'optionalAccess', _103 => _103.formatters, 'optionalAccess', _104 => _104.block]) || formatBlock
3871
4275
  });
3872
4276
  }
3873
4277
 
@@ -4079,7 +4483,7 @@ async function getTransaction(client, {
4079
4483
  index
4080
4484
  });
4081
4485
  return format3(transaction, {
4082
- formatter: _optionalChain([client, 'access', _99 => _99.chain, 'optionalAccess', _100 => _100.formatters, 'optionalAccess', _101 => _101.transaction]) || formatTransaction
4486
+ formatter: _optionalChain([client, 'access', _105 => _105.chain, 'optionalAccess', _106 => _106.formatters, 'optionalAccess', _107 => _107.transaction]) || formatTransaction
4083
4487
  });
4084
4488
  }
4085
4489
 
@@ -4089,7 +4493,7 @@ async function getTransactionConfirmations(client, { hash: hash2, transactionRec
4089
4493
  getBlockNumber(client),
4090
4494
  hash2 ? getTransaction(client, { hash: hash2 }) : void 0
4091
4495
  ]);
4092
- const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess', _102 => _102.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _103 => _103.blockNumber]);
4496
+ const transactionBlockNumber = _optionalChain([transactionReceipt, 'optionalAccess', _108 => _108.blockNumber]) || _optionalChain([transaction, 'optionalAccess', _109 => _109.blockNumber]);
4093
4497
  if (!transactionBlockNumber)
4094
4498
  return 0n;
4095
4499
  return blockNumber - transactionBlockNumber + 1n;
@@ -4113,7 +4517,7 @@ async function getTransactionReceipt(client, { hash: hash2 }) {
4113
4517
  if (!receipt)
4114
4518
  throw new TransactionReceiptNotFoundError({ hash: hash2 });
4115
4519
  return format3(receipt, {
4116
- formatter: _optionalChain([client, 'access', _104 => _104.chain, 'optionalAccess', _105 => _105.formatters, 'optionalAccess', _106 => _106.transactionReceipt]) || formatTransactionReceipt
4520
+ formatter: _optionalChain([client, 'access', _110 => _110.chain, 'optionalAccess', _111 => _111.formatters, 'optionalAccess', _112 => _112.transactionReceipt]) || formatTransactionReceipt
4117
4521
  });
4118
4522
  }
4119
4523
 
@@ -4282,7 +4686,7 @@ function observe(observerId, callbacks, fn) {
4282
4686
  const listeners2 = getListeners();
4283
4687
  if (listeners2.length === 0)
4284
4688
  return;
4285
- listeners2.forEach((listener) => _optionalChain([listener, 'access', _107 => _107.fns, 'access', _108 => _108[key], 'optionalCall', _109 => _109(...args)]));
4689
+ listeners2.forEach((listener) => _optionalChain([listener, 'access', _113 => _113.fns, 'access', _114 => _114[key], 'optionalCall', _115 => _115(...args)]));
4286
4690
  };
4287
4691
  }
4288
4692
  const cleanup = fn(emit);
@@ -4320,6 +4724,7 @@ async function waitForTransactionReceipt(client, {
4320
4724
  const unwatch = watchBlockNumber(client, {
4321
4725
  emitMissed: true,
4322
4726
  emitOnBegin: true,
4727
+ poll: true,
4323
4728
  pollingInterval,
4324
4729
  async onBlockNumber(blockNumber) {
4325
4730
  const done = async (fn) => {
@@ -4363,7 +4768,7 @@ async function waitForTransactionReceipt(client, {
4363
4768
  reason = "cancelled";
4364
4769
  }
4365
4770
  done(() => {
4366
- _optionalChain([emit, 'access', _110 => _110.onReplaced, 'optionalCall', _111 => _111({
4771
+ _optionalChain([emit, 'access', _116 => _116.onReplaced, 'optionalCall', _117 => _117({
4367
4772
  reason,
4368
4773
  replacedTransaction,
4369
4774
  transaction: replacementTransaction,
@@ -4391,7 +4796,7 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
4391
4796
  let data;
4392
4797
  if (emitOnBegin)
4393
4798
  data = await fn({ unpoll: unwatch });
4394
- const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _112 => _112(data)]), async () => ( interval));
4799
+ const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _118 => _118(data)]), async () => ( interval));
4395
4800
  await wait(initialWait);
4396
4801
  const poll2 = async () => {
4397
4802
  if (!active)
@@ -4412,47 +4817,79 @@ function watchBlockNumber(client, {
4412
4817
  emitMissed = false,
4413
4818
  onBlockNumber,
4414
4819
  onError,
4820
+ poll: poll_,
4415
4821
  pollingInterval = client.pollingInterval
4416
4822
  }) {
4417
- const observerId = JSON.stringify([
4418
- "watchBlockNumber",
4419
- client.uid,
4420
- emitOnBegin,
4421
- emitMissed,
4422
- pollingInterval
4423
- ]);
4823
+ const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
4424
4824
  let prevBlockNumber;
4425
- return observe(
4426
- observerId,
4427
- { onBlockNumber, onError },
4428
- (emit) => poll(
4429
- async () => {
4430
- try {
4431
- const blockNumber = await getBlockNumber(client, { maxAge: 0 });
4432
- if (prevBlockNumber) {
4433
- if (blockNumber === prevBlockNumber)
4434
- return;
4435
- if (blockNumber - prevBlockNumber > 1 && emitMissed) {
4436
- for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {
4437
- emit.onBlockNumber(i, prevBlockNumber);
4438
- prevBlockNumber = i;
4825
+ const pollBlockNumber = () => {
4826
+ const observerId = JSON.stringify([
4827
+ "watchBlockNumber",
4828
+ client.uid,
4829
+ emitOnBegin,
4830
+ emitMissed,
4831
+ pollingInterval
4832
+ ]);
4833
+ return observe(
4834
+ observerId,
4835
+ { onBlockNumber, onError },
4836
+ (emit) => poll(
4837
+ async () => {
4838
+ try {
4839
+ const blockNumber = await getBlockNumber(client, { maxAge: 0 });
4840
+ if (prevBlockNumber) {
4841
+ if (blockNumber === prevBlockNumber)
4842
+ return;
4843
+ if (blockNumber - prevBlockNumber > 1 && emitMissed) {
4844
+ for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {
4845
+ emit.onBlockNumber(i, prevBlockNumber);
4846
+ prevBlockNumber = i;
4847
+ }
4439
4848
  }
4440
4849
  }
4850
+ if (!prevBlockNumber || blockNumber > prevBlockNumber) {
4851
+ emit.onBlockNumber(blockNumber, prevBlockNumber);
4852
+ prevBlockNumber = blockNumber;
4853
+ }
4854
+ } catch (err) {
4855
+ _optionalChain([emit, 'access', _119 => _119.onError, 'optionalCall', _120 => _120(err)]);
4441
4856
  }
4442
- if (!prevBlockNumber || blockNumber > prevBlockNumber) {
4443
- emit.onBlockNumber(blockNumber, prevBlockNumber);
4857
+ },
4858
+ {
4859
+ emitOnBegin,
4860
+ interval: pollingInterval
4861
+ }
4862
+ )
4863
+ );
4864
+ };
4865
+ const subscribeBlockNumber = () => {
4866
+ let active = true;
4867
+ let unsubscribe = () => active = false;
4868
+ (async () => {
4869
+ try {
4870
+ const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
4871
+ params: ["newHeads"],
4872
+ onData(data) {
4873
+ if (!active)
4874
+ return;
4875
+ const blockNumber = hexToBigInt(_optionalChain([data, 'access', _121 => _121.result, 'optionalAccess', _122 => _122.number]));
4876
+ onBlockNumber(blockNumber, prevBlockNumber);
4444
4877
  prevBlockNumber = blockNumber;
4878
+ },
4879
+ onError(error) {
4880
+ _optionalChain([onError, 'optionalCall', _123 => _123(error)]);
4445
4881
  }
4446
- } catch (err) {
4447
- _optionalChain([emit, 'access', _113 => _113.onError, 'optionalCall', _114 => _114(err)]);
4448
- }
4449
- },
4450
- {
4451
- emitOnBegin,
4452
- interval: pollingInterval
4882
+ });
4883
+ unsubscribe = unsubscribe_;
4884
+ if (!active)
4885
+ unsubscribe();
4886
+ } catch (err) {
4887
+ _optionalChain([onError, 'optionalCall', _124 => _124(err)]);
4453
4888
  }
4454
- )
4455
- );
4889
+ })();
4890
+ return unsubscribe;
4891
+ };
4892
+ return enablePolling ? pollBlockNumber() : subscribeBlockNumber();
4456
4893
  }
4457
4894
 
4458
4895
  // src/actions/public/watchBlocks.ts
@@ -4463,61 +4900,93 @@ function watchBlocks(client, {
4463
4900
  onBlock,
4464
4901
  onError,
4465
4902
  includeTransactions = false,
4903
+ poll: poll_,
4466
4904
  pollingInterval = client.pollingInterval
4467
4905
  }) {
4468
- const observerId = JSON.stringify([
4469
- "watchBlocks",
4470
- client.uid,
4471
- emitMissed,
4472
- emitOnBegin,
4473
- includeTransactions,
4474
- pollingInterval
4475
- ]);
4906
+ const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
4476
4907
  let prevBlock;
4477
- return observe(
4478
- observerId,
4479
- { onBlock, onError },
4480
- (emit) => poll(
4481
- async () => {
4482
- try {
4483
- const block = await getBlock(client, {
4484
- blockTag,
4485
- includeTransactions
4486
- });
4487
- if (block.number && _optionalChain([prevBlock, 'optionalAccess', _115 => _115.number])) {
4488
- if (block.number === prevBlock.number)
4489
- return;
4490
- if (block.number - prevBlock.number > 1 && emitMissed) {
4491
- for (let i = _optionalChain([prevBlock, 'optionalAccess', _116 => _116.number]) + 1n; i < block.number; i++) {
4492
- const block2 = await getBlock(client, {
4493
- blockNumber: i,
4494
- includeTransactions
4495
- });
4496
- emit.onBlock(block2, prevBlock);
4497
- prevBlock = block2;
4908
+ const pollBlocks = () => {
4909
+ const observerId = JSON.stringify([
4910
+ "watchBlocks",
4911
+ client.uid,
4912
+ emitMissed,
4913
+ emitOnBegin,
4914
+ includeTransactions,
4915
+ pollingInterval
4916
+ ]);
4917
+ return observe(
4918
+ observerId,
4919
+ { onBlock, onError },
4920
+ (emit) => poll(
4921
+ async () => {
4922
+ try {
4923
+ const block = await getBlock(client, {
4924
+ blockTag,
4925
+ includeTransactions
4926
+ });
4927
+ if (block.number && _optionalChain([prevBlock, 'optionalAccess', _125 => _125.number])) {
4928
+ if (block.number === prevBlock.number)
4929
+ return;
4930
+ if (block.number - prevBlock.number > 1 && emitMissed) {
4931
+ for (let i = _optionalChain([prevBlock, 'optionalAccess', _126 => _126.number]) + 1n; i < block.number; i++) {
4932
+ const block2 = await getBlock(client, {
4933
+ blockNumber: i,
4934
+ includeTransactions
4935
+ });
4936
+ emit.onBlock(block2, prevBlock);
4937
+ prevBlock = block2;
4938
+ }
4498
4939
  }
4499
4940
  }
4941
+ if (
4942
+ // If no previous block exists, emit.
4943
+ !_optionalChain([prevBlock, 'optionalAccess', _127 => _127.number]) || // If the block tag is "pending" with no block number, emit.
4944
+ blockTag === "pending" && !_optionalChain([block, 'optionalAccess', _128 => _128.number]) || // If the next block number is greater than the previous block number, emit.
4945
+ // We don't want to emit blocks in the past.
4946
+ block.number && block.number > prevBlock.number
4947
+ ) {
4948
+ emit.onBlock(block, prevBlock);
4949
+ prevBlock = block;
4950
+ }
4951
+ } catch (err) {
4952
+ _optionalChain([emit, 'access', _129 => _129.onError, 'optionalCall', _130 => _130(err)]);
4500
4953
  }
4501
- if (
4502
- // If no previous block exists, emit.
4503
- !_optionalChain([prevBlock, 'optionalAccess', _117 => _117.number]) || // If the block tag is "pending" with no block number, emit.
4504
- blockTag === "pending" && !_optionalChain([block, 'optionalAccess', _118 => _118.number]) || // If the next block number is greater than the previous block number, emit.
4505
- // We don't want to emit blocks in the past.
4506
- block.number && block.number > prevBlock.number
4507
- ) {
4508
- emit.onBlock(block, prevBlock);
4954
+ },
4955
+ {
4956
+ emitOnBegin,
4957
+ interval: pollingInterval
4958
+ }
4959
+ )
4960
+ );
4961
+ };
4962
+ const subscribeBlocks = () => {
4963
+ let active = true;
4964
+ let unsubscribe = () => active = false;
4965
+ (async () => {
4966
+ try {
4967
+ const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
4968
+ params: ["newHeads"],
4969
+ onData(data) {
4970
+ if (!active)
4971
+ return;
4972
+ const block = data.result;
4973
+ onBlock(block, prevBlock);
4509
4974
  prevBlock = block;
4975
+ },
4976
+ onError(error) {
4977
+ _optionalChain([onError, 'optionalCall', _131 => _131(error)]);
4510
4978
  }
4511
- } catch (err) {
4512
- _optionalChain([emit, 'access', _119 => _119.onError, 'optionalCall', _120 => _120(err)]);
4513
- }
4514
- },
4515
- {
4516
- emitOnBegin,
4517
- interval: pollingInterval
4979
+ });
4980
+ unsubscribe = unsubscribe_;
4981
+ if (!active)
4982
+ unsubscribe();
4983
+ } catch (err) {
4984
+ _optionalChain([onError, 'optionalCall', _132 => _132(err)]);
4518
4985
  }
4519
- )
4520
- );
4986
+ })();
4987
+ return unsubscribe;
4988
+ };
4989
+ return enablePolling ? pollBlocks() : subscribeBlocks();
4521
4990
  }
4522
4991
 
4523
4992
  // src/actions/public/watchContractEvent.ts
@@ -4588,7 +5057,7 @@ function watchContractEvent(client, {
4588
5057
  else
4589
5058
  logs.forEach((log) => emit.onLogs([log]));
4590
5059
  } catch (err) {
4591
- _optionalChain([emit, 'access', _121 => _121.onError, 'optionalCall', _122 => _122(err)]);
5060
+ _optionalChain([emit, 'access', _133 => _133.onError, 'optionalCall', _134 => _134(err)]);
4592
5061
  }
4593
5062
  },
4594
5063
  {
@@ -4667,7 +5136,7 @@ function watchEvent(client, {
4667
5136
  else
4668
5137
  logs.forEach((log) => emit.onLogs([log]));
4669
5138
  } catch (err) {
4670
- _optionalChain([emit, 'access', _123 => _123.onError, 'optionalCall', _124 => _124(err)]);
5139
+ _optionalChain([emit, 'access', _135 => _135.onError, 'optionalCall', _136 => _136(err)]);
4671
5140
  }
4672
5141
  },
4673
5142
  {
@@ -4688,50 +5157,81 @@ function watchPendingTransactions(client, {
4688
5157
  batch = true,
4689
5158
  onError,
4690
5159
  onTransactions,
5160
+ poll: poll_,
4691
5161
  pollingInterval = client.pollingInterval
4692
5162
  }) {
4693
- const observerId = JSON.stringify([
4694
- "watchPendingTransactions",
4695
- client.uid,
4696
- batch,
4697
- pollingInterval
4698
- ]);
4699
- return observe(observerId, { onTransactions, onError }, (emit) => {
4700
- let filter;
4701
- const unwatch = poll(
4702
- async () => {
4703
- try {
4704
- if (!filter) {
4705
- try {
4706
- filter = await createPendingTransactionFilter(client);
4707
- return;
4708
- } catch (err) {
4709
- unwatch();
4710
- throw err;
5163
+ const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
5164
+ const pollPendingTransactions = () => {
5165
+ const observerId = JSON.stringify([
5166
+ "watchPendingTransactions",
5167
+ client.uid,
5168
+ batch,
5169
+ pollingInterval
5170
+ ]);
5171
+ return observe(observerId, { onTransactions, onError }, (emit) => {
5172
+ let filter;
5173
+ const unwatch = poll(
5174
+ async () => {
5175
+ try {
5176
+ if (!filter) {
5177
+ try {
5178
+ filter = await createPendingTransactionFilter(client);
5179
+ return;
5180
+ } catch (err) {
5181
+ unwatch();
5182
+ throw err;
5183
+ }
4711
5184
  }
5185
+ const hashes = await getFilterChanges(client, { filter });
5186
+ if (hashes.length === 0)
5187
+ return;
5188
+ if (batch)
5189
+ emit.onTransactions(hashes);
5190
+ else
5191
+ hashes.forEach((hash2) => emit.onTransactions([hash2]));
5192
+ } catch (err) {
5193
+ _optionalChain([emit, 'access', _137 => _137.onError, 'optionalCall', _138 => _138(err)]);
4712
5194
  }
4713
- const hashes = await getFilterChanges(client, { filter });
4714
- if (hashes.length === 0)
4715
- return;
4716
- if (batch)
4717
- emit.onTransactions(hashes);
4718
- else
4719
- hashes.forEach((hash2) => emit.onTransactions([hash2]));
4720
- } catch (err) {
4721
- _optionalChain([emit, 'access', _125 => _125.onError, 'optionalCall', _126 => _126(err)]);
5195
+ },
5196
+ {
5197
+ emitOnBegin: true,
5198
+ interval: pollingInterval
4722
5199
  }
4723
- },
4724
- {
4725
- emitOnBegin: true,
4726
- interval: pollingInterval
5200
+ );
5201
+ return async () => {
5202
+ if (filter)
5203
+ await uninstallFilter(client, { filter });
5204
+ unwatch();
5205
+ };
5206
+ });
5207
+ };
5208
+ const subscribePendingTransactions = () => {
5209
+ let active = true;
5210
+ let unsubscribe = () => active = false;
5211
+ (async () => {
5212
+ try {
5213
+ const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
5214
+ params: ["newPendingTransactions"],
5215
+ onData(data) {
5216
+ if (!active)
5217
+ return;
5218
+ const transaction = data.result;
5219
+ onTransactions([transaction]);
5220
+ },
5221
+ onError(error) {
5222
+ _optionalChain([onError, 'optionalCall', _139 => _139(error)]);
5223
+ }
5224
+ });
5225
+ unsubscribe = unsubscribe_;
5226
+ if (!active)
5227
+ unsubscribe();
5228
+ } catch (err) {
5229
+ _optionalChain([onError, 'optionalCall', _140 => _140(err)]);
4727
5230
  }
4728
- );
4729
- return async () => {
4730
- if (filter)
4731
- await uninstallFilter(client, { filter });
4732
- unwatch();
4733
- };
4734
- });
5231
+ })();
5232
+ return unsubscribe;
5233
+ };
5234
+ return enablePolling ? pollPendingTransactions() : subscribePendingTransactions();
4735
5235
  }
4736
5236
 
4737
5237
  // src/actions/test/dropTransaction.ts
@@ -4980,7 +5480,12 @@ async function addChain(client, { chain }) {
4980
5480
  }
4981
5481
 
4982
5482
  // src/actions/wallet/deployContract.ts
4983
- function deployContract(walletClient, { abi, args, bytecode, ...request }) {
5483
+ function deployContract(walletClient, {
5484
+ abi,
5485
+ args,
5486
+ bytecode,
5487
+ ...request
5488
+ }) {
4984
5489
  const calldata = encodeDeployData({
4985
5490
  abi,
4986
5491
  args,
@@ -5021,10 +5526,9 @@ async function requestPermissions(client, permissions) {
5021
5526
  // src/actions/wallet/sendTransaction.ts
5022
5527
  async function sendTransaction(client, args) {
5023
5528
  const {
5024
- account,
5529
+ account: account_ = client.account,
5025
5530
  chain = client.chain,
5026
5531
  accessList,
5027
- assertChain = true,
5028
5532
  data,
5029
5533
  gas,
5030
5534
  gasPrice,
@@ -5035,13 +5539,20 @@ async function sendTransaction(client, args) {
5035
5539
  value,
5036
5540
  ...rest
5037
5541
  } = args;
5542
+ if (!account_)
5543
+ throw new AccountNotFoundError({
5544
+ docsPath: "/docs/actions/wallet/sendTransaction"
5545
+ });
5546
+ const account = parseAccount(account_);
5038
5547
  try {
5039
5548
  assertRequest(args);
5040
- const currentChainId = await getChainId(client);
5041
- if (assertChain && chain && currentChainId !== _optionalChain([chain, 'optionalAccess', _127 => _127.id]))
5042
- throw new ChainMismatchError({ chain, currentChainId });
5549
+ const chainId = await getChainId(client);
5550
+ if (chain !== null && chainId !== _optionalChain([chain, 'optionalAccess', _141 => _141.id])) {
5551
+ if (!chain)
5552
+ throw new ChainNotFoundError();
5553
+ throw new ChainMismatchError({ chain, currentChainId: chainId });
5554
+ }
5043
5555
  if (account.type === "local") {
5044
- const chainId = _nullishCoalesce(_optionalChain([chain, 'optionalAccess', _128 => _128.id]), () => ( currentChainId));
5045
5556
  const request2 = await prepareRequest(client, {
5046
5557
  account,
5047
5558
  accessList,
@@ -5065,7 +5576,7 @@ async function sendTransaction(client, args) {
5065
5576
  params: [signedRequest]
5066
5577
  });
5067
5578
  }
5068
- const formatter = _optionalChain([chain, 'optionalAccess', _129 => _129.formatters, 'optionalAccess', _130 => _130.transactionRequest]);
5579
+ const formatter = _optionalChain([chain, 'optionalAccess', _142 => _142.formatters, 'optionalAccess', _143 => _143.transactionRequest]);
5069
5580
  const request = format3(
5070
5581
  {
5071
5582
  accessList,
@@ -5090,15 +5601,28 @@ async function sendTransaction(client, args) {
5090
5601
  params: [request]
5091
5602
  });
5092
5603
  } catch (err) {
5093
- throw getTransactionError(err, args);
5604
+ throw getTransactionError(err, {
5605
+ ...args,
5606
+ account,
5607
+ chain: args.chain || void 0
5608
+ });
5094
5609
  }
5095
5610
  }
5096
5611
 
5097
5612
  // src/actions/wallet/signMessage.ts
5098
- async function signMessage(client, { account, data, message }) {
5613
+ async function signMessage(client, {
5614
+ account: account_ = client.account,
5615
+ data,
5616
+ message
5617
+ }) {
5618
+ if (!account_)
5619
+ throw new AccountNotFoundError({
5620
+ docsPath: "/docs/actions/wallet/signMessage"
5621
+ });
5622
+ const account = parseAccount(account_);
5099
5623
  const message_ = message || data;
5100
5624
  if (account.type === "local")
5101
- return account.signMessage(message_);
5625
+ return account.signMessage({ message: message_ });
5102
5626
  return client.request({
5103
5627
  method: "personal_sign",
5104
5628
  params: [toHex(message_), account.address]
@@ -5107,22 +5631,27 @@ async function signMessage(client, { account, data, message }) {
5107
5631
 
5108
5632
  // src/actions/wallet/signTypedData.ts
5109
5633
  async function signTypedData(client, {
5110
- account,
5634
+ account: account_ = client.account,
5111
5635
  domain,
5112
5636
  message,
5113
5637
  primaryType,
5114
5638
  types: types_
5115
5639
  }) {
5640
+ if (!account_)
5641
+ throw new AccountNotFoundError({
5642
+ docsPath: "/docs/actions/wallet/signTypedData"
5643
+ });
5644
+ const account = parseAccount(account_);
5116
5645
  const types = {
5117
5646
  EIP712Domain: [
5118
- _optionalChain([domain, 'optionalAccess', _131 => _131.name]) && { name: "name", type: "string" },
5119
- _optionalChain([domain, 'optionalAccess', _132 => _132.version]) && { name: "version", type: "string" },
5120
- _optionalChain([domain, 'optionalAccess', _133 => _133.chainId]) && { name: "chainId", type: "uint256" },
5121
- _optionalChain([domain, 'optionalAccess', _134 => _134.verifyingContract]) && {
5647
+ _optionalChain([domain, 'optionalAccess', _144 => _144.name]) && { name: "name", type: "string" },
5648
+ _optionalChain([domain, 'optionalAccess', _145 => _145.version]) && { name: "version", type: "string" },
5649
+ _optionalChain([domain, 'optionalAccess', _146 => _146.chainId]) && { name: "chainId", type: "uint256" },
5650
+ _optionalChain([domain, 'optionalAccess', _147 => _147.verifyingContract]) && {
5122
5651
  name: "verifyingContract",
5123
5652
  type: "address"
5124
5653
  },
5125
- _optionalChain([domain, 'optionalAccess', _135 => _135.salt]) && { name: "salt", type: "bytes32" }
5654
+ _optionalChain([domain, 'optionalAccess', _148 => _148.salt]) && { name: "salt", type: "bytes32" }
5126
5655
  ].filter(Boolean),
5127
5656
  ...types_
5128
5657
  };
@@ -5148,47 +5677,6 @@ async function signTypedData(client, {
5148
5677
  params: [account.address, typedData]
5149
5678
  });
5150
5679
  }
5151
- function validateTypedData({
5152
- domain,
5153
- message,
5154
- primaryType,
5155
- types: types_
5156
- }) {
5157
- const types = types_;
5158
- const validateData = (struct, value_) => {
5159
- for (const param of struct) {
5160
- const { name, type: type_ } = param;
5161
- const type2 = type_;
5162
- const value = value_[name];
5163
- const integerMatch = type2.match(integerRegex);
5164
- if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
5165
- const [_type, base, size_] = integerMatch;
5166
- numberToHex(value, {
5167
- signed: base === "int",
5168
- size: parseInt(size_) / 8
5169
- });
5170
- }
5171
- if (type2 === "address" && typeof value === "string" && !isAddress(value))
5172
- throw new InvalidAddressError({ address: value });
5173
- const bytesMatch = type2.match(bytesRegex);
5174
- if (bytesMatch) {
5175
- const [_type, size_] = bytesMatch;
5176
- if (size_ && size(value) !== parseInt(size_))
5177
- throw new BytesSizeMismatchError({
5178
- expectedSize: parseInt(size_),
5179
- givenSize: size(value)
5180
- });
5181
- }
5182
- const struct2 = types[type2];
5183
- if (struct2)
5184
- validateData(struct2, value);
5185
- }
5186
- };
5187
- if (types["EIP712Domain"] && domain)
5188
- validateData(types["EIP712Domain"], domain);
5189
- const type = types[primaryType];
5190
- validateData(type, message);
5191
- }
5192
5680
 
5193
5681
  // src/actions/wallet/switchChain.ts
5194
5682
  async function switchChain(client, { id: id2 }) {
@@ -5262,7 +5750,17 @@ function parseGwei(ether, unit = "wei") {
5262
5750
  // src/utils/transaction/prepareRequest.ts
5263
5751
  var defaultTip = parseGwei("1.5");
5264
5752
  async function prepareRequest(client, args) {
5265
- const { account, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce } = args;
5753
+ const {
5754
+ account: account_,
5755
+ gas,
5756
+ gasPrice,
5757
+ maxFeePerGas,
5758
+ maxPriorityFeePerGas,
5759
+ nonce
5760
+ } = args;
5761
+ if (!account_)
5762
+ throw new AccountNotFoundError();
5763
+ const account = parseAccount(account_);
5266
5764
  const block = await getBlock(client, { blockTag: "latest" });
5267
5765
  const request = { ...args, from: account.address };
5268
5766
  if (typeof nonce === "undefined")
@@ -5299,6 +5797,400 @@ async function prepareRequest(client, args) {
5299
5797
  return request;
5300
5798
  }
5301
5799
 
5800
+ // src/utils/transaction/assertTransaction.ts
5801
+ function assertTransactionEIP1559(transaction) {
5802
+ const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
5803
+ if (chainId <= 0)
5804
+ throw new InvalidChainIdError({ chainId });
5805
+ if (to && !isAddress(to))
5806
+ throw new InvalidAddressError({ address: to });
5807
+ if (gasPrice)
5808
+ throw new BaseError(
5809
+ "`gasPrice` is not a valid EIP-1559 Transaction attribute."
5810
+ );
5811
+ if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
5812
+ throw new FeeCapTooHighError({ maxFeePerGas });
5813
+ if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
5814
+ throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
5815
+ }
5816
+ function assertTransactionEIP2930(transaction) {
5817
+ const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to } = transaction;
5818
+ if (chainId <= 0)
5819
+ throw new InvalidChainIdError({ chainId });
5820
+ if (to && !isAddress(to))
5821
+ throw new InvalidAddressError({ address: to });
5822
+ if (maxPriorityFeePerGas || maxFeePerGas)
5823
+ throw new BaseError(
5824
+ "`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute."
5825
+ );
5826
+ if (gasPrice && gasPrice > 2n ** 256n - 1n)
5827
+ throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
5828
+ }
5829
+ function assertTransactionLegacy(transaction) {
5830
+ const {
5831
+ chainId,
5832
+ maxPriorityFeePerGas,
5833
+ gasPrice,
5834
+ maxFeePerGas,
5835
+ to,
5836
+ accessList
5837
+ } = transaction;
5838
+ if (to && !isAddress(to))
5839
+ throw new InvalidAddressError({ address: to });
5840
+ if (typeof chainId !== "undefined" && chainId <= 0)
5841
+ throw new InvalidChainIdError({ chainId });
5842
+ if (maxPriorityFeePerGas || maxFeePerGas)
5843
+ throw new BaseError(
5844
+ "`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute."
5845
+ );
5846
+ if (gasPrice && gasPrice > 2n ** 256n - 1n)
5847
+ throw new FeeCapTooHighError({ maxFeePerGas: gasPrice });
5848
+ if (accessList)
5849
+ throw new BaseError(
5850
+ "`accessList` is not a valid Legacy Transaction attribute."
5851
+ );
5852
+ }
5853
+
5854
+ // src/utils/transaction/parseTransaction.ts
5855
+ function parseTransaction(serializedTransaction) {
5856
+ const type = getSerializedTransactionType(serializedTransaction);
5857
+ if (type === "eip1559")
5858
+ return parseTransactionEIP1559(
5859
+ serializedTransaction
5860
+ );
5861
+ if (type === "eip2930")
5862
+ return parseTransactionEIP2930(
5863
+ serializedTransaction
5864
+ );
5865
+ return parseTransactionLegacy(
5866
+ serializedTransaction
5867
+ );
5868
+ }
5869
+ function parseTransactionEIP1559(serializedTransaction) {
5870
+ const transactionArray = fromRlp(
5871
+ `0x${serializedTransaction.slice(4)}`,
5872
+ "hex"
5873
+ );
5874
+ const [
5875
+ chainId,
5876
+ nonce,
5877
+ maxPriorityFeePerGas,
5878
+ maxFeePerGas,
5879
+ gas,
5880
+ to,
5881
+ value,
5882
+ data,
5883
+ accessList,
5884
+ v,
5885
+ r,
5886
+ s
5887
+ ] = transactionArray;
5888
+ if (!(transactionArray.length === 9 || transactionArray.length === 12))
5889
+ throw new InvalidSerializedTransactionError({
5890
+ attributes: {
5891
+ chainId,
5892
+ nonce,
5893
+ maxPriorityFeePerGas,
5894
+ maxFeePerGas,
5895
+ gas,
5896
+ to,
5897
+ value,
5898
+ data,
5899
+ accessList,
5900
+ ...transactionArray.length > 9 ? {
5901
+ v,
5902
+ r,
5903
+ s
5904
+ } : {}
5905
+ },
5906
+ serializedTransaction,
5907
+ type: "eip1559"
5908
+ });
5909
+ let transaction = {
5910
+ chainId: hexToNumber(chainId),
5911
+ type: "eip1559"
5912
+ };
5913
+ if (isHex(to) && to !== "0x")
5914
+ transaction.to = to;
5915
+ if (isHex(gas) && gas !== "0x")
5916
+ transaction.gas = hexToBigInt(gas);
5917
+ if (isHex(data) && data !== "0x")
5918
+ transaction.data = data;
5919
+ if (isHex(nonce) && nonce !== "0x")
5920
+ transaction.nonce = hexToNumber(nonce);
5921
+ if (isHex(value) && value !== "0x")
5922
+ transaction.value = hexToBigInt(value);
5923
+ if (isHex(maxFeePerGas) && maxFeePerGas !== "0x")
5924
+ transaction.maxFeePerGas = hexToBigInt(maxFeePerGas);
5925
+ if (isHex(maxPriorityFeePerGas) && maxPriorityFeePerGas !== "0x")
5926
+ transaction.maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGas);
5927
+ if (accessList.length !== 0 && accessList !== "0x")
5928
+ transaction.accessList = parseAccessList(accessList);
5929
+ assertTransactionEIP1559(transaction);
5930
+ const signature = transactionArray.length === 12 ? parseEIP155Signature(transactionArray) : void 0;
5931
+ return { ...signature, ...transaction };
5932
+ }
5933
+ function parseTransactionEIP2930(serializedTransaction) {
5934
+ const transactionArray = fromRlp(
5935
+ `0x${serializedTransaction.slice(4)}`,
5936
+ "hex"
5937
+ );
5938
+ const [chainId, nonce, gasPrice, gas, to, value, data, accessList, v, r, s] = transactionArray;
5939
+ if (!(transactionArray.length === 8 || transactionArray.length === 11))
5940
+ throw new InvalidSerializedTransactionError({
5941
+ attributes: {
5942
+ chainId,
5943
+ nonce,
5944
+ gasPrice,
5945
+ gas,
5946
+ to,
5947
+ value,
5948
+ data,
5949
+ accessList,
5950
+ ...transactionArray.length > 8 ? {
5951
+ v,
5952
+ r,
5953
+ s
5954
+ } : {}
5955
+ },
5956
+ serializedTransaction,
5957
+ type: "eip2930"
5958
+ });
5959
+ let transaction = {
5960
+ chainId: hexToNumber(chainId),
5961
+ type: "eip2930"
5962
+ };
5963
+ if (isHex(to) && to !== "0x")
5964
+ transaction.to = to;
5965
+ if (isHex(gas) && gas !== "0x")
5966
+ transaction.gas = hexToBigInt(gas);
5967
+ if (isHex(data) && data !== "0x")
5968
+ transaction.data = data;
5969
+ if (isHex(nonce) && nonce !== "0x")
5970
+ transaction.nonce = hexToNumber(nonce);
5971
+ if (isHex(value) && value !== "0x")
5972
+ transaction.value = hexToBigInt(value);
5973
+ if (isHex(gasPrice) && gasPrice !== "0x")
5974
+ transaction.gasPrice = hexToBigInt(gasPrice);
5975
+ if (accessList.length !== 0 && accessList !== "0x")
5976
+ transaction.accessList = parseAccessList(accessList);
5977
+ assertTransactionEIP2930(transaction);
5978
+ const signature = transactionArray.length === 11 ? parseEIP155Signature(transactionArray) : void 0;
5979
+ return { ...signature, ...transaction };
5980
+ }
5981
+ function parseTransactionLegacy(serializedTransaction) {
5982
+ const transactionArray = fromRlp(serializedTransaction, "hex");
5983
+ const [nonce, gasPrice, gas, to, value, data, chainIdOrV_, r, s] = transactionArray;
5984
+ if (!(transactionArray.length === 6 || transactionArray.length === 9))
5985
+ throw new InvalidSerializedTransactionError({
5986
+ attributes: {
5987
+ nonce,
5988
+ gasPrice,
5989
+ gas,
5990
+ to,
5991
+ value,
5992
+ data,
5993
+ ...transactionArray.length > 6 ? {
5994
+ v: chainIdOrV_,
5995
+ r,
5996
+ s
5997
+ } : {}
5998
+ },
5999
+ serializedTransaction,
6000
+ type: "legacy"
6001
+ });
6002
+ let transaction = {
6003
+ type: "legacy"
6004
+ };
6005
+ if (isHex(to) && to !== "0x")
6006
+ transaction.to = to;
6007
+ if (isHex(gas) && gas !== "0x")
6008
+ transaction.gas = hexToBigInt(gas);
6009
+ if (isHex(data) && data !== "0x")
6010
+ transaction.data = data;
6011
+ if (isHex(nonce) && nonce !== "0x")
6012
+ transaction.nonce = hexToNumber(nonce);
6013
+ if (isHex(value) && value !== "0x")
6014
+ transaction.value = hexToBigInt(value);
6015
+ if (isHex(gasPrice) && gasPrice !== "0x")
6016
+ transaction.gasPrice = hexToBigInt(gasPrice);
6017
+ assertTransactionLegacy(transaction);
6018
+ if (transactionArray.length === 6)
6019
+ return transaction;
6020
+ const chainIdOrV = isHex(chainIdOrV_) && chainIdOrV_ !== "0x" ? hexToBigInt(chainIdOrV_) : 0n;
6021
+ if (s === "0x" && r === "0x") {
6022
+ if (chainIdOrV > 0)
6023
+ transaction.chainId = Number(chainIdOrV);
6024
+ return transaction;
6025
+ }
6026
+ const v = chainIdOrV;
6027
+ let chainId = Number((v - 35n) / 2n);
6028
+ if (chainId > 0)
6029
+ transaction.chainId = chainId;
6030
+ else if (v !== 27n && v !== 28n)
6031
+ throw new InvalidLegacyVError({ v });
6032
+ transaction.v = v;
6033
+ transaction.s = s;
6034
+ transaction.r = r;
6035
+ return transaction;
6036
+ }
6037
+ function parseAccessList(accessList_) {
6038
+ let accessList = [];
6039
+ for (let i = 0; i < accessList_.length; i++) {
6040
+ const [address, storageKeys] = accessList_[i];
6041
+ if (!isAddress(address))
6042
+ throw new InvalidAddressError({ address });
6043
+ accessList.push({
6044
+ address,
6045
+ storageKeys: storageKeys.map((key) => isHash(key) ? key : trim(key))
6046
+ });
6047
+ }
6048
+ return accessList;
6049
+ }
6050
+ function parseEIP155Signature(transactionArray) {
6051
+ const signature = transactionArray.slice(-3);
6052
+ const v = signature[0] === "0x" || hexToBigInt(signature[0]) === 0n ? 27n : 28n;
6053
+ return {
6054
+ r: padHex(signature[1], { size: 32 }),
6055
+ s: padHex(signature[2], { size: 32 }),
6056
+ v,
6057
+ yParity: v === 27n ? 0 : 1
6058
+ };
6059
+ }
6060
+
6061
+ // src/utils/transaction/serializeTransaction.ts
6062
+ function serializeTransaction(transaction, signature) {
6063
+ const type = getTransactionType(transaction);
6064
+ if (type === "eip1559")
6065
+ return serializeTransactionEIP1559(
6066
+ transaction,
6067
+ signature
6068
+ );
6069
+ if (type === "eip2930")
6070
+ return serializeTransactionEIP2930(
6071
+ transaction,
6072
+ signature
6073
+ );
6074
+ return serializeTransactionLegacy(
6075
+ transaction,
6076
+ signature
6077
+ );
6078
+ }
6079
+ function serializeTransactionEIP1559(transaction, signature) {
6080
+ const {
6081
+ chainId,
6082
+ gas,
6083
+ nonce,
6084
+ to,
6085
+ value,
6086
+ maxFeePerGas,
6087
+ maxPriorityFeePerGas,
6088
+ accessList,
6089
+ data
6090
+ } = transaction;
6091
+ assertTransactionEIP1559(transaction);
6092
+ const serializedAccessList = serializeAccessList(accessList);
6093
+ const serializedTransaction = [
6094
+ toHex(chainId),
6095
+ typeof nonce !== "undefined" ? toHex(nonce) : "0x",
6096
+ typeof maxPriorityFeePerGas !== "undefined" ? toHex(maxPriorityFeePerGas) : "0x",
6097
+ typeof maxFeePerGas !== "undefined" ? toHex(maxFeePerGas) : "0x",
6098
+ typeof gas !== "undefined" ? toHex(gas) : "0x",
6099
+ _nullishCoalesce(to, () => ( "0x")),
6100
+ typeof value !== "undefined" ? toHex(value) : "0x",
6101
+ _nullishCoalesce(data, () => ( "0x")),
6102
+ serializedAccessList
6103
+ ];
6104
+ if (signature)
6105
+ serializedTransaction.push(
6106
+ signature.v === 27n ? "0x" : toHex(1),
6107
+ // yParity
6108
+ signature.r,
6109
+ signature.s
6110
+ );
6111
+ return concatHex([
6112
+ "0x02",
6113
+ toRlp(serializedTransaction)
6114
+ ]);
6115
+ }
6116
+ function serializeTransactionEIP2930(transaction, signature) {
6117
+ const { chainId, gas, data, nonce, to, value, accessList, gasPrice } = transaction;
6118
+ assertTransactionEIP2930(transaction);
6119
+ const serializedAccessList = serializeAccessList(accessList);
6120
+ const serializedTransaction = [
6121
+ toHex(chainId),
6122
+ typeof nonce !== "undefined" ? toHex(nonce) : "0x",
6123
+ typeof gasPrice !== "undefined" ? toHex(gasPrice) : "0x",
6124
+ typeof gas !== "undefined" ? toHex(gas) : "0x",
6125
+ _nullishCoalesce(to, () => ( "0x")),
6126
+ typeof value !== "undefined" ? toHex(value) : "0x",
6127
+ _nullishCoalesce(data, () => ( "0x")),
6128
+ serializedAccessList
6129
+ ];
6130
+ if (signature)
6131
+ serializedTransaction.push(
6132
+ signature.v === 27n ? "0x" : toHex(1),
6133
+ // yParity
6134
+ signature.r,
6135
+ signature.s
6136
+ );
6137
+ return concatHex([
6138
+ "0x01",
6139
+ toRlp(serializedTransaction)
6140
+ ]);
6141
+ }
6142
+ function serializeTransactionLegacy(transaction, signature) {
6143
+ const { chainId = 0, gas, data, nonce, to, value, gasPrice } = transaction;
6144
+ assertTransactionLegacy(transaction);
6145
+ let serializedTransaction = [
6146
+ typeof nonce !== "undefined" ? toHex(nonce) : "0x",
6147
+ typeof gasPrice !== "undefined" ? toHex(gasPrice) : "0x",
6148
+ typeof gas !== "undefined" ? toHex(gas) : "0x",
6149
+ _nullishCoalesce(to, () => ( "0x")),
6150
+ typeof value !== "undefined" ? toHex(value) : "0x",
6151
+ _nullishCoalesce(data, () => ( "0x"))
6152
+ ];
6153
+ if (signature) {
6154
+ let v = 27n + (signature.v === 27n ? 0n : 1n);
6155
+ if (chainId > 0)
6156
+ v = BigInt(chainId * 2) + BigInt(35n + signature.v - 27n);
6157
+ else if (signature.v !== v)
6158
+ throw new InvalidLegacyVError({ v: signature.v });
6159
+ serializedTransaction = [
6160
+ ...serializedTransaction,
6161
+ toHex(v),
6162
+ signature.r,
6163
+ signature.s
6164
+ ];
6165
+ } else if (chainId > 0) {
6166
+ serializedTransaction = [
6167
+ ...serializedTransaction,
6168
+ toHex(chainId),
6169
+ "0x",
6170
+ "0x"
6171
+ ];
6172
+ }
6173
+ return toRlp(serializedTransaction);
6174
+ }
6175
+ function serializeAccessList(accessList) {
6176
+ if (!accessList || accessList.length === 0)
6177
+ return [];
6178
+ let serializedAccessList = [];
6179
+ for (let i = 0; i < accessList.length; i++) {
6180
+ const { address, storageKeys } = accessList[i];
6181
+ for (let j = 0; j < storageKeys.length; j++) {
6182
+ if (storageKeys[j].length - 2 !== 64) {
6183
+ throw new InvalidStorageKeySizeError({ storageKey: storageKeys[j] });
6184
+ }
6185
+ }
6186
+ if (!isAddress(address)) {
6187
+ throw new InvalidAddressError({ address });
6188
+ }
6189
+ serializedAccessList.push([address, storageKeys]);
6190
+ }
6191
+ return serializedAccessList;
6192
+ }
6193
+
5302
6194
  // src/utils/unit/formatUnits.ts
5303
6195
  function formatUnits(value, decimals) {
5304
6196
  let display = value.toString();
@@ -5592,5 +6484,20 @@ function parseEther(ether, unit = "wei") {
5592
6484
 
5593
6485
 
5594
6486
 
5595
- 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.AbiEventSignatureEmptyTopicsError = AbiEventSignatureEmptyTopicsError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.DecodeLogTopicsMismatch = DecodeLogTopicsMismatch; 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.concatBytes = concatBytes; exports.concatHex = concatHex; 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.arrayRegex = arrayRegex; exports.bytesRegex = bytesRegex; exports.integerRegex = integerRegex; exports.encodePacked = encodePacked; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.parseAbi = _abitype.parseAbi; exports.parseAbiItem = _abitype.parseAbiItem; exports.parseAbiParameter = _abitype.parseAbiParameter; exports.parseAbiParameters = _abitype.parseAbiParameters; exports.getAccount = getAccount; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.getChainContractAddress = getChainContractAddress; 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.hashMessage = hashMessage; exports.recoverAddress = recoverAddress; exports.recoverMessageAddress = recoverMessageAddress; exports.verifyMessage = verifyMessage; 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.signTypedData = signTypedData; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract; exports.parseUnits = parseUnits; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.formatUnits = formatUnits; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther;
5596
- //# sourceMappingURL=chunk-Z54YSSBJ.js.map
6487
+
6488
+
6489
+
6490
+
6491
+
6492
+
6493
+
6494
+
6495
+
6496
+
6497
+
6498
+
6499
+
6500
+
6501
+
6502
+ 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.AbiEventSignatureEmptyTopicsError = AbiEventSignatureEmptyTopicsError; exports.AbiEventSignatureNotFoundError = AbiEventSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.DecodeLogTopicsMismatch = DecodeLogTopicsMismatch; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.ChainDoesNotSupportContract = ChainDoesNotSupportContract; exports.InvalidChainIdError = InvalidChainIdError; exports.multicall3Abi = multicall3Abi; exports.panicReasons = panicReasons; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.InvalidLegacyVError = InvalidLegacyVError; 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.concatBytes = concatBytes; exports.concatHex = concatHex; 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.isHash = isHash; exports.isAddress = isAddress; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress2; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddressEqual = isAddressEqual; exports.encodeAbiParameters = encodeAbiParameters; exports.decodeAbiParameters = decodeAbiParameters; exports.formatAbiItem = formatAbiItem; exports.decodeErrorResult = decodeErrorResult; exports.decodeEventLog = decodeEventLog; exports.decodeFunctionData = decodeFunctionData; exports.getAbiItem = getAbiItem; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.arrayRegex = arrayRegex; exports.bytesRegex = bytesRegex; exports.integerRegex = integerRegex; exports.encodePacked = encodePacked; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.parseAbi = _abitype.parseAbi; exports.parseAbiItem = _abitype.parseAbiItem; exports.parseAbiParameter = _abitype.parseAbiParameter; exports.parseAbiParameters = _abitype.parseAbiParameters; exports.parseAccount = parseAccount; exports.isDeterministicError = isDeterministicError; exports.buildRequest = buildRequest; exports.defineChain = defineChain; exports.getChainContractAddress = getChainContractAddress; 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.hashMessage = hashMessage; exports.validateTypedData = validateTypedData; exports.hashTypedData = hashTypedData; exports.recoverAddress = recoverAddress; exports.recoverMessageAddress = recoverMessageAddress; exports.recoverTypedDataAddress = recoverTypedDataAddress; exports.verifyMessage = verifyMessage; exports.verifyTypedData = verifyTypedData; exports.assertRequest = assertRequest; exports.getSerializedTransactionType = getSerializedTransactionType; exports.getTransactionType = getTransactionType; 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.signTypedData = signTypedData; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract; exports.parseUnits = parseUnits; exports.parseGwei = parseGwei; exports.prepareRequest = prepareRequest; exports.assertTransactionEIP1559 = assertTransactionEIP1559; exports.assertTransactionEIP2930 = assertTransactionEIP2930; exports.assertTransactionLegacy = assertTransactionLegacy; exports.parseTransaction = parseTransaction; exports.serializeTransaction = serializeTransaction; exports.formatUnits = formatUnits; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseEther = parseEther;
6503
+ //# sourceMappingURL=chunk-OW7TKT7L.js.map