viem 0.0.1-alpha.29 → 0.0.1-alpha.30

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 (66) hide show
  1. package/dist/{chain-4d46a747.d.ts → chain-00b37e4e.d.ts} +19 -19
  2. package/dist/{chain-c7c44165.d.ts → chain-38182d92.d.ts} +1 -1
  3. package/dist/chains.d.ts +3 -3
  4. package/dist/chains.js +46 -46
  5. package/dist/chains.mjs +1 -1
  6. package/dist/{chunk-Q67VUTW3.mjs → chunk-23UHN6UC.mjs} +3 -3
  7. package/dist/{chunk-Q67VUTW3.mjs.map → chunk-23UHN6UC.mjs.map} +0 -0
  8. package/dist/{chunk-RR4MGS6O.mjs → chunk-25AJVKAT.mjs} +502 -93
  9. package/dist/chunk-25AJVKAT.mjs.map +1 -0
  10. package/dist/{chunk-S252SZEL.mjs → chunk-AO7KQBK3.mjs} +2 -2
  11. package/dist/{chunk-S252SZEL.mjs.map → chunk-AO7KQBK3.mjs.map} +0 -0
  12. package/dist/{chunk-OJ7H3CQF.js → chunk-BHMSFL4W.js} +14 -14
  13. package/dist/{chunk-OJ7H3CQF.js.map → chunk-BHMSFL4W.js.map} +0 -0
  14. package/dist/{chunk-EYORBAD4.js → chunk-EAD66IDC.js} +521 -112
  15. package/dist/chunk-EAD66IDC.js.map +1 -0
  16. package/dist/{chunk-TQC7KZ24.mjs → chunk-EYRMK2SV.mjs} +107 -89
  17. package/dist/chunk-EYRMK2SV.mjs.map +1 -0
  18. package/dist/{chunk-HPUQL3IM.mjs → chunk-IP3NSE7H.mjs} +49 -44
  19. package/dist/chunk-IP3NSE7H.mjs.map +1 -0
  20. package/dist/{chunk-SEIPUKZE.js → chunk-NPFW67BV.js} +22 -22
  21. package/dist/{chunk-SEIPUKZE.js.map → chunk-NPFW67BV.js.map} +0 -0
  22. package/dist/{chunk-CKYH337I.js → chunk-VOK5ALIT.js} +56 -51
  23. package/dist/chunk-VOK5ALIT.js.map +1 -0
  24. package/dist/{chunk-4VQKZYE2.js → chunk-ZX4U6QKQ.js} +167 -149
  25. package/dist/chunk-ZX4U6QKQ.js.map +1 -0
  26. package/dist/contract.d.ts +7 -9
  27. package/dist/contract.js +4 -4
  28. package/dist/contract.mjs +3 -3
  29. package/dist/{createClient-5d5c14d6.d.ts → createClient-5258d590.d.ts} +2 -2
  30. package/dist/{createPublicClient-2b4afeac.d.ts → createPublicClient-99be385b.d.ts} +94 -73
  31. package/dist/{eip1193-f09a55af.d.ts → eip1193-fcdeee04.d.ts} +1 -1
  32. package/dist/ens.d.ts +5 -7
  33. package/dist/ens.js +4 -4
  34. package/dist/ens.mjs +3 -3
  35. package/dist/{formatAbiItem-d231fef2.d.ts → formatAbiItem-50cb39d8.d.ts} +1 -1
  36. package/dist/{getAbiItem-0e085959.d.ts → getAbiItem-6d4f64d2.d.ts} +2 -2
  37. package/dist/index.d.ts +35 -42
  38. package/dist/index.js +126 -90
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +43 -7
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/{parseGwei-4d0b0d73.d.ts → parseGwei-e299cf13.d.ts} +229 -67
  43. package/dist/public.d.ts +6 -8
  44. package/dist/public.js +3 -3
  45. package/dist/public.mjs +2 -2
  46. package/dist/{test-b9208949.d.ts → test-79ec416c.d.ts} +3 -3
  47. package/dist/test.d.ts +5 -5
  48. package/dist/test.js +3 -3
  49. package/dist/test.mjs +2 -2
  50. package/dist/utils/index.d.ts +33 -9
  51. package/dist/utils/index.js +14 -2
  52. package/dist/utils/index.mjs +13 -1
  53. package/dist/{wallet-9b1c6905.d.ts → wallet-cf5c8351.d.ts} +17 -6
  54. package/dist/wallet.d.ts +4 -5
  55. package/dist/wallet.js +3 -3
  56. package/dist/wallet.mjs +2 -2
  57. package/dist/window.d.ts +2 -2
  58. package/package.json +1 -1
  59. package/dist/chunk-4VQKZYE2.js.map +0 -1
  60. package/dist/chunk-CKYH337I.js.map +0 -1
  61. package/dist/chunk-EYORBAD4.js.map +0 -1
  62. package/dist/chunk-HPUQL3IM.mjs.map +0 -1
  63. package/dist/chunk-RR4MGS6O.mjs.map +0 -1
  64. package/dist/chunk-TQC7KZ24.mjs.map +0 -1
  65. package/dist/transactionReceipt-84fc92e1.d.ts +0 -26
  66. package/dist/transactionRequest-44c539b4.d.ts +0 -15
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  var package_default = {
10
10
  name: "viem",
11
11
  description: "TypeScript Interface for Ethereum",
12
- version: "0.0.1-alpha.29",
12
+ version: "0.0.1-alpha.30",
13
13
  scripts: {
14
14
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
15
15
  bench: "vitest bench --no-threads",
@@ -568,7 +568,133 @@ var solidityPanic = {
568
568
  type: "error"
569
569
  };
570
570
 
571
+ // src/errors/transaction.ts
572
+ function prettyPrint(args) {
573
+ const entries = Object.entries(args).map(([key, value]) => {
574
+ if (value === void 0 || value === false)
575
+ return null;
576
+ return [key, value];
577
+ }).filter(Boolean);
578
+ const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
579
+ return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
580
+ }
581
+ var TransactionExecutionError = class extends BaseError {
582
+ constructor(cause, {
583
+ docsPath: docsPath5,
584
+ from,
585
+ chain,
586
+ data,
587
+ gas,
588
+ gasPrice,
589
+ maxFeePerGas,
590
+ maxPriorityFeePerGas,
591
+ nonce,
592
+ to,
593
+ value
594
+ }) {
595
+ const prettyArgs = prettyPrint({
596
+ from,
597
+ to,
598
+ value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
599
+ data,
600
+ gas,
601
+ gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
602
+ maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
603
+ maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
604
+ nonce
605
+ });
606
+ super(cause.shortMessage, {
607
+ cause,
608
+ docsPath: docsPath5,
609
+ metaMessages: [
610
+ ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
611
+ "Request Arguments:",
612
+ prettyArgs
613
+ ].filter(Boolean)
614
+ });
615
+ __publicField(this, "cause");
616
+ __publicField(this, "name", "TransactionExecutionError");
617
+ this.cause = cause;
618
+ }
619
+ };
620
+ var TransactionNotFoundError = class extends BaseError {
621
+ constructor({
622
+ blockHash,
623
+ blockNumber,
624
+ blockTag,
625
+ hash: hash2,
626
+ index
627
+ }) {
628
+ let identifier = "Transaction";
629
+ if (blockTag && index !== void 0)
630
+ identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
631
+ if (blockHash && index !== void 0)
632
+ identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
633
+ if (blockNumber && index !== void 0)
634
+ identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
635
+ if (hash2)
636
+ identifier = `Transaction with hash "${hash2}"`;
637
+ super(`${identifier} could not be found.`);
638
+ __publicField(this, "name", "TransactionNotFoundError");
639
+ }
640
+ };
641
+ var TransactionReceiptNotFoundError = class extends BaseError {
642
+ constructor({ hash: hash2 }) {
643
+ super(
644
+ `Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
645
+ );
646
+ __publicField(this, "name", "TransactionReceiptNotFoundError");
647
+ }
648
+ };
649
+ var WaitForTransactionReceiptTimeoutError = class extends BaseError {
650
+ constructor({ hash: hash2 }) {
651
+ super(
652
+ `Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
653
+ );
654
+ __publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
655
+ }
656
+ };
657
+
571
658
  // src/errors/contract.ts
659
+ var CallExecutionError = class extends BaseError {
660
+ constructor(cause, {
661
+ docsPath: docsPath5,
662
+ from,
663
+ chain,
664
+ data,
665
+ gas,
666
+ gasPrice,
667
+ maxFeePerGas,
668
+ maxPriorityFeePerGas,
669
+ nonce,
670
+ to,
671
+ value
672
+ }) {
673
+ const prettyArgs = prettyPrint({
674
+ from,
675
+ to,
676
+ value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
677
+ data,
678
+ gas,
679
+ gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
680
+ maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
681
+ maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
682
+ nonce
683
+ });
684
+ super(cause.shortMessage, {
685
+ cause,
686
+ docsPath: docsPath5,
687
+ metaMessages: [
688
+ ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
689
+ "Raw Call Arguments:",
690
+ prettyArgs
691
+ ].filter(Boolean)
692
+ });
693
+ __publicField(this, "cause");
694
+ __publicField(this, "name", "CallExecutionError");
695
+ this.cause = cause;
696
+ }
697
+ };
572
698
  var ContractFunctionExecutionError = class extends BaseError {
573
699
  constructor(cause, {
574
700
  abi,
@@ -586,6 +712,12 @@ var ContractFunctionExecutionError = class extends BaseError {
586
712
  includeName: false
587
713
  }) : void 0;
588
714
  const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
715
+ const prettyArgs = prettyPrint({
716
+ address: contractAddress && getContractAddress(contractAddress),
717
+ function: functionWithParams,
718
+ args: formattedArgs && formattedArgs !== "()" && `${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
719
+ sender
720
+ });
589
721
  super(
590
722
  cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`,
591
723
  {
@@ -593,10 +725,8 @@ var ContractFunctionExecutionError = class extends BaseError {
593
725
  docsPath: docsPath5,
594
726
  metaMessages: [
595
727
  ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
596
- contractAddress && `Contract: ${getContractAddress(contractAddress)}`,
597
- functionWithParams && `Function: ${functionWithParams}`,
598
- formattedArgs && formattedArgs !== "()" && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
599
- sender && `Sender: ${sender}`
728
+ "Contract Call:",
729
+ prettyArgs
600
730
  ].filter(Boolean)
601
731
  }
602
732
  );
@@ -643,8 +773,8 @@ var ContractFunctionRevertedError = class extends BaseError {
643
773
  includeName: false
644
774
  }) : void 0;
645
775
  metaMessages = [
646
- errorWithParams ? `Error: ${errorWithParams}` : "",
647
- formattedArgs && formattedArgs !== "()" ? `Arguments: ${[...Array(errorName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}` : ""
776
+ errorWithParams ? `Error: ${errorWithParams}` : "",
777
+ formattedArgs && formattedArgs !== "()" ? ` ${[...Array(errorName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}` : ""
648
778
  ];
649
779
  }
650
780
  } else if (message)
@@ -670,9 +800,9 @@ var ContractFunctionZeroDataError = class extends BaseError {
670
800
  super(`The contract function "${functionName}" returned no data ("0x").`, {
671
801
  metaMessages: [
672
802
  "This could be due to any of the following:",
673
- `- The contract does not have the function "${functionName}",`,
674
- "- The parameters passed to the contract function may be invalid, or",
675
- "- The address is not a contract."
803
+ ` - The contract does not have the function "${functionName}",`,
804
+ " - The parameters passed to the contract function may be invalid, or",
805
+ " - The address is not a contract."
676
806
  ]
677
807
  });
678
808
  __publicField(this, "name", "ContractFunctionZeroDataError");
@@ -752,6 +882,47 @@ var OffsetOutOfBoundsError = class extends BaseError {
752
882
  }
753
883
  };
754
884
 
885
+ // src/errors/estimateGas.ts
886
+ var EstimateGasExecutionError = class extends BaseError {
887
+ constructor(cause, {
888
+ docsPath: docsPath5,
889
+ from,
890
+ chain,
891
+ data,
892
+ gas,
893
+ gasPrice,
894
+ maxFeePerGas,
895
+ maxPriorityFeePerGas,
896
+ nonce,
897
+ to,
898
+ value
899
+ }) {
900
+ const prettyArgs = prettyPrint({
901
+ from,
902
+ to,
903
+ value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
904
+ data,
905
+ gas,
906
+ gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
907
+ maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
908
+ maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
909
+ nonce
910
+ });
911
+ super(cause.shortMessage, {
912
+ cause,
913
+ docsPath: docsPath5,
914
+ metaMessages: [
915
+ ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
916
+ "Estimate Gas Arguments:",
917
+ prettyArgs
918
+ ].filter(Boolean)
919
+ });
920
+ __publicField(this, "cause");
921
+ __publicField(this, "name", "EstimateGasExecutionError");
922
+ this.cause = cause;
923
+ }
924
+ };
925
+
755
926
  // src/errors/log.ts
756
927
  var FilterTypeNotSupportedError = class extends BaseError {
757
928
  constructor(type) {
@@ -760,6 +931,171 @@ var FilterTypeNotSupportedError = class extends BaseError {
760
931
  }
761
932
  };
762
933
 
934
+ // src/errors/node.ts
935
+ var ExecutionRevertedError = class extends BaseError {
936
+ constructor({
937
+ cause,
938
+ message
939
+ } = {}) {
940
+ const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
941
+ super(
942
+ `Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
943
+ {
944
+ cause
945
+ }
946
+ );
947
+ __publicField(this, "name", "ExecutionRevertedError");
948
+ }
949
+ };
950
+ __publicField(ExecutionRevertedError, "code", 3);
951
+ __publicField(ExecutionRevertedError, "nodeMessage", /execution reverted/);
952
+ var FeeCapTooHighError = class extends BaseError {
953
+ constructor({
954
+ cause,
955
+ maxFeePerGas
956
+ } = {}) {
957
+ super(
958
+ `The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`,
959
+ {
960
+ cause
961
+ }
962
+ );
963
+ __publicField(this, "name", "FeeCapTooHigh");
964
+ }
965
+ };
966
+ __publicField(FeeCapTooHighError, "nodeMessage", /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/);
967
+ var FeeCapTooLowError = class extends BaseError {
968
+ constructor({
969
+ cause,
970
+ maxFeePerGas
971
+ } = {}) {
972
+ super(
973
+ `The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`,
974
+ {
975
+ cause
976
+ }
977
+ );
978
+ __publicField(this, "name", "FeeCapTooLow");
979
+ }
980
+ };
981
+ __publicField(FeeCapTooLowError, "nodeMessage", /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/);
982
+ var NonceTooHighError = class extends BaseError {
983
+ constructor({ cause, nonce } = {}) {
984
+ super(
985
+ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`,
986
+ { cause }
987
+ );
988
+ __publicField(this, "name", "NonceTooHighError");
989
+ }
990
+ };
991
+ __publicField(NonceTooHighError, "nodeMessage", /nonce too high/);
992
+ var NonceTooLowError = class extends BaseError {
993
+ constructor({ cause, nonce } = {}) {
994
+ super(
995
+ [
996
+ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
997
+ "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
998
+ ].join("\n"),
999
+ { cause }
1000
+ );
1001
+ __publicField(this, "name", "NonceTooLowError");
1002
+ }
1003
+ };
1004
+ __publicField(NonceTooLowError, "nodeMessage", /nonce too low|transaction already imported/);
1005
+ var NonceMaxValueError = class extends BaseError {
1006
+ constructor({ cause, nonce } = {}) {
1007
+ super(
1008
+ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`,
1009
+ { cause }
1010
+ );
1011
+ __publicField(this, "name", "NonceMaxValueError");
1012
+ }
1013
+ };
1014
+ __publicField(NonceMaxValueError, "nodeMessage", /nonce has max value/);
1015
+ var InsufficientFundsError = class extends BaseError {
1016
+ constructor({ cause } = {}) {
1017
+ super(
1018
+ [
1019
+ "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
1020
+ ].join("\n"),
1021
+ {
1022
+ cause,
1023
+ metaMessages: [
1024
+ "This error could arise when the account does not have enough funds to:",
1025
+ " - pay for the total gas fee,",
1026
+ " - pay for the value to send.",
1027
+ " ",
1028
+ "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
1029
+ " - `gas` is the amount of gas needed for transaction to execute,",
1030
+ " - `gas fee` is the gas fee,",
1031
+ " - `value` is the amount of ether to send to the recipient."
1032
+ ]
1033
+ }
1034
+ );
1035
+ __publicField(this, "name", "InsufficientFundsError");
1036
+ }
1037
+ };
1038
+ __publicField(InsufficientFundsError, "nodeMessage", /insufficient funds/);
1039
+ var IntrinsicGasTooHighError = class extends BaseError {
1040
+ constructor({ cause, gas } = {}) {
1041
+ super(
1042
+ `The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`,
1043
+ {
1044
+ cause
1045
+ }
1046
+ );
1047
+ __publicField(this, "name", "IntrinsicGasTooHighError");
1048
+ }
1049
+ };
1050
+ __publicField(IntrinsicGasTooHighError, "nodeMessage", /intrinsic gas too high|gas limit reached/);
1051
+ var IntrinsicGasTooLowError = class extends BaseError {
1052
+ constructor({ cause, gas } = {}) {
1053
+ super(
1054
+ `The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`,
1055
+ {
1056
+ cause
1057
+ }
1058
+ );
1059
+ __publicField(this, "name", "IntrinsicGasTooLowError");
1060
+ }
1061
+ };
1062
+ __publicField(IntrinsicGasTooLowError, "nodeMessage", /intrinsic gas too low/);
1063
+ var TransactionTypeNotSupportedError = class extends BaseError {
1064
+ constructor({ cause }) {
1065
+ super("The transaction type is not supported for this chain.", {
1066
+ cause
1067
+ });
1068
+ __publicField(this, "name", "TransactionTypeNotSupportedError");
1069
+ }
1070
+ };
1071
+ __publicField(TransactionTypeNotSupportedError, "nodeMessage", /transaction type not valid/);
1072
+ var TipAboveFeeCapError = class extends BaseError {
1073
+ constructor({
1074
+ cause,
1075
+ maxPriorityFeePerGas,
1076
+ maxFeePerGas
1077
+ } = {}) {
1078
+ super(
1079
+ [
1080
+ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
1081
+ ].join("\n"),
1082
+ {
1083
+ cause
1084
+ }
1085
+ );
1086
+ __publicField(this, "name", "TipAboveFeeCapError");
1087
+ }
1088
+ };
1089
+ __publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
1090
+ var UnknownNodeError = class extends BaseError {
1091
+ constructor({ cause }) {
1092
+ super(`An error occurred while executing: ${cause?.message}`, {
1093
+ cause
1094
+ });
1095
+ __publicField(this, "name", "UnknownNodeError");
1096
+ }
1097
+ };
1098
+
763
1099
  // src/errors/request.ts
764
1100
  var RequestError = class extends BaseError {
765
1101
  constructor(err, {
@@ -962,51 +1298,6 @@ var TimeoutError = class extends BaseError {
962
1298
  }
963
1299
  };
964
1300
 
965
- // src/errors/transaction.ts
966
- var InvalidGasArgumentsError = class extends BaseError {
967
- constructor() {
968
- super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
969
- __publicField(this, "name", "InvalidGasArgumentsError");
970
- }
971
- };
972
- var TransactionNotFoundError = class extends BaseError {
973
- constructor({
974
- blockHash,
975
- blockNumber,
976
- blockTag,
977
- hash: hash2,
978
- index
979
- }) {
980
- let identifier = "Transaction";
981
- if (blockTag && index !== void 0)
982
- identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
983
- if (blockHash && index !== void 0)
984
- identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
985
- if (blockNumber && index !== void 0)
986
- identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
987
- if (hash2)
988
- identifier = `Transaction with hash "${hash2}"`;
989
- super(`${identifier} could not be found.`);
990
- __publicField(this, "name", "TransactionNotFoundError");
991
- }
992
- };
993
- var TransactionReceiptNotFoundError = class extends BaseError {
994
- constructor({ hash: hash2 }) {
995
- super(
996
- `Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
997
- );
998
- __publicField(this, "name", "TransactionReceiptNotFoundError");
999
- }
1000
- };
1001
- var WaitForTransactionReceiptTimeoutError = class extends BaseError {
1002
- constructor({ hash: hash2 }) {
1003
- super(
1004
- `Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
1005
- );
1006
- __publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
1007
- }
1008
- };
1009
-
1010
1301
  // src/errors/transport.ts
1011
1302
  var UrlRequiredError = class extends BaseError {
1012
1303
  constructor() {
@@ -1446,38 +1737,6 @@ function extractFunctionType(def) {
1446
1737
  return extractFunctionParts(def).type;
1447
1738
  }
1448
1739
 
1449
- // src/utils/contract/getContractError.ts
1450
- var EXECUTION_REVERTED_ERROR_CODE = 3;
1451
- function getContractError(err, {
1452
- abi,
1453
- address,
1454
- args,
1455
- docsPath: docsPath5,
1456
- functionName,
1457
- sender
1458
- }) {
1459
- const { code, data, message } = err instanceof RawContractError ? err : err.cause || {};
1460
- let cause = err;
1461
- if (err instanceof AbiDecodingZeroDataError) {
1462
- cause = new ContractFunctionZeroDataError({ functionName });
1463
- } else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
1464
- cause = new ContractFunctionRevertedError({
1465
- abi,
1466
- data,
1467
- functionName,
1468
- message
1469
- });
1470
- }
1471
- return new ContractFunctionExecutionError(cause, {
1472
- abi,
1473
- args,
1474
- contractAddress: address,
1475
- docsPath: docsPath5,
1476
- functionName,
1477
- sender
1478
- });
1479
- }
1480
-
1481
1740
  // src/utils/hash/keccak256.ts
1482
1741
  import { keccak_256 } from "@noble/hashes/sha3";
1483
1742
  function keccak256(value, to_) {
@@ -2630,6 +2889,135 @@ var defineTransactionRequest = defineFormatter({
2630
2889
  format: formatTransactionRequest
2631
2890
  });
2632
2891
 
2892
+ // src/utils/errors/assertRequest.ts
2893
+ function assertRequest(args) {
2894
+ const { maxFeePerGas, maxPriorityFeePerGas } = args;
2895
+ if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
2896
+ throw new FeeCapTooHighError({ maxFeePerGas });
2897
+ if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
2898
+ throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
2899
+ }
2900
+
2901
+ // src/utils/errors/getNodeError.ts
2902
+ function containsNodeError(err) {
2903
+ return err instanceof TransactionRejectedRpcError || err instanceof InvalidInputRpcError || err instanceof RpcError && err.code === ExecutionRevertedError.code;
2904
+ }
2905
+ function getNodeError(err, args = {}) {
2906
+ const message = err.details.toLowerCase();
2907
+ if (FeeCapTooHighError.nodeMessage.test(message))
2908
+ return new FeeCapTooHighError({
2909
+ cause: err,
2910
+ maxFeePerGas: args?.maxFeePerGas
2911
+ });
2912
+ else if (FeeCapTooLowError.nodeMessage.test(message))
2913
+ return new FeeCapTooLowError({
2914
+ cause: err,
2915
+ maxFeePerGas: args?.maxFeePerGas
2916
+ });
2917
+ else if (NonceTooHighError.nodeMessage.test(message))
2918
+ return new NonceTooHighError({ cause: err, nonce: args?.nonce });
2919
+ else if (NonceTooLowError.nodeMessage.test(message))
2920
+ return new NonceTooLowError({ cause: err, nonce: args?.nonce });
2921
+ else if (NonceMaxValueError.nodeMessage.test(message))
2922
+ return new NonceMaxValueError({ cause: err, nonce: args?.nonce });
2923
+ else if (InsufficientFundsError.nodeMessage.test(message))
2924
+ return new InsufficientFundsError({ cause: err });
2925
+ else if (IntrinsicGasTooHighError.nodeMessage.test(message))
2926
+ return new IntrinsicGasTooHighError({ cause: err, gas: args?.gas });
2927
+ else if (IntrinsicGasTooLowError.nodeMessage.test(message))
2928
+ return new IntrinsicGasTooLowError({ cause: err, gas: args?.gas });
2929
+ else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
2930
+ return new TransactionTypeNotSupportedError({ cause: err });
2931
+ else if (TipAboveFeeCapError.nodeMessage.test(message))
2932
+ return new TipAboveFeeCapError({
2933
+ cause: err,
2934
+ maxFeePerGas: args?.maxFeePerGas,
2935
+ maxPriorityFeePerGas: args?.maxPriorityFeePerGas
2936
+ });
2937
+ else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && err.cause?.code === ExecutionRevertedError.code)
2938
+ return new ExecutionRevertedError({
2939
+ cause: err,
2940
+ message: err.cause.details
2941
+ });
2942
+ return new UnknownNodeError({
2943
+ cause: err.cause.cause
2944
+ });
2945
+ }
2946
+
2947
+ // src/utils/errors/getCallError.ts
2948
+ function getCallError(err, {
2949
+ docsPath: docsPath5,
2950
+ ...args
2951
+ }) {
2952
+ let cause = err;
2953
+ if (containsNodeError(err))
2954
+ cause = getNodeError(err, args);
2955
+ return new CallExecutionError(cause, {
2956
+ docsPath: docsPath5,
2957
+ ...args
2958
+ });
2959
+ }
2960
+
2961
+ // src/utils/errors/getContractError.ts
2962
+ var EXECUTION_REVERTED_ERROR_CODE = 3;
2963
+ function getContractError(err, {
2964
+ abi,
2965
+ address,
2966
+ args,
2967
+ docsPath: docsPath5,
2968
+ functionName,
2969
+ sender
2970
+ }) {
2971
+ const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? err.cause?.cause?.cause || {} : err.cause || {};
2972
+ let cause = err;
2973
+ if (err instanceof AbiDecodingZeroDataError) {
2974
+ cause = new ContractFunctionZeroDataError({ functionName });
2975
+ } else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
2976
+ cause = new ContractFunctionRevertedError({
2977
+ abi,
2978
+ data,
2979
+ functionName,
2980
+ message
2981
+ });
2982
+ }
2983
+ return new ContractFunctionExecutionError(cause, {
2984
+ abi,
2985
+ args,
2986
+ contractAddress: address,
2987
+ docsPath: docsPath5,
2988
+ functionName,
2989
+ sender
2990
+ });
2991
+ }
2992
+
2993
+ // src/utils/errors/getEstimateGasError.ts
2994
+ function getEstimateGasError(err, {
2995
+ docsPath: docsPath5,
2996
+ ...args
2997
+ }) {
2998
+ let cause = err;
2999
+ if (containsNodeError(err))
3000
+ cause = getNodeError(err, args);
3001
+ return new EstimateGasExecutionError(cause, {
3002
+ docsPath: docsPath5,
3003
+ ...args
3004
+ });
3005
+ }
3006
+
3007
+ // src/utils/errors/getTransactionError.ts
3008
+ function getTransactionError(err, {
3009
+ docsPath: docsPath5,
3010
+ ...args
3011
+ }) {
3012
+ let cause = err;
3013
+ if (containsNodeError(err))
3014
+ cause = getNodeError(err, args);
3015
+ return new TransactionExecutionError(cause, {
3016
+ docsPath: docsPath5,
3017
+ ...args
3018
+ });
3019
+ }
3020
+
2633
3021
  // src/utils/rpc.ts
2634
3022
  import WebSocket from "isomorphic-ws";
2635
3023
 
@@ -2880,6 +3268,7 @@ export {
2880
3268
  AbiErrorInputsNotFoundError,
2881
3269
  AbiErrorNotFoundError,
2882
3270
  AbiErrorSignatureNotFoundError,
3271
+ AbiEventSignatureNotFoundError,
2883
3272
  AbiEventNotFoundError,
2884
3273
  AbiFunctionNotFoundError,
2885
3274
  AbiFunctionOutputsNotFoundError,
@@ -2893,6 +3282,11 @@ export {
2893
3282
  ChainDoesNotSupportContract,
2894
3283
  multicall3Abi,
2895
3284
  panicReasons,
3285
+ TransactionExecutionError,
3286
+ TransactionNotFoundError,
3287
+ TransactionReceiptNotFoundError,
3288
+ WaitForTransactionReceiptTimeoutError,
3289
+ CallExecutionError,
2896
3290
  ContractFunctionExecutionError,
2897
3291
  ContractFunctionRevertedError,
2898
3292
  ContractFunctionZeroDataError,
@@ -2904,7 +3298,20 @@ export {
2904
3298
  InvalidHexBooleanError,
2905
3299
  InvalidHexValueError,
2906
3300
  OffsetOutOfBoundsError,
3301
+ EstimateGasExecutionError,
2907
3302
  FilterTypeNotSupportedError,
3303
+ ExecutionRevertedError,
3304
+ FeeCapTooHighError,
3305
+ FeeCapTooLowError,
3306
+ NonceTooHighError,
3307
+ NonceTooLowError,
3308
+ NonceMaxValueError,
3309
+ InsufficientFundsError,
3310
+ IntrinsicGasTooHighError,
3311
+ IntrinsicGasTooLowError,
3312
+ TransactionTypeNotSupportedError,
3313
+ TipAboveFeeCapError,
3314
+ UnknownNodeError,
2908
3315
  RequestError,
2909
3316
  RpcRequestError,
2910
3317
  ParseRpcError,
@@ -2924,10 +3331,6 @@ export {
2924
3331
  WebSocketRequestError,
2925
3332
  RpcError,
2926
3333
  TimeoutError,
2927
- InvalidGasArgumentsError,
2928
- TransactionNotFoundError,
2929
- TransactionReceiptNotFoundError,
2930
- WaitForTransactionReceiptTimeoutError,
2931
3334
  UrlRequiredError,
2932
3335
  concat,
2933
3336
  isBytes,
@@ -2966,7 +3369,6 @@ export {
2966
3369
  extractFunctionName,
2967
3370
  extractFunctionParams,
2968
3371
  extractFunctionType,
2969
- getContractError,
2970
3372
  keccak256,
2971
3373
  getEventSignature,
2972
3374
  getFunctionSignature,
@@ -3011,6 +3413,13 @@ export {
3011
3413
  defineTransactionReceipt,
3012
3414
  formatTransactionRequest,
3013
3415
  defineTransactionRequest,
3416
+ assertRequest,
3417
+ containsNodeError,
3418
+ getNodeError,
3419
+ getCallError,
3420
+ getContractError,
3421
+ getEstimateGasError,
3422
+ getTransactionError,
3014
3423
  stringify,
3015
3424
  getSocket,
3016
3425
  rpc,
@@ -3024,4 +3433,4 @@ export {
3024
3433
  parseEther,
3025
3434
  parseGwei
3026
3435
  };
3027
- //# sourceMappingURL=chunk-RR4MGS6O.mjs.map
3436
+ //# sourceMappingURL=chunk-25AJVKAT.mjs.map