essential-eth 0.5.11-next.1 → 0.5.13-next.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 (187) hide show
  1. package/dist/{classes → cjs/classes}/Contract.d.ts +0 -0
  2. package/dist/cjs/classes/Contract.js +140 -0
  3. package/dist/{classes → cjs/classes}/test/Contract/crv-abi.d.ts +0 -0
  4. package/dist/cjs/classes/test/Contract/crv-abi.js +488 -0
  5. package/dist/{classes → cjs/classes}/test/Contract/ens-abi.d.ts +0 -0
  6. package/dist/cjs/classes/test/Contract/ens-abi.js +453 -0
  7. package/dist/{classes → cjs/classes}/test/Contract/fei-abi.d.ts +0 -0
  8. package/dist/cjs/classes/test/Contract/fei-abi.js +526 -0
  9. package/dist/{classes → cjs/classes}/test/Contract/foo-abi.d.ts +0 -0
  10. package/dist/cjs/classes/test/Contract/foo-abi.js +42 -0
  11. package/dist/{classes → cjs/classes}/test/Contract/uniswap-abi.d.ts +0 -0
  12. package/dist/cjs/classes/test/Contract/uniswap-abi.js +121 -0
  13. package/dist/{classes → cjs/classes}/utils/clean-block.d.ts +0 -0
  14. package/dist/cjs/classes/utils/clean-block.js +160 -0
  15. package/dist/{classes → cjs/classes}/utils/clean-log.d.ts +0 -0
  16. package/dist/cjs/classes/utils/clean-log.js +37 -0
  17. package/dist/{classes → cjs/classes}/utils/clean-transaction-receipt.d.ts +0 -0
  18. package/dist/cjs/classes/utils/clean-transaction-receipt.js +50 -0
  19. package/dist/{classes → cjs/classes}/utils/clean-transaction.d.ts +0 -0
  20. package/dist/cjs/classes/utils/clean-transaction.js +51 -0
  21. package/dist/{classes → cjs/classes}/utils/encode-decode-transaction.d.ts +0 -0
  22. package/dist/cjs/classes/utils/encode-decode-transaction.js +137 -0
  23. package/dist/{classes → cjs/classes}/utils/fetchers.d.ts +0 -0
  24. package/dist/cjs/classes/utils/fetchers.js +81 -0
  25. package/dist/{classes → cjs/classes}/utils/hex-to-decimal.d.ts +0 -0
  26. package/dist/cjs/classes/utils/hex-to-decimal.js +24 -0
  27. package/dist/{classes → cjs/classes}/utils/prepare-transaction.d.ts +0 -0
  28. package/dist/cjs/classes/utils/prepare-transaction.js +45 -0
  29. package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  30. package/dist/cjs/index.js +54 -0
  31. package/dist/cjs/index.umd.js +2 -0
  32. package/dist/cjs/index.umd.js.map +1 -0
  33. package/dist/{logger → cjs/logger}/logger.d.ts +0 -0
  34. package/dist/cjs/logger/logger.js +36 -0
  35. package/dist/cjs/logger/package-version.d.ts +1 -0
  36. package/dist/cjs/logger/package-version.js +5 -0
  37. package/dist/{providers → cjs/providers}/BaseProvider.d.ts +0 -0
  38. package/dist/cjs/providers/BaseProvider.js +512 -0
  39. package/dist/{providers → cjs/providers}/FallthroughProvider.d.ts +0 -0
  40. package/dist/cjs/providers/FallthroughProvider.js +65 -0
  41. package/dist/{providers → cjs/providers}/JsonRpcProvider.d.ts +0 -0
  42. package/dist/cjs/providers/JsonRpcProvider.js +46 -0
  43. package/dist/{providers → cjs/providers}/test/rpc-urls.d.ts +0 -0
  44. package/dist/cjs/providers/test/rpc-urls.js +14 -0
  45. package/dist/{providers → cjs/providers}/utils/chains-info.d.ts +0 -0
  46. package/dist/cjs/providers/utils/chains-info.js +1402 -0
  47. package/dist/{shared → cjs/shared}/tiny-big/helpers.d.ts +0 -0
  48. package/dist/cjs/shared/tiny-big/helpers.js +97 -0
  49. package/dist/{shared → cjs/shared}/tiny-big/tiny-big.d.ts +0 -0
  50. package/dist/cjs/shared/tiny-big/tiny-big.js +101 -0
  51. package/dist/{shared → cjs/shared}/validate-type.d.ts +0 -0
  52. package/dist/cjs/shared/validate-type.js +9 -0
  53. package/dist/{types → cjs/types}/Block.types.d.ts +0 -0
  54. package/dist/cjs/types/Block.types.js +2 -0
  55. package/dist/{types → cjs/types}/Contract.types.d.ts +0 -0
  56. package/dist/cjs/types/Contract.types.js +2 -0
  57. package/dist/{types → cjs/types}/Filter.types.d.ts +0 -0
  58. package/dist/cjs/types/Filter.types.js +2 -0
  59. package/dist/{types → cjs/types}/Network.types.d.ts +0 -0
  60. package/dist/cjs/types/Network.types.js +2 -0
  61. package/dist/{types → cjs/types}/Transaction.types.d.ts +0 -0
  62. package/dist/cjs/types/Transaction.types.js +2 -0
  63. package/dist/{utils → cjs/utils}/bytes.d.ts +0 -0
  64. package/dist/cjs/utils/bytes.js +711 -0
  65. package/dist/{utils → cjs/utils}/compute-address.d.ts +0 -0
  66. package/dist/cjs/utils/compute-address.js +33 -0
  67. package/dist/{utils → cjs/utils}/compute-public-key.d.ts +0 -0
  68. package/dist/cjs/utils/compute-public-key.js +26 -0
  69. package/dist/{utils → cjs/utils}/ether-to-gwei.d.ts +0 -0
  70. package/dist/cjs/utils/ether-to-gwei.js +35 -0
  71. package/dist/{utils → cjs/utils}/ether-to-wei.d.ts +0 -0
  72. package/dist/cjs/utils/ether-to-wei.js +35 -0
  73. package/dist/{utils → cjs/utils}/gwei-to-ether.d.ts +0 -0
  74. package/dist/cjs/utils/gwei-to-ether.js +35 -0
  75. package/dist/{utils → cjs/utils}/hash-message.d.ts +0 -0
  76. package/dist/cjs/utils/hash-message.js +28 -0
  77. package/dist/{utils → cjs/utils}/is-address.d.ts +0 -0
  78. package/dist/cjs/utils/is-address.js +39 -0
  79. package/dist/{utils → cjs/utils}/keccak256.d.ts +0 -0
  80. package/dist/cjs/utils/keccak256.js +31 -0
  81. package/dist/{utils → cjs/utils}/solidity-keccak256.d.ts +0 -0
  82. package/dist/cjs/utils/solidity-keccak256.js +138 -0
  83. package/dist/{utils → cjs/utils}/split-signature.d.ts +0 -0
  84. package/dist/cjs/utils/split-signature.js +163 -0
  85. package/dist/{utils → cjs/utils}/to-checksum-address.d.ts +0 -0
  86. package/dist/cjs/utils/to-checksum-address.js +46 -0
  87. package/dist/{utils → cjs/utils}/to-utf8-bytes.d.ts +0 -0
  88. package/dist/cjs/utils/to-utf8-bytes.js +21 -0
  89. package/dist/{utils → cjs/utils}/wei-to-ether.d.ts +0 -0
  90. package/dist/cjs/utils/wei-to-ether.js +45 -0
  91. package/dist/esm/classes/Contract.d.ts +11 -0
  92. package/dist/esm/classes/Contract.js +65 -0
  93. package/dist/esm/classes/test/Contract/crv-abi.d.ts +2 -0
  94. package/dist/esm/classes/test/Contract/crv-abi.js +470 -0
  95. package/dist/esm/classes/test/Contract/ens-abi.d.ts +2 -0
  96. package/dist/esm/classes/test/Contract/ens-abi.js +435 -0
  97. package/dist/esm/classes/test/Contract/fei-abi.d.ts +2 -0
  98. package/dist/esm/classes/test/Contract/fei-abi.js +521 -0
  99. package/dist/esm/classes/test/Contract/foo-abi.d.ts +2 -0
  100. package/dist/esm/classes/test/Contract/foo-abi.js +33 -0
  101. package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +2 -0
  102. package/dist/esm/classes/test/Contract/uniswap-abi.js +116 -0
  103. package/dist/esm/classes/utils/clean-block.d.ts +3 -0
  104. package/dist/esm/classes/utils/clean-block.js +35 -0
  105. package/dist/esm/classes/utils/clean-log.d.ts +2 -0
  106. package/dist/esm/classes/utils/clean-log.js +26 -0
  107. package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +2 -0
  108. package/dist/esm/classes/utils/clean-transaction-receipt.js +34 -0
  109. package/dist/esm/classes/utils/clean-transaction.d.ts +2 -0
  110. package/dist/esm/classes/utils/clean-transaction.js +33 -0
  111. package/dist/esm/classes/utils/encode-decode-transaction.d.ts +4 -0
  112. package/dist/esm/classes/utils/encode-decode-transaction.js +98 -0
  113. package/dist/esm/classes/utils/fetchers.d.ts +9 -0
  114. package/dist/esm/classes/utils/fetchers.js +43 -0
  115. package/dist/esm/classes/utils/hex-to-decimal.d.ts +1 -0
  116. package/dist/esm/classes/utils/hex-to-decimal.js +3 -0
  117. package/dist/esm/classes/utils/prepare-transaction.d.ts +2 -0
  118. package/dist/esm/classes/utils/prepare-transaction.js +34 -0
  119. package/dist/esm/index.d.ts +25 -0
  120. package/dist/esm/index.js +20 -0
  121. package/dist/esm/logger/logger.d.ts +11 -0
  122. package/dist/esm/logger/logger.js +33 -0
  123. package/dist/esm/logger/package-version.d.ts +1 -0
  124. package/dist/esm/logger/package-version.js +1 -0
  125. package/dist/esm/providers/BaseProvider.d.ts +24 -0
  126. package/dist/esm/providers/BaseProvider.js +157 -0
  127. package/dist/esm/providers/FallthroughProvider.d.ts +11 -0
  128. package/dist/esm/providers/FallthroughProvider.js +41 -0
  129. package/dist/esm/providers/JsonRpcProvider.d.ts +7 -0
  130. package/dist/esm/providers/JsonRpcProvider.js +15 -0
  131. package/dist/esm/providers/test/rpc-urls.d.ts +11 -0
  132. package/dist/esm/providers/test/rpc-urls.js +11 -0
  133. package/dist/esm/providers/utils/chains-info.d.ts +467 -0
  134. package/dist/esm/providers/utils/chains-info.js +1398 -0
  135. package/dist/esm/shared/tiny-big/helpers.d.ts +1 -0
  136. package/dist/esm/shared/tiny-big/helpers.js +58 -0
  137. package/dist/esm/shared/tiny-big/tiny-big.d.ts +10 -0
  138. package/dist/esm/shared/tiny-big/tiny-big.js +45 -0
  139. package/dist/esm/shared/validate-type.d.ts +3 -0
  140. package/dist/esm/shared/validate-type.js +5 -0
  141. package/dist/esm/types/Block.types.d.ts +40 -0
  142. package/dist/esm/types/Block.types.js +1 -0
  143. package/dist/esm/types/Contract.types.d.ts +24 -0
  144. package/dist/esm/types/Contract.types.js +1 -0
  145. package/dist/esm/types/Filter.types.d.ts +12 -0
  146. package/dist/esm/types/Filter.types.js +1 -0
  147. package/dist/esm/types/Network.types.d.ts +5 -0
  148. package/dist/esm/types/Network.types.js +1 -0
  149. package/dist/esm/types/Transaction.types.d.ts +113 -0
  150. package/dist/esm/types/Transaction.types.js +1 -0
  151. package/dist/esm/utils/bytes.d.ts +40 -0
  152. package/dist/esm/utils/bytes.js +245 -0
  153. package/dist/esm/utils/compute-address.d.ts +1 -0
  154. package/dist/esm/utils/compute-address.js +11 -0
  155. package/dist/esm/utils/compute-public-key.d.ts +2 -0
  156. package/dist/esm/utils/compute-public-key.js +6 -0
  157. package/dist/esm/utils/ether-to-gwei.d.ts +3 -0
  158. package/dist/esm/utils/ether-to-gwei.js +7 -0
  159. package/dist/esm/utils/ether-to-wei.d.ts +3 -0
  160. package/dist/esm/utils/ether-to-wei.js +7 -0
  161. package/dist/esm/utils/gwei-to-ether.d.ts +3 -0
  162. package/dist/esm/utils/gwei-to-ether.js +7 -0
  163. package/dist/esm/utils/hash-message.d.ts +2 -0
  164. package/dist/esm/utils/hash-message.js +12 -0
  165. package/dist/esm/utils/is-address.d.ts +1 -0
  166. package/dist/esm/utils/is-address.js +12 -0
  167. package/dist/esm/utils/keccak256.d.ts +2 -0
  168. package/dist/esm/utils/keccak256.js +13 -0
  169. package/dist/esm/utils/solidity-keccak256.d.ts +2 -0
  170. package/dist/esm/utils/solidity-keccak256.js +85 -0
  171. package/dist/esm/utils/split-signature.d.ts +2 -0
  172. package/dist/esm/utils/split-signature.js +126 -0
  173. package/dist/esm/utils/to-checksum-address.d.ts +1 -0
  174. package/dist/esm/utils/to-checksum-address.js +25 -0
  175. package/dist/esm/utils/to-utf8-bytes.d.ts +1 -0
  176. package/dist/esm/utils/to-utf8-bytes.js +3 -0
  177. package/dist/esm/utils/wei-to-ether.d.ts +3 -0
  178. package/dist/esm/utils/wei-to-ether.js +16 -0
  179. package/package.json +10 -10
  180. package/readme.md +5 -1
  181. package/dist/index.js +0 -1904
  182. package/dist/index.js.map +0 -1
  183. package/dist/index.module.js +0 -1865
  184. package/dist/index.module.js.map +0 -1
  185. package/dist/index.umd.js +0 -2
  186. package/dist/index.umd.js.map +0 -1
  187. package/dist/logger/package-version.d.ts +0 -1
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scientificStrToDecimalStr = void 0;
4
+ /**
5
+ * Strips both leading and trailing zeroes from a number string
6
+ *
7
+ * @param numberString the string of numbers to strip zeros from
8
+ * @returns a string of numbers without leading or trailing zeros
9
+ * @example
10
+ * ```javascript
11
+ * stripTrailingZeros('0005280');
12
+ * // '5280'
13
+ * ```
14
+ */
15
+ function stripTrailingZeroes(numberString) {
16
+ const isNegative = numberString.startsWith('-');
17
+ numberString = numberString.replace('-', '');
18
+ numberString = numberString.replace(/\.0*$/g, '' /* for numbers like "1.0" -> "1" */);
19
+ numberString = numberString.replace(/^0+/, '');
20
+ // for numbers like "1.10" -> "1.1"
21
+ if (numberString.includes('.')) {
22
+ numberString = numberString.replace(/0+$/, '');
23
+ }
24
+ if (numberString.startsWith('.')) {
25
+ // so that ".1" returns as "0.1"
26
+ numberString = `0${numberString}`;
27
+ }
28
+ return `${isNegative ? '-' : ''}${numberString}`;
29
+ }
30
+ /**
31
+ * Converts a string in scientific notation formatting to string in decimal format
32
+ *
33
+ * @param scientificString a string in scientific format to convert to decimal
34
+ * @returns a string of a decimal number equivalent to the specified scientificString
35
+ * @example
36
+ * ```javascript
37
+ * scientificStrToDecimalStr('2.3e-5');
38
+ * // '0.000023'
39
+ * ```
40
+ * @example
41
+ * ```javascript
42
+ * scientificStrToDecimalStr('2.3e+5');
43
+ * // '230000'
44
+ * ```
45
+ */
46
+ function scientificStrToDecimalStr(scientificString) {
47
+ // Does not contain "e" nor "E"
48
+ if (!scientificString.match(/e/i /* lowercase and uppercase E */)) {
49
+ return stripTrailingZeroes(scientificString);
50
+ }
51
+ // eslint-disable-next-line prefer-const
52
+ let [base, power] = scientificString.split(/e/i /* lowercase and uppercase E */);
53
+ // remove the leading "-" if negative
54
+ const isNegative = Number(base) < 0;
55
+ base = base.replace('-', '');
56
+ base = stripTrailingZeroes(base);
57
+ const [wholeNumber, fraction /* move decimal this many places */ = ''] = base.split('.');
58
+ if (Number(power) === 0) {
59
+ return `${isNegative ? '-' : ''}${stripTrailingZeroes(base)}`;
60
+ }
61
+ else {
62
+ const includesDecimal = base.includes('.');
63
+ if (!includesDecimal) {
64
+ base = `${base}.`;
65
+ }
66
+ base = base.replace('.', '');
67
+ const baseLength = base.length;
68
+ let splitPaddedNumber;
69
+ if (Number(power) < 0) {
70
+ // move decimal left
71
+ if (wholeNumber.length < Math.abs(Number(power))) {
72
+ base = base.padStart(baseLength + Math.abs(Number(power)) - wholeNumber.length, '0');
73
+ }
74
+ splitPaddedNumber = base.split('');
75
+ if (wholeNumber.length < Math.abs(Number(power))) {
76
+ // starts with zeroes
77
+ splitPaddedNumber = ['.', ...splitPaddedNumber];
78
+ }
79
+ else {
80
+ splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
81
+ }
82
+ }
83
+ else {
84
+ // move decimal right
85
+ if (fraction.length < Math.abs(Number(power))) {
86
+ base = base.padEnd(baseLength + Math.abs(Number(power)) - fraction.length, '0');
87
+ }
88
+ splitPaddedNumber = base.split('');
89
+ if (fraction.length > Math.abs(Number(power))) {
90
+ splitPaddedNumber.splice(splitPaddedNumber.length - Math.abs(Number(power)), 0, '.');
91
+ }
92
+ }
93
+ const toReturn = stripTrailingZeroes(splitPaddedNumber.join(''));
94
+ return `${isNegative ? '-' : ''}${toReturn}`;
95
+ }
96
+ }
97
+ exports.scientificStrToDecimalStr = scientificStrToDecimalStr;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.tinyBig = exports.TinyBig = void 0;
7
+ const big_js_1 = __importDefault(require("big.js"));
8
+ const hex_to_decimal_1 = require("../../classes/utils/hex-to-decimal");
9
+ const helpers_1 = require("./helpers");
10
+ /**
11
+ * A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
12
+ * This is the return type of every operation on ether, wei, etc.
13
+ */
14
+ class TinyBig extends big_js_1.default {
15
+ constructor(value) {
16
+ if (typeof value === 'string' && value.startsWith('0x')) {
17
+ value = (0, hex_to_decimal_1.hexToDecimal)(value);
18
+ }
19
+ super(value);
20
+ /**
21
+ * Eithers pads or shortens a string to a specified length
22
+ *
23
+ * @param str the string to pad or chop
24
+ * @param padChar the character to pad the string with
25
+ * @param length the desired length of the given string
26
+ * @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
27
+ * @example
28
+ * ```javascript
29
+ * padAndChop('essential-eth', 'a', 8);
30
+ * // 'tial-eth'
31
+ * ```
32
+ * @example
33
+ * ```javascript
34
+ * padAndChop('essential-eth', 'A', 20);
35
+ * // 'AAAAAAAessential-eth'
36
+ * ```
37
+ */
38
+ this.padAndChop = (str, padChar, length) => {
39
+ return (Array(length).fill(padChar).join('') + str).slice(length * -1);
40
+ };
41
+ }
42
+ /**
43
+ * Used anytime you're passing in "value" to ethers or web3
44
+ * For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
45
+ *
46
+ * @returns the TinyBig represented as a hex string
47
+ * @example
48
+ * ```javascript
49
+ * tinyBig(293).toHexString();
50
+ * // '0x125'
51
+ * ```
52
+ * @example
53
+ * ```javascript
54
+ * tinyBig(681365874).toHexString();
55
+ * // '0x289cd172'
56
+ */
57
+ toHexString() {
58
+ return `0x${BigInt(this.toString()).toString(16)}`;
59
+ }
60
+ toNumber() {
61
+ return Number((0, helpers_1.scientificStrToDecimalStr)(super.toString()));
62
+ }
63
+ toString() {
64
+ if (this.toNumber() === 0) {
65
+ return '0';
66
+ }
67
+ return (0, helpers_1.scientificStrToDecimalStr)(super.toString());
68
+ }
69
+ toTwos(bitCount) {
70
+ let binaryStr;
71
+ if (this.gte(0)) {
72
+ const twosComp = this.toNumber().toString(2);
73
+ binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
74
+ }
75
+ else {
76
+ binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
77
+ if (Number(binaryStr) < 0) {
78
+ throw new Error('Cannot calculate twos complement');
79
+ }
80
+ }
81
+ const binary = `0b${binaryStr}`;
82
+ const decimal = Number(binary);
83
+ return tinyBig(decimal);
84
+ }
85
+ }
86
+ exports.TinyBig = TinyBig;
87
+ /**
88
+ * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
89
+ *
90
+ * @param value the value to initiate the TinyBig with
91
+ * @returns an initiated {@link TinyBig}
92
+ * @example
93
+ * ```javascript
94
+ * tinyBig(10).times(3).toNumber()
95
+ * // 30
96
+ * ```
97
+ */
98
+ function tinyBig(value) {
99
+ return new TinyBig(value);
100
+ }
101
+ exports.tinyBig = tinyBig;
File without changes
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateType = void 0;
4
+ const validateType = (value, allowedTypes) => {
5
+ if (!allowedTypes.includes(typeof value)) {
6
+ throw new Error(`${allowedTypes.join(' or ')} required. Received ${typeof value}`);
7
+ }
8
+ };
9
+ exports.validateType = validateType;
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
File without changes