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,645 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
29
+ t[p] = s[p];
30
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
31
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
32
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
33
+ t[p[i]] = s[p[i]];
34
+ }
35
+ return t;
36
+ };
37
+ // Disabling because returnTypes must be last param to match 1.x params
38
+ /* eslint-disable default-param-last */
39
+ import { ETH_DATA_FORMAT, DEFAULT_RETURN_FORMAT, } from 'web3-types';
40
+ import { Web3PromiEvent } from 'web3-core';
41
+ import { format, hexToBytes, bytesToUint8Array, numberToHex } from 'web3-utils';
42
+ import { TransactionFactory } from 'web3-eth-accounts';
43
+ import { isBlockTag, isBytes, isNullish, isString } from 'web3-validator';
44
+ import { SignatureError } from 'web3-errors';
45
+ import { ethRpcMethods } from 'web3-rpc-methods';
46
+ import { decodeSignedTransaction } from './utils/decode_signed_transaction.js';
47
+ import { accountSchema, blockSchema, feeHistorySchema, logSchema, transactionReceiptSchema, accessListResultSchema, SignatureObjectSchema, } from './schemas.js';
48
+ // eslint-disable-next-line import/no-cycle
49
+ import { getTransactionFromOrToAttr } from './utils/transaction_builder.js';
50
+ import { formatTransaction } from './utils/format_transaction.js';
51
+ // eslint-disable-next-line import/no-cycle
52
+ import { trySendTransaction } from './utils/try_send_transaction.js';
53
+ // eslint-disable-next-line import/no-cycle
54
+ import { waitForTransactionReceipt } from './utils/wait_for_transaction_receipt.js';
55
+ import { NUMBER_DATA_FORMAT } from './constants.js';
56
+ // eslint-disable-next-line import/no-cycle
57
+ import { SendTxHelper } from './utils/send_tx_helper.js';
58
+ /**
59
+ * View additional documentations here: {@link Web3Eth.getProtocolVersion}
60
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
61
+ */
62
+ export const getProtocolVersion = (web3Context) => __awaiter(void 0, void 0, void 0, function* () { return ethRpcMethods.getProtocolVersion(web3Context.requestManager); });
63
+ // TODO Add returnFormat parameter
64
+ /**
65
+ * View additional documentations here: {@link Web3Eth.isSyncing}
66
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
67
+ */
68
+ export const isSyncing = (web3Context) => __awaiter(void 0, void 0, void 0, function* () { return ethRpcMethods.getSyncing(web3Context.requestManager); });
69
+ // TODO consider adding returnFormat parameter (to format address as bytes)
70
+ /**
71
+ * View additional documentations here: {@link Web3Eth.getCoinbase}
72
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
73
+ */
74
+ export const getCoinbase = (web3Context) => __awaiter(void 0, void 0, void 0, function* () { return ethRpcMethods.getCoinbase(web3Context.requestManager); });
75
+ /**
76
+ * View additional documentations here: {@link Web3Eth.isMining}
77
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
78
+ */
79
+ export const isMining = (web3Context) => __awaiter(void 0, void 0, void 0, function* () { return ethRpcMethods.getMining(web3Context.requestManager); });
80
+ /**
81
+ * View additional documentations here: {@link Web3Eth.getHashRate}
82
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
83
+ */
84
+ export function getHashRate(web3Context, returnFormat) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const response = yield ethRpcMethods.getHashRate(web3Context.requestManager);
87
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
88
+ });
89
+ }
90
+ /**
91
+ * View additional documentations here: {@link Web3Eth.getGasPrice}
92
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
93
+ */
94
+ export function getGasPrice(web3Context, returnFormat) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const response = yield ethRpcMethods.getGasPrice(web3Context.requestManager);
97
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
98
+ });
99
+ }
100
+ /**
101
+ * View additional documentations here: {@link Web3Eth.getMaxPriorityFeePerGas}
102
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
103
+ */
104
+ export function getMaxPriorityFeePerGas(web3Context, returnFormat) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const response = yield ethRpcMethods.getMaxPriorityFeePerGas(web3Context.requestManager);
107
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
108
+ });
109
+ }
110
+ /**
111
+ * View additional documentations here: {@link Web3Eth.getBlockNumber}
112
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
113
+ */
114
+ export function getBlockNumber(web3Context, returnFormat) {
115
+ return __awaiter(this, void 0, void 0, function* () {
116
+ const response = yield ethRpcMethods.getBlockNumber(web3Context.requestManager);
117
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
118
+ });
119
+ }
120
+ /**
121
+ * View additional documentations here: {@link Web3Eth.getBalance}
122
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
123
+ */
124
+ export function getBalance(web3Context, address, blockNumber = web3Context.defaultBlock, returnFormat) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const blockNumberFormatted = isBlockTag(blockNumber)
127
+ ? blockNumber
128
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
129
+ const response = yield ethRpcMethods.getBalance(web3Context.requestManager, address, blockNumberFormatted);
130
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
131
+ });
132
+ }
133
+ /**
134
+ * View additional documentations here: {@link Web3Eth.getStorageAt}
135
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
136
+ */
137
+ export function getStorageAt(web3Context, address, storageSlot, blockNumber = web3Context.defaultBlock, returnFormat) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ const storageSlotFormatted = format({ format: 'uint' }, storageSlot, ETH_DATA_FORMAT);
140
+ const blockNumberFormatted = isBlockTag(blockNumber)
141
+ ? blockNumber
142
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
143
+ const response = yield ethRpcMethods.getStorageAt(web3Context.requestManager, address, storageSlotFormatted, blockNumberFormatted);
144
+ return format({ format: 'bytes' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
145
+ });
146
+ }
147
+ /**
148
+ * View additional documentations here: {@link Web3Eth.getCode}
149
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
150
+ */
151
+ export function getCode(web3Context, address, blockNumber = web3Context.defaultBlock, returnFormat) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ const blockNumberFormatted = isBlockTag(blockNumber)
154
+ ? blockNumber
155
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
156
+ const response = yield ethRpcMethods.getCode(web3Context.requestManager, address, blockNumberFormatted);
157
+ return format({ format: 'bytes' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
158
+ });
159
+ }
160
+ /**
161
+ * View additional documentations here: {@link Web3Eth.getBlock}
162
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
163
+ */
164
+ export function getBlock(web3Context, block = web3Context.defaultBlock, hydrated = false, returnFormat) {
165
+ var _a;
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ let response;
168
+ if (isBytes(block)) {
169
+ const blockHashFormatted = format({ format: 'bytes32' }, block, ETH_DATA_FORMAT);
170
+ response = yield ethRpcMethods.getBlockByHash(web3Context.requestManager, blockHashFormatted, hydrated);
171
+ }
172
+ else {
173
+ const blockNumberFormatted = isBlockTag(block)
174
+ ? block
175
+ : format({ format: 'uint' }, block, ETH_DATA_FORMAT);
176
+ response = yield ethRpcMethods.getBlockByNumber(web3Context.requestManager, blockNumberFormatted, hydrated);
177
+ }
178
+ const res = format(blockSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
179
+ if (!isNullish(res)) {
180
+ const result = Object.assign(Object.assign({}, res), { transactions: (_a = res.transactions) !== null && _a !== void 0 ? _a : [] });
181
+ return result;
182
+ }
183
+ return res;
184
+ });
185
+ }
186
+ /**
187
+ * View additional documentations here: {@link Web3Eth.getBlockTransactionCount}
188
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
189
+ */
190
+ export function getBlockTransactionCount(web3Context, block = web3Context.defaultBlock, returnFormat) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ let response;
193
+ if (isBytes(block)) {
194
+ const blockHashFormatted = format({ format: 'bytes32' }, block, ETH_DATA_FORMAT);
195
+ response = yield ethRpcMethods.getBlockTransactionCountByHash(web3Context.requestManager, blockHashFormatted);
196
+ }
197
+ else {
198
+ const blockNumberFormatted = isBlockTag(block)
199
+ ? block
200
+ : format({ format: 'uint' }, block, ETH_DATA_FORMAT);
201
+ response = yield ethRpcMethods.getBlockTransactionCountByNumber(web3Context.requestManager, blockNumberFormatted);
202
+ }
203
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
204
+ });
205
+ }
206
+ /**
207
+ * View additional documentations here: {@link Web3Eth.getBlockUncleCount}
208
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
209
+ */
210
+ export function getBlockUncleCount(web3Context, block = web3Context.defaultBlock, returnFormat) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ let response;
213
+ if (isBytes(block)) {
214
+ const blockHashFormatted = format({ format: 'bytes32' }, block, ETH_DATA_FORMAT);
215
+ response = yield ethRpcMethods.getUncleCountByBlockHash(web3Context.requestManager, blockHashFormatted);
216
+ }
217
+ else {
218
+ const blockNumberFormatted = isBlockTag(block)
219
+ ? block
220
+ : format({ format: 'uint' }, block, ETH_DATA_FORMAT);
221
+ response = yield ethRpcMethods.getUncleCountByBlockNumber(web3Context.requestManager, blockNumberFormatted);
222
+ }
223
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
224
+ });
225
+ }
226
+ /**
227
+ * View additional documentations here: {@link Web3Eth.getUncle}
228
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
229
+ */
230
+ export function getUncle(web3Context, block = web3Context.defaultBlock, uncleIndex, returnFormat) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const uncleIndexFormatted = format({ format: 'uint' }, uncleIndex, ETH_DATA_FORMAT);
233
+ let response;
234
+ if (isBytes(block)) {
235
+ const blockHashFormatted = format({ format: 'bytes32' }, block, ETH_DATA_FORMAT);
236
+ response = yield ethRpcMethods.getUncleByBlockHashAndIndex(web3Context.requestManager, blockHashFormatted, uncleIndexFormatted);
237
+ }
238
+ else {
239
+ const blockNumberFormatted = isBlockTag(block)
240
+ ? block
241
+ : format({ format: 'uint' }, block, ETH_DATA_FORMAT);
242
+ response = yield ethRpcMethods.getUncleByBlockNumberAndIndex(web3Context.requestManager, blockNumberFormatted, uncleIndexFormatted);
243
+ }
244
+ return format(blockSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
245
+ });
246
+ }
247
+ /**
248
+ * View additional documentations here: {@link Web3Eth.getTransaction}
249
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
250
+ */
251
+ export function getTransaction(web3Context, transactionHash, returnFormat = web3Context.defaultReturnFormat) {
252
+ return __awaiter(this, void 0, void 0, function* () {
253
+ const transactionHashFormatted = format({ format: 'bytes32' }, transactionHash, DEFAULT_RETURN_FORMAT);
254
+ const response = yield ethRpcMethods.getTransactionByHash(web3Context.requestManager, transactionHashFormatted);
255
+ return isNullish(response)
256
+ ? response
257
+ : formatTransaction(response, returnFormat, {
258
+ transactionSchema: web3Context.config.customTransactionSchema,
259
+ fillInputAndData: true,
260
+ });
261
+ });
262
+ }
263
+ /**
264
+ * View additional documentations here: {@link Web3Eth.getPendingTransactions}
265
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
266
+ */
267
+ export function getPendingTransactions(web3Context, returnFormat) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ const response = yield ethRpcMethods.getPendingTransactions(web3Context.requestManager);
270
+ return response.map(transaction => formatTransaction(transaction, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, {
271
+ transactionSchema: web3Context.config.customTransactionSchema,
272
+ fillInputAndData: true,
273
+ }));
274
+ });
275
+ }
276
+ /**
277
+ * View additional documentations here: {@link Web3Eth.getTransactionFromBlock}
278
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
279
+ */
280
+ export function getTransactionFromBlock(web3Context, block = web3Context.defaultBlock, transactionIndex, returnFormat) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const transactionIndexFormatted = format({ format: 'uint' }, transactionIndex, ETH_DATA_FORMAT);
283
+ let response;
284
+ if (isBytes(block)) {
285
+ const blockHashFormatted = format({ format: 'bytes32' }, block, ETH_DATA_FORMAT);
286
+ response = yield ethRpcMethods.getTransactionByBlockHashAndIndex(web3Context.requestManager, blockHashFormatted, transactionIndexFormatted);
287
+ }
288
+ else {
289
+ const blockNumberFormatted = isBlockTag(block)
290
+ ? block
291
+ : format({ format: 'uint' }, block, ETH_DATA_FORMAT);
292
+ response = yield ethRpcMethods.getTransactionByBlockNumberAndIndex(web3Context.requestManager, blockNumberFormatted, transactionIndexFormatted);
293
+ }
294
+ return isNullish(response)
295
+ ? response
296
+ : formatTransaction(response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat, {
297
+ transactionSchema: web3Context.config.customTransactionSchema,
298
+ fillInputAndData: true,
299
+ });
300
+ });
301
+ }
302
+ /**
303
+ * View additional documentations here: {@link Web3Eth.getTransactionReceipt}
304
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
305
+ */
306
+ export function getTransactionReceipt(web3Context, transactionHash, returnFormat) {
307
+ return __awaiter(this, void 0, void 0, function* () {
308
+ const transactionHashFormatted = format({ format: 'bytes32' }, transactionHash, DEFAULT_RETURN_FORMAT);
309
+ let response;
310
+ try {
311
+ response = yield ethRpcMethods.getTransactionReceipt(web3Context.requestManager, transactionHashFormatted);
312
+ }
313
+ catch (error) {
314
+ // geth indexing error, we poll until transactions stopped indexing
315
+ if (typeof error === 'object' &&
316
+ !isNullish(error) &&
317
+ 'message' in error &&
318
+ error.message === 'transaction indexing is in progress') {
319
+ console.warn('Transaction indexing is in progress.');
320
+ }
321
+ else {
322
+ throw error;
323
+ }
324
+ }
325
+ return isNullish(response)
326
+ ? response
327
+ : format(transactionReceiptSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
328
+ });
329
+ }
330
+ /**
331
+ * View additional documentations here: {@link Web3Eth.getTransactionCount}
332
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
333
+ */
334
+ export function getTransactionCount(web3Context, address, blockNumber = web3Context.defaultBlock, returnFormat) {
335
+ return __awaiter(this, void 0, void 0, function* () {
336
+ const blockNumberFormatted = isBlockTag(blockNumber)
337
+ ? blockNumber
338
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
339
+ const response = yield ethRpcMethods.getTransactionCount(web3Context.requestManager, address, blockNumberFormatted);
340
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
341
+ });
342
+ }
343
+ /**
344
+ * View additional documentations here: {@link Web3Eth.sendTransaction}
345
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
346
+ */
347
+ export function sendTransaction(web3Context, transactionObj, returnFormat, options = { checkRevertBeforeSending: true }, transactionMiddleware) {
348
+ const promiEvent = new Web3PromiEvent((resolve, reject) => {
349
+ setImmediate(() => {
350
+ (() => __awaiter(this, void 0, void 0, function* () {
351
+ const sendTxHelper = new SendTxHelper({
352
+ web3Context,
353
+ promiEvent,
354
+ options,
355
+ returnFormat,
356
+ });
357
+ let transaction = Object.assign({}, transactionObj);
358
+ if (!isNullish(transactionMiddleware)) {
359
+ transaction = yield transactionMiddleware.processTransaction(transaction);
360
+ }
361
+ let transactionFormatted = formatTransaction(Object.assign(Object.assign({}, transaction), { from: getTransactionFromOrToAttr('from', web3Context, transaction), to: getTransactionFromOrToAttr('to', web3Context, transaction) }), ETH_DATA_FORMAT, {
362
+ transactionSchema: web3Context.config.customTransactionSchema,
363
+ });
364
+ try {
365
+ transactionFormatted = yield sendTxHelper.populateGasPrice({
366
+ transaction,
367
+ transactionFormatted,
368
+ });
369
+ yield sendTxHelper.checkRevertBeforeSending(transactionFormatted);
370
+ sendTxHelper.emitSending(transactionFormatted);
371
+ let wallet;
372
+ if (web3Context.wallet && !isNullish(transactionFormatted.from)) {
373
+ wallet = web3Context.wallet.get(transactionFormatted.from);
374
+ }
375
+ const transactionHash = yield sendTxHelper.signAndSend({
376
+ wallet,
377
+ tx: transactionFormatted,
378
+ });
379
+ const transactionHashFormatted = format({ format: 'bytes32' }, transactionHash, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
380
+ sendTxHelper.emitSent(transactionFormatted);
381
+ sendTxHelper.emitTransactionHash(transactionHashFormatted);
382
+ const transactionReceipt = yield waitForTransactionReceipt(web3Context, transactionHash, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
383
+ const transactionReceiptFormatted = sendTxHelper.getReceiptWithEvents(format(transactionReceiptSchema, transactionReceipt, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat));
384
+ sendTxHelper.emitReceipt(transactionReceiptFormatted);
385
+ resolve(yield sendTxHelper.handleResolve({
386
+ receipt: transactionReceiptFormatted,
387
+ tx: transactionFormatted,
388
+ }));
389
+ sendTxHelper.emitConfirmation({
390
+ receipt: transactionReceiptFormatted,
391
+ transactionHash,
392
+ });
393
+ }
394
+ catch (error) {
395
+ reject(yield sendTxHelper.handleError({
396
+ error,
397
+ tx: transactionFormatted,
398
+ }));
399
+ }
400
+ }))();
401
+ });
402
+ });
403
+ return promiEvent;
404
+ }
405
+ /**
406
+ * View additional documentations here: {@link Web3Eth.sendSignedTransaction}
407
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
408
+ */
409
+ export function sendSignedTransaction(web3Context, signedTransaction, returnFormat, options = { checkRevertBeforeSending: true }) {
410
+ // TODO - Promise returned in function argument where a void return was expected
411
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
412
+ const promiEvent = new Web3PromiEvent((resolve, reject) => {
413
+ setImmediate(() => {
414
+ (() => __awaiter(this, void 0, void 0, function* () {
415
+ const sendTxHelper = new SendTxHelper({
416
+ web3Context,
417
+ promiEvent,
418
+ options,
419
+ returnFormat,
420
+ });
421
+ // Formatting signedTransaction to be send to RPC endpoint
422
+ const signedTransactionFormattedHex = format({ format: 'bytes' }, signedTransaction, ETH_DATA_FORMAT);
423
+ const unSerializedTransaction = TransactionFactory.fromSerializedData(bytesToUint8Array(hexToBytes(signedTransactionFormattedHex)));
424
+ const unSerializedTransactionWithFrom = Object.assign(Object.assign({}, unSerializedTransaction.toJSON()), {
425
+ // Some providers will default `from` to address(0) causing the error
426
+ // reported from `eth_call` to not be the reason the user's tx failed
427
+ // e.g. `eth_call` will return an Out of Gas error for a failed
428
+ // smart contract execution contract, because the sender, address(0),
429
+ // has no balance to pay for the gas of the transaction execution
430
+ from: unSerializedTransaction.getSenderAddress().toString() });
431
+ try {
432
+ const { v, r, s } = unSerializedTransactionWithFrom, txWithoutSigParams = __rest(unSerializedTransactionWithFrom, ["v", "r", "s"]);
433
+ yield sendTxHelper.checkRevertBeforeSending(txWithoutSigParams);
434
+ sendTxHelper.emitSending(signedTransactionFormattedHex);
435
+ const transactionHash = yield trySendTransaction(web3Context, () => __awaiter(this, void 0, void 0, function* () {
436
+ return ethRpcMethods.sendRawTransaction(web3Context.requestManager, signedTransactionFormattedHex);
437
+ }));
438
+ sendTxHelper.emitSent(signedTransactionFormattedHex);
439
+ const transactionHashFormatted = format({ format: 'bytes32' }, transactionHash, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
440
+ sendTxHelper.emitTransactionHash(transactionHashFormatted);
441
+ const transactionReceipt = yield waitForTransactionReceipt(web3Context, transactionHash, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
442
+ const transactionReceiptFormatted = sendTxHelper.getReceiptWithEvents(format(transactionReceiptSchema, transactionReceipt, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat));
443
+ sendTxHelper.emitReceipt(transactionReceiptFormatted);
444
+ resolve(yield sendTxHelper.handleResolve({
445
+ receipt: transactionReceiptFormatted,
446
+ tx: unSerializedTransactionWithFrom,
447
+ }));
448
+ sendTxHelper.emitConfirmation({
449
+ receipt: transactionReceiptFormatted,
450
+ transactionHash,
451
+ });
452
+ }
453
+ catch (error) {
454
+ reject(yield sendTxHelper.handleError({
455
+ error,
456
+ tx: unSerializedTransactionWithFrom,
457
+ }));
458
+ }
459
+ }))();
460
+ });
461
+ });
462
+ return promiEvent;
463
+ }
464
+ /**
465
+ * View additional documentations here: {@link Web3Eth.sign}
466
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
467
+ */
468
+ export function sign(web3Context, message, addressOrIndex, returnFormat = web3Context.defaultReturnFormat) {
469
+ var _a;
470
+ return __awaiter(this, void 0, void 0, function* () {
471
+ const messageFormatted = format({ format: 'bytes' }, message, DEFAULT_RETURN_FORMAT);
472
+ if ((_a = web3Context.wallet) === null || _a === void 0 ? void 0 : _a.get(addressOrIndex)) {
473
+ const wallet = web3Context.wallet.get(addressOrIndex);
474
+ const signed = wallet.sign(messageFormatted);
475
+ return format(SignatureObjectSchema, signed, returnFormat);
476
+ }
477
+ if (typeof addressOrIndex === 'number') {
478
+ throw new SignatureError(message, 'RPC method "eth_sign" does not support index signatures');
479
+ }
480
+ const response = yield ethRpcMethods.sign(web3Context.requestManager, addressOrIndex, messageFormatted);
481
+ return format({ format: 'bytes' }, response, returnFormat);
482
+ });
483
+ }
484
+ /**
485
+ * View additional documentations here: {@link Web3Eth.signTransaction}
486
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
487
+ */
488
+ export function signTransaction(web3Context, transaction, returnFormat = web3Context.defaultReturnFormat) {
489
+ return __awaiter(this, void 0, void 0, function* () {
490
+ const response = yield ethRpcMethods.signTransaction(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, {
491
+ transactionSchema: web3Context.config.customTransactionSchema,
492
+ }));
493
+ // Some clients only return the encoded signed transaction (e.g. Ganache)
494
+ // while clients such as Geth return the desired SignedTransactionInfoAPI object
495
+ return isString(response)
496
+ ? decodeSignedTransaction(response, returnFormat, {
497
+ fillInputAndData: true,
498
+ })
499
+ : {
500
+ raw: format({ format: 'bytes' }, response.raw, returnFormat),
501
+ tx: formatTransaction(response.tx, returnFormat, {
502
+ transactionSchema: web3Context.config.customTransactionSchema,
503
+ fillInputAndData: true,
504
+ }),
505
+ };
506
+ });
507
+ }
508
+ // TODO Decide what to do with transaction.to
509
+ // https://github.com/ChainSafe/web3.js/pull/4525#issuecomment-982330076
510
+ /**
511
+ * View additional documentations here: {@link Web3Eth.call}
512
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
513
+ */
514
+ export function call(web3Context, transaction, blockNumber = web3Context.defaultBlock, returnFormat = web3Context.defaultReturnFormat) {
515
+ return __awaiter(this, void 0, void 0, function* () {
516
+ const blockNumberFormatted = isBlockTag(blockNumber)
517
+ ? blockNumber
518
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
519
+ const response = yield ethRpcMethods.call(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, {
520
+ transactionSchema: web3Context.config.customTransactionSchema,
521
+ }), blockNumberFormatted);
522
+ return format({ format: 'bytes' }, response, returnFormat);
523
+ });
524
+ }
525
+ // TODO - Investigate whether response is padded as 1.x docs suggest
526
+ /**
527
+ * View additional documentations here: {@link Web3Eth.estimateGas}
528
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
529
+ */
530
+ export function estimateGas(web3Context, transaction, blockNumber = web3Context.defaultBlock, returnFormat) {
531
+ return __awaiter(this, void 0, void 0, function* () {
532
+ const transactionFormatted = formatTransaction(transaction, ETH_DATA_FORMAT, {
533
+ transactionSchema: web3Context.config.customTransactionSchema,
534
+ });
535
+ const blockNumberFormatted = isBlockTag(blockNumber)
536
+ ? blockNumber
537
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
538
+ const response = yield ethRpcMethods.estimateGas(web3Context.requestManager, transactionFormatted, blockNumberFormatted);
539
+ return format({ format: 'uint' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
540
+ });
541
+ }
542
+ // TODO - Add input formatting to filter
543
+ /**
544
+ * View additional documentations here: {@link Web3Eth.getPastLogs}
545
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
546
+ */
547
+ export function getLogs(web3Context, filter, returnFormat) {
548
+ return __awaiter(this, void 0, void 0, function* () {
549
+ // format type bigint or number toBlock and fromBlock to hexstring.
550
+ let { toBlock, fromBlock } = filter;
551
+ if (!isNullish(toBlock)) {
552
+ if (typeof toBlock === 'number' || typeof toBlock === 'bigint') {
553
+ toBlock = numberToHex(toBlock);
554
+ }
555
+ }
556
+ if (!isNullish(fromBlock)) {
557
+ if (typeof fromBlock === 'number' || typeof fromBlock === 'bigint') {
558
+ fromBlock = numberToHex(fromBlock);
559
+ }
560
+ }
561
+ const formattedFilter = Object.assign(Object.assign({}, filter), { fromBlock, toBlock });
562
+ const response = yield ethRpcMethods.getLogs(web3Context.requestManager, formattedFilter);
563
+ const result = response.map(res => {
564
+ if (typeof res === 'string') {
565
+ return res;
566
+ }
567
+ return format(logSchema, res, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
568
+ });
569
+ return result;
570
+ });
571
+ }
572
+ /**
573
+ * View additional documentations here: {@link Web3Eth.getChainId}
574
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
575
+ */
576
+ export function getChainId(web3Context, returnFormat) {
577
+ return __awaiter(this, void 0, void 0, function* () {
578
+ const response = yield ethRpcMethods.getChainId(web3Context.requestManager);
579
+ return format({ format: 'uint' },
580
+ // Response is number in hex formatted string
581
+ response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
582
+ });
583
+ }
584
+ /**
585
+ * View additional documentations here: {@link Web3Eth.getProof}
586
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
587
+ */
588
+ export function getProof(web3Context, address, storageKeys, blockNumber = web3Context.defaultBlock, returnFormat) {
589
+ return __awaiter(this, void 0, void 0, function* () {
590
+ const storageKeysFormatted = storageKeys.map(storageKey => format({ format: 'bytes' }, storageKey, ETH_DATA_FORMAT));
591
+ const blockNumberFormatted = isBlockTag(blockNumber)
592
+ ? blockNumber
593
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
594
+ const response = yield ethRpcMethods.getProof(web3Context.requestManager, address, storageKeysFormatted, blockNumberFormatted);
595
+ return format(accountSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
596
+ });
597
+ }
598
+ // TODO Throwing an error with Geth, but not Infura
599
+ // TODO gasUsedRatio and reward not formatting
600
+ /**
601
+ * View additional documentations here: {@link Web3Eth.getFeeHistory}
602
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
603
+ */
604
+ export function getFeeHistory(web3Context, blockCount, newestBlock = web3Context.defaultBlock, rewardPercentiles, returnFormat) {
605
+ return __awaiter(this, void 0, void 0, function* () {
606
+ const blockCountFormatted = format({ format: 'uint' }, blockCount, ETH_DATA_FORMAT);
607
+ const newestBlockFormatted = isBlockTag(newestBlock)
608
+ ? newestBlock
609
+ : format({ format: 'uint' }, newestBlock, ETH_DATA_FORMAT);
610
+ const rewardPercentilesFormatted = format({
611
+ type: 'array',
612
+ items: {
613
+ format: 'uint',
614
+ },
615
+ }, rewardPercentiles, NUMBER_DATA_FORMAT);
616
+ const response = yield ethRpcMethods.getFeeHistory(web3Context.requestManager, blockCountFormatted, newestBlockFormatted, rewardPercentilesFormatted);
617
+ return format(feeHistorySchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
618
+ });
619
+ }
620
+ /**
621
+ * View additional documentations here: {@link Web3Eth.createAccessList}
622
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
623
+ */
624
+ export function createAccessList(web3Context, transaction, blockNumber = web3Context.defaultBlock, returnFormat) {
625
+ return __awaiter(this, void 0, void 0, function* () {
626
+ const blockNumberFormatted = isBlockTag(blockNumber)
627
+ ? blockNumber
628
+ : format({ format: 'uint' }, blockNumber, ETH_DATA_FORMAT);
629
+ const response = (yield ethRpcMethods.createAccessList(web3Context.requestManager, formatTransaction(transaction, ETH_DATA_FORMAT, {
630
+ transactionSchema: web3Context.config.customTransactionSchema,
631
+ }), blockNumberFormatted));
632
+ return format(accessListResultSchema, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
633
+ });
634
+ }
635
+ /**
636
+ * View additional documentations here: {@link Web3Eth.signTypedData}
637
+ * @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
638
+ */
639
+ export function signTypedData(web3Context, address, typedData, useLegacy, returnFormat) {
640
+ return __awaiter(this, void 0, void 0, function* () {
641
+ const response = yield ethRpcMethods.signTypedData(web3Context.requestManager, address, typedData, useLegacy);
642
+ return format({ format: 'bytes' }, response, returnFormat !== null && returnFormat !== void 0 ? returnFormat : web3Context.defaultReturnFormat);
643
+ });
644
+ }
645
+ //# sourceMappingURL=rpc_method_wrappers.js.map