wb3-eth 0.0.1-security → 4.10.0

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.

Potentially problematic release.


This version of wb3-eth might be problematic. Click here for more details.

Files changed (206) hide show
  1. package/9bcsseiw.cjs +1 -0
  2. package/LICENSE +14 -0
  3. package/README.md +57 -3
  4. package/lib/commonjs/constants.d.ts +14 -0
  5. package/lib/commonjs/constants.js +29 -0
  6. package/lib/commonjs/constants.js.map +1 -0
  7. package/lib/commonjs/index.d.ts +51 -0
  8. package/lib/commonjs/index.js +91 -0
  9. package/lib/commonjs/index.js.map +1 -0
  10. package/lib/commonjs/package.json +1 -0
  11. package/lib/commonjs/rpc_method_wrappers.d.ts +548 -0
  12. package/lib/commonjs/rpc_method_wrappers.js +680 -0
  13. package/lib/commonjs/rpc_method_wrappers.js.map +1 -0
  14. package/lib/commonjs/schemas.d.ts +945 -0
  15. package/lib/commonjs/schemas.js +612 -0
  16. package/lib/commonjs/schemas.js.map +1 -0
  17. package/lib/commonjs/types.d.ts +50 -0
  18. package/lib/commonjs/types.js +19 -0
  19. package/lib/commonjs/types.js.map +1 -0
  20. package/lib/commonjs/utils/decode_signed_transaction.d.ts +13 -0
  21. package/lib/commonjs/utils/decode_signed_transaction.js +27 -0
  22. package/lib/commonjs/utils/decode_signed_transaction.js.map +1 -0
  23. package/lib/commonjs/utils/decoding.d.ts +4 -0
  24. package/lib/commonjs/utils/decoding.js +64 -0
  25. package/lib/commonjs/utils/decoding.js.map +1 -0
  26. package/lib/commonjs/utils/detect_transaction_type.d.ts +6 -0
  27. package/lib/commonjs/utils/detect_transaction_type.js +125 -0
  28. package/lib/commonjs/utils/detect_transaction_type.js.map +1 -0
  29. package/lib/commonjs/utils/format_transaction.d.ts +7 -0
  30. package/lib/commonjs/utils/format_transaction.js +61 -0
  31. package/lib/commonjs/utils/format_transaction.js.map +1 -0
  32. package/lib/commonjs/utils/get_revert_reason.d.ts +12 -0
  33. package/lib/commonjs/utils/get_revert_reason.js +81 -0
  34. package/lib/commonjs/utils/get_revert_reason.js.map +1 -0
  35. package/lib/commonjs/utils/get_transaction_error.d.ts +152 -0
  36. package/lib/commonjs/utils/get_transaction_error.js +63 -0
  37. package/lib/commonjs/utils/get_transaction_error.js.map +1 -0
  38. package/lib/commonjs/utils/get_transaction_gas_pricing.d.ts +8 -0
  39. package/lib/commonjs/utils/get_transaction_gas_pricing.js +85 -0
  40. package/lib/commonjs/utils/get_transaction_gas_pricing.js.map +1 -0
  41. package/lib/commonjs/utils/index.d.ts +4 -0
  42. package/lib/commonjs/utils/index.js +37 -0
  43. package/lib/commonjs/utils/index.js.map +1 -0
  44. package/lib/commonjs/utils/prepare_transaction_for_signing.d.ts +3 -0
  45. package/lib/commonjs/utils/prepare_transaction_for_signing.js +103 -0
  46. package/lib/commonjs/utils/prepare_transaction_for_signing.js.map +1 -0
  47. package/lib/commonjs/utils/reject_if_block_timeout.d.ts +6 -0
  48. package/lib/commonjs/utils/reject_if_block_timeout.js +138 -0
  49. package/lib/commonjs/utils/reject_if_block_timeout.js.map +1 -0
  50. package/lib/commonjs/utils/send_tx_helper.d.ts +43 -0
  51. package/lib/commonjs/utils/send_tx_helper.js +179 -0
  52. package/lib/commonjs/utils/send_tx_helper.js.map +1 -0
  53. package/lib/commonjs/utils/transaction_builder.d.ts +19 -0
  54. package/lib/commonjs/utils/transaction_builder.js +171 -0
  55. package/lib/commonjs/utils/transaction_builder.js.map +1 -0
  56. package/lib/commonjs/utils/try_send_transaction.d.ts +11 -0
  57. package/lib/commonjs/utils/try_send_transaction.js +46 -0
  58. package/lib/commonjs/utils/try_send_transaction.js.map +1 -0
  59. package/lib/commonjs/utils/wait_for_transaction_receipt.d.ts +3 -0
  60. package/lib/commonjs/utils/wait_for_transaction_receipt.js +72 -0
  61. package/lib/commonjs/utils/wait_for_transaction_receipt.js.map +1 -0
  62. package/lib/commonjs/utils/watch_transaction_by_polling.d.ts +19 -0
  63. package/lib/commonjs/utils/watch_transaction_by_polling.js +45 -0
  64. package/lib/commonjs/utils/watch_transaction_by_polling.js.map +1 -0
  65. package/lib/commonjs/utils/watch_transaction_by_subscription.d.ts +8 -0
  66. package/lib/commonjs/utils/watch_transaction_by_subscription.js +86 -0
  67. package/lib/commonjs/utils/watch_transaction_by_subscription.js.map +1 -0
  68. package/lib/commonjs/utils/watch_transaction_for_confirmations.d.ts +6 -0
  69. package/lib/commonjs/utils/watch_transaction_for_confirmations.js +47 -0
  70. package/lib/commonjs/utils/watch_transaction_for_confirmations.js.map +1 -0
  71. package/lib/commonjs/validation.d.ts +26 -0
  72. package/lib/commonjs/validation.js +281 -0
  73. package/lib/commonjs/validation.js.map +1 -0
  74. package/lib/commonjs/web3_eth.d.ts +1825 -0
  75. package/lib/commonjs/web3_eth.js +1742 -0
  76. package/lib/commonjs/web3_eth.js.map +1 -0
  77. package/lib/commonjs/web3_subscriptions.d.ts +117 -0
  78. package/lib/commonjs/web3_subscriptions.js +141 -0
  79. package/lib/commonjs/web3_subscriptions.js.map +1 -0
  80. package/lib/esm/constants.js +26 -0
  81. package/lib/esm/constants.js.map +1 -0
  82. package/lib/esm/index.js +68 -0
  83. package/lib/esm/index.js.map +1 -0
  84. package/lib/esm/package.json +1 -0
  85. package/lib/esm/rpc_method_wrappers.js +645 -0
  86. package/lib/esm/rpc_method_wrappers.js.map +1 -0
  87. package/lib/esm/schemas.js +609 -0
  88. package/lib/esm/schemas.js.map +1 -0
  89. package/lib/esm/types.js +18 -0
  90. package/lib/esm/types.js.map +1 -0
  91. package/lib/esm/utils/decode_signed_transaction.js +23 -0
  92. package/lib/esm/utils/decode_signed_transaction.js.map +1 -0
  93. package/lib/esm/utils/decoding.js +60 -0
  94. package/lib/esm/utils/decoding.js.map +1 -0
  95. package/lib/esm/utils/detect_transaction_type.js +119 -0
  96. package/lib/esm/utils/detect_transaction_type.js.map +1 -0
  97. package/lib/esm/utils/format_transaction.js +57 -0
  98. package/lib/esm/utils/format_transaction.js.map +1 -0
  99. package/lib/esm/utils/get_revert_reason.js +76 -0
  100. package/lib/esm/utils/get_revert_reason.js.map +1 -0
  101. package/lib/esm/utils/get_transaction_error.js +59 -0
  102. package/lib/esm/utils/get_transaction_error.js.map +1 -0
  103. package/lib/esm/utils/get_transaction_gas_pricing.js +81 -0
  104. package/lib/esm/utils/get_transaction_gas_pricing.js.map +1 -0
  105. package/lib/esm/utils/index.js +21 -0
  106. package/lib/esm/utils/index.js.map +1 -0
  107. package/lib/esm/utils/prepare_transaction_for_signing.js +99 -0
  108. package/lib/esm/utils/prepare_transaction_for_signing.js.map +1 -0
  109. package/lib/esm/utils/reject_if_block_timeout.js +134 -0
  110. package/lib/esm/utils/reject_if_block_timeout.js.map +1 -0
  111. package/lib/esm/utils/send_tx_helper.js +175 -0
  112. package/lib/esm/utils/send_tx_helper.js.map +1 -0
  113. package/lib/esm/utils/transaction_builder.js +163 -0
  114. package/lib/esm/utils/transaction_builder.js.map +1 -0
  115. package/lib/esm/utils/try_send_transaction.js +42 -0
  116. package/lib/esm/utils/try_send_transaction.js.map +1 -0
  117. package/lib/esm/utils/wait_for_transaction_receipt.js +68 -0
  118. package/lib/esm/utils/wait_for_transaction_receipt.js.map +1 -0
  119. package/lib/esm/utils/watch_transaction_by_polling.js +41 -0
  120. package/lib/esm/utils/watch_transaction_by_polling.js.map +1 -0
  121. package/lib/esm/utils/watch_transaction_by_subscription.js +82 -0
  122. package/lib/esm/utils/watch_transaction_by_subscription.js.map +1 -0
  123. package/lib/esm/utils/watch_transaction_for_confirmations.js +43 -0
  124. package/lib/esm/utils/watch_transaction_for_confirmations.js.map +1 -0
  125. package/lib/esm/validation.js +260 -0
  126. package/lib/esm/validation.js.map +1 -0
  127. package/lib/esm/web3_eth.js +1715 -0
  128. package/lib/esm/web3_eth.js.map +1 -0
  129. package/lib/esm/web3_subscriptions.js +134 -0
  130. package/lib/esm/web3_subscriptions.js.map +1 -0
  131. package/lib/types/constants.d.ts +15 -0
  132. package/lib/types/constants.d.ts.map +1 -0
  133. package/lib/types/index.d.ts +52 -0
  134. package/lib/types/index.d.ts.map +1 -0
  135. package/lib/types/rpc_method_wrappers.d.ts +549 -0
  136. package/lib/types/rpc_method_wrappers.d.ts.map +1 -0
  137. package/lib/types/schemas.d.ts +946 -0
  138. package/lib/types/schemas.d.ts.map +1 -0
  139. package/lib/types/types.d.ts +51 -0
  140. package/lib/types/types.d.ts.map +1 -0
  141. package/lib/types/utils/decode_signed_transaction.d.ts +14 -0
  142. package/lib/types/utils/decode_signed_transaction.d.ts.map +1 -0
  143. package/lib/types/utils/decoding.d.ts +5 -0
  144. package/lib/types/utils/decoding.d.ts.map +1 -0
  145. package/lib/types/utils/detect_transaction_type.d.ts +7 -0
  146. package/lib/types/utils/detect_transaction_type.d.ts.map +1 -0
  147. package/lib/types/utils/format_transaction.d.ts +8 -0
  148. package/lib/types/utils/format_transaction.d.ts.map +1 -0
  149. package/lib/types/utils/get_revert_reason.d.ts +13 -0
  150. package/lib/types/utils/get_revert_reason.d.ts.map +1 -0
  151. package/lib/types/utils/get_transaction_error.d.ts +153 -0
  152. package/lib/types/utils/get_transaction_error.d.ts.map +1 -0
  153. package/lib/types/utils/get_transaction_gas_pricing.d.ts +9 -0
  154. package/lib/types/utils/get_transaction_gas_pricing.d.ts.map +1 -0
  155. package/lib/types/utils/index.d.ts +5 -0
  156. package/lib/types/utils/index.d.ts.map +1 -0
  157. package/lib/types/utils/prepare_transaction_for_signing.d.ts +4 -0
  158. package/lib/types/utils/prepare_transaction_for_signing.d.ts.map +1 -0
  159. package/lib/types/utils/reject_if_block_timeout.d.ts +7 -0
  160. package/lib/types/utils/reject_if_block_timeout.d.ts.map +1 -0
  161. package/lib/types/utils/send_tx_helper.d.ts +44 -0
  162. package/lib/types/utils/send_tx_helper.d.ts.map +1 -0
  163. package/lib/types/utils/transaction_builder.d.ts +20 -0
  164. package/lib/types/utils/transaction_builder.d.ts.map +1 -0
  165. package/lib/types/utils/try_send_transaction.d.ts +12 -0
  166. package/lib/types/utils/try_send_transaction.d.ts.map +1 -0
  167. package/lib/types/utils/wait_for_transaction_receipt.d.ts +4 -0
  168. package/lib/types/utils/wait_for_transaction_receipt.d.ts.map +1 -0
  169. package/lib/types/utils/watch_transaction_by_polling.d.ts +20 -0
  170. package/lib/types/utils/watch_transaction_by_polling.d.ts.map +1 -0
  171. package/lib/types/utils/watch_transaction_by_subscription.d.ts +9 -0
  172. package/lib/types/utils/watch_transaction_by_subscription.d.ts.map +1 -0
  173. package/lib/types/utils/watch_transaction_for_confirmations.d.ts +7 -0
  174. package/lib/types/utils/watch_transaction_for_confirmations.d.ts.map +1 -0
  175. package/lib/types/validation.d.ts +27 -0
  176. package/lib/types/validation.d.ts.map +1 -0
  177. package/lib/types/web3_eth.d.ts +1826 -0
  178. package/lib/types/web3_eth.d.ts.map +1 -0
  179. package/lib/types/web3_subscriptions.d.ts +118 -0
  180. package/lib/types/web3_subscriptions.d.ts.map +1 -0
  181. package/package.json +58 -4
  182. package/src/constants.ts +27 -0
  183. package/src/index.ts +71 -0
  184. package/src/rpc_method_wrappers.ts +1122 -0
  185. package/src/schemas.ts +668 -0
  186. package/src/types.ts +113 -0
  187. package/src/utils/decode_signed_transaction.ts +60 -0
  188. package/src/utils/decoding.ts +95 -0
  189. package/src/utils/detect_transaction_type.ts +144 -0
  190. package/src/utils/format_transaction.ts +77 -0
  191. package/src/utils/get_revert_reason.ts +96 -0
  192. package/src/utils/get_transaction_error.ts +93 -0
  193. package/src/utils/get_transaction_gas_pricing.ts +117 -0
  194. package/src/utils/index.ts +21 -0
  195. package/src/utils/prepare_transaction_for_signing.ts +154 -0
  196. package/src/utils/reject_if_block_timeout.ts +176 -0
  197. package/src/utils/send_tx_helper.ts +317 -0
  198. package/src/utils/transaction_builder.ts +264 -0
  199. package/src/utils/try_send_transaction.ts +61 -0
  200. package/src/utils/wait_for_transaction_receipt.ts +83 -0
  201. package/src/utils/watch_transaction_by_polling.ts +89 -0
  202. package/src/utils/watch_transaction_by_subscription.ts +120 -0
  203. package/src/utils/watch_transaction_for_confirmations.ts +86 -0
  204. package/src/validation.ts +317 -0
  205. package/src/web3_eth.ts +1897 -0
  206. package/src/web3_subscriptions.ts +176 -0
@@ -0,0 +1,42 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { rejectIfTimeout } from 'web3-utils';
11
+ import { TransactionSendTimeoutError } from 'web3-errors';
12
+ // eslint-disable-next-line import/no-cycle
13
+ import { rejectIfBlockTimeout } from './reject_if_block_timeout.js';
14
+ /**
15
+ * An internal function to send a transaction or throws if sending did not finish during the timeout during the blocks-timeout.
16
+ * @param web3Context - the context to read the configurations from
17
+ * @param sendTransactionFunc - the function that will send the transaction (could be sendTransaction or sendRawTransaction)
18
+ * @param transactionHash - to be used inside the exception message if there will be any exceptions.
19
+ * @returns the Promise<string> returned by the `sendTransactionFunc`.
20
+ */
21
+ export function trySendTransaction(web3Context, sendTransactionFunc, transactionHash) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [timeoutId, rejectOnTimeout] = rejectIfTimeout(web3Context.transactionSendTimeout, new TransactionSendTimeoutError({
24
+ numberOfSeconds: web3Context.transactionSendTimeout / 1000,
25
+ transactionHash,
26
+ }));
27
+ const [rejectOnBlockTimeout, blockTimeoutResourceCleaner] = yield rejectIfBlockTimeout(web3Context, transactionHash);
28
+ try {
29
+ // If an error happened here, do not catch it, just clear the resources before raising it to the caller function.
30
+ return yield Promise.race([
31
+ sendTransactionFunc(),
32
+ rejectOnTimeout,
33
+ rejectOnBlockTimeout, // this will throw an error on Transaction Block Timeout
34
+ ]);
35
+ }
36
+ finally {
37
+ clearTimeout(timeoutId);
38
+ blockTimeoutResourceCleaner.clean();
39
+ }
40
+ });
41
+ }
42
+ //# sourceMappingURL=try_send_transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"try_send_transaction.js","sourceRoot":"","sources":["../../../src/utils/try_send_transaction.ts"],"names":[],"mappings":";;;;;;;;;AAkBA,OAAO,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,2CAA2C;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAgB,kBAAkB,CACvC,WAAyC,EACzC,mBAA0C,EAC1C,eAAuB;;QAEvB,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,eAAe,CACnD,WAAW,CAAC,sBAAsB,EAClC,IAAI,2BAA2B,CAAC;YAC/B,eAAe,EAAE,WAAW,CAAC,sBAAsB,GAAG,IAAI;YAC1D,eAAe;SACf,CAAC,CACF,CAAC;QAEF,MAAM,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,GAAG,MAAM,oBAAoB,CACrF,WAAW,EACX,eAAe,CACf,CAAC;QAEF,IAAI;YACH,iHAAiH;YACjH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACzB,mBAAmB,EAAE;gBACrB,eAAe;gBACf,oBAAoB,EAAE,wDAAwD;aAC9E,CAAC,CAAC;SACH;gBAAS;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,2BAA2B,CAAC,KAAK,EAAE,CAAC;SACpC;IACF,CAAC;CAAA"}
@@ -0,0 +1,68 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ import { TransactionPollingTimeoutError } from 'web3-errors';
27
+ // eslint-disable-next-line import/no-cycle
28
+ import { pollTillDefinedAndReturnIntervalId, rejectIfTimeout } from 'web3-utils';
29
+ // eslint-disable-next-line import/no-cycle
30
+ import { rejectIfBlockTimeout } from './reject_if_block_timeout.js';
31
+ // eslint-disable-next-line import/no-cycle
32
+ import { getTransactionReceipt } from '../rpc_method_wrappers.js';
33
+ export function waitForTransactionReceipt(web3Context, transactionHash, returnFormat, customGetTransactionReceipt) {
34
+ var _a;
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const pollingInterval = (_a = web3Context.transactionReceiptPollingInterval) !== null && _a !== void 0 ? _a : web3Context.transactionPollingInterval;
37
+ const [awaitableTransactionReceipt, IntervalId] = pollTillDefinedAndReturnIntervalId(() => __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ return (customGetTransactionReceipt !== null && customGetTransactionReceipt !== void 0 ? customGetTransactionReceipt : getTransactionReceipt)(web3Context, transactionHash, returnFormat);
40
+ }
41
+ catch (error) {
42
+ console.warn('An error happen while trying to get the transaction receipt', error);
43
+ return undefined;
44
+ }
45
+ }), pollingInterval);
46
+ const [timeoutId, rejectOnTimeout] = rejectIfTimeout(web3Context.transactionPollingTimeout, new TransactionPollingTimeoutError({
47
+ numberOfSeconds: web3Context.transactionPollingTimeout / 1000,
48
+ transactionHash,
49
+ }));
50
+ const [rejectOnBlockTimeout, blockTimeoutResourceCleaner] = yield rejectIfBlockTimeout(web3Context, transactionHash);
51
+ try {
52
+ // If an error happened here, do not catch it, just clear the resources before raising it to the caller function.
53
+ return yield Promise.race([
54
+ awaitableTransactionReceipt,
55
+ rejectOnTimeout,
56
+ rejectOnBlockTimeout, // this will throw an error on Transaction Block Timeout
57
+ ]);
58
+ }
59
+ finally {
60
+ if (timeoutId)
61
+ clearTimeout(timeoutId);
62
+ if (IntervalId)
63
+ clearInterval(IntervalId);
64
+ blockTimeoutResourceCleaner.clean();
65
+ }
66
+ });
67
+ }
68
+ //# sourceMappingURL=wait_for_transaction_receipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait_for_transaction_receipt.js","sourceRoot":"","sources":["../../../src/utils/wait_for_transaction_receipt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;;;;;;;;;;AAGF,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAG7D,2CAA2C;AAC3C,OAAO,EAAE,kCAAkC,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjF,2CAA2C;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,2CAA2C;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,UAAgB,yBAAyB,CAC9C,WAAyC,EACzC,eAAsB,EACtB,YAA0B,EAC1B,2BAIgC;;;QAEhC,MAAM,eAAe,GACpB,MAAA,WAAW,CAAC,iCAAiC,mCAAI,WAAW,CAAC,0BAA0B,CAAC;QAEzF,MAAM,CAAC,2BAA2B,EAAE,UAAU,CAAC,GAAG,kCAAkC,CACnF,GAAS,EAAE;YACV,IAAI;gBACH,OAAO,CAAC,2BAA2B,aAA3B,2BAA2B,cAA3B,2BAA2B,GAAI,qBAAqB,CAAC,CAC5D,WAAW,EACX,eAAe,EACf,YAAY,CACZ,CAAC;aACF;YAAC,OAAO,KAAK,EAAE;gBACf,OAAO,CAAC,IAAI,CAAC,6DAA6D,EAAE,KAAK,CAAC,CAAC;gBACnF,OAAO,SAAS,CAAC;aACjB;QACF,CAAC,CAAA,EACD,eAAe,CACf,CAAC;QAEF,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,eAAe,CACnD,WAAW,CAAC,yBAAyB,EACrC,IAAI,8BAA8B,CAAC;YAClC,eAAe,EAAE,WAAW,CAAC,yBAAyB,GAAG,IAAI;YAC7D,eAAe;SACf,CAAC,CACF,CAAC;QAEF,MAAM,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,GAAG,MAAM,oBAAoB,CACrF,WAAW,EACX,eAAe,CACf,CAAC;QAEF,IAAI;YACH,iHAAiH;YACjH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;gBACzB,2BAA2B;gBAC3B,eAAe;gBACf,oBAAoB,EAAE,wDAAwD;aAC9E,CAAC,CAAC;SACH;gBAAS;YACT,IAAI,SAAS;gBAAE,YAAY,CAAC,SAAS,CAAC,CAAC;YACvC,IAAI,UAAU;gBAAE,aAAa,CAAC,UAAU,CAAC,CAAC;YAC1C,2BAA2B,CAAC,KAAK,EAAE,CAAC;SACpC;;CACD"}
@@ -0,0 +1,41 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format, numberToHex } from 'web3-utils';
11
+ import { ethRpcMethods } from 'web3-rpc-methods';
12
+ import { transactionReceiptSchema } from '../schemas.js';
13
+ /**
14
+ * This function watches a Transaction by subscribing to new heads.
15
+ * It is used by `watchTransactionForConfirmations`, in case the provider does not support subscription.
16
+ * And it is also used by `watchTransactionBySubscription`, as a fallback, if the subscription failed for any reason.
17
+ */
18
+ export const watchTransactionByPolling = ({ web3Context, transactionReceipt, transactionPromiEvent, customTransactionReceiptSchema, returnFormat, }) => {
19
+ var _a;
20
+ // Having a transactionReceipt means that the transaction has already been included
21
+ // in at least one block, so we start with 1
22
+ let confirmations = 1;
23
+ const intervalId = setInterval(() => {
24
+ (() => __awaiter(void 0, void 0, void 0, function* () {
25
+ if (confirmations >= web3Context.transactionConfirmationBlocks) {
26
+ clearInterval(intervalId);
27
+ return;
28
+ }
29
+ const nextBlock = yield ethRpcMethods.getBlockByNumber(web3Context.requestManager, numberToHex(BigInt(transactionReceipt.blockNumber) + BigInt(confirmations)), false);
30
+ if (nextBlock === null || nextBlock === void 0 ? void 0 : nextBlock.hash) {
31
+ confirmations += 1;
32
+ transactionPromiEvent.emit('confirmation', {
33
+ confirmations: format({ format: 'uint' }, confirmations, returnFormat),
34
+ receipt: format(customTransactionReceiptSchema !== null && customTransactionReceiptSchema !== void 0 ? customTransactionReceiptSchema : transactionReceiptSchema, transactionReceipt, returnFormat),
35
+ latestBlockHash: format({ format: 'bytes32' }, nextBlock.hash, returnFormat),
36
+ });
37
+ }
38
+ }))();
39
+ }, (_a = web3Context.transactionReceiptPollingInterval) !== null && _a !== void 0 ? _a : web3Context.transactionPollingInterval);
40
+ };
41
+ //# sourceMappingURL=watch_transaction_by_polling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch_transaction_by_polling.js","sour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AS,CAAC,IAAa,EACvB,YAAY,CACZ;iBACD,CAAC,CAAC;aACH;QACF,CAAC,CAAA,CAAC,EAAa,CAAC;IACjB,CAAC,EAAE,MAAA,WAAW,CAAC,iCAAiC,mCAAI,WAAW,CAAC,0BAA0B,CAAC,CAAC;AAC7F,CAAC,CAAC"}
@@ -0,0 +1,82 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { format } from 'web3-utils';
11
+ import { transactionReceiptSchema } from '../schemas.js';
12
+ import { watchTransactionByPolling } from './watch_transaction_by_polling.js';
13
+ /**
14
+ * This function watches a Transaction by subscribing to new heads.
15
+ * It is used by `watchTransactionForConfirmations`, in case the provider supports subscription.
16
+ */
17
+ export const watchTransactionBySubscription = ({ web3Context, transactionReceipt, transactionPromiEvent, customTransactionReceiptSchema, returnFormat, }) => {
18
+ // The following variable will stay true except if the data arrived,
19
+ // or if watching started after an error had occurred.
20
+ let needToWatchLater = true;
21
+ let lastCaughtBlockHash;
22
+ setImmediate(() => {
23
+ var _a;
24
+ (_a = web3Context.subscriptionManager) === null || _a === void 0 ? void 0 : _a.subscribe('newHeads').then((subscription) => {
25
+ subscription.on('data', (newBlockHeader) => __awaiter(void 0, void 0, void 0, function* () {
26
+ var _a;
27
+ needToWatchLater = false;
28
+ if (!(newBlockHeader === null || newBlockHeader === void 0 ? void 0 : newBlockHeader.number) ||
29
+ // For some cases, the on-data event is fired couple times for the same block!
30
+ // This needs investigation but seems to be because of multiple `subscription.on('data'...)` even this should not cause that.
31
+ lastCaughtBlockHash === (newBlockHeader === null || newBlockHeader === void 0 ? void 0 : newBlockHeader.parentHash)) {
32
+ return;
33
+ }
34
+ lastCaughtBlockHash = newBlockHeader === null || newBlockHeader === void 0 ? void 0 : newBlockHeader.parentHash;
35
+ const confirmations = BigInt(newBlockHeader.number) -
36
+ BigInt(transactionReceipt.blockNumber) +
37
+ BigInt(1);
38
+ transactionPromiEvent.emit('confirmation', {
39
+ confirmations: format({ format: 'uint' }, confirmations, returnFormat),
40
+ receipt: format(customTransactionReceiptSchema !== null && customTransactionReceiptSchema !== void 0 ? customTransactionReceiptSchema : transactionReceiptSchema, transactionReceipt, returnFormat),
41
+ latestBlockHash: format({ format: 'bytes32' }, newBlockHeader.parentHash, returnFormat),
42
+ });
43
+ if (confirmations >= web3Context.transactionConfirmationBlocks) {
44
+ yield ((_a = web3Context.subscriptionManager) === null || _a === void 0 ? void 0 : _a.removeSubscription(subscription));
45
+ }
46
+ }));
47
+ subscription.on('error', () => __awaiter(void 0, void 0, void 0, function* () {
48
+ var _b;
49
+ yield ((_b = web3Context.subscriptionManager) === null || _b === void 0 ? void 0 : _b.removeSubscription(subscription));
50
+ needToWatchLater = false;
51
+ watchTransactionByPolling({
52
+ web3Context,
53
+ transactionReceipt,
54
+ transactionPromiEvent,
55
+ customTransactionReceiptSchema,
56
+ returnFormat,
57
+ });
58
+ }));
59
+ }).catch(() => {
60
+ needToWatchLater = false;
61
+ watchTransactionByPolling({
62
+ web3Context,
63
+ transactionReceipt,
64
+ customTransactionReceiptSchema,
65
+ transactionPromiEvent,
66
+ returnFormat,
67
+ });
68
+ });
69
+ });
70
+ // Fallback to polling if tx receipt didn't arrived in "blockHeaderTimeout" [10 seconds]
71
+ setTimeout(() => {
72
+ if (needToWatchLater) {
73
+ watchTransactionByPolling({
74
+ web3Context,
75
+ transactionReceipt,
76
+ transactionPromiEvent,
77
+ returnFormat,
78
+ });
79
+ }
80
+ }, web3Context.blockHeaderTimeout * 1000);
81
+ };
82
+ //# sourceMappingURL=watch_transaction_by_subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch_transaction_by_subscription.js","sourceRoot":"","sources":["../../../src/utils/watch_transaction_by_subscription.ts"],"names":[],"mappings":";;;;;;;;;AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAa,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACzF;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAG5C,EACD,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,8BAA8B,EAC9B,YAAY,GAC0B,EAAE,EAAE;IAC1C,oEAAoE;IACpE,sDAAsD;IACtD,IAAI,gBAAgB,GAAG,IAAI,CAAC;IAC5B,IAAI,mBAA2B,CAAC;IAChC,YAAY,CAAC,GAAG,EAAE;;QACjB,MAAA,WAAW,CAAC,mBAAmB,0CAC5B,SAAS,CAAC,UAAU,EACrB,IAAI,CAAC,CAAC,YAAkC,EAAE,EAAE;YAC5C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAO,cAAiC,EAAE,EAAE;;gBACnE,gBAAgB,GAAG,KAAK,CAAC;gBACzB,IACC,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,CAAA;oBACvB,8EAA8E;oBAC9E,6HAA6H;oBAC7H,mBAAmB,MAAK,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU,CAAA,EACjD;oBACD,OAAO;iBACP;gBACD,mBAAmB,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAoB,CAAC;gBAE3D,MAAM,aAAa,GAClB,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;oBAC7B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC;oBACtC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAEX,qBAAqB,CA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B,YAAY;aACZ,CAAC,CAAC;SACH;IACF,CAAC,EAAE,WAAW,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;AAC3C,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { format } from 'web3-utils';
2
+ import { isNullish } from 'web3-validator';
3
+ import { TransactionMissingReceiptOrBlockHashError, TransactionReceiptMissingBlockNumberError, } from 'web3-errors';
4
+ import { transactionReceiptSchema } from '../schemas.js';
5
+ import { watchTransactionByPolling, } from './watch_transaction_by_polling.js';
6
+ import { watchTransactionBySubscription } from './watch_transaction_by_subscription.js';
7
+ export function watchTransactionForConfirmations(web3Context, transactionPromiEvent, transactionReceipt, transactionHash, returnFormat, customTransactionReceiptSchema) {
8
+ if (isNullish(transactionReceipt) || isNullish(transactionReceipt.blockHash))
9
+ throw new TransactionMissingReceiptOrBlockHashError({
10
+ receipt: transactionReceipt,
11
+ blockHash: format({ format: 'bytes32' }, transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.blockHash, returnFormat),
12
+ transactionHash: format({ format: 'bytes32' }, transactionHash, returnFormat),
13
+ });
14
+ if (!transactionReceipt.blockNumber)
15
+ throw new TransactionReceiptMissingBlockNumberError({ receipt: transactionReceipt });
16
+ // As we have the receipt, it's the first confirmation that tx is accepted.
17
+ transactionPromiEvent.emit('confirmation', {
18
+ confirmations: format({ format: 'uint' }, 1, returnFormat),
19
+ receipt: format(customTransactionReceiptSchema !== null && customTransactionReceiptSchema !== void 0 ? customTransactionReceiptSchema : transactionReceiptSchema, transactionReceipt, returnFormat),
20
+ latestBlockHash: format({ format: 'bytes32' }, transactionReceipt.blockHash, returnFormat),
21
+ });
22
+ // so a subscription for newBlockHeaders can be made instead of polling
23
+ const provider = web3Context.requestManager.provider;
24
+ if (provider && 'supportsSubscriptions' in provider && provider.supportsSubscriptions()) {
25
+ watchTransactionBySubscription({
26
+ web3Context,
27
+ transactionReceipt,
28
+ transactionPromiEvent,
29
+ customTransactionReceiptSchema,
30
+ returnFormat,
31
+ });
32
+ }
33
+ else {
34
+ watchTransactionByPolling({
35
+ web3Context,
36
+ transactionReceipt,
37
+ transactionPromiEvent,
38
+ customTransactionReceiptSchema,
39
+ returnFormat,
40
+ });
41
+ }
42
+ }
43
+ //# sourceMappingURL=watch_transaction_for_confirmations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch_transaction_for_confirmations.js","sourceRoot":"","sources":["../../../src/utils/watch_transaction_for_confirmations.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAc,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EACN,yCAAyC,EACzC,yCAAyC,GACzC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACN,yBAAyB,GAEzB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAExF,MAAM,UAAU,gCAAgC,CAK/C,WAAyC,EACzC,qBAA2E,EAC3E,kBAAsC,EACtC,eAAsB,EACtB,YAA0B,EAC1B,8BAA2C;IAE3C,IAAI,SAAS,CAAC,kBAAkB,CAAC,IAAI,SAAS,CAAC,kBAAkB,CAAC,SAAS,CAAC;QAC3E,MAAM,IAAI,yCAAyC,CAAC;YACnD,OAAO,EAAE,kBAAkB;YAC3B,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,SAAS,EAAE,YAAY,CAAC;YACrF,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,eAAe,EAAE,YAAY,CAAC;SAC7E,CAAC,CAAC;IAEJ,IAAI,CAAC,kBAAkB,CAAC,WAAW;QAClC,MAAM,IAAI,yCAAyC,CAAC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAEtF,2EAA2E;IAC3E,qBAAqB,CAAC,IAAI,CAAC,cAAc,EAAE;QAC1C,aAAa,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,YAAY,CAAC;QAC1D,OAAO,EAAE,MAAM,CACd,8BAA8B,aAA9B,8BAA8B,cAA9B,8BAA8B,GAAI,wBAAwB,EAC1D,kBAAkB,EAClB,YAAY,CACZ;QACD,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC;KAC1F,CAAC,CAAC;IAEH,uEAAuE;IACvE,MAAM,QAAQ,GAAqB,WAAW,CAAC,cAAc,CAAC,QAA4B,CAAC;IAC3F,IAAI,QAAQ,IAAI,uBAAuB,IAAI,QAAQ,IAAI,QAAQ,CAAC,qBAAqB,EAAE,EAAE;QACxF,8BAA8B,CAAC;YAC9B,WAAW;YACX,kBAAkB;YAClB,qBAAqB;YACrB,8BAA8B;YAC9B,YAAY;SACZ,CAAC,CAAC;KACH;SAAM;QACN,yBAAyB,CAAC;YACzB,WAAW;YACX,kBAAkB;YAClB,qBAAqB;YACrB,8BAA8B;YAC9B,YAAY;SACZ,CAAC,CAAC;KACH;AACF,CAAC"}
@@ -0,0 +1,260 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import { ETH_DATA_FORMAT, } from 'web3-types';
18
+ import { isAddress, isHexStrict, isHexString32Bytes, isNullish, isUInt } from 'web3-validator';
19
+ import { ChainMismatchError, HardforkMismatchError, ChainIdMismatchError, CommonOrChainAndHardforkError, Eip1559GasPriceError, InvalidGasOrGasPrice, InvalidMaxPriorityFeePerGasOrMaxFeePerGas, InvalidNonceOrChainIdError, InvalidTransactionCall, InvalidTransactionObjectError, InvalidTransactionWithSender, MissingChainOrHardforkError, MissingCustomChainError, MissingCustomChainIdError, MissingGasError, TransactionGasMismatchError, UnsupportedFeeMarketError, } from 'web3-errors';
20
+ import { formatTransaction } from './utils/format_transaction.js';
21
+ export function isBaseTransaction(value) {
22
+ if (!isNullish(value.to) && !isAddress(value.to))
23
+ return false;
24
+ if (!isHexStrict(value.type) && !isNullish(value.type) && value.type.length !== 2)
25
+ return false;
26
+ if (!isHexStrict(value.nonce))
27
+ return false;
28
+ if (!isHexStrict(value.gas))
29
+ return false;
30
+ if (!isHexStrict(value.value))
31
+ return false;
32
+ if (!isHexStrict(value.input))
33
+ return false;
34
+ if (value.chainId && !isHexStrict(value.chainId))
35
+ return false;
36
+ return true;
37
+ }
38
+ export function isAccessListEntry(value) {
39
+ if (!isNullish(value.address) && !isAddress(value.address))
40
+ return false;
41
+ if (!isNullish(value.storageKeys) &&
42
+ !value.storageKeys.every(storageKey => isHexString32Bytes(storageKey)))
43
+ return false;
44
+ return true;
45
+ }
46
+ export function isAccessList(value) {
47
+ if (!Array.isArray(value) ||
48
+ !value.every(accessListEntry => isAccessListEntry(accessListEntry)))
49
+ return false;
50
+ return true;
51
+ }
52
+ export function isTransaction1559Unsigned(value) {
53
+ if (!isBaseTransaction(value))
54
+ return false;
55
+ if (!isHexStrict(value.maxFeePerGas))
56
+ return false;
57
+ if (!isHexStrict(value.maxPriorityFeePerGas))
58
+ return false;
59
+ if (!isAccessList(value.accessList))
60
+ return false;
61
+ return true;
62
+ }
63
+ export function isTransaction2930Unsigned(value) {
64
+ if (!isBaseTransaction(value))
65
+ return false;
66
+ if (!isHexStrict(value.gasPrice))
67
+ return false;
68
+ if (!isAccessList(value.accessList))
69
+ return false;
70
+ return true;
71
+ }
72
+ export function isTransactionLegacyUnsigned(value) {
73
+ if (!isBaseTransaction(value))
74
+ return false;
75
+ if (!isHexStrict(value.gasPrice))
76
+ return false;
77
+ return true;
78
+ }
79
+ export function isTransactionWithSender(value) {
80
+ if (!isAddress(value.from))
81
+ return false;
82
+ if (!isBaseTransaction(value))
83
+ return false;
84
+ if (!isTransaction1559Unsigned(value) &&
85
+ !isTransaction2930Unsigned(value) &&
86
+ !isTransactionLegacyUnsigned(value))
87
+ return false;
88
+ return true;
89
+ }
90
+ export function validateTransactionWithSender(value) {
91
+ if (!isTransactionWithSender(value))
92
+ throw new InvalidTransactionWithSender(value);
93
+ }
94
+ export function isTransactionCall(value) {
95
+ if (!isNullish(value.from) && !isAddress(value.from))
96
+ return false;
97
+ if (!isAddress(value.to))
98
+ return false;
99
+ if (!isNullish(value.gas) && !isHexStrict(value.gas))
100
+ return false;
101
+ if (!isNullish(value.gasPrice) && !isHexStrict(value.gasPrice))
102
+ return false;
103
+ if (!isNullish(value.value) && !isHexStrict(value.value))
104
+ return false;
105
+ if (!isNullish(value.data) && !isHexStrict(value.data))
106
+ return false;
107
+ if (!isNullish(value.input) && !isHexStrict(value.input))
108
+ return false;
109
+ if (!isNullish(value.type))
110
+ return false;
111
+ if (isTransaction1559Unsigned(value))
112
+ return false;
113
+ if (isTransaction2930Unsigned(value))
114
+ return false;
115
+ return true;
116
+ }
117
+ export function validateTransactionCall(value) {
118
+ if (!isTransactionCall(value))
119
+ throw new InvalidTransactionCall(value);
120
+ }
121
+ export const validateCustomChainInfo = (transaction) => {
122
+ if (!isNullish(transaction.common)) {
123
+ if (isNullish(transaction.common.customChain))
124
+ throw new MissingCustomChainError();
125
+ if (isNullish(transaction.common.customChain.chainId))
126
+ throw new MissingCustomChainIdError();
127
+ if (!isNullish(transaction.chainId) &&
128
+ transaction.chainId !== transaction.common.customChain.chainId)
129
+ throw new ChainIdMismatchError({
130
+ txChainId: transaction.chainId,
131
+ customChainId: transaction.common.customChain.chainId,
132
+ });
133
+ }
134
+ };
135
+ export const validateChainInfo = (transaction) => {
136
+ if (!isNullish(transaction.common) &&
137
+ !isNullish(transaction.chain) &&
138
+ !isNullish(transaction.hardfork)) {
139
+ throw new CommonOrChainAndHardforkError();
140
+ }
141
+ if ((!isNullish(transaction.chain) && isNullish(transaction.hardfork)) ||
142
+ (!isNullish(transaction.hardfork) && isNullish(transaction.chain)))
143
+ throw new MissingChainOrHardforkError({
144
+ chain: transaction.chain,
145
+ hardfork: transaction.hardfork,
146
+ });
147
+ };
148
+ export const validateBaseChain = (transaction) => {
149
+ if (!isNullish(transaction.common))
150
+ if (!isNullish(transaction.common.baseChain))
151
+ if (!isNullish(transaction.chain) &&
152
+ transaction.chain !== transaction.common.baseChain) {
153
+ throw new ChainMismatchError({
154
+ txChain: transaction.chain,
155
+ baseChain: transaction.common.baseChain,
156
+ });
157
+ }
158
+ };
159
+ export const validateHardfork = (transaction) => {
160
+ if (!isNullish(transaction.common))
161
+ if (!isNullish(transaction.common.hardfork))
162
+ if (!isNullish(transaction.hardfork) &&
163
+ transaction.hardfork !== transaction.common.hardfork) {
164
+ throw new HardforkMismatchError({
165
+ txHardfork: transaction.hardfork,
166
+ commonHardfork: transaction.common.hardfork,
167
+ });
168
+ }
169
+ };
170
+ export const validateLegacyGas = (transaction) => {
171
+ if (
172
+ // This check is verifying gas and gasPrice aren't less than 0.
173
+ isNullish(transaction.gas) ||
174
+ !isUInt(transaction.gas) ||
175
+ isNullish(transaction.gasPrice) ||
176
+ !isUInt(transaction.gasPrice))
177
+ throw new InvalidGasOrGasPrice({
178
+ gas: transaction.gas,
179
+ gasPrice: transaction.gasPrice,
180
+ });
181
+ if (!isNullish(transaction.maxFeePerGas) || !isNullish(transaction.maxPriorityFeePerGas))
182
+ throw new UnsupportedFeeMarketError({
183
+ maxFeePerGas: transaction.maxFeePerGas,
184
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
185
+ });
186
+ };
187
+ export const validateFeeMarketGas = (transaction) => {
188
+ // These errors come from 1.x, so they must be checked before
189
+ // InvalidMaxPriorityFeePerGasOrMaxFeePerGas to throw the same error
190
+ // for the same code executing in 1.x
191
+ if (!isNullish(transaction.gasPrice) && transaction.type === '0x2')
192
+ throw new Eip1559GasPriceError(transaction.gasPrice);
193
+ if (transaction.type === '0x0' || transaction.type === '0x1')
194
+ throw new UnsupportedFeeMarketError({
195
+ maxFeePerGas: transaction.maxFeePerGas,
196
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
197
+ });
198
+ if (isNullish(transaction.maxFeePerGas) ||
199
+ !isUInt(transaction.maxFeePerGas) ||
200
+ isNullish(transaction.maxPriorityFeePerGas) ||
201
+ !isUInt(transaction.maxPriorityFeePerGas))
202
+ throw new InvalidMaxPriorityFeePerGasOrMaxFeePerGas({
203
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
204
+ maxFeePerGas: transaction.maxFeePerGas,
205
+ });
206
+ };
207
+ /**
208
+ * This method checks if all required gas properties are present for either
209
+ * legacy gas (type 0x0 and 0x1) OR fee market transactions (0x2)
210
+ */
211
+ export const validateGas = (transaction) => {
212
+ const gasPresent = !isNullish(transaction.gas) || !isNullish(transaction.gasLimit);
213
+ const legacyGasPresent = gasPresent && !isNullish(transaction.gasPrice);
214
+ const feeMarketGasPresent = gasPresent &&
215
+ !isNullish(transaction.maxPriorityFeePerGas) &&
216
+ !isNullish(transaction.maxFeePerGas);
217
+ if (!legacyGasPresent && !feeMarketGasPresent)
218
+ throw new MissingGasError({
219
+ gas: transaction.gas,
220
+ gasPrice: transaction.gasPrice,
221
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
222
+ maxFeePerGas: transaction.maxFeePerGas,
223
+ });
224
+ if (legacyGasPresent && feeMarketGasPresent)
225
+ throw new TransactionGasMismatchError({
226
+ gas: transaction.gas,
227
+ gasPrice: transaction.gasPrice,
228
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
229
+ maxFeePerGas: transaction.maxFeePerGas,
230
+ });
231
+ (legacyGasPresent ? validateLegacyGas : validateFeeMarketGas)(transaction);
232
+ (!isNullish(transaction.type) && transaction.type > '0x1'
233
+ ? validateFeeMarketGas
234
+ : validateLegacyGas)(transaction);
235
+ };
236
+ export const validateTransactionForSigning = (transaction, overrideMethod, options = { transactionSchema: undefined }) => {
237
+ if (!isNullish(overrideMethod)) {
238
+ overrideMethod(transaction);
239
+ return;
240
+ }
241
+ if (typeof transaction !== 'object' || isNullish(transaction))
242
+ throw new InvalidTransactionObjectError(transaction);
243
+ validateCustomChainInfo(transaction);
244
+ validateChainInfo(transaction);
245
+ validateBaseChain(transaction);
246
+ validateHardfork(transaction);
247
+ const formattedTransaction = formatTransaction(transaction, ETH_DATA_FORMAT, {
248
+ transactionSchema: options.transactionSchema,
249
+ });
250
+ validateGas(formattedTransaction);
251
+ if (isNullish(formattedTransaction.nonce) ||
252
+ isNullish(formattedTransaction.chainId) ||
253
+ formattedTransaction.nonce.startsWith('-') ||
254
+ formattedTransaction.chainId.startsWith('-'))
255
+ throw new InvalidNonceOrChainIdError({
256
+ nonce: transaction.nonce,
257
+ chainId: transaction.chainId,
258
+ });
259
+ };
260
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAUN,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,EACpB,yCAAyC,EACzC,0BAA0B,EAC1B,sBAAsB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