essential-eth 0.10.3 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/index.cjs +2024 -0
  2. package/dist/index.d.cts +330 -0
  3. package/dist/index.d.ts +330 -0
  4. package/dist/index.js +1952 -0
  5. package/package.json +14 -15
  6. package/readme.md +2 -2
  7. package/dist/cjs/classes/Contract.d.ts +0 -81
  8. package/dist/cjs/classes/Contract.js +0 -139
  9. package/dist/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
  10. package/dist/cjs/classes/test/Contract/crv-abi.js +0 -413
  11. package/dist/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
  12. package/dist/cjs/classes/test/Contract/ens-abi.js +0 -453
  13. package/dist/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
  14. package/dist/cjs/classes/test/Contract/fei-abi.js +0 -526
  15. package/dist/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
  16. package/dist/cjs/classes/test/Contract/foo-abi.js +0 -42
  17. package/dist/cjs/classes/test/Contract/jokerrace-abi.d.ts +0 -2
  18. package/dist/cjs/classes/test/Contract/jokerrace-abi.js +0 -22
  19. package/dist/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
  20. package/dist/cjs/classes/test/Contract/uniswap-abi.js +0 -121
  21. package/dist/cjs/classes/utils/clean-block.d.ts +0 -120
  22. package/dist/cjs/classes/utils/clean-block.js +0 -160
  23. package/dist/cjs/classes/utils/clean-log.d.ts +0 -9
  24. package/dist/cjs/classes/utils/clean-log.js +0 -39
  25. package/dist/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -14
  26. package/dist/cjs/classes/utils/clean-transaction-receipt.js +0 -53
  27. package/dist/cjs/classes/utils/clean-transaction.d.ts +0 -14
  28. package/dist/cjs/classes/utils/clean-transaction.js +0 -54
  29. package/dist/cjs/classes/utils/encode-decode-transaction.d.ts +0 -16
  30. package/dist/cjs/classes/utils/encode-decode-transaction.js +0 -185
  31. package/dist/cjs/classes/utils/fetchers.d.ts +0 -53
  32. package/dist/cjs/classes/utils/fetchers.js +0 -85
  33. package/dist/cjs/classes/utils/hex-to-decimal.d.ts +0 -18
  34. package/dist/cjs/classes/utils/hex-to-decimal.js +0 -24
  35. package/dist/cjs/classes/utils/prepare-transaction.d.ts +0 -6
  36. package/dist/cjs/classes/utils/prepare-transaction.js +0 -47
  37. package/dist/cjs/index.d.ts +0 -24
  38. package/dist/cjs/index.js +0 -58
  39. package/dist/cjs/index.umd.js +0 -2
  40. package/dist/cjs/index.umd.js.map +0 -1
  41. package/dist/cjs/logger/logger.d.ts +0 -11
  42. package/dist/cjs/logger/logger.js +0 -37
  43. package/dist/cjs/logger/package-version.d.ts +0 -1
  44. package/dist/cjs/logger/package-version.js +0 -5
  45. package/dist/cjs/package.json +0 -1
  46. package/dist/cjs/providers/AlchemyProvider.d.ts +0 -4
  47. package/dist/cjs/providers/AlchemyProvider.js +0 -11
  48. package/dist/cjs/providers/BaseProvider.d.ts +0 -374
  49. package/dist/cjs/providers/BaseProvider.js +0 -514
  50. package/dist/cjs/providers/FallthroughProvider.d.ts +0 -24
  51. package/dist/cjs/providers/FallthroughProvider.js +0 -74
  52. package/dist/cjs/providers/JsonRpcProvider.d.ts +0 -33
  53. package/dist/cjs/providers/JsonRpcProvider.js +0 -46
  54. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
  55. package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +0 -152
  56. package/dist/cjs/providers/test/mock-of.d.ts +0 -8
  57. package/dist/cjs/providers/test/mock-of.js +0 -12
  58. package/dist/cjs/providers/test/rpc-urls.d.ts +0 -12
  59. package/dist/cjs/providers/test/rpc-urls.js +0 -27
  60. package/dist/cjs/providers/utils/chains-info.d.ts +0 -24
  61. package/dist/cjs/providers/utils/chains-info.js +0 -71
  62. package/dist/cjs/shared/tiny-big/helpers.d.ts +0 -17
  63. package/dist/cjs/shared/tiny-big/helpers.js +0 -97
  64. package/dist/cjs/shared/tiny-big/tiny-big.d.ts +0 -58
  65. package/dist/cjs/shared/tiny-big/tiny-big.js +0 -101
  66. package/dist/cjs/shared/validate-type.d.ts +0 -3
  67. package/dist/cjs/shared/validate-type.js +0 -9
  68. package/dist/cjs/types/Block.types.d.ts +0 -41
  69. package/dist/cjs/types/Block.types.js +0 -2
  70. package/dist/cjs/types/Contract.types.d.ts +0 -24
  71. package/dist/cjs/types/Contract.types.js +0 -2
  72. package/dist/cjs/types/FeeData.types.d.ts +0 -7
  73. package/dist/cjs/types/FeeData.types.js +0 -2
  74. package/dist/cjs/types/Filter.types.d.ts +0 -16
  75. package/dist/cjs/types/Filter.types.js +0 -2
  76. package/dist/cjs/types/Network.types.d.ts +0 -8
  77. package/dist/cjs/types/Network.types.js +0 -2
  78. package/dist/cjs/types/Transaction.types.d.ts +0 -123
  79. package/dist/cjs/types/Transaction.types.js +0 -2
  80. package/dist/cjs/utils/bytes.d.ts +0 -289
  81. package/dist/cjs/utils/bytes.js +0 -711
  82. package/dist/cjs/utils/compute-address.d.ts +0 -17
  83. package/dist/cjs/utils/compute-address.js +0 -34
  84. package/dist/cjs/utils/compute-public-key.d.ts +0 -18
  85. package/dist/cjs/utils/compute-public-key.js +0 -26
  86. package/dist/cjs/utils/ether-to-gwei.d.ts +0 -27
  87. package/dist/cjs/utils/ether-to-gwei.js +0 -35
  88. package/dist/cjs/utils/ether-to-wei.d.ts +0 -27
  89. package/dist/cjs/utils/ether-to-wei.js +0 -35
  90. package/dist/cjs/utils/gwei-to-ether.d.ts +0 -27
  91. package/dist/cjs/utils/gwei-to-ether.js +0 -35
  92. package/dist/cjs/utils/hash-message.d.ts +0 -14
  93. package/dist/cjs/utils/hash-message.js +0 -30
  94. package/dist/cjs/utils/is-address.d.ts +0 -24
  95. package/dist/cjs/utils/is-address.js +0 -39
  96. package/dist/cjs/utils/keccak256.d.ts +0 -16
  97. package/dist/cjs/utils/keccak256.js +0 -31
  98. package/dist/cjs/utils/solidity-keccak256.d.ts +0 -39
  99. package/dist/cjs/utils/solidity-keccak256.js +0 -138
  100. package/dist/cjs/utils/split-signature.d.ts +0 -24
  101. package/dist/cjs/utils/split-signature.js +0 -163
  102. package/dist/cjs/utils/to-checksum-address.d.ts +0 -17
  103. package/dist/cjs/utils/to-checksum-address.js +0 -46
  104. package/dist/cjs/utils/to-utf8-bytes.d.ts +0 -15
  105. package/dist/cjs/utils/to-utf8-bytes.js +0 -21
  106. package/dist/cjs/utils/wei-to-ether.d.ts +0 -27
  107. package/dist/cjs/utils/wei-to-ether.js +0 -45
  108. package/dist/esm/classes/Contract.d.ts +0 -11
  109. package/dist/esm/classes/Contract.js +0 -58
  110. package/dist/esm/classes/test/Contract/crv-abi.d.ts +0 -2
  111. package/dist/esm/classes/test/Contract/crv-abi.js +0 -395
  112. package/dist/esm/classes/test/Contract/ens-abi.d.ts +0 -2
  113. package/dist/esm/classes/test/Contract/ens-abi.js +0 -435
  114. package/dist/esm/classes/test/Contract/fei-abi.d.ts +0 -2
  115. package/dist/esm/classes/test/Contract/fei-abi.js +0 -521
  116. package/dist/esm/classes/test/Contract/foo-abi.d.ts +0 -2
  117. package/dist/esm/classes/test/Contract/foo-abi.js +0 -33
  118. package/dist/esm/classes/test/Contract/jokerrace-abi.d.ts +0 -2
  119. package/dist/esm/classes/test/Contract/jokerrace-abi.js +0 -18
  120. package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
  121. package/dist/esm/classes/test/Contract/uniswap-abi.js +0 -116
  122. package/dist/esm/classes/utils/clean-block.d.ts +0 -2
  123. package/dist/esm/classes/utils/clean-block.js +0 -35
  124. package/dist/esm/classes/utils/clean-log.d.ts +0 -2
  125. package/dist/esm/classes/utils/clean-log.js +0 -28
  126. package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +0 -2
  127. package/dist/esm/classes/utils/clean-transaction-receipt.js +0 -37
  128. package/dist/esm/classes/utils/clean-transaction.d.ts +0 -2
  129. package/dist/esm/classes/utils/clean-transaction.js +0 -36
  130. package/dist/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
  131. package/dist/esm/classes/utils/encode-decode-transaction.js +0 -143
  132. package/dist/esm/classes/utils/fetchers.d.ts +0 -15
  133. package/dist/esm/classes/utils/fetchers.js +0 -37
  134. package/dist/esm/classes/utils/hex-to-decimal.d.ts +0 -1
  135. package/dist/esm/classes/utils/hex-to-decimal.js +0 -3
  136. package/dist/esm/classes/utils/prepare-transaction.d.ts +0 -2
  137. package/dist/esm/classes/utils/prepare-transaction.js +0 -36
  138. package/dist/esm/index.d.ts +0 -24
  139. package/dist/esm/index.js +0 -19
  140. package/dist/esm/logger/logger.d.ts +0 -11
  141. package/dist/esm/logger/logger.js +0 -34
  142. package/dist/esm/logger/package-version.d.ts +0 -1
  143. package/dist/esm/logger/package-version.js +0 -1
  144. package/dist/esm/providers/AlchemyProvider.d.ts +0 -4
  145. package/dist/esm/providers/AlchemyProvider.js +0 -7
  146. package/dist/esm/providers/BaseProvider.d.ts +0 -26
  147. package/dist/esm/providers/BaseProvider.js +0 -137
  148. package/dist/esm/providers/FallthroughProvider.d.ts +0 -11
  149. package/dist/esm/providers/FallthroughProvider.js +0 -50
  150. package/dist/esm/providers/JsonRpcProvider.d.ts +0 -7
  151. package/dist/esm/providers/JsonRpcProvider.js +0 -15
  152. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
  153. package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +0 -142
  154. package/dist/esm/providers/test/mock-of.d.ts +0 -1
  155. package/dist/esm/providers/test/mock-of.js +0 -1
  156. package/dist/esm/providers/test/rpc-urls.d.ts +0 -12
  157. package/dist/esm/providers/test/rpc-urls.js +0 -21
  158. package/dist/esm/providers/utils/chains-info.d.ts +0 -24
  159. package/dist/esm/providers/utils/chains-info.js +0 -67
  160. package/dist/esm/shared/tiny-big/helpers.d.ts +0 -1
  161. package/dist/esm/shared/tiny-big/helpers.js +0 -58
  162. package/dist/esm/shared/tiny-big/tiny-big.d.ts +0 -10
  163. package/dist/esm/shared/tiny-big/tiny-big.js +0 -45
  164. package/dist/esm/shared/validate-type.d.ts +0 -3
  165. package/dist/esm/shared/validate-type.js +0 -5
  166. package/dist/esm/types/Block.types.d.ts +0 -40
  167. package/dist/esm/types/Block.types.js +0 -1
  168. package/dist/esm/types/Contract.types.d.ts +0 -24
  169. package/dist/esm/types/Contract.types.js +0 -1
  170. package/dist/esm/types/FeeData.types.d.ts +0 -7
  171. package/dist/esm/types/FeeData.types.js +0 -1
  172. package/dist/esm/types/Filter.types.d.ts +0 -12
  173. package/dist/esm/types/Filter.types.js +0 -1
  174. package/dist/esm/types/Network.types.d.ts +0 -5
  175. package/dist/esm/types/Network.types.js +0 -1
  176. package/dist/esm/types/Transaction.types.d.ts +0 -113
  177. package/dist/esm/types/Transaction.types.js +0 -1
  178. package/dist/esm/utils/bytes.d.ts +0 -40
  179. package/dist/esm/utils/bytes.js +0 -245
  180. package/dist/esm/utils/compute-address.d.ts +0 -1
  181. package/dist/esm/utils/compute-address.js +0 -12
  182. package/dist/esm/utils/compute-public-key.d.ts +0 -2
  183. package/dist/esm/utils/compute-public-key.js +0 -6
  184. package/dist/esm/utils/ether-to-gwei.d.ts +0 -3
  185. package/dist/esm/utils/ether-to-gwei.js +0 -7
  186. package/dist/esm/utils/ether-to-wei.d.ts +0 -3
  187. package/dist/esm/utils/ether-to-wei.js +0 -7
  188. package/dist/esm/utils/gwei-to-ether.d.ts +0 -3
  189. package/dist/esm/utils/gwei-to-ether.js +0 -7
  190. package/dist/esm/utils/hash-message.d.ts +0 -2
  191. package/dist/esm/utils/hash-message.js +0 -14
  192. package/dist/esm/utils/is-address.d.ts +0 -1
  193. package/dist/esm/utils/is-address.js +0 -12
  194. package/dist/esm/utils/keccak256.d.ts +0 -2
  195. package/dist/esm/utils/keccak256.js +0 -13
  196. package/dist/esm/utils/solidity-keccak256.d.ts +0 -2
  197. package/dist/esm/utils/solidity-keccak256.js +0 -85
  198. package/dist/esm/utils/split-signature.d.ts +0 -2
  199. package/dist/esm/utils/split-signature.js +0 -126
  200. package/dist/esm/utils/to-checksum-address.d.ts +0 -1
  201. package/dist/esm/utils/to-checksum-address.js +0 -25
  202. package/dist/esm/utils/to-utf8-bytes.d.ts +0 -1
  203. package/dist/esm/utils/to-utf8-bytes.js +0 -3
  204. package/dist/esm/utils/wei-to-ether.d.ts +0 -3
  205. package/dist/esm/utils/wei-to-ether.js +0 -16
package/dist/index.js ADDED
@@ -0,0 +1,1952 @@
1
+ // src/classes/utils/encode-decode-transaction.ts
2
+ import { Keccak as Keccak2 } from "sha3";
3
+
4
+ // src/shared/tiny-big/tiny-big.ts
5
+ import Big from "big.js";
6
+
7
+ // src/classes/utils/hex-to-decimal.ts
8
+ function hexToDecimal(hex) {
9
+ return BigInt(hex).toString();
10
+ }
11
+
12
+ // src/shared/tiny-big/helpers.ts
13
+ function stripTrailingZeroes(numberString) {
14
+ const isNegative = numberString.startsWith("-");
15
+ numberString = numberString.replace("-", "");
16
+ numberString = numberString.replace(
17
+ /\.0*$/g,
18
+ ""
19
+ );
20
+ numberString = numberString.replace(/^0+/, "");
21
+ if (numberString.includes(".")) {
22
+ numberString = numberString.replace(/0+$/, "");
23
+ }
24
+ if (numberString.startsWith(".")) {
25
+ numberString = `0${numberString}`;
26
+ }
27
+ return `${isNegative ? "-" : ""}${numberString}`;
28
+ }
29
+ function scientificStrToDecimalStr(scientificString) {
30
+ if (!scientificString.match(
31
+ /e/i
32
+ /* lowercase and uppercase E */
33
+ )) {
34
+ return stripTrailingZeroes(scientificString);
35
+ }
36
+ let [base, power] = scientificString.split(
37
+ /e/i
38
+ );
39
+ const isNegative = Number(base) < 0;
40
+ base = base.replace("-", "");
41
+ base = stripTrailingZeroes(base);
42
+ const [wholeNumber, fraction = ""] = base.split(".");
43
+ if (Number(power) === 0) {
44
+ return `${isNegative ? "-" : ""}${stripTrailingZeroes(base)}`;
45
+ } else {
46
+ const includesDecimal = base.includes(".");
47
+ if (!includesDecimal) {
48
+ base = `${base}.`;
49
+ }
50
+ base = base.replace(".", "");
51
+ const baseLength = base.length;
52
+ let splitPaddedNumber;
53
+ if (Number(power) < 0) {
54
+ if (wholeNumber.length < Math.abs(Number(power))) {
55
+ base = base.padStart(
56
+ baseLength + Math.abs(Number(power)) - wholeNumber.length,
57
+ "0"
58
+ );
59
+ }
60
+ splitPaddedNumber = base.split("");
61
+ if (wholeNumber.length < Math.abs(Number(power))) {
62
+ splitPaddedNumber = [".", ...splitPaddedNumber];
63
+ } else {
64
+ splitPaddedNumber.splice(
65
+ splitPaddedNumber.length - Math.abs(Number(power)),
66
+ 0,
67
+ "."
68
+ );
69
+ }
70
+ } else {
71
+ if (fraction.length < Math.abs(Number(power))) {
72
+ base = base.padEnd(
73
+ baseLength + Math.abs(Number(power)) - fraction.length,
74
+ "0"
75
+ );
76
+ }
77
+ splitPaddedNumber = base.split("");
78
+ if (fraction.length > Math.abs(Number(power))) {
79
+ splitPaddedNumber.splice(
80
+ splitPaddedNumber.length - Math.abs(Number(power)),
81
+ 0,
82
+ "."
83
+ );
84
+ }
85
+ }
86
+ const toReturn = stripTrailingZeroes(splitPaddedNumber.join(""));
87
+ return `${isNegative ? "-" : ""}${toReturn}`;
88
+ }
89
+ }
90
+
91
+ // src/shared/tiny-big/tiny-big.ts
92
+ var TinyBig = class extends Big {
93
+ constructor(value) {
94
+ if (typeof value === "string" && value.startsWith("0x")) {
95
+ value = hexToDecimal(value);
96
+ }
97
+ super(value);
98
+ }
99
+ /**
100
+ * Used anytime you're passing in "value" to ethers or web3
101
+ * For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
102
+ *
103
+ * @returns the TinyBig represented as a hex string
104
+ * @example
105
+ * ```javascript
106
+ * tinyBig(293).toHexString();
107
+ * // '0x125'
108
+ * ```
109
+ * @example
110
+ * ```javascript
111
+ * tinyBig(681365874).toHexString();
112
+ * // '0x289cd172'
113
+ */
114
+ toHexString() {
115
+ return `0x${BigInt(this.toString()).toString(16)}`;
116
+ }
117
+ toNumber() {
118
+ return Number(scientificStrToDecimalStr(super.toString()));
119
+ }
120
+ toString() {
121
+ if (this.toNumber() === 0) {
122
+ return "0";
123
+ }
124
+ return scientificStrToDecimalStr(super.toString());
125
+ }
126
+ /**
127
+ * Eithers pads or shortens a string to a specified length
128
+ *
129
+ * @param str the string to pad or chop
130
+ * @param padChar the character to pad the string with
131
+ * @param length the desired length of the given string
132
+ * @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
133
+ * @example
134
+ * ```javascript
135
+ * padAndChop('essential-eth', 'a', 8);
136
+ * // 'tial-eth'
137
+ * ```
138
+ * @example
139
+ * ```javascript
140
+ * padAndChop('essential-eth', 'A', 20);
141
+ * // 'AAAAAAAessential-eth'
142
+ * ```
143
+ */
144
+ padAndChop = (str, padChar, length) => {
145
+ return (Array(length).fill(padChar).join("") + str).slice(length * -1);
146
+ };
147
+ toTwos(bitCount) {
148
+ let binaryStr;
149
+ if (this.gte(0)) {
150
+ const twosComp = this.toNumber().toString(2);
151
+ binaryStr = this.padAndChop(twosComp, "0", bitCount || twosComp.length);
152
+ } else {
153
+ binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
154
+ if (Number(binaryStr) < 0) {
155
+ throw new Error("Cannot calculate twos complement");
156
+ }
157
+ }
158
+ const binary = `0b${binaryStr}`;
159
+ const decimal = Number(binary);
160
+ return tinyBig(decimal);
161
+ }
162
+ };
163
+ function tinyBig(value) {
164
+ return new TinyBig(value);
165
+ }
166
+
167
+ // src/utils/to-checksum-address.ts
168
+ import { Keccak } from "sha3";
169
+
170
+ // src/shared/validate-type.ts
171
+ var validateType = (value, allowedTypes) => {
172
+ if (!allowedTypes.includes(typeof value)) {
173
+ throw new Error(
174
+ `${allowedTypes.join(" or ")} required. Received ${typeof value}`
175
+ );
176
+ }
177
+ };
178
+
179
+ // src/utils/to-checksum-address.ts
180
+ function toChecksumAddress(address) {
181
+ validateType(address, ["string"]);
182
+ if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
183
+ throw new Error(`Invalid Ethereum address "${address}"`);
184
+ }
185
+ const _address = address.toLowerCase().replace(/^0x/i, "");
186
+ const keccak = new Keccak(256);
187
+ const addressHash = keccak.update(_address).digest("hex").replace(/^0x/i, "");
188
+ let checksumAddress = "0x";
189
+ for (let i = 0; i < _address.length; i++) {
190
+ if (parseInt(addressHash[i], 16) > 7) {
191
+ checksumAddress += _address[i].toUpperCase();
192
+ } else {
193
+ checksumAddress += _address[i];
194
+ }
195
+ }
196
+ if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && checksumAddress !== address) {
197
+ throw new Error(`Invalid Checksum address for "${address}"`);
198
+ }
199
+ return checksumAddress;
200
+ }
201
+
202
+ // src/classes/utils/encode-decode-transaction.ts
203
+ var hexFalse = "0".repeat(64);
204
+ var hexTrue = "0".repeat(63) + "1";
205
+ function hexToUtf8(hex) {
206
+ let str = "";
207
+ let i = 0;
208
+ const l = hex.length;
209
+ if (hex.substring(0, 2) === "0x") {
210
+ i = 2;
211
+ }
212
+ for (; i < l; i += 2) {
213
+ const code = parseInt(hex.substr(i, 2), 16);
214
+ if (code === 0) continue;
215
+ str += String.fromCharCode(code);
216
+ }
217
+ try {
218
+ return decodeURIComponent(escape(str));
219
+ } catch (e) {
220
+ return str;
221
+ }
222
+ }
223
+ function expandType(type) {
224
+ if (type === "uint[]") {
225
+ return "uint256[]";
226
+ }
227
+ if (type === "int[]") {
228
+ return "int256[]";
229
+ }
230
+ return type;
231
+ }
232
+ function encodeData(jsonABIArgument, args) {
233
+ const hash = new Keccak2(256);
234
+ const functionString = `${jsonABIArgument.name}(${jsonABIArgument.inputs.map(
235
+ (input) => expandType(input.type)
236
+ )})`;
237
+ const functionHash = hash.update(functionString).digest("hex");
238
+ const jsonABIInputsLength = jsonABIArgument.inputs.length;
239
+ let shouldValidateInputLength = true;
240
+ if (jsonABIArgument.inputs.find((input) => input.type.includes("["))) {
241
+ shouldValidateInputLength = false;
242
+ }
243
+ if (shouldValidateInputLength && args.length !== jsonABIInputsLength) {
244
+ throw new Error(
245
+ `args inputs of "${args.length}" does not match expected length of "${jsonABIArgument.inputs.length}"`
246
+ );
247
+ }
248
+ const argsWithTypes = (jsonABIArgument.inputs || []).reduce(
249
+ (acc, input, i) => {
250
+ if (input.type.includes("[")) {
251
+ const basicType = /([^[]*)\[.*$/g.exec(input.type)?.[1];
252
+ args.forEach((arg) => {
253
+ acc = acc.concat([[arg, basicType]]);
254
+ });
255
+ return acc;
256
+ } else {
257
+ return acc.concat([[args[i], input.type]]);
258
+ }
259
+ },
260
+ []
261
+ );
262
+ const encodedArgs = argsWithTypes.map(([arg, inputType]) => {
263
+ let rawArg = arg;
264
+ switch (inputType) {
265
+ case "bool":
266
+ return arg ? hexTrue : hexFalse;
267
+ case "address":
268
+ rawArg = arg.replace(/^0x/g, "").toLowerCase();
269
+ break;
270
+ default:
271
+ if (inputType.startsWith("bytes")) {
272
+ if (Array.isArray(arg)) {
273
+ throw new Error(
274
+ `essential-eth does not yet support "${inputType}[]" inputs. Make a PR today!"`
275
+ );
276
+ }
277
+ const argEncoded2 = BigInt(arg).toString(16);
278
+ const paddedEncodedArg2 = argEncoded2.padStart(64, "0");
279
+ return paddedEncodedArg2;
280
+ } else if (inputType === "uint256") {
281
+ const argEncoded2 = BigInt(arg).toString(16);
282
+ const paddedEncodedArg2 = argEncoded2.padStart(64, "0");
283
+ return paddedEncodedArg2;
284
+ } else if (inputType.startsWith("uint")) {
285
+ break;
286
+ } else {
287
+ throw new Error(
288
+ `essential-eth does not yet support "${inputType}" inputs. Make a PR today!"`
289
+ );
290
+ }
291
+ }
292
+ const argEncoded = rawArg.toString(16);
293
+ const paddedEncodedArg = argEncoded.padStart(64, "0");
294
+ return paddedEncodedArg;
295
+ });
296
+ const functionEncoded = functionHash.slice(0, 8);
297
+ const data = `0x${functionEncoded}${encodedArgs.join("")}`;
298
+ return data;
299
+ }
300
+ function decodeRPCResponse(jsonABIArgument, nodeResponse) {
301
+ const rawOutputs = jsonABIArgument.outputs || [];
302
+ const slicedResponse = nodeResponse.slice(2);
303
+ if (rawOutputs.length === 1 && rawOutputs[0].type === "string") {
304
+ const [hexOffset, responseData] = [
305
+ slicedResponse.slice(0, 64),
306
+ slicedResponse.slice(64)
307
+ ];
308
+ const decimalOffset = Number(hexToDecimal(`0x${hexOffset}`));
309
+ const hexLength = responseData.slice(0, decimalOffset * 2);
310
+ const decimalLength = Number(hexToDecimal(`0x${hexLength}`));
311
+ const hexToDecode = responseData.slice(
312
+ decimalOffset * 2,
313
+ decimalOffset * 2 + decimalLength * 2
314
+ );
315
+ return hexToUtf8(hexToDecode);
316
+ }
317
+ const encodedOutputs = slicedResponse.match(/.{1,64}/g) || [];
318
+ if (rawOutputs.length === 1 && rawOutputs[0].type === "address[]") {
319
+ const unformattedAddresses = encodedOutputs.slice(2);
320
+ return unformattedAddresses.map((unformattedAddress) => {
321
+ return toChecksumAddress(`0x${unformattedAddress.slice(24)}`);
322
+ });
323
+ }
324
+ if (rawOutputs?.length === 1 && rawOutputs[0].type === "uint256[]") {
325
+ const outputs2 = encodedOutputs.slice(2);
326
+ return outputs2.map((output) => {
327
+ return tinyBig(hexToDecimal(`0x${output}`));
328
+ });
329
+ }
330
+ const outputs = encodedOutputs.map((output, i) => {
331
+ const outputType = rawOutputs[i].type;
332
+ switch (outputType) {
333
+ case "bool":
334
+ return output === hexTrue;
335
+ case "address":
336
+ return toChecksumAddress(`0x${output.slice(24)}`);
337
+ case "uint256":
338
+ case "uint120":
339
+ return tinyBig(hexToDecimal(`0x${output}`));
340
+ case "bytes32":
341
+ return `0x${output}`;
342
+ case "uint8":
343
+ return Number(hexToDecimal(`0x${output}`));
344
+ default:
345
+ throw new Error(
346
+ `essential-eth does not yet support "${outputType}" outputs. Make a PR today!"`
347
+ );
348
+ }
349
+ });
350
+ return outputs.length === 1 ? outputs[0] : outputs;
351
+ }
352
+
353
+ // src/classes/Contract.ts
354
+ function estimateGas(txnData) {
355
+ txnData.split("").reduce((previousValue, currentValue) => {
356
+ const characterCost = currentValue === "0" ? 4 : 68;
357
+ return previousValue + characterCost;
358
+ }, 0);
359
+ }
360
+ var BaseContract = class {
361
+ /**
362
+ * The URL to your Eth node. Consider POKT or Infura
363
+ */
364
+ _address;
365
+ _provider;
366
+ /**
367
+ * @param addressOrName The ethereum address of the smart-contract
368
+ * @param contractInterface The JSON ABI of the smart-contract (like http://api.etherscan.io/api?module=contract&action=getabi&address=0x090d4613473dee047c3f2706764f49e0821d256e&format=raw)
369
+ * @param signerOrProvider An instantiated essential-eth provider
370
+ * @example
371
+ */
372
+ constructor(addressOrName, contractInterface, signerOrProvider) {
373
+ this._address = addressOrName;
374
+ this._provider = signerOrProvider;
375
+ contractInterface.filter((jsonABIArgument) => jsonABIArgument.type === "function").forEach((jsonABIArgument) => {
376
+ if ("name" in jsonABIArgument && typeof jsonABIArgument.name === "string") {
377
+ defineReadOnly(
378
+ this,
379
+ jsonABIArgument.name,
380
+ async (..._args) => {
381
+ let functionArguments = _args;
382
+ let options = {};
383
+ const lastArg = _args[_args.length - 1];
384
+ if (!Array.isArray(lastArg) && typeof lastArg === "object") {
385
+ options = lastArg;
386
+ functionArguments = _args.slice(0, _args.length - 1);
387
+ }
388
+ const data = encodeData(jsonABIArgument, functionArguments);
389
+ const decimalGas = typeof options.gasLimit === "number" ? options.gasLimit : typeof jsonABIArgument?.gas === "number" ? estimateGas(data) : null;
390
+ const req = async () => {
391
+ return await this._provider.call(
392
+ {
393
+ to: this._address.toLowerCase(),
394
+ data,
395
+ // sometimes gas is defined in the ABI
396
+ ...decimalGas ? { gas: `0x${decimalGas.toString(16)}` } : {}
397
+ },
398
+ "latest"
399
+ );
400
+ };
401
+ const nodeResponse = await req();
402
+ return decodeRPCResponse(jsonABIArgument, nodeResponse);
403
+ }
404
+ );
405
+ }
406
+ });
407
+ }
408
+ };
409
+ function defineReadOnly(object, name, value) {
410
+ Object.defineProperty(object, name, {
411
+ enumerable: true,
412
+ value,
413
+ writable: false
414
+ });
415
+ }
416
+ var Contract = class extends BaseContract {
417
+ // readonly [key: string]: ContractFunction | any;
418
+ };
419
+
420
+ // src/classes/utils/clean-transaction.ts
421
+ function cleanTransaction(transaction) {
422
+ const cleanedTransaction = {
423
+ ...transaction
424
+ };
425
+ Object.keys(transaction).forEach((key) => {
426
+ if (!transaction[key]) return;
427
+ switch (key) {
428
+ case "blockNumber":
429
+ case "chainId":
430
+ case "transactionIndex":
431
+ case "type":
432
+ case "v":
433
+ cleanedTransaction[key] = Number(hexToDecimal(transaction[key]));
434
+ break;
435
+ case "from":
436
+ case "to":
437
+ if (transaction[key]) {
438
+ cleanedTransaction[key] = toChecksumAddress(transaction[key]);
439
+ }
440
+ break;
441
+ case "value":
442
+ case "gas":
443
+ case "gasPrice":
444
+ case "maxFeePerGas":
445
+ case "maxPriorityFeePerGas":
446
+ case "nonce":
447
+ cleanedTransaction[key] = tinyBig(hexToDecimal(transaction[key]));
448
+ break;
449
+ }
450
+ });
451
+ return cleanedTransaction;
452
+ }
453
+
454
+ // src/classes/utils/clean-block.ts
455
+ function cleanBlock(block, returnTransactionObjects) {
456
+ const cleanedBlock = { ...block };
457
+ Object.keys(block).forEach((key) => {
458
+ if (!block[key]) return;
459
+ switch (key) {
460
+ case "difficulty":
461
+ case "totalDifficulty":
462
+ case "gasLimit":
463
+ case "gasUsed":
464
+ case "size":
465
+ case "timestamp":
466
+ case "baseFeePerGas":
467
+ cleanedBlock[key] = tinyBig(hexToDecimal(block[key]));
468
+ break;
469
+ case "number":
470
+ cleanedBlock[key] = Number(hexToDecimal(block[key]));
471
+ break;
472
+ case "miner":
473
+ cleanedBlock[key] = toChecksumAddress(block[key]);
474
+ break;
475
+ }
476
+ });
477
+ if (returnTransactionObjects) {
478
+ const txns = block.transactions;
479
+ txns.forEach((transaction, index) => {
480
+ cleanedBlock.transactions[index] = cleanTransaction(transaction);
481
+ });
482
+ }
483
+ return cleanedBlock;
484
+ }
485
+
486
+ // src/classes/utils/clean-log.ts
487
+ function cleanLog(log, receiptLog) {
488
+ const cleanedLog = {
489
+ ...log
490
+ };
491
+ Object.keys(log).forEach((key) => {
492
+ switch (key) {
493
+ case "address":
494
+ cleanedLog[key] = toChecksumAddress(log[key]);
495
+ break;
496
+ case "blockNumber":
497
+ case "logIndex":
498
+ case "transactionIndex":
499
+ cleanedLog[key] = Number(hexToDecimal(log[key]));
500
+ break;
501
+ case "removed":
502
+ if (receiptLog) {
503
+ delete cleanedLog[key];
504
+ } else if (log[key] == null) {
505
+ cleanedLog[key] === false;
506
+ }
507
+ break;
508
+ }
509
+ });
510
+ return cleanedLog;
511
+ }
512
+
513
+ // src/classes/utils/clean-transaction-receipt.ts
514
+ function cleanTransactionReceipt(transactionReceipt) {
515
+ const cleanedTransaction = cleanTransaction(transactionReceipt);
516
+ const cleanedTransactionReceipt = {
517
+ ...cleanedTransaction
518
+ };
519
+ Object.keys(transactionReceipt).forEach((key) => {
520
+ if (!transactionReceipt[key]) return;
521
+ switch (key) {
522
+ case "status":
523
+ cleanedTransactionReceipt[key] = Number(
524
+ hexToDecimal(transactionReceipt[key])
525
+ );
526
+ break;
527
+ case "contractAddress":
528
+ if (transactionReceipt[key]) {
529
+ cleanedTransactionReceipt[key] = toChecksumAddress(
530
+ transactionReceipt[key]
531
+ );
532
+ }
533
+ break;
534
+ case "cumulativeGasUsed":
535
+ case "effectiveGasPrice":
536
+ case "gasUsed":
537
+ cleanedTransactionReceipt[key] = tinyBig(
538
+ hexToDecimal(transactionReceipt[key])
539
+ );
540
+ break;
541
+ case "logs":
542
+ transactionReceipt[key].forEach((log, index) => {
543
+ cleanedTransactionReceipt[key][index] = cleanLog(log, true);
544
+ });
545
+ }
546
+ });
547
+ cleanedTransactionReceipt.byzantium = cleanedTransactionReceipt.blockNumber >= 437e4;
548
+ return cleanedTransactionReceipt;
549
+ }
550
+
551
+ // src/classes/utils/fetchers.ts
552
+ import unfetch from "isomorphic-unfetch";
553
+ function buildFetchInit(body) {
554
+ return {
555
+ method: "POST",
556
+ headers: {
557
+ "Content-Type": "application/json"
558
+ },
559
+ body: JSON.stringify(body)
560
+ };
561
+ }
562
+ function post(url, body) {
563
+ return unfetch(url, buildFetchInit(body)).then(async (r) => {
564
+ const t = await r.text();
565
+ try {
566
+ return JSON.parse(t);
567
+ } catch {
568
+ throw new Error(`Invalid JSON RPC response: "${t}"`);
569
+ }
570
+ }).then((response) => {
571
+ const result = response?.result;
572
+ if (!result) {
573
+ throw new Error(
574
+ `Invalid JSON RPC response: ${JSON.stringify(response)}`
575
+ );
576
+ }
577
+ return response.result;
578
+ });
579
+ }
580
+ function buildRPCPostBody(method, params) {
581
+ return {
582
+ jsonrpc: "2.0",
583
+ // TODO: Increment ID will be needed when websocket support is added
584
+ id: 1,
585
+ method,
586
+ params
587
+ };
588
+ }
589
+
590
+ // src/classes/utils/prepare-transaction.ts
591
+ import Big2 from "big.js";
592
+
593
+ // src/logger/package-version.ts
594
+ var version = "0.11.1";
595
+
596
+ // src/logger/logger.ts
597
+ var Logger = class {
598
+ packageVersion;
599
+ constructor() {
600
+ this.packageVersion = version;
601
+ }
602
+ throwError(message, args) {
603
+ const argsLength = Object.keys(args).length;
604
+ throw new Error(
605
+ `${message} (${Object.entries(args).map(
606
+ ([key, value], index) => `${key}=${value}${index < argsLength - 1 && ", "}`
607
+ )}, version=essential-eth@${this.packageVersion})`
608
+ );
609
+ }
610
+ throwArgumentError(message, arg, value) {
611
+ throw new Error(
612
+ `${message} (argument="${arg}" value=${value}, version=essential-eth@${this.packageVersion})`
613
+ );
614
+ }
615
+ checkSafeUint53(value, message = "value not safe") {
616
+ if (typeof value !== "number") {
617
+ return;
618
+ }
619
+ if (value < 0 || value >= 9007199254740991) {
620
+ this.throwError(message, {
621
+ operation: "checkSafeInteger",
622
+ fault: "out-of-safe-range",
623
+ value
624
+ });
625
+ }
626
+ if (value % 1) {
627
+ this.throwError(message, {
628
+ operation: "checkSafeInteger",
629
+ fault: "non-integer",
630
+ value
631
+ });
632
+ }
633
+ }
634
+ };
635
+ var logger = new Logger();
636
+
637
+ // src/utils/bytes.ts
638
+ function isHexable(value) {
639
+ return !!value.toHexString;
640
+ }
641
+ function isBytesLike(value) {
642
+ return isHexString(value) && !(value.length % 2) || isBytes(value);
643
+ }
644
+ function isInteger(value) {
645
+ return typeof value === "number" && value == value && value % 1 === 0;
646
+ }
647
+ function isBytes(value) {
648
+ if (value == null) {
649
+ return false;
650
+ }
651
+ if (value.constructor === Uint8Array) {
652
+ return true;
653
+ }
654
+ if (typeof value === "string") {
655
+ return false;
656
+ }
657
+ if (!isInteger(value.length) || value.length < 0) {
658
+ return false;
659
+ }
660
+ for (let i = 0; i < value.length; i++) {
661
+ const v = value[i];
662
+ if (!isInteger(v) || v < 0 || v >= 256) {
663
+ return false;
664
+ }
665
+ }
666
+ return true;
667
+ }
668
+ function arrayify(value, options) {
669
+ if (!options) {
670
+ options = {};
671
+ }
672
+ if (typeof value === "number") {
673
+ logger.checkSafeUint53(value, "invalid arrayify value");
674
+ const result = [];
675
+ while (value) {
676
+ result.unshift(value & 255);
677
+ value = parseInt(String(value / 256));
678
+ }
679
+ if (result.length === 0) {
680
+ result.push(0);
681
+ }
682
+ return new Uint8Array(result);
683
+ }
684
+ if (options.allowMissingPrefix && typeof value === "string" && value.substring(0, 2) !== "0x") {
685
+ value = "0x" + value;
686
+ }
687
+ if (isHexable(value)) {
688
+ value = value.toHexString();
689
+ }
690
+ if (isHexString(value)) {
691
+ let hex = value.substring(2);
692
+ if (hex.length % 2) {
693
+ if (options.hexPad === "left") {
694
+ hex = "0" + hex;
695
+ } else if (options.hexPad === "right") {
696
+ hex += "0";
697
+ } else {
698
+ logger.throwArgumentError("hex data is odd-length", "value", value);
699
+ }
700
+ }
701
+ const result = [];
702
+ for (let i = 0; i < hex.length; i += 2) {
703
+ result.push(parseInt(hex.substring(i, i + 2), 16));
704
+ }
705
+ return new Uint8Array(result);
706
+ }
707
+ if (isBytes(value)) {
708
+ return new Uint8Array(value);
709
+ }
710
+ return logger.throwArgumentError("invalid arrayify value", "value", value);
711
+ }
712
+ function concat(arrayOfBytesLike) {
713
+ const objects = arrayOfBytesLike.map((item) => arrayify(item));
714
+ const length = objects.reduce((accum, item) => accum + item.length, 0);
715
+ const result = new Uint8Array(length);
716
+ objects.reduce((offset, object) => {
717
+ result.set(object, offset);
718
+ return offset + object.length;
719
+ }, 0);
720
+ return result;
721
+ }
722
+ function stripZeros(value) {
723
+ let result = arrayify(value);
724
+ if (result.length === 0) {
725
+ return result;
726
+ }
727
+ let start = 0;
728
+ while (start < result.length && result[start] === 0) {
729
+ start++;
730
+ }
731
+ if (start) {
732
+ result = result.slice(start);
733
+ }
734
+ return result;
735
+ }
736
+ function zeroPad(value, length) {
737
+ value = arrayify(value);
738
+ if (value.length > length) {
739
+ logger.throwArgumentError("value out of range", "value", value);
740
+ }
741
+ const result = new Uint8Array(length);
742
+ result.set(value, length - value.length);
743
+ return result;
744
+ }
745
+ function isHexString(value, length) {
746
+ if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
747
+ return false;
748
+ }
749
+ if (length && value.length !== 2 + 2 * length) {
750
+ return false;
751
+ }
752
+ return true;
753
+ }
754
+ var HexCharacters = "0123456789abcdef";
755
+ function hexlify(value, options) {
756
+ if (!options) {
757
+ options = {};
758
+ }
759
+ if (typeof value === "number") {
760
+ logger.checkSafeUint53(value, "invalid hexlify value");
761
+ let hex = "";
762
+ while (value) {
763
+ hex = HexCharacters[value & 15] + hex;
764
+ value = Math.floor(value / 16);
765
+ }
766
+ if (hex.length) {
767
+ if (hex.length % 2) {
768
+ hex = "0" + hex;
769
+ }
770
+ return "0x" + hex;
771
+ }
772
+ return "0x00";
773
+ }
774
+ if (typeof value === "bigint") {
775
+ value = value.toString(16);
776
+ if (value.length % 2) {
777
+ return "0x0" + value;
778
+ }
779
+ return "0x" + value;
780
+ }
781
+ if (options.allowMissingPrefix && typeof value === "string" && value.substring(0, 2) !== "0x") {
782
+ value = "0x" + value;
783
+ }
784
+ if (isHexable(value)) {
785
+ return value.toHexString();
786
+ }
787
+ if (isHexString(value)) {
788
+ if (value.length % 2) {
789
+ if (options.hexPad === "left") {
790
+ value = "0x0" + value.substring(2);
791
+ } else if (options.hexPad === "right") {
792
+ value += "0";
793
+ } else {
794
+ logger.throwArgumentError("hex data is odd-length", "value", value);
795
+ }
796
+ }
797
+ return value.toLowerCase();
798
+ }
799
+ if (isBytes(value)) {
800
+ let result = "0x";
801
+ for (let i = 0; i < value.length; i++) {
802
+ const v = value[i];
803
+ result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15];
804
+ }
805
+ return result;
806
+ }
807
+ return logger.throwArgumentError("invalid hexlify value", "value", value);
808
+ }
809
+ function hexDataLength(data) {
810
+ if (typeof data !== "string") {
811
+ data = hexlify(data);
812
+ } else if (!isHexString(data) || data.length % 2) {
813
+ return null;
814
+ }
815
+ return (data.length - 2) / 2;
816
+ }
817
+ function hexDataSlice(data, offset, endOffset) {
818
+ if (typeof data !== "string") {
819
+ data = hexlify(data);
820
+ } else if (!isHexString(data) || data.length % 2) {
821
+ logger.throwArgumentError("invalid hexData", "value", data);
822
+ }
823
+ offset = 2 + 2 * offset;
824
+ if (endOffset != null) {
825
+ return "0x" + data.substring(offset, 2 + 2 * endOffset);
826
+ }
827
+ return "0x" + data.substring(offset);
828
+ }
829
+ function hexConcat(items) {
830
+ let result = "0x";
831
+ items.forEach((item) => {
832
+ result += hexlify(item).substring(2);
833
+ });
834
+ return result;
835
+ }
836
+ function hexValue(value) {
837
+ const trimmed = hexStripZeros(hexlify(value, { hexPad: "left" }));
838
+ if (trimmed === "0x") {
839
+ return "0x0";
840
+ }
841
+ return trimmed;
842
+ }
843
+ function hexStripZeros(value) {
844
+ if (typeof value !== "string") {
845
+ value = hexlify(value);
846
+ }
847
+ if (!isHexString(value)) {
848
+ logger.throwArgumentError("invalid hex string", "value", value);
849
+ }
850
+ value = value.substring(2);
851
+ let offset = 0;
852
+ while (offset < value.length && value[offset] === "0") {
853
+ offset++;
854
+ }
855
+ return "0x" + value.substring(offset);
856
+ }
857
+ function hexZeroPad(value, length) {
858
+ if (typeof value !== "string") {
859
+ value = hexlify(value);
860
+ } else if (!isHexString(value)) {
861
+ logger.throwArgumentError("invalid hex string", "value", value);
862
+ }
863
+ if (value.length > 2 * length + 2) {
864
+ logger.throwError("value out of range", { value, length });
865
+ }
866
+ while (value.length < 2 * length + 2) {
867
+ value = "0x0" + value.substring(2);
868
+ }
869
+ return value;
870
+ }
871
+
872
+ // src/classes/utils/prepare-transaction.ts
873
+ function prepareTransaction(transaction) {
874
+ const preparedTransaction = {
875
+ ...transaction
876
+ };
877
+ Object.keys(transaction).forEach(
878
+ (key) => {
879
+ switch (key) {
880
+ case "gas":
881
+ case "gasPrice":
882
+ case "nonce":
883
+ case "maxFeePerGas":
884
+ case "maxPriorityFeePerGas":
885
+ case "value": {
886
+ const value = transaction[key];
887
+ if (value instanceof TinyBig) {
888
+ preparedTransaction[key] = value.toHexString();
889
+ } else if (value instanceof Big2) {
890
+ preparedTransaction[key] = `0x${BigInt(value.toString()).toString(
891
+ 16
892
+ )}`;
893
+ } else if (typeof transaction[key] === "number")
894
+ preparedTransaction[key] = "0x" + transaction[key].toString(16);
895
+ else preparedTransaction[key] = transaction[key].toString();
896
+ break;
897
+ }
898
+ case "data":
899
+ preparedTransaction[key] = hexlify(transaction[key]);
900
+ break;
901
+ }
902
+ }
903
+ );
904
+ return preparedTransaction;
905
+ }
906
+
907
+ // src/providers/utils/chains-info.ts
908
+ var chains_info_default = {
909
+ "1": [
910
+ "eth",
911
+ "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
912
+ ],
913
+ "5": [
914
+ "gor",
915
+ "0x112234455c3a32fd11230c42e7bccd4a84e02010"
916
+ ],
917
+ "10": [
918
+ "oeth"
919
+ ],
920
+ "50": [
921
+ "xdc"
922
+ ],
923
+ "56": [
924
+ "bnb"
925
+ ],
926
+ "100": [
927
+ "gno"
928
+ ],
929
+ "137": [
930
+ "pol"
931
+ ],
932
+ "250": [
933
+ "ftm"
934
+ ],
935
+ "324": [
936
+ "zksync"
937
+ ],
938
+ "1101": [
939
+ "zkevm"
940
+ ],
941
+ "1337": [
942
+ "geth"
943
+ ],
944
+ "7700": [
945
+ "canto"
946
+ ],
947
+ "9001": [
948
+ "evmos"
949
+ ],
950
+ "42161": [
951
+ "arb1"
952
+ ],
953
+ "42220": [
954
+ "celo"
955
+ ],
956
+ "43114": [
957
+ "avax"
958
+ ],
959
+ "59140": [
960
+ "linea-goerli"
961
+ ],
962
+ "80001": [
963
+ "maticmum"
964
+ ],
965
+ "421613": [
966
+ "arb-goerli"
967
+ ],
968
+ "534352": [
969
+ "scr"
970
+ ],
971
+ "11155111": [
972
+ "sep"
973
+ ]
974
+ };
975
+
976
+ // src/providers/BaseProvider.ts
977
+ function prepBlockTag(blockTag) {
978
+ return typeof blockTag === "number" ? tinyBig(blockTag).toHexString() : blockTag;
979
+ }
980
+ var BaseProvider = class {
981
+ /**
982
+ * @ignore
983
+ */
984
+ _rpcUrls = [];
985
+ /**
986
+ * @ignore
987
+ */
988
+ _post = (body) => post(this.selectRpcUrl(), body);
989
+ /**
990
+ * @param rpcUrls The URL(s) to your Eth node(s). Consider POKT or Infura
991
+ * @example
992
+ * `https://free-eth-node.com/api/eth`
993
+ * @example
994
+ * `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
995
+ */
996
+ constructor(rpcUrls) {
997
+ this._rpcUrls = rpcUrls;
998
+ }
999
+ /**
1000
+ * Gets information (name, chainId, and ensAddress when applicable) about the network the provider is connected to.
1001
+ *
1002
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getNetwork`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getNetwork) in ethers.js
1003
+ * * [Similar](/docs/api#isd) to [`web3.eth.getChainId`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getchainid) in web3.js, returns more than just the `chainId`
1004
+ *
1005
+ * @returns information about the network this provider is currently connected to
1006
+ * @example
1007
+ * ```javascript
1008
+ * jsonRpcProvider('https://free-eth-node.com/api/eth').getNetwork();
1009
+ * // { chainId: 1, name: 'eth', ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' }
1010
+ * ```
1011
+ * @example
1012
+ * ```javascript
1013
+ * jsonRpcProvider('https://free-eth-node.com/api/MATIC').getNetwork();
1014
+ * // { chainId: 137, name: 'MATIC', ensAddress: null }
1015
+ * ```
1016
+ */
1017
+ async getNetwork() {
1018
+ const hexChainId = await this.post(
1019
+ buildRPCPostBody("eth_chainId", [])
1020
+ );
1021
+ const chainId = hexToDecimal(hexChainId);
1022
+ const info = chains_info_default[chainId];
1023
+ return {
1024
+ chainId: Number(chainId),
1025
+ name: info[0] || "unknown",
1026
+ ensAddress: info[1] || null
1027
+ // only send ensAddress if it exists
1028
+ };
1029
+ }
1030
+ /**
1031
+ * Gets the number of the most recently mined block on the network the provider is connected to.
1032
+ *
1033
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getBlockNumber`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBlockNumber) in ethers.js
1034
+ * * [Identical](/docs/api#isd) to [`web3.eth.getBlockNumber`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getblocknumber) in web3.js
1035
+ *
1036
+ * @returns the number of the most recently mined block
1037
+ * @example
1038
+ * ```javascript
1039
+ * await provider.getBlockNumber();
1040
+ * // 1053312
1041
+ * ```
1042
+ */
1043
+ async getBlockNumber() {
1044
+ const currentBlockNumber = await this.post(
1045
+ buildRPCPostBody("eth_blockNumber", [])
1046
+ );
1047
+ return Number(hexToDecimal(currentBlockNumber));
1048
+ }
1049
+ /**
1050
+ * Gets information about a specified transaction, even if it hasn't been mined yet.
1051
+ *
1052
+ * * [Similar](/docs/api#isd) to [`ethers.provider.getTransaction`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransaction) in ethers.js, does not have `wait` method that waits until the transaction has been mined
1053
+ * * [Similar](/docs/api#isd) to [`web3.eth.getTransaction`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#gettransaction) in web3.js, some information returned using different types
1054
+ *
1055
+ * @param transactionHash the hash of the transaction to get information about
1056
+ * @returns information about the specified transaction
1057
+ * @example
1058
+ * ```javascript
1059
+ * await provider.getTransaction('0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789');
1060
+ * // {
1061
+ * // accessList: [],
1062
+ * // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1063
+ * // blockNumber: 14578286,
1064
+ * // chainId: 1,
1065
+ * // from: "0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4",
1066
+ * // gas: { TinyBig: 112163 },
1067
+ * // gasPrice: { TinyBig: 48592426858 },
1068
+ * // hash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1069
+ * // input: "0x83259f17000000000000000000000000000000000000000000...",
1070
+ * // maxFeePerGas: { TinyBig: 67681261618 },
1071
+ * // maxPriorityFeePerGas: { TinyBig: 1500000000 },
1072
+ * // nonce: { TinyBig: 129 },
1073
+ * // r: "0x59a7c15b12c18cd68d6c440963d959bff3e73831ffc938e75ecad07f7ee43fbc",
1074
+ * // s: "0x1ebaf05f0d9273b16c2a7748b150a79d22533a8cd74552611cbe620fee3dcf1c",
1075
+ * // to: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1076
+ * // transactionIndex: 29,
1077
+ * // type: 2,
1078
+ * // v: 0,
1079
+ * // value: { TinyBig: 0 },
1080
+ * // confirmations: 298140,
1081
+ * // }
1082
+ * ```
1083
+ */
1084
+ async getTransaction(transactionHash) {
1085
+ const [rpcTransaction, blockNumber] = await Promise.all([
1086
+ this.post(
1087
+ buildRPCPostBody("eth_getTransactionByHash", [transactionHash])
1088
+ ),
1089
+ this.getBlock("latest")
1090
+ ]);
1091
+ const cleanedTransaction = cleanTransaction(rpcTransaction);
1092
+ cleanedTransaction.confirmations = blockNumber.number - cleanedTransaction.blockNumber + 1;
1093
+ return cleanedTransaction;
1094
+ }
1095
+ /**
1096
+ * Gives information about a transaction that has already been mined. Includes additional information beyond what's provided by [`getTransaction`](/docs/api/modules#gettransaction).
1097
+ *
1098
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getTransactionReceipt`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionReceipt) in ethers.js
1099
+ * * [Similar](/docs/api#isd) to [`web3.eth.getTransactionReceipt`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#gettransactionreceipt) in web3.js, some information returned using different types
1100
+ *
1101
+ * @param transactionHash the hash of the transaction to get information about
1102
+ * @returns information about the specified transaction that has already been mined
1103
+ * @example
1104
+ * ```javascript
1105
+ * await provider.getTransactionReceipt('0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789');
1106
+ * // {
1107
+ * // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1108
+ * // blockNumber: 14578286,
1109
+ * // contractAddress: null,
1110
+ * // cumulativeGasUsed: { TinyBig: 3067973 },
1111
+ * // effectiveGasPrice: { TinyBig: 48592426858 },
1112
+ * // from: "0xdfD9dE5f6FA60BD70636c0900752E93a6144AEd4",
1113
+ * // gasUsed: { TinyBig: 112163 },
1114
+ * // logs: [
1115
+ * // {
1116
+ * // address: "0x0eDF9bc41Bbc1354c70e2107F80C42caE7FBBcA8",
1117
+ * // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1118
+ * // blockNumber: 14578286,
1119
+ * // data: "0x0000000000000000000000000000000000000000000003a12ec797b5484968c1",
1120
+ * // logIndex: 42,
1121
+ * // topics: [
1122
+ * // "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
1123
+ * // "0x00000000000000000000000039b72d136ba3e4cef35f48cd09587ffab754dd8b",
1124
+ * // "0x000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed4",
1125
+ * // ],
1126
+ * // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1127
+ * // transactionIndex: 29,
1128
+ * // },
1129
+ * // {
1130
+ * // address: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1131
+ * // blockHash: "0x876810a013dbcd140f6fd6048c1dc33abbb901f1f96b394c2fa63aef3cb40b5d",
1132
+ * // blockNumber: 14578286,
1133
+ * // data: "0x0000000000000000000000000000000000000000000003a12ec797b5484968c1",
1134
+ * // logIndex: 43,
1135
+ * // topics: [
1136
+ * // "0x34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf7",
1137
+ * // "0x000000000000000000000000dfd9de5f6fa60bd70636c0900752e93a6144aed4",
1138
+ * // "0x0000000000000000000000000000000000000000000000000000000000000003",
1139
+ * // ],
1140
+ * // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1141
+ * // transactionIndex: 29,
1142
+ * // },
1143
+ * // ],
1144
+ * // logsBloom: "0x00000000000000000000000000000...",
1145
+ * // status: 1,
1146
+ * // to: "0x39B72d136ba3e4ceF35F48CD09587ffaB754DD8B",
1147
+ * // transactionHash: "0x9014ae6ef92464338355a79e5150e542ff9a83e2323318b21f40d6a3e65b4789",
1148
+ * // transactionIndex: 29,
1149
+ * // type: 2,
1150
+ * // byzantium: true,
1151
+ * // confirmations: 298171,
1152
+ * // }
1153
+ * ```
1154
+ */
1155
+ async getTransactionReceipt(transactionHash) {
1156
+ const [rpcTransaction, blockNumber] = await Promise.all([
1157
+ this.post(
1158
+ buildRPCPostBody("eth_getTransactionReceipt", [transactionHash])
1159
+ ),
1160
+ this.getBlock("latest")
1161
+ ]);
1162
+ const cleanedTransactionReceipt = cleanTransactionReceipt(rpcTransaction);
1163
+ cleanedTransactionReceipt.confirmations = blockNumber.number - cleanedTransactionReceipt.blockNumber + 1;
1164
+ return cleanedTransactionReceipt;
1165
+ }
1166
+ /**
1167
+ * Returns the number of sent transactions by an address, from genesis (or as far back as a provider looks) up to specified block.
1168
+ *
1169
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getTransactionCount`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getTransactionCount) in ethers.js
1170
+ * * [Identical](/docs/api#isd) to [`web3.eth.getTransactionCount`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#gettransactioncount) in web3.js
1171
+ *
1172
+ * @param address the address to count number of sent transactions
1173
+ * @param blockTag the block to count transactions up to, inclusive
1174
+ * @returns the number of transactions sent by the specified address
1175
+ * @example
1176
+ * ```javascript
1177
+ * await provider.getTransactionCount('0x71660c4005ba85c37ccec55d0c4493e66fe775d3');
1178
+ * // 1060000
1179
+ * ```
1180
+ * @example
1181
+ * ```javascript
1182
+ * await provider.getTransactionCount('0x71660c4005ba85c37ccec55d0c4493e66fe775d3', 'latest');
1183
+ * // 1060000
1184
+ * ```
1185
+ * @example
1186
+ * ```javascript
1187
+ * await provider.getTransactionCount('0x71660c4005ba85c37ccec55d0c4493e66fe775d3', 14649390);
1188
+ * // 1053312
1189
+ * ```
1190
+ */
1191
+ async getTransactionCount(address, blockTag = "latest") {
1192
+ blockTag = prepBlockTag(blockTag);
1193
+ const transactionCount = await this.post(
1194
+ buildRPCPostBody("eth_getTransactionCount", [address, blockTag])
1195
+ );
1196
+ return Number(hexToDecimal(transactionCount));
1197
+ }
1198
+ /**
1199
+ * Gets information about a certain block, optionally with full transaction objects.
1200
+ *
1201
+ * * [Similar](/docs/api#isd) to [`ethers.provider.getBlock`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getLogs) in ethers.js, includes some additional information. Can also return block with full transaction objects, similar to [`ethers.providers.getBlockWithTransactions`]
1202
+ * * [Identical](/docs/api#isd) to [`web3.eth.getBlock`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getpastlogs) in web3.js
1203
+ *
1204
+ * @param timeFrame The number, hash, or text-based description ('latest', 'earliest', or 'pending') of the block to collect information on.
1205
+ * @param returnTransactionObjects Whether to also return data about the transactions on the block.
1206
+ * @returns A BlockResponse object with information about the specified block
1207
+ * @example
1208
+ * ```javascript
1209
+ * await provider.getBlock(14879862);
1210
+ * // {
1211
+ * // baseFeePerGas: { TinyBig: 39095728776 },
1212
+ * // difficulty: { TinyBig: 14321294455359973 },
1213
+ * // extraData: "0x486976656f6e2073672d6865617679",
1214
+ * // gasLimit: { TinyBig: 29970620 },
1215
+ * // gasUsed: { TinyBig: 20951384 },
1216
+ * // hash: "0x563b458ec3c4f87393b53f70bdddc0058497109b784d8cacd9247ddf267049ab",
1217
+ * // logsBloom:
1218
+ * // "0x9f38794fe80b521794df6efad8b0d2e9582f9ec3959a3f9384bda0fa371cfa5fac5af9d515c6bdf1ec325f5b5f7ebdd6a3a9fae17b38a86d4dc4b0971afc68d8086640550f4c156e6f923f4a1bb94fb0bed6cdcc474c5c64bfeff7a4a906f72b9a7b94004ee58efc53d63ac66961acd3a431b2d896cc9fd75f6072960bced45f770587caf130f57504decfcb63c6ca8fbc5bdbd749edd5a99a7375d2b81872289adb775fb3c928259f4be39c6d3f4d5b6217822979bb88c1f1fb62429b1b6d41cf4e3f77f9e1db3f5723108f1e5b1255dd734ad8cdb11e7ea22487c788e67c83777b6f395e504ca59c64f52245ee6de3804cf809e5caa4f0ea6a9aa9eb6ed801",
1219
+ * // miner: "0x1aD91ee08f21bE3dE0BA2ba6918E714dA6B45836",
1220
+ * // mixHash: "0x73cc9419bfb89c9d41c3a8c34ce56b5ebe468bdcf870258d2e77262275d580ec",
1221
+ * // nonce: "0x976f3f5d596ffb08",
1222
+ * // number: 14879862,
1223
+ * // parentHash: "0x95986ae14a71face8d9a6a379edd875b2e8bc73e4de0d9d460e7752bddb0f579",
1224
+ * // receiptsRoot: "0x8e6ba2fd9bee602b653dae6e3132f16538c2c5df24f1df8c000392053f73defa",
1225
+ * // sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
1226
+ * // size: { TinyBig: 134483 },
1227
+ * // stateRoot: "0xbf2bb67bd1c741f3d00904b8451d7c2cf4e3a2726f5a5884792ede2074747b85",
1228
+ * // timestamp: { TinyBig: 1654016186 },
1229
+ * // totalDifficulty: { TinyBig: 50478104614257705213748 },
1230
+ * // transactions: [
1231
+ * // "0xb3326a9149809603a2c28545e50e4f7d16e194bf5ee9764e0544603854c4a8d2",
1232
+ * // "0x8b42095f8d335404a4896b2817b8e5e3d86a5a87cb434a8eec295d5280a7f48e",
1233
+ * // "0x882f78fcb73f0f7ad0700bb0424a8b4beb366aaa93b88a3562c49a8d0ce4dcff",
1234
+ * // ...
1235
+ * // ],
1236
+ * // transactionsRoot: "0x5934902f3dcc263ec34f24318179bf6301f53f4834685792066026f3a4849d72",
1237
+ * // uncles: [],
1238
+ * // }
1239
+ * ```
1240
+ */
1241
+ async getBlock(timeFrame = "latest", returnTransactionObjects = false) {
1242
+ let type = "Number";
1243
+ if (typeof timeFrame === "string" && timeFrame.length === 66) {
1244
+ type = "Hash";
1245
+ } else {
1246
+ timeFrame = prepBlockTag(timeFrame);
1247
+ }
1248
+ const rpcBlock = await this.post(
1249
+ buildRPCPostBody(`eth_getBlockBy${type}`, [
1250
+ timeFrame,
1251
+ returnTransactionObjects
1252
+ ])
1253
+ );
1254
+ return cleanBlock(rpcBlock, returnTransactionObjects);
1255
+ }
1256
+ /**
1257
+ * Gives an estimate of the current gas price in wei.
1258
+ *
1259
+ * * [Similar](/docs/api#isd) to [`ethers.provider.getGasPrice`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getGasPrice) in ethers.js, does not have a parameter specifying what unit you'd like to return. See also [`weiToEther`](/docs/api/modules#weitoether) and [`etherToGwei`](/docs/api/modules#ethertogwei)
1260
+ * * [Identical](/docs/api#isd) to [`web3.eth.getGasPrice`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getgasprice) in web3.js, returns a number (TinyBig) instead of a string
1261
+ *
1262
+ * @returns an estimate of the current gas price in wei
1263
+ * @example
1264
+ * ```javascript
1265
+ * await provider.getGasPrice();
1266
+ * // 52493941856
1267
+ * ```
1268
+ */
1269
+ async getGasPrice() {
1270
+ const hexGasPrice = await this.post(
1271
+ buildRPCPostBody("eth_gasPrice", [])
1272
+ );
1273
+ return tinyBig(hexToDecimal(hexGasPrice));
1274
+ }
1275
+ /**
1276
+ * Returns the balance of the account in wei.
1277
+ *
1278
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getBalance`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getBalance) in ethers.js
1279
+ * * [Identical](/docs/api#isd) to [`web3.eth.getBalance`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getbalance) in web3.js, returns a number (TinyBig) instead of a string
1280
+ *
1281
+ * @param address the address to check the balance of
1282
+ * @param blockTag the block to check the specified address' balance on
1283
+ * @returns the balance of the network's native token for the specified address on the specified block
1284
+ * @example
1285
+ * ```javascript
1286
+ * await provider.getBalance('0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8');
1287
+ * // 28798127851528138
1288
+ * ```
1289
+ */
1290
+ async getBalance(address, blockTag = "latest") {
1291
+ blockTag = prepBlockTag(blockTag);
1292
+ const hexBalance = await this.post(
1293
+ buildRPCPostBody("eth_getBalance", [address, blockTag])
1294
+ );
1295
+ return tinyBig(hexToDecimal(hexBalance));
1296
+ }
1297
+ /**
1298
+ * Gets the code of a contract on a specified block.
1299
+ *
1300
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getCode`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getCode) in ethers.js
1301
+ * * [Identical](/docs/api#isd) to [`web3.eth.getCode`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getcode) in web3.js
1302
+ *
1303
+ * @param address the contract address to get the contract code from
1304
+ * @param blockTag the block height to search for the contract code from. Contract code can change, so this allows for checking a specific block
1305
+ * @returns the contract creation code for the specified address at the specified block height
1306
+ * @example
1307
+ * ```javascript
1308
+ * await jsonRpcProvider().getCode('0xaC6095720221C79C6E7C638d260A2eFBC5D8d880', 'latest');
1309
+ * // '0x608060405234801561001057600080fd5b506004361061...'
1310
+ * ```
1311
+ */
1312
+ async getCode(address, blockTag = "latest") {
1313
+ blockTag = prepBlockTag(blockTag);
1314
+ const contractCode = await this.post(
1315
+ buildRPCPostBody("eth_getCode", [address, blockTag])
1316
+ );
1317
+ return contractCode;
1318
+ }
1319
+ /**
1320
+ * Returns an estimate of the amount of gas that would be required to submit transaction to the network.
1321
+ * An estimate may not be accurate since there could be another transaction on the network that was not accounted for.
1322
+ *
1323
+ * * [Identical](/docs/api#isd) to [`ethers.provider.estimateGas`](https://docs.ethers.io/v5/api/providers/provider/#Provider-estimateGas) in ethers.js
1324
+ * * [Identical](/docs/api#isd) to [`web3.eth.estimateGas`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#estimateGas) in web3.js
1325
+ *
1326
+ * @param transaction the transaction to check the estimated gas cost for
1327
+ * @returns the estimated amount of gas charged for submitting the specified transaction to the blockchain
1328
+ * @example
1329
+ * ```javascript
1330
+ * await provider.estimateGas({
1331
+ * // Wrapped ETH address
1332
+ * to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
1333
+ * data: "0xd0e30db0",
1334
+ * value: etherToWei('1.0').toHexString(),
1335
+ * });
1336
+ * // { TinyBig: "27938" }
1337
+ * ```
1338
+ */
1339
+ async estimateGas(transaction) {
1340
+ const rpcTransaction = prepareTransaction(transaction);
1341
+ const gasUsed = await this.post(
1342
+ buildRPCPostBody("eth_estimateGas", [rpcTransaction])
1343
+ );
1344
+ return tinyBig(hexToDecimal(gasUsed));
1345
+ }
1346
+ /**
1347
+ * Returns the current recommended FeeData to use in a transaction.
1348
+ * For an EIP-1559 transaction, the maxFeePerGas and maxPriorityFeePerGas should be used.
1349
+ * For legacy transactions and networks which do not support EIP-1559, the gasPrice should be used.Returns an estimate of the amount of gas that would be required to submit transaction to the network.
1350
+ *
1351
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getFeeData`](https://docs.ethers.org/v5/api/providers/provider/#Provider-getFeeData) in ethers.js
1352
+ *
1353
+ * @returns an object with gas estimates for the network currently
1354
+ * @example
1355
+ * ```javascript
1356
+ * await provider.getFeeData();
1357
+ * // {
1358
+ * // gasPrice: { TinyBig: "14184772639" },
1359
+ * // lastBaseFeePerGas: { TinyBig: "14038523098" },
1360
+ * // maxFeePerGas: { TinyBig: "29577046196" },
1361
+ * // maxPriorityFeePerGas: { TinyBig: "1500000000" }
1362
+ * // }
1363
+ * ```
1364
+ */
1365
+ async getFeeData() {
1366
+ const [block, gasPrice] = await Promise.all([
1367
+ this.getBlock("latest"),
1368
+ this.getGasPrice()
1369
+ ]);
1370
+ let lastBaseFeePerGas = null, maxFeePerGas = null, maxPriorityFeePerGas = null;
1371
+ if (block && block.baseFeePerGas) {
1372
+ lastBaseFeePerGas = block.baseFeePerGas;
1373
+ maxPriorityFeePerGas = tinyBig("1500000000");
1374
+ maxFeePerGas = tinyBig(
1375
+ block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas)
1376
+ );
1377
+ }
1378
+ return { lastBaseFeePerGas, maxFeePerGas, maxPriorityFeePerGas, gasPrice };
1379
+ }
1380
+ /**
1381
+ * Returns transaction receipt event logs that match a specified filter.
1382
+ * May return `[]` if parameters are too broad, even if logs exist.
1383
+ *
1384
+ * * [Identical](/docs/api#isd) to [`ethers.provider.getLogs`](https://docs.ethers.io/v5/api/providers/provider/#Provider-getLogs) in ethers.js
1385
+ * * [Identical](/docs/api#isd) to [`web3.eth.getPastLogs`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#getpastlogs) in web3.js
1386
+ *
1387
+ * @param filter parameters to filter the logs by
1388
+ * @returns an array of logs matching the specified filter
1389
+ * @example
1390
+ * ```javascript
1391
+ * provider.getLogs({
1392
+ * address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
1393
+ * topics: [
1394
+ * "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
1395
+ * "0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e",
1396
+ * ],
1397
+ * fromBlock: 14825027,
1398
+ * toBlock: 14825039,
1399
+ * });
1400
+ *
1401
+ * [
1402
+ * {
1403
+ * address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
1404
+ * blockHash: '0x8e0dfac2f704851960f866c8708b3bef2f66c0fee0329cf25ff0261b264ca6bc',
1405
+ * blockNumber: 14825029,
1406
+ * data: '0x000000000000000000000000000000000000000000000000005f862ee352a38a',
1407
+ * logIndex: 384,
1408
+ * removed: false,
1409
+ * topics: [
1410
+ * '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
1411
+ * '0x00000000000000000000000021b8065d10f73ee2e260e5b47d3344d3ced7596e',
1412
+ * '0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45'
1413
+ * ],
1414
+ * transactionHash: '0xbd49031be16f8fd1775f4e0fe79b408ffd8ae9c65b2827ee47e3238e3f51f4c0',
1415
+ * transactionIndex: 226
1416
+ * }
1417
+ * ]
1418
+ * ```
1419
+ */
1420
+ async getLogs(filter) {
1421
+ const filterByRange = filter;
1422
+ if (filterByRange.fromBlock)
1423
+ filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
1424
+ if (filterByRange.toBlock)
1425
+ filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
1426
+ const rpcLogs = await this.post(
1427
+ buildRPCPostBody("eth_getLogs", [filter])
1428
+ );
1429
+ const logs = rpcLogs.map((log) => cleanLog(log, false));
1430
+ return logs;
1431
+ }
1432
+ /**
1433
+ * Returns the result of adding a transaction to the blockchain without actually adding that transaction to the blockchain.
1434
+ * Does not require any ether as gas.
1435
+ *
1436
+ * * [Identical](/docs/api#isd) to [`ethers.provider.call`](https://docs.ethers.io/v5/api/providers/provider/#Provider-call) in ethers.js
1437
+ * * [Identical](/docs/api#isd) to [`web3.eth.call`](https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#call) in web3.js
1438
+ *
1439
+ * @param transaction the transaction object to, in theory, execute. Doesn't actually get added to the blockchain.
1440
+ * @param blockTag the block to execute this transaction on
1441
+ * @returns the result of executing the transaction on the specified block
1442
+ * @example
1443
+ * ```javascript
1444
+ * await provider.call({ to: "0x6b175474e89094c44da98b954eedeac495271d0f", data: "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE" });
1445
+ * // '0x0000000000000000000000000000000000000000000000000858898f93629000'
1446
+ * ```
1447
+ */
1448
+ async call(transaction, blockTag = "latest") {
1449
+ if (transaction.gasPrice && (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
1450
+ logger.throwError(
1451
+ 'Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")',
1452
+ {
1453
+ gasPrice: transaction.gasPrice,
1454
+ maxFeePerGas: transaction.maxFeePerGas,
1455
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
1456
+ }
1457
+ );
1458
+ }
1459
+ if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
1460
+ logger.throwError(
1461
+ 'Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"',
1462
+ {
1463
+ maxFeePerGas: transaction.maxFeePerGas,
1464
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas
1465
+ }
1466
+ );
1467
+ }
1468
+ blockTag = prepBlockTag(blockTag);
1469
+ const rpcTransaction = prepareTransaction(transaction);
1470
+ const transactionRes = await this.post(
1471
+ buildRPCPostBody("eth_call", [rpcTransaction, blockTag])
1472
+ );
1473
+ return transactionRes;
1474
+ }
1475
+ };
1476
+
1477
+ // src/providers/JsonRpcProvider.ts
1478
+ var JsonRpcProvider = class extends BaseProvider {
1479
+ /**
1480
+ * @ignore
1481
+ */
1482
+ selectRpcUrl() {
1483
+ return this._rpcUrls[0];
1484
+ }
1485
+ /**
1486
+ * @ignore
1487
+ */
1488
+ post(body) {
1489
+ return this._post(body);
1490
+ }
1491
+ /**
1492
+ * @param rpcUrl The URL to your Eth node. Consider POKT or Infura
1493
+ * @example
1494
+ * `https://free-eth-node.com/api/eth`
1495
+ * @example
1496
+ * `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
1497
+ */
1498
+ constructor(rpcUrl = "https://free-eth-node.com/api/eth") {
1499
+ super([rpcUrl]);
1500
+ }
1501
+ };
1502
+ function jsonRpcProvider(rpcUrl) {
1503
+ return new JsonRpcProvider(rpcUrl);
1504
+ }
1505
+
1506
+ // src/providers/AlchemyProvider.ts
1507
+ var AlchemyProvider = class extends JsonRpcProvider {
1508
+ constructor(apiKey, network = "mainnet") {
1509
+ const alchemyUrl = `https://eth-${network}.alchemyapi.io/v2/${apiKey}`;
1510
+ super(alchemyUrl);
1511
+ }
1512
+ };
1513
+
1514
+ // src/providers/FallthroughProvider.ts
1515
+ var promiseTimeout = (prom, time) => new Promise((resolve, reject) => {
1516
+ const timeout = setTimeout(
1517
+ () => reject(new Error("Promise timed out")),
1518
+ time
1519
+ );
1520
+ prom.then((result) => {
1521
+ clearTimeout(timeout);
1522
+ resolve(result);
1523
+ }).catch((error) => {
1524
+ clearTimeout(timeout);
1525
+ reject(error);
1526
+ });
1527
+ });
1528
+ var DEFAULT_TIMEOUT_DURATION = 8e3;
1529
+ var FallthroughProvider = class extends BaseProvider {
1530
+ // index of current trusted rpc url
1531
+ /**
1532
+ * @ignore
1533
+ */
1534
+ rpcUrlCounter = 0;
1535
+ timeoutDuration;
1536
+ /**
1537
+ * @ignore
1538
+ */
1539
+ selectRpcUrl() {
1540
+ return this._rpcUrls[this.rpcUrlCounter];
1541
+ }
1542
+ constructor(rpcUrls, options = {}) {
1543
+ if (!Array.isArray(rpcUrls)) {
1544
+ logger.throwError("Array required", { rpcUrls });
1545
+ }
1546
+ if (rpcUrls.length <= 1) {
1547
+ logger.throwError("More than one rpcUrl is required", { rpcUrls });
1548
+ }
1549
+ super(rpcUrls);
1550
+ this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
1551
+ }
1552
+ /**
1553
+ * @ignore
1554
+ */
1555
+ post = (body) => {
1556
+ const genesisCount = this.rpcUrlCounter;
1557
+ const recursivePostRetry = () => {
1558
+ const genesisRpcUrl = this.selectRpcUrl();
1559
+ const res = promiseTimeout(this._post(body), this.timeoutDuration).catch(
1560
+ (e) => {
1561
+ if (genesisRpcUrl === this.selectRpcUrl()) {
1562
+ this.rpcUrlCounter = (this.rpcUrlCounter + 1) % this._rpcUrls.length;
1563
+ }
1564
+ if (this.rpcUrlCounter === genesisCount) {
1565
+ throw e;
1566
+ }
1567
+ return recursivePostRetry();
1568
+ }
1569
+ );
1570
+ return res;
1571
+ };
1572
+ return recursivePostRetry();
1573
+ };
1574
+ };
1575
+
1576
+ // src/utils/compute-public-key.ts
1577
+ import { Point } from "@noble/secp256k1";
1578
+ function computePublicKey(privKey) {
1579
+ privKey = hexlify(privKey).slice(2);
1580
+ return "0x" + Point.fromPrivateKey(privKey).toHex();
1581
+ }
1582
+
1583
+ // src/utils/keccak256.ts
1584
+ import { Keccak as Keccak3 } from "sha3";
1585
+ function keccak256(data) {
1586
+ let bufferableData;
1587
+ if (typeof data === "string") {
1588
+ bufferableData = Buffer.from(data.replace(/^0x/, ""), "hex");
1589
+ } else {
1590
+ bufferableData = Buffer.from(data);
1591
+ }
1592
+ const keccak = new Keccak3(256);
1593
+ const addressHash = "0x" + keccak.update(bufferableData).digest("hex");
1594
+ return addressHash;
1595
+ }
1596
+
1597
+ // src/utils/compute-address.ts
1598
+ function computeAddress(key) {
1599
+ if (!key.startsWith("0x04") && !key.startsWith("0x03") && !key.startsWith("0x02")) {
1600
+ key = computePublicKey(key);
1601
+ }
1602
+ return toChecksumAddress(hexDataSlice(keccak256(hexDataSlice(key, 1)), 12));
1603
+ }
1604
+
1605
+ // src/utils/ether-to-gwei.ts
1606
+ function etherToGwei(etherQuantity) {
1607
+ validateType(etherQuantity, ["string", "number", "object"]);
1608
+ const result = tinyBig(etherQuantity).times("1000000000");
1609
+ return tinyBig(result);
1610
+ }
1611
+
1612
+ // src/utils/ether-to-wei.ts
1613
+ function etherToWei(etherQuantity) {
1614
+ validateType(etherQuantity, ["string", "number", "object"]);
1615
+ const result = tinyBig(etherQuantity).times("1000000000000000000");
1616
+ return tinyBig(result);
1617
+ }
1618
+
1619
+ // src/utils/gwei-to-ether.ts
1620
+ function gweiToEther(gweiQuantity) {
1621
+ validateType(gweiQuantity, ["string", "number", "object"]);
1622
+ const result = tinyBig(gweiQuantity).div("1000000000");
1623
+ return tinyBig(result);
1624
+ }
1625
+
1626
+ // src/utils/to-utf8-bytes.ts
1627
+ function toUtf8Bytes(data) {
1628
+ return new Uint8Array(Buffer.from(data));
1629
+ }
1630
+
1631
+ // src/utils/hash-message.ts
1632
+ var messagePrefix = "Ethereum Signed Message:\n";
1633
+ function hashMessage(message) {
1634
+ if (typeof message === "string") {
1635
+ message = toUtf8Bytes(message);
1636
+ }
1637
+ return keccak256(
1638
+ concat([
1639
+ toUtf8Bytes(messagePrefix),
1640
+ toUtf8Bytes(String(message.length)),
1641
+ message
1642
+ ])
1643
+ );
1644
+ }
1645
+
1646
+ // src/utils/is-address.ts
1647
+ function isAddress(address) {
1648
+ validateType(address, ["string"]);
1649
+ try {
1650
+ toChecksumAddress(address);
1651
+ return true;
1652
+ } catch (error) {
1653
+ return false;
1654
+ }
1655
+ }
1656
+
1657
+ // src/utils/solidity-keccak256.ts
1658
+ import { Buffer as Buffer2 } from "buffer";
1659
+ var regexBytes = new RegExp("^bytes([0-9]+)$");
1660
+ var regexNumber = new RegExp("^(u?int)([0-9]*)$");
1661
+ var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
1662
+ function _pack(type, value, isArray) {
1663
+ switch (type) {
1664
+ case "address":
1665
+ if (isArray) {
1666
+ return zeroPad(value, 32);
1667
+ }
1668
+ return arrayify(value);
1669
+ case "string":
1670
+ return Buffer2.from(value);
1671
+ case "bytes":
1672
+ return arrayify(value);
1673
+ case "bool":
1674
+ value = value ? "0x01" : "0x00";
1675
+ if (isArray) {
1676
+ return zeroPad(value, 32);
1677
+ }
1678
+ return arrayify(value);
1679
+ }
1680
+ let match = type.match(regexNumber);
1681
+ if (match) {
1682
+ let size = parseInt(match[2] || "256");
1683
+ if (match[2] && String(size) !== match[2] || size % 8 !== 0 || size === 0 || size > 256) {
1684
+ logger.throwArgumentError("invalid number type", "type", type);
1685
+ }
1686
+ if (isArray) {
1687
+ size = 256;
1688
+ }
1689
+ value = tinyBig(value).toTwos(size).toNumber();
1690
+ const hexValue2 = hexlify(value);
1691
+ return zeroPad(hexValue2, size / 8);
1692
+ }
1693
+ match = type.match(regexBytes);
1694
+ if (match) {
1695
+ const size = parseInt(match[1]);
1696
+ if (String(size) !== match[1] || size === 0 || size > 32) {
1697
+ logger.throwArgumentError("invalid bytes type", "type", type);
1698
+ }
1699
+ if (arrayify(value).byteLength !== size) {
1700
+ logger.throwArgumentError(`invalid value for ${type}`, "value", value);
1701
+ }
1702
+ if (isArray) {
1703
+ return arrayify((value + hexFalse).substring(0, 66));
1704
+ }
1705
+ return value;
1706
+ }
1707
+ match = type.match(regexArray);
1708
+ if (match && Array.isArray(value)) {
1709
+ const baseType = match[1];
1710
+ const count = parseInt(match[2] || String(value.length));
1711
+ if (count != value.length) {
1712
+ logger.throwArgumentError(
1713
+ `invalid array length for ${type}`,
1714
+ "value",
1715
+ value
1716
+ );
1717
+ }
1718
+ const result = [];
1719
+ value.forEach(function(value2) {
1720
+ result.push(_pack(baseType, value2, true));
1721
+ });
1722
+ return concat(result);
1723
+ }
1724
+ return logger.throwArgumentError("invalid type", "type", type);
1725
+ }
1726
+ function pack(types, values) {
1727
+ if (types.length != values.length) {
1728
+ logger.throwArgumentError(
1729
+ "wrong number of values; expected ${ types.length }",
1730
+ "values",
1731
+ values
1732
+ );
1733
+ }
1734
+ const tight = [];
1735
+ types.forEach(function(type, index) {
1736
+ tight.push(_pack(type, values[index]));
1737
+ });
1738
+ return hexlify(concat(tight));
1739
+ }
1740
+ function solidityKeccak256(types, values) {
1741
+ return keccak256(pack(types, values));
1742
+ }
1743
+
1744
+ // src/utils/split-signature.ts
1745
+ function splitSignature(signature) {
1746
+ const result = {
1747
+ r: "0x",
1748
+ s: "0x",
1749
+ _vs: "0x",
1750
+ recoveryParam: 0,
1751
+ v: 0,
1752
+ yParityAndS: "0x",
1753
+ compact: "0x"
1754
+ };
1755
+ if (isBytesLike(signature)) {
1756
+ const bytes = arrayify(signature);
1757
+ if (bytes.length === 64) {
1758
+ result.v = 27 + (bytes[32] >> 7);
1759
+ bytes[32] &= 127;
1760
+ result.r = hexlify(bytes.slice(0, 32));
1761
+ result.s = hexlify(bytes.slice(32, 64));
1762
+ } else if (bytes.length === 65) {
1763
+ result.r = hexlify(bytes.slice(0, 32));
1764
+ result.s = hexlify(bytes.slice(32, 64));
1765
+ result.v = bytes[64];
1766
+ } else {
1767
+ logger.throwArgumentError(
1768
+ "invalid signature string",
1769
+ "signature",
1770
+ signature
1771
+ );
1772
+ }
1773
+ if (result.v < 27) {
1774
+ if (result.v === 0 || result.v === 1) {
1775
+ result.v += 27;
1776
+ } else {
1777
+ logger.throwArgumentError(
1778
+ "signature invalid v byte",
1779
+ "signature",
1780
+ signature
1781
+ );
1782
+ }
1783
+ }
1784
+ result.recoveryParam = 1 - result.v % 2;
1785
+ if (result.recoveryParam) {
1786
+ bytes[32] |= 128;
1787
+ }
1788
+ result._vs = hexlify(bytes.slice(32, 64));
1789
+ } else {
1790
+ result.r = signature.r;
1791
+ result.s = signature.s;
1792
+ result.v = signature.v;
1793
+ result.recoveryParam = signature.recoveryParam;
1794
+ result._vs = signature._vs;
1795
+ if (result._vs != null) {
1796
+ const vs_1 = zeroPad(arrayify(result._vs), 32);
1797
+ result._vs = hexlify(vs_1);
1798
+ const recoveryParam = vs_1[0] >= 128 ? 1 : 0;
1799
+ if (result.recoveryParam == null) {
1800
+ result.recoveryParam = recoveryParam;
1801
+ } else if (result.recoveryParam !== recoveryParam) {
1802
+ logger.throwArgumentError(
1803
+ "signature recoveryParam mismatch _vs",
1804
+ "signature",
1805
+ signature
1806
+ );
1807
+ }
1808
+ vs_1[0] &= 127;
1809
+ const s = hexlify(vs_1);
1810
+ if (result.s == null) {
1811
+ result.s = s;
1812
+ } else if (result.s !== s) {
1813
+ logger.throwArgumentError(
1814
+ "signature v mismatch _vs",
1815
+ "signature",
1816
+ signature
1817
+ );
1818
+ }
1819
+ }
1820
+ if (result.recoveryParam == null) {
1821
+ if (result.v == null) {
1822
+ logger.throwArgumentError(
1823
+ "signature missing v and recoveryParam",
1824
+ "signature",
1825
+ signature
1826
+ );
1827
+ } else if (result.v === 0 || result.v === 1) {
1828
+ result.recoveryParam = result.v;
1829
+ } else {
1830
+ result.recoveryParam = 1 - result.v % 2;
1831
+ }
1832
+ } else {
1833
+ if (result.v == null) {
1834
+ result.v = 27 + result.recoveryParam;
1835
+ } else {
1836
+ const recId = result.v === 0 || result.v === 1 ? result.v : 1 - result.v % 2;
1837
+ if (result.recoveryParam !== recId) {
1838
+ logger.throwArgumentError(
1839
+ "signature recoveryParam mismatch v",
1840
+ "signature",
1841
+ signature
1842
+ );
1843
+ }
1844
+ }
1845
+ }
1846
+ if (result.r == null || !isHexString(result.r)) {
1847
+ logger.throwArgumentError(
1848
+ "signature missing or invalid r",
1849
+ "signature",
1850
+ signature
1851
+ );
1852
+ } else {
1853
+ result.r = hexZeroPad(result.r, 32);
1854
+ }
1855
+ if (result.s == null || !isHexString(result.s)) {
1856
+ logger.throwArgumentError(
1857
+ "signature missing or invalid s",
1858
+ "signature",
1859
+ signature
1860
+ );
1861
+ } else {
1862
+ result.s = hexZeroPad(result.s, 32);
1863
+ }
1864
+ const vs = arrayify(result.s);
1865
+ if (vs[0] >= 128) {
1866
+ logger.throwArgumentError(
1867
+ "signature s out of range",
1868
+ "signature",
1869
+ signature
1870
+ );
1871
+ }
1872
+ if (result.recoveryParam) {
1873
+ vs[0] |= 128;
1874
+ }
1875
+ const _vs = hexlify(vs);
1876
+ if (result._vs) {
1877
+ if (!isHexString(result._vs)) {
1878
+ logger.throwArgumentError(
1879
+ "signature invalid _vs",
1880
+ "signature",
1881
+ signature
1882
+ );
1883
+ }
1884
+ result._vs = hexZeroPad(result._vs, 32);
1885
+ }
1886
+ if (result._vs == null) {
1887
+ result._vs = _vs;
1888
+ } else if (result._vs !== _vs) {
1889
+ logger.throwArgumentError(
1890
+ "signature _vs mismatch v and s",
1891
+ "signature",
1892
+ signature
1893
+ );
1894
+ }
1895
+ }
1896
+ result.yParityAndS = result._vs;
1897
+ result.compact = result.r + result.yParityAndS.substring(2);
1898
+ return result;
1899
+ }
1900
+
1901
+ // src/utils/wei-to-ether.ts
1902
+ function weiToEther(weiQuantity) {
1903
+ validateType(weiQuantity, ["string", "number", "object"]);
1904
+ try {
1905
+ let _weiQuantity = weiQuantity;
1906
+ if (typeof weiQuantity === "string" && weiQuantity.slice(0, 2) === "0x") {
1907
+ _weiQuantity = BigInt(weiQuantity).toString();
1908
+ }
1909
+ const result = tinyBig(_weiQuantity).div("1000000000000000000");
1910
+ return tinyBig(result);
1911
+ } catch (error) {
1912
+ throw error;
1913
+ }
1914
+ }
1915
+ export {
1916
+ AlchemyProvider,
1917
+ BaseContract,
1918
+ Contract,
1919
+ FallthroughProvider,
1920
+ JsonRpcProvider,
1921
+ TinyBig,
1922
+ arrayify,
1923
+ computeAddress,
1924
+ computePublicKey,
1925
+ concat,
1926
+ etherToGwei,
1927
+ etherToWei,
1928
+ gweiToEther,
1929
+ hashMessage,
1930
+ hexConcat,
1931
+ hexDataLength,
1932
+ hexDataSlice,
1933
+ hexStripZeros,
1934
+ hexValue,
1935
+ hexZeroPad,
1936
+ hexlify,
1937
+ isAddress,
1938
+ isBytes,
1939
+ isBytesLike,
1940
+ isHexString,
1941
+ jsonRpcProvider,
1942
+ keccak256,
1943
+ pack,
1944
+ solidityKeccak256,
1945
+ splitSignature,
1946
+ stripZeros,
1947
+ tinyBig,
1948
+ toChecksumAddress,
1949
+ toUtf8Bytes,
1950
+ weiToEther,
1951
+ zeroPad
1952
+ };