essential-eth 0.10.2 → 0.10.4-beta.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.
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 +13 -14
  6. package/readme.md +1 -1
  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 -186
  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
@@ -1,17 +0,0 @@
1
- /**
2
- * Computes the address that corresponds to a specified public or private key
3
- *
4
- * @param key the public or private key to find the address related to
5
- * @returns the address that corresponds to the key specified
6
- * @example
7
- * ```javascript
8
- * computeAddress('0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952'); // public key
9
- * // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
10
- * ```
11
- * @example
12
- * ```javascript
13
- * computeAddress('0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427'); // private key
14
- * // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
15
- * ```
16
- */
17
- export declare function computeAddress(key: string): string;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computeAddress = void 0;
4
- const bytes_1 = require("./bytes");
5
- const compute_public_key_1 = require("./compute-public-key");
6
- const keccak256_1 = require("./keccak256");
7
- const to_checksum_address_1 = require("./to-checksum-address");
8
- /**
9
- * Computes the address that corresponds to a specified public or private key
10
- *
11
- * @param key the public or private key to find the address related to
12
- * @returns the address that corresponds to the key specified
13
- * @example
14
- * ```javascript
15
- * computeAddress('0x0458eb591f407aef12936bd2989ca699cf5061de9c4964dd6eb6005fd8f580c407434447e813969a1be6e9954b002cad84dfc67a69e032b273e4695e7d0db2d952'); // public key
16
- * // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
17
- * ```
18
- * @example
19
- * ```javascript
20
- * computeAddress('0x2f2c419acf4a1da8c1ebea75bb3fcfbd3ec2aa3bf0162901ccdc2f38b8f92427'); // private key
21
- * // '0xA2902059a7BF992f1450BACD7357CCAa5cC8336a'
22
- * ```
23
- */
24
- function computeAddress(key) {
25
- // compressed public keys start with 0x04
26
- // uncompressed public keys start with 0x03 or 0x02
27
- if (!key.startsWith('0x04') &&
28
- !key.startsWith('0x03') &&
29
- !key.startsWith('0x02')) {
30
- key = (0, compute_public_key_1.computePublicKey)(key);
31
- }
32
- return (0, to_checksum_address_1.toChecksumAddress)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.hexDataSlice)(key, 1)), 12));
33
- }
34
- exports.computeAddress = computeAddress;
@@ -1,18 +0,0 @@
1
- import type { BytesLike } from './bytes';
2
- /**
3
- * Computes the public key from a given private key
4
- *
5
- * @param privKey the private key to find a public key from
6
- * @returns the public key related to the specified private key
7
- * @example
8
- * ```javascript
9
- * computePublicKey('0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c');
10
- * // '0x045cd0032015eecfde49f82f4e149d804e8ac6e3a0bface32e37c72a71ceac864fe84da7e8df84342f7b11dfb753c4d158f636142b46b29cf7f0f171ae0aa4fb87'
11
- * ```
12
- * @example
13
- * ```javascript
14
- * computePublicKey([50,102,50,99,52,49,57,97,99,102,52,97,49,100,97,56,99,49,101,98,101,97,55,53,98,98,51,102,99,102,98,100]);
15
- * // '0x04a9cea77eca949df84f661cee153426fb51f2294b9364b4fac240df57360b9b0ac9c99e4d7966491ab4c81f8c82e0cd24ec5759832ad4ab736d22c7d90b806ee8'
16
- * ```
17
- */
18
- export declare function computePublicKey(privKey: BytesLike): string;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computePublicKey = void 0;
4
- const secp256k1_1 = require("@noble/secp256k1");
5
- const bytes_1 = require("./bytes");
6
- /**
7
- * Computes the public key from a given private key
8
- *
9
- * @param privKey the private key to find a public key from
10
- * @returns the public key related to the specified private key
11
- * @example
12
- * ```javascript
13
- * computePublicKey('0xb27cc8dea0177d910110e8d3ec5480d56c723abf433529f4063f261ffdb9297c');
14
- * // '0x045cd0032015eecfde49f82f4e149d804e8ac6e3a0bface32e37c72a71ceac864fe84da7e8df84342f7b11dfb753c4d158f636142b46b29cf7f0f171ae0aa4fb87'
15
- * ```
16
- * @example
17
- * ```javascript
18
- * computePublicKey([50,102,50,99,52,49,57,97,99,102,52,97,49,100,97,56,99,49,101,98,101,97,55,53,98,98,51,102,99,102,98,100]);
19
- * // '0x04a9cea77eca949df84f661cee153426fb51f2294b9364b4fac240df57360b9b0ac9c99e4d7966491ab4c81f8c82e0cd24ec5759832ad4ab736d22c7d90b806ee8'
20
- * ```
21
- */
22
- function computePublicKey(privKey) {
23
- privKey = (0, bytes_1.hexlify)(privKey).slice(2);
24
- return '0x' + secp256k1_1.Point.fromPrivateKey(privKey).toHex();
25
- }
26
- exports.computePublicKey = computePublicKey;
@@ -1,27 +0,0 @@
1
- import type Big from 'big.js';
2
- import type { TinyBig } from '../shared/tiny-big/tiny-big';
3
- /**
4
- * Convert from Ether to Gwei
5
- *
6
- * No direct equivalent in ether.js; requires multiple functions to achieve.
7
- *
8
- * No direct equivalent in web3; requires multiple functions to achieve.
9
- *
10
- * @param etherQuantity the amount of ether to convert to gwei
11
- * @returns a number of gwei equivalent to the specified ether
12
- * @example
13
- * ```javascript
14
- * etherToGwei('1000').toString()
15
- * // '1000000000000'
16
- * etherToGwei(1000).toString()
17
- * // '1000000000000'
18
- * ```
19
- * @example
20
- * ```javascript
21
- * etherToGwei('1000').toNumber()
22
- * // 1000000000000
23
- * etherToGwei(1000).toNumber()
24
- * // 1000000000000
25
- * ```
26
- */
27
- export declare function etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.etherToGwei = void 0;
4
- const tiny_big_1 = require("../shared/tiny-big/tiny-big");
5
- const validate_type_1 = require("../shared/validate-type");
6
- /**
7
- * Convert from Ether to Gwei
8
- *
9
- * No direct equivalent in ether.js; requires multiple functions to achieve.
10
- *
11
- * No direct equivalent in web3; requires multiple functions to achieve.
12
- *
13
- * @param etherQuantity the amount of ether to convert to gwei
14
- * @returns a number of gwei equivalent to the specified ether
15
- * @example
16
- * ```javascript
17
- * etherToGwei('1000').toString()
18
- * // '1000000000000'
19
- * etherToGwei(1000).toString()
20
- * // '1000000000000'
21
- * ```
22
- * @example
23
- * ```javascript
24
- * etherToGwei('1000').toNumber()
25
- * // 1000000000000
26
- * etherToGwei(1000).toNumber()
27
- * // 1000000000000
28
- * ```
29
- */
30
- function etherToGwei(etherQuantity) {
31
- (0, validate_type_1.validateType)(etherQuantity, ['string', 'number', 'object']);
32
- const result = (0, tiny_big_1.tinyBig)(etherQuantity).times('1000000000');
33
- return (0, tiny_big_1.tinyBig)(result);
34
- }
35
- exports.etherToGwei = etherToGwei;
@@ -1,27 +0,0 @@
1
- import type Big from 'big.js';
2
- import type { TinyBig } from '../shared/tiny-big/tiny-big';
3
- /**
4
- * Convert Ether to Wei
5
- *
6
- * Similar to ["parseEther" in ethers.js](https://docs.ethers.io/v5/api/utils/display-logic/#utils-parseEther)
7
- *
8
- * Similar to ["toWei" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#towei)
9
- *
10
- * @param etherQuantity the amount of ether to convert to wei
11
- * @returns a number of wei equivalent to the specified ether
12
- * @example
13
- * ```javascript
14
- * etherToWei('1000').toString()
15
- * // '1000000000000000000000'
16
- * etherToWei(1000).toString()
17
- * // '1000000000000000000000'
18
- * ```
19
- * @example
20
- * ```javascript
21
- * etherToWei('1000').toNumber()
22
- * // 1000000000000000000000
23
- * etherToWei(1000).toNumber()
24
- * // 1000000000000000000000
25
- * ```
26
- */
27
- export declare function etherToWei(etherQuantity: string | number | TinyBig | Big): TinyBig;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.etherToWei = void 0;
4
- const tiny_big_1 = require("../shared/tiny-big/tiny-big");
5
- const validate_type_1 = require("../shared/validate-type");
6
- /**
7
- * Convert Ether to Wei
8
- *
9
- * Similar to ["parseEther" in ethers.js](https://docs.ethers.io/v5/api/utils/display-logic/#utils-parseEther)
10
- *
11
- * Similar to ["toWei" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#towei)
12
- *
13
- * @param etherQuantity the amount of ether to convert to wei
14
- * @returns a number of wei equivalent to the specified ether
15
- * @example
16
- * ```javascript
17
- * etherToWei('1000').toString()
18
- * // '1000000000000000000000'
19
- * etherToWei(1000).toString()
20
- * // '1000000000000000000000'
21
- * ```
22
- * @example
23
- * ```javascript
24
- * etherToWei('1000').toNumber()
25
- * // 1000000000000000000000
26
- * etherToWei(1000).toNumber()
27
- * // 1000000000000000000000
28
- * ```
29
- */
30
- function etherToWei(etherQuantity) {
31
- (0, validate_type_1.validateType)(etherQuantity, ['string', 'number', 'object']);
32
- const result = (0, tiny_big_1.tinyBig)(etherQuantity).times('1000000000000000000');
33
- return (0, tiny_big_1.tinyBig)(result);
34
- }
35
- exports.etherToWei = etherToWei;
@@ -1,27 +0,0 @@
1
- import type Big from 'big.js';
2
- import type { TinyBig } from './../shared/tiny-big/tiny-big';
3
- /**
4
- * Convert from Gwei to Ether
5
- *
6
- * No direct equivalent in ethers.js; requires multiple functions to achieve.
7
- *
8
- * No direct equivalent in web3; requires multiple functions to achieve.
9
- *
10
- * @param gweiQuantity the amount of gwei to convert to ether
11
- * @returns a number of ether equivalent to the specified gwei
12
- * @example
13
- * ```javascript
14
- * gweiToEther('1000000000000').toString()
15
- * // '1000'
16
- * gweiToEther(1000000000000).toString()
17
- * // '1000'
18
- * ```
19
- * @example
20
- * ```javascript
21
- * gweiToEther('1000000000000').toNumber()
22
- * // 1000
23
- * gweiToEther(1000000000000).toNumber()
24
- * // 1000
25
- * ```
26
- */
27
- export declare function gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gweiToEther = void 0;
4
- const tiny_big_1 = require("../shared/tiny-big/tiny-big");
5
- const validate_type_1 = require("../shared/validate-type");
6
- /**
7
- * Convert from Gwei to Ether
8
- *
9
- * No direct equivalent in ethers.js; requires multiple functions to achieve.
10
- *
11
- * No direct equivalent in web3; requires multiple functions to achieve.
12
- *
13
- * @param gweiQuantity the amount of gwei to convert to ether
14
- * @returns a number of ether equivalent to the specified gwei
15
- * @example
16
- * ```javascript
17
- * gweiToEther('1000000000000').toString()
18
- * // '1000'
19
- * gweiToEther(1000000000000).toString()
20
- * // '1000'
21
- * ```
22
- * @example
23
- * ```javascript
24
- * gweiToEther('1000000000000').toNumber()
25
- * // 1000
26
- * gweiToEther(1000000000000).toNumber()
27
- * // 1000
28
- * ```
29
- */
30
- function gweiToEther(gweiQuantity) {
31
- (0, validate_type_1.validateType)(gweiQuantity, ['string', 'number', 'object']);
32
- const result = (0, tiny_big_1.tinyBig)(gweiQuantity).div('1000000000');
33
- return (0, tiny_big_1.tinyBig)(result);
34
- }
35
- exports.gweiToEther = gweiToEther;
@@ -1,14 +0,0 @@
1
- import type { Bytes } from './bytes';
2
- /**
3
- * Computes the EIP-191 personal message digest of message.
4
- * Personal messages are converted to UTF-8 bytes and prefixed with \x19Ethereum Signed Message: and the length of message.
5
- *
6
- * @param message the message to hash
7
- * @returns a message hashed using Keccak256 that matches the EIP-191 standard
8
- * @example
9
- * ```javascript
10
- * hashMessage("Hello World");
11
- * // '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
12
- * ```
13
- */
14
- export declare function hashMessage(message: Bytes | string): string;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hashMessage = void 0;
4
- const bytes_1 = require("./bytes");
5
- const keccak256_1 = require("./keccak256");
6
- const to_utf8_bytes_1 = require("./to-utf8-bytes");
7
- const messagePrefix = '\x19Ethereum Signed Message:\n';
8
- /**
9
- * Computes the EIP-191 personal message digest of message.
10
- * Personal messages are converted to UTF-8 bytes and prefixed with \x19Ethereum Signed Message: and the length of message.
11
- *
12
- * @param message the message to hash
13
- * @returns a message hashed using Keccak256 that matches the EIP-191 standard
14
- * @example
15
- * ```javascript
16
- * hashMessage("Hello World");
17
- * // '0xa1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2'
18
- * ```
19
- */
20
- function hashMessage(message) {
21
- if (typeof message === 'string') {
22
- message = (0, to_utf8_bytes_1.toUtf8Bytes)(message);
23
- }
24
- return (0, keccak256_1.keccak256)((0, bytes_1.concat)([
25
- (0, to_utf8_bytes_1.toUtf8Bytes)(messagePrefix),
26
- (0, to_utf8_bytes_1.toUtf8Bytes)(String(message.length)),
27
- message,
28
- ]));
29
- }
30
- exports.hashMessage = hashMessage;
@@ -1,24 +0,0 @@
1
- /**
2
- * Returns a boolean as to whether the input is a valid address.
3
- * Does NOT support ICAP addresses
4
- *
5
- * @param address the address to check the validity of
6
- * @returns a boolean for whether the input is a valid address
7
- * @example
8
- * ```javascript
9
- * isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
10
- * // true
11
- * ```
12
- * @example
13
- * ```javascript
14
- * isAddress('bad');
15
- * // false
16
- * ```
17
- * @example
18
- * ```javascript
19
- * // Does NOT support ENS.
20
- * isAddress('vitalik.eth');
21
- * // false
22
- * ```
23
- */
24
- export declare function isAddress(address: string): boolean;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAddress = void 0;
4
- const validate_type_1 = require("../shared/validate-type");
5
- const to_checksum_address_1 = require("./to-checksum-address");
6
- /**
7
- * Returns a boolean as to whether the input is a valid address.
8
- * Does NOT support ICAP addresses
9
- *
10
- * @param address the address to check the validity of
11
- * @returns a boolean for whether the input is a valid address
12
- * @example
13
- * ```javascript
14
- * isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
15
- * // true
16
- * ```
17
- * @example
18
- * ```javascript
19
- * isAddress('bad');
20
- * // false
21
- * ```
22
- * @example
23
- * ```javascript
24
- * // Does NOT support ENS.
25
- * isAddress('vitalik.eth');
26
- * // false
27
- * ```
28
- */
29
- function isAddress(address) {
30
- (0, validate_type_1.validateType)(address, ['string']);
31
- try {
32
- (0, to_checksum_address_1.toChecksumAddress)(address);
33
- return true;
34
- }
35
- catch (error) {
36
- return false;
37
- }
38
- }
39
- exports.isAddress = isAddress;
@@ -1,16 +0,0 @@
1
- import type { BytesLike } from './bytes';
2
- /**
3
- * Hashes data into a Keccak256 hex string
4
- *
5
- * @param data the data to be hashed using Keccak256
6
- * @returns a hex string with data hashed using Keccak256
7
- * @example
8
- * ```javascript
9
- * keccak256('essential-eth');
10
- * // '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
11
- *
12
- * keccak256('0x123');
13
- * // '0x5fa2358263196dbbf23d1ca7a509451f7a2f64c15837bfbb81298b1e3e24e4fa'
14
- * ```
15
- */
16
- export declare function keccak256(data: BytesLike): string;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.keccak256 = void 0;
4
- const sha3_1 = require("sha3");
5
- /**
6
- * Hashes data into a Keccak256 hex string
7
- *
8
- * @param data the data to be hashed using Keccak256
9
- * @returns a hex string with data hashed using Keccak256
10
- * @example
11
- * ```javascript
12
- * keccak256('essential-eth');
13
- * // '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
14
- *
15
- * keccak256('0x123');
16
- * // '0x5fa2358263196dbbf23d1ca7a509451f7a2f64c15837bfbb81298b1e3e24e4fa'
17
- * ```
18
- */
19
- function keccak256(data) {
20
- let bufferableData;
21
- if (typeof data === 'string') {
22
- bufferableData = Buffer.from(data.replace(/^0x/, ''), 'hex');
23
- }
24
- else {
25
- bufferableData = Buffer.from(data);
26
- }
27
- const keccak = new sha3_1.Keccak(256);
28
- const addressHash = '0x' + keccak.update(bufferableData).digest('hex');
29
- return addressHash;
30
- }
31
- exports.keccak256 = keccak256;
@@ -1,39 +0,0 @@
1
- /**
2
- * Converts arrays with types and values into a hex string that can be hashed
3
- *
4
- * @param types array of Solidity types, where `type[0]` is the type for `value[0]`
5
- * @param values array of values, where `value[0]` is of type `type[0]`
6
- * @returns a hex string with the data given, packed to include its types
7
- * @example
8
- * ```javascript
9
- * const types = ['bool', 'string', 'uint64'];
10
- * const values = [true, 'text', 30];
11
- * pack(types, values);
12
- * // '0x0174657874000000000000001e'
13
- * ```
14
- */
15
- export declare function pack(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
16
- /**
17
- * Hashes data from Solidity using the Keccak256 algorithm.
18
- *
19
- * Similar to ["solidityKeccak256" in ethers.js](https://docs.ethers.io/v5/api/utils/hashing/#utils-solidityKeccak256)
20
- *
21
- * @param types Each [Solidity type](https://docs.soliditylang.org/en/v0.8.13/types.html) corresponding to the values passed in. Helps the function parse and pack data properly.
22
- * @param values Data to be concatenated (combined) and then hashed.
23
- * @returns A Keccak256 hash (hex string) based on the values provided
24
- * @example
25
- * ```javascript
26
- * const types = ['string', 'bool', 'uint32'];
27
- * const values = ['essential-eth is great', true, 14];
28
- * solidityKeccak256(types, values);
29
- * // '0xe4d4c8e809faac09d58f468f0aeab9474fe8965d554c6c0f868c433c3fd6acab'
30
- * ```
31
- * @example
32
- * ```javascript
33
- * const types = ['bytes4', 'uint32[5]'];
34
- * const values = [[116, 101, 115, 116], [5, 3, 4, 9, 18]];
35
- * solidityKeccak256(types, values);
36
- * // '0x038707a887f09355dc545412b058e7ba8f3c74047050c7c5e5e52eec608053d9'
37
- * ```
38
- */
39
- export declare function solidityKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string;
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.solidityKeccak256 = exports.pack = void 0;
4
- const buffer_1 = require("buffer");
5
- const encode_decode_transaction_1 = require("../classes/utils/encode-decode-transaction");
6
- const logger_1 = require("../logger/logger");
7
- const tiny_big_1 = require("../shared/tiny-big/tiny-big");
8
- const bytes_1 = require("./bytes");
9
- const keccak256_1 = require("./keccak256");
10
- const regexBytes = new RegExp('^bytes([0-9]+)$');
11
- const regexNumber = new RegExp('^(u?int)([0-9]*)$');
12
- const regexArray = new RegExp('^(.*)\\[([0-9]*)\\]$');
13
- /**
14
- * Packs a type and value together into a UTF-8 Byte Array
15
- *
16
- * @internal
17
- * @param type the Solidity type used for the value given
18
- * @param value the value to pack with its type
19
- * @param isArray whether the specified data is in an array
20
- * @returns packed data consisting of the type and value
21
- * @example N/A - internal function
22
- */
23
- function _pack(type, value, isArray) {
24
- switch (type) {
25
- case 'address':
26
- if (isArray) {
27
- return (0, bytes_1.zeroPad)(value, 32);
28
- }
29
- return (0, bytes_1.arrayify)(value);
30
- case 'string':
31
- return buffer_1.Buffer.from(value);
32
- case 'bytes':
33
- return (0, bytes_1.arrayify)(value);
34
- case 'bool':
35
- value = value ? '0x01' : '0x00';
36
- if (isArray) {
37
- return (0, bytes_1.zeroPad)(value, 32);
38
- }
39
- return (0, bytes_1.arrayify)(value);
40
- }
41
- let match = type.match(regexNumber);
42
- if (match) {
43
- //let signed = (match[1] === "int")
44
- let size = parseInt(match[2] || '256');
45
- if ((match[2] && String(size) !== match[2]) ||
46
- size % 8 !== 0 ||
47
- size === 0 ||
48
- size > 256) {
49
- logger_1.logger.throwArgumentError('invalid number type', 'type', type);
50
- }
51
- if (isArray) {
52
- size = 256;
53
- }
54
- value = (0, tiny_big_1.tinyBig)(value).toTwos(size).toNumber();
55
- const hexValue = (0, bytes_1.hexlify)(value);
56
- return (0, bytes_1.zeroPad)(hexValue, size / 8);
57
- }
58
- match = type.match(regexBytes);
59
- if (match) {
60
- const size = parseInt(match[1]);
61
- if (String(size) !== match[1] || size === 0 || size > 32) {
62
- logger_1.logger.throwArgumentError('invalid bytes type', 'type', type);
63
- }
64
- if ((0, bytes_1.arrayify)(value).byteLength !== size) {
65
- logger_1.logger.throwArgumentError(`invalid value for ${type}`, 'value', value);
66
- }
67
- if (isArray) {
68
- return (0, bytes_1.arrayify)((value + encode_decode_transaction_1.hexFalse).substring(0, 66));
69
- }
70
- return value;
71
- }
72
- match = type.match(regexArray);
73
- if (match && Array.isArray(value)) {
74
- const baseType = match[1];
75
- const count = parseInt(match[2] || String(value.length));
76
- if (count != value.length) {
77
- logger_1.logger.throwArgumentError(`invalid array length for ${type}`, 'value', value);
78
- }
79
- const result = [];
80
- value.forEach(function (value) {
81
- result.push(_pack(baseType, value, true));
82
- });
83
- return (0, bytes_1.concat)(result);
84
- }
85
- return logger_1.logger.throwArgumentError('invalid type', 'type', type);
86
- }
87
- /**
88
- * Converts arrays with types and values into a hex string that can be hashed
89
- *
90
- * @param types array of Solidity types, where `type[0]` is the type for `value[0]`
91
- * @param values array of values, where `value[0]` is of type `type[0]`
92
- * @returns a hex string with the data given, packed to include its types
93
- * @example
94
- * ```javascript
95
- * const types = ['bool', 'string', 'uint64'];
96
- * const values = [true, 'text', 30];
97
- * pack(types, values);
98
- * // '0x0174657874000000000000001e'
99
- * ```
100
- */
101
- function pack(types, values) {
102
- if (types.length != values.length) {
103
- logger_1.logger.throwArgumentError('wrong number of values; expected ${ types.length }', 'values', values);
104
- }
105
- const tight = [];
106
- types.forEach(function (type, index) {
107
- tight.push(_pack(type, values[index]));
108
- });
109
- return (0, bytes_1.hexlify)((0, bytes_1.concat)(tight));
110
- }
111
- exports.pack = pack;
112
- /**
113
- * Hashes data from Solidity using the Keccak256 algorithm.
114
- *
115
- * Similar to ["solidityKeccak256" in ethers.js](https://docs.ethers.io/v5/api/utils/hashing/#utils-solidityKeccak256)
116
- *
117
- * @param types Each [Solidity type](https://docs.soliditylang.org/en/v0.8.13/types.html) corresponding to the values passed in. Helps the function parse and pack data properly.
118
- * @param values Data to be concatenated (combined) and then hashed.
119
- * @returns A Keccak256 hash (hex string) based on the values provided
120
- * @example
121
- * ```javascript
122
- * const types = ['string', 'bool', 'uint32'];
123
- * const values = ['essential-eth is great', true, 14];
124
- * solidityKeccak256(types, values);
125
- * // '0xe4d4c8e809faac09d58f468f0aeab9474fe8965d554c6c0f868c433c3fd6acab'
126
- * ```
127
- * @example
128
- * ```javascript
129
- * const types = ['bytes4', 'uint32[5]'];
130
- * const values = [[116, 101, 115, 116], [5, 3, 4, 9, 18]];
131
- * solidityKeccak256(types, values);
132
- * // '0x038707a887f09355dc545412b058e7ba8f3c74047050c7c5e5e52eec608053d9'
133
- * ```
134
- */
135
- function solidityKeccak256(types, values) {
136
- return (0, keccak256_1.keccak256)(pack(types, values));
137
- }
138
- exports.solidityKeccak256 = solidityKeccak256;
@@ -1,24 +0,0 @@
1
- import type { Signature, SignatureLike } from './bytes';
2
- /**
3
- * Expands a signature into the full signature object and fills in missing properties.
4
- *
5
- * Same as ["splitSignature" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-splitSignature)
6
- *
7
- * @param signature the signature object to split, parse, and compute missing properties from
8
- * @returns a full signature object with all properties filled
9
- * @example
10
- * ```javascript
11
- * const signature = '0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee331b';
12
- * splitSignature(signature);
13
- * {
14
- * r: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b39716",
15
- * s: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
16
- * _vs: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
17
- * recoveryParam: 0,
18
- * v: 27,
19
- * yParityAndS: "0x47252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33",
20
- * compact: "0x60bc4ed91f2021aefe7045f3f77bd12f87eb733aee24bd1965343b3c27b3971647252185b7d2abb411b01b5d1ac4ab41ea486df1e9b396758c1aec6c1b6eee33"
21
- * }
22
- * ```
23
- */
24
- export declare function splitSignature(signature: SignatureLike): Signature;