essential-eth 0.5.4 → 0.5.9

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 (98) hide show
  1. package/lib/cjs/classes/Contract.d.ts +10 -4
  2. package/lib/cjs/classes/Contract.js +15 -4
  3. package/lib/cjs/classes/utils/clean-block.d.ts +115 -0
  4. package/lib/cjs/classes/utils/clean-block.js +122 -9
  5. package/lib/cjs/classes/utils/clean-log.d.ts +9 -0
  6. package/lib/cjs/classes/utils/clean-log.js +37 -0
  7. package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +9 -0
  8. package/lib/cjs/classes/utils/clean-transaction-receipt.js +11 -16
  9. package/lib/cjs/classes/utils/clean-transaction.d.ts +9 -0
  10. package/lib/cjs/classes/utils/clean-transaction.js +10 -1
  11. package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +12 -0
  12. package/lib/cjs/classes/utils/encode-decode-transaction.js +24 -0
  13. package/lib/cjs/classes/utils/fetchers.d.ts +31 -1
  14. package/lib/cjs/classes/utils/fetchers.js +30 -0
  15. package/lib/cjs/classes/utils/hex-to-decimal.d.ts +14 -1
  16. package/lib/cjs/classes/utils/hex-to-decimal.js +14 -1
  17. package/lib/cjs/classes/utils/prepare-transaction.d.ts +6 -0
  18. package/lib/cjs/classes/utils/prepare-transaction.js +45 -0
  19. package/lib/cjs/index.d.ts +10 -5
  20. package/lib/cjs/index.js +10 -2
  21. package/lib/cjs/logger/package-version.d.ts +1 -1
  22. package/lib/cjs/logger/package-version.js +1 -1
  23. package/lib/cjs/providers/BaseProvider.d.ts +282 -199
  24. package/lib/cjs/providers/BaseProvider.js +365 -214
  25. package/lib/cjs/providers/FallthroughProvider.d.ts +1 -2
  26. package/lib/cjs/providers/JsonRpcProvider.d.ts +6 -0
  27. package/lib/cjs/providers/JsonRpcProvider.js +6 -0
  28. package/lib/cjs/providers/utils/chains-info.d.ts +27 -0
  29. package/lib/cjs/providers/utils/chains-info.js +84 -3
  30. package/lib/cjs/shared/tiny-big/helpers.d.ts +16 -0
  31. package/lib/cjs/shared/tiny-big/helpers.js +27 -1
  32. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +30 -4
  33. package/lib/cjs/shared/tiny-big/tiny-big.js +34 -4
  34. package/lib/cjs/types/Block.types.d.ts +11 -7
  35. package/lib/cjs/types/Filter.types.d.ts +16 -0
  36. package/lib/cjs/types/Filter.types.js +2 -0
  37. package/lib/cjs/types/Transaction.types.d.ts +33 -6
  38. package/lib/cjs/utils/bytes.d.ts +150 -33
  39. package/lib/cjs/utils/bytes.js +179 -32
  40. package/lib/cjs/utils/compute-address.d.ts +17 -0
  41. package/lib/cjs/utils/compute-address.js +33 -0
  42. package/lib/cjs/utils/compute-public-key.d.ts +18 -0
  43. package/lib/cjs/utils/compute-public-key.js +26 -0
  44. package/lib/cjs/utils/ether-to-gwei.d.ts +2 -1
  45. package/lib/cjs/utils/ether-to-gwei.js +2 -1
  46. package/lib/cjs/utils/ether-to-wei.d.ts +2 -1
  47. package/lib/cjs/utils/ether-to-wei.js +2 -1
  48. package/lib/cjs/utils/gwei-to-ether.d.ts +2 -1
  49. package/lib/cjs/utils/gwei-to-ether.js +2 -1
  50. package/lib/cjs/utils/hash-message.d.ts +3 -1
  51. package/lib/cjs/utils/hash-message.js +3 -1
  52. package/lib/cjs/utils/is-address.d.ts +2 -2
  53. package/lib/cjs/utils/is-address.js +2 -2
  54. package/lib/cjs/utils/keccak256.d.ts +15 -1
  55. package/lib/cjs/utils/keccak256.js +16 -2
  56. package/lib/cjs/utils/solidity-keccak256.d.ts +17 -7
  57. package/lib/cjs/utils/solidity-keccak256.js +27 -7
  58. package/lib/cjs/utils/split-signature.d.ts +24 -0
  59. package/lib/cjs/utils/split-signature.js +163 -0
  60. package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
  61. package/lib/cjs/utils/to-checksum-address.js +2 -2
  62. package/lib/cjs/utils/to-utf8-bytes.d.ts +14 -0
  63. package/lib/cjs/utils/to-utf8-bytes.js +14 -0
  64. package/lib/cjs/utils/wei-to-ether.d.ts +2 -1
  65. package/lib/cjs/utils/wei-to-ether.js +14 -3
  66. package/lib/esm/classes/utils/clean-block.js +7 -8
  67. package/lib/esm/classes/utils/clean-log.d.ts +2 -0
  68. package/lib/esm/classes/utils/clean-log.js +26 -0
  69. package/lib/esm/classes/utils/clean-transaction-receipt.js +2 -16
  70. package/lib/esm/classes/utils/clean-transaction.js +1 -1
  71. package/lib/esm/classes/utils/fetchers.d.ts +1 -1
  72. package/lib/esm/classes/utils/prepare-transaction.d.ts +2 -0
  73. package/lib/esm/classes/utils/prepare-transaction.js +34 -0
  74. package/lib/esm/index.d.ts +10 -5
  75. package/lib/esm/index.js +7 -3
  76. package/lib/esm/logger/package-version.d.ts +1 -1
  77. package/lib/esm/logger/package-version.js +1 -1
  78. package/lib/esm/providers/BaseProvider.d.ts +7 -1
  79. package/lib/esm/providers/BaseProvider.js +67 -11
  80. package/lib/esm/providers/FallthroughProvider.d.ts +1 -2
  81. package/lib/esm/providers/utils/chains-info.d.ts +27 -0
  82. package/lib/esm/providers/utils/chains-info.js +84 -3
  83. package/lib/esm/shared/tiny-big/tiny-big.js +4 -0
  84. package/lib/esm/types/Block.types.d.ts +11 -7
  85. package/lib/esm/types/Filter.types.d.ts +12 -0
  86. package/lib/esm/types/Filter.types.js +1 -0
  87. package/lib/esm/types/Transaction.types.d.ts +31 -5
  88. package/lib/esm/utils/compute-address.d.ts +1 -0
  89. package/lib/esm/utils/compute-address.js +11 -0
  90. package/lib/esm/utils/compute-public-key.d.ts +2 -0
  91. package/lib/esm/utils/compute-public-key.js +6 -0
  92. package/lib/esm/utils/keccak256.d.ts +1 -1
  93. package/lib/esm/utils/keccak256.js +2 -2
  94. package/lib/esm/utils/split-signature.d.ts +2 -0
  95. package/lib/esm/utils/split-signature.js +126 -0
  96. package/lib/esm/utils/wei-to-ether.js +11 -2
  97. package/package.json +38 -11
  98. package/readme.md +1209 -335
@@ -1,5 +1,5 @@
1
1
  import { BaseProvider } from './BaseProvider';
2
- interface ConstructorOptions {
2
+ export interface ConstructorOptions {
3
3
  timeoutDuration?: number;
4
4
  }
5
5
  /**
@@ -22,4 +22,3 @@ export declare class FallthroughProvider extends BaseProvider {
22
22
  */
23
23
  post: (body: Record<string, unknown>) => Promise<any>;
24
24
  }
25
- export {};
@@ -10,12 +10,18 @@ export declare class JsonRpcProvider extends BaseProvider {
10
10
  post(body: Record<string, unknown>): Promise<any>;
11
11
  /**
12
12
  * @param rpcUrl The URL to your Eth node. Consider POKT or Infura
13
+ * @example
14
+ * `https://free-eth-node.com/api/eth`
15
+ * @example
16
+ * `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
13
17
  */
14
18
  constructor(rpcUrl?: string);
15
19
  }
16
20
  /**
17
21
  * Helper function to avoid "new"
18
22
  *
23
+ * @param rpcUrl the RPC URL to post requests to
24
+ * @returns an initiated {@link JsonRpcProvider}
19
25
  * @example
20
26
  * ```javascript
21
27
  * jsonRpcProvider().getBlock('latest').then(block => {
@@ -17,6 +17,10 @@ class JsonRpcProvider extends BaseProvider_1.BaseProvider {
17
17
  }
18
18
  /**
19
19
  * @param rpcUrl The URL to your Eth node. Consider POKT or Infura
20
+ * @example
21
+ * `https://free-eth-node.com/api/eth`
22
+ * @example
23
+ * `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
20
24
  */
21
25
  constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
22
26
  super([rpcUrl]);
@@ -26,6 +30,8 @@ exports.JsonRpcProvider = JsonRpcProvider;
26
30
  /**
27
31
  * Helper function to avoid "new"
28
32
  *
33
+ * @param rpcUrl the RPC URL to post requests to
34
+ * @returns an initiated {@link JsonRpcProvider}
29
35
  * @example
30
36
  * ```javascript
31
37
  * jsonRpcProvider().getBlock('latest').then(block => {
@@ -119,6 +119,7 @@ declare const _default: {
119
119
  "222": string[];
120
120
  "225": string[];
121
121
  "226": string[];
122
+ "239": string[];
122
123
  "246": string[];
123
124
  "250": string[];
124
125
  "256": string[];
@@ -143,10 +144,14 @@ declare const _default: {
143
144
  "499": string[];
144
145
  "512": string[];
145
146
  "513": string[];
147
+ "534": string[];
146
148
  "555": string[];
147
149
  "558": string[];
148
150
  "588": string[];
151
+ "592": string[];
149
152
  "595": string[];
153
+ "596": string[];
154
+ "597": string[];
150
155
  "600": string[];
151
156
  "666": string[];
152
157
  "686": string[];
@@ -154,6 +159,7 @@ declare const _default: {
154
159
  "707": string[];
155
160
  "708": string[];
156
161
  "721": string[];
162
+ "776": string[];
157
163
  "777": string[];
158
164
  "787": string[];
159
165
  "788": string[];
@@ -197,18 +203,24 @@ declare const _default: {
197
203
  "1287": string[];
198
204
  "1288": string[];
199
205
  "1337": string[];
206
+ "1506": string[];
207
+ "1507": string[];
200
208
  "1618": string[];
201
209
  "1620": string[];
202
210
  "1657": string[];
203
211
  "1688": string[];
212
+ "1819": string[];
204
213
  "1856": string[];
205
214
  "1898": string[];
206
215
  "1984": string[];
207
216
  "1987": string[];
208
217
  "2001": string[];
218
+ "2008": string[];
219
+ "2009": string[];
209
220
  "2020": string[];
210
221
  "2021": string[];
211
222
  "2022": string[];
223
+ "2023": string[];
212
224
  "2025": string[];
213
225
  "2100": string[];
214
226
  "2101": string[];
@@ -219,6 +231,8 @@ declare const _default: {
219
231
  "2223": string[];
220
232
  "2559": string[];
221
233
  "2569": string[];
234
+ "2612": string[];
235
+ "2613": string[];
222
236
  "3000": string[];
223
237
  "3001": string[];
224
238
  "3331": string[];
@@ -231,6 +245,7 @@ declare const _default: {
231
245
  "3967": string[];
232
246
  "4002": string[];
233
247
  "4102": string[];
248
+ "4181": string[];
234
249
  "4689": string[];
235
250
  "4690": string[];
236
251
  "4918": string[];
@@ -254,6 +269,7 @@ declare const _default: {
254
269
  "8723": string[];
255
270
  "8724": string[];
256
271
  "8888": string[];
272
+ "8898": string[];
257
273
  "8995": string[];
258
274
  "9000": string[];
259
275
  "9001": string[];
@@ -264,6 +280,8 @@ declare const _default: {
264
280
  "10001": string[];
265
281
  "10101": string[];
266
282
  "10823": string[];
283
+ "10946": string[];
284
+ "10947": string[];
267
285
  "11111": string[];
268
286
  "11437": string[];
269
287
  "12051": string[];
@@ -274,10 +292,14 @@ declare const _default: {
274
292
  "19845": string[];
275
293
  "21337": string[];
276
294
  "21816": string[];
295
+ "22023": string[];
277
296
  "24484": string[];
278
297
  "24734": string[];
298
+ "26863": string[];
299
+ "30067": string[];
279
300
  "31102": string[];
280
301
  "31337": string[];
302
+ "32520": string[];
281
303
  "32659": string[];
282
304
  "39797": string[];
283
305
  "42069": string[];
@@ -309,6 +331,8 @@ declare const _default: {
309
331
  "70002": string[];
310
332
  "70103": string[];
311
333
  "71393": string[];
334
+ "71401": string[];
335
+ "71402": string[];
312
336
  "73799": string[];
313
337
  "78110": string[];
314
338
  "80001": string[];
@@ -345,7 +369,9 @@ declare const _default: {
345
369
  "333888": string[];
346
370
  "333999": string[];
347
371
  "421611": string[];
372
+ "432201": string[];
348
373
  "444900": string[];
374
+ "474142": string[];
349
375
  "512512": string[];
350
376
  "666666": string[];
351
377
  "888888": string[];
@@ -353,6 +379,7 @@ declare const _default: {
353
379
  "1313114": string[];
354
380
  "1313500": string[];
355
381
  "1337702": string[];
382
+ "1337802": string[];
356
383
  "2203181": string[];
357
384
  "7762959": string[];
358
385
  "11155111": string[];
@@ -367,6 +367,9 @@ exports.default = {
367
367
  "226": [
368
368
  "TLA"
369
369
  ],
370
+ "239": [
371
+ "AITD"
372
+ ],
370
373
  "246": [
371
374
  "ewt"
372
375
  ],
@@ -439,6 +442,9 @@ exports.default = {
439
442
  "513": [
440
443
  "aact"
441
444
  ],
445
+ "534": [
446
+ "CNDL"
447
+ ],
442
448
  "555": [
443
449
  "CLASS"
444
450
  ],
@@ -448,9 +454,18 @@ exports.default = {
448
454
  "588": [
449
455
  "metis-stardust"
450
456
  ],
457
+ "592": [
458
+ "astr"
459
+ ],
451
460
  "595": [
452
461
  "maca"
453
462
  ],
463
+ "596": [
464
+ "tkar"
465
+ ],
466
+ "597": [
467
+ "taca"
468
+ ],
454
469
  "600": [
455
470
  "mesh-chain-testnet"
456
471
  ],
@@ -472,6 +487,9 @@ exports.default = {
472
487
  "721": [
473
488
  "tfeth"
474
489
  ],
490
+ "776": [
491
+ "opc"
492
+ ],
475
493
  "777": [
476
494
  "cth"
477
495
  ],
@@ -601,6 +619,12 @@ exports.default = {
601
619
  "1337": [
602
620
  "cennz-old"
603
621
  ],
622
+ "1506": [
623
+ "Sherpax"
624
+ ],
625
+ "1507": [
626
+ "Sherpax Testnet"
627
+ ],
604
628
  "1618": [
605
629
  "cate"
606
630
  ],
@@ -613,6 +637,9 @@ exports.default = {
613
637
  "1688": [
614
638
  "LUDAN"
615
639
  ],
640
+ "1819": [
641
+ "cubet"
642
+ ],
616
643
  "1856": [
617
644
  "tsf"
618
645
  ],
@@ -628,6 +655,12 @@ exports.default = {
628
655
  "2001": [
629
656
  "milkAda"
630
657
  ],
658
+ "2008": [
659
+ "cloudwalk_testnet"
660
+ ],
661
+ "2009": [
662
+ "cloudwalk_mainnet"
663
+ ],
631
664
  "2020": [
632
665
  "420"
633
666
  ],
@@ -637,6 +670,9 @@ exports.default = {
637
670
  "2022": [
638
671
  "edgt"
639
672
  ],
673
+ "2023": [
674
+ "taycan-testnet"
675
+ ],
640
676
  "2025": [
641
677
  "rpg"
642
678
  ],
@@ -667,6 +703,12 @@ exports.default = {
667
703
  "2569": [
668
704
  "tpc"
669
705
  ],
706
+ "2612": [
707
+ "EZChain"
708
+ ],
709
+ "2613": [
710
+ "Fuji-EZChain"
711
+ ],
670
712
  "3000": [
671
713
  "cennz-r"
672
714
  ],
@@ -703,6 +745,9 @@ exports.default = {
703
745
  "4102": [
704
746
  "aioz-testnet"
705
747
  ],
748
+ "4181": [
749
+ "PHI"
750
+ ],
706
751
  "4689": [
707
752
  "iotex-mainnet"
708
753
  ],
@@ -772,6 +817,9 @@ exports.default = {
772
817
  "8888": [
773
818
  "ambrostestnet"
774
819
  ],
820
+ "8898": [
821
+ "mmt"
822
+ ],
775
823
  "8995": [
776
824
  "berg"
777
825
  ],
@@ -802,6 +850,12 @@ exports.default = {
802
850
  "10823": [
803
851
  "CCP"
804
852
  ],
853
+ "10946": [
854
+ "quadrans"
855
+ ],
856
+ "10947": [
857
+ "quadranstestnet"
858
+ ],
805
859
  "11111": [
806
860
  "WAGMI"
807
861
  ],
@@ -830,7 +884,10 @@ exports.default = {
830
884
  "cennz-a"
831
885
  ],
832
886
  "21816": [
833
- "oml"
887
+ "omc"
888
+ ],
889
+ "22023": [
890
+ "SFL"
834
891
  ],
835
892
  "24484": [
836
893
  "web"
@@ -838,12 +895,21 @@ exports.default = {
838
895
  "24734": [
839
896
  "mintme"
840
897
  ],
898
+ "26863": [
899
+ "OAC"
900
+ ],
901
+ "30067": [
902
+ "Piece"
903
+ ],
841
904
  "31102": [
842
905
  "esn"
843
906
  ],
844
907
  "31337": [
845
908
  "got"
846
909
  ],
910
+ "32520": [
911
+ "Brise"
912
+ ],
847
913
  "32659": [
848
914
  "fsn"
849
915
  ],
@@ -878,7 +944,7 @@ exports.default = {
878
944
  "ALFA"
879
945
  ],
880
946
  "45000": [
881
- "autobahn"
947
+ "Autobahn Network"
882
948
  ],
883
949
  "47805": [
884
950
  "REI"
@@ -937,6 +1003,12 @@ exports.default = {
937
1003
  "71393": [
938
1004
  "ckb"
939
1005
  ],
1006
+ "71401": [
1007
+ "gw-testnet-v1"
1008
+ ],
1009
+ "71402": [
1010
+ "gw-mainnet-v1"
1011
+ ],
940
1012
  "73799": [
941
1013
  "vt"
942
1014
  ],
@@ -1045,9 +1117,15 @@ exports.default = {
1045
1117
  "421611": [
1046
1118
  "arb-rinkeby"
1047
1119
  ],
1120
+ "432201": [
1121
+ "Dexalot"
1122
+ ],
1048
1123
  "444900": [
1049
1124
  "wlkt"
1050
1125
  ],
1126
+ "474142": [
1127
+ "oc"
1128
+ ],
1051
1129
  "512512": [
1052
1130
  "cmp"
1053
1131
  ],
@@ -1069,6 +1147,9 @@ exports.default = {
1069
1147
  "1337702": [
1070
1148
  "kintsugi"
1071
1149
  ],
1150
+ "1337802": [
1151
+ "kiln"
1152
+ ],
1072
1153
  "2203181": [
1073
1154
  "platondev"
1074
1155
  ],
@@ -1184,6 +1265,6 @@ exports.default = {
1184
1265
  "mole"
1185
1266
  ],
1186
1267
  "868455272153094": [
1187
- "gw-testnet-v1"
1268
+ "gw-testnet-v1-deprecated"
1188
1269
  ]
1189
1270
  };
@@ -1 +1,17 @@
1
+ /**
2
+ * Converts a string in scientific notation formatting to string in decimal format
3
+ *
4
+ * @param scientificString a string in scientific format to convert to decimal
5
+ * @returns a string of a decimal number equivalent to the specified scientificString
6
+ * @example
7
+ * ```javascript
8
+ * scientificStrToDecimalStr('2.3e-5');
9
+ * // '0.000023'
10
+ * ```
11
+ * @example
12
+ * ```javascript
13
+ * scientificStrToDecimalStr('2.3e+5');
14
+ * // '230000'
15
+ * ```
16
+ */
1
17
  export declare function scientificStrToDecimalStr(scientificString: string): string;
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scientificStrToDecimalStr = void 0;
4
- // strips both leading and trailing zeroes
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
+ */
5
15
  function stripTrailingZeroes(numberString) {
6
16
  const isNegative = numberString.startsWith('-');
7
17
  numberString = numberString.replace('-', '');
@@ -17,6 +27,22 @@ function stripTrailingZeroes(numberString) {
17
27
  }
18
28
  return `${isNegative ? '-' : ''}${numberString}`;
19
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
+ */
20
46
  function scientificStrToDecimalStr(scientificString) {
21
47
  // Does not contain "e" nor "E"
22
48
  if (!scientificString.match(/e/i /* lowercase and uppercase E */)) {
@@ -1,21 +1,45 @@
1
1
  import Big from 'big.js';
2
2
  /**
3
3
  * A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
4
- * * This is the return type of every operation on ether, wei, etc.
4
+ * This is the return type of every operation on ether, wei, etc.
5
5
  */
6
6
  export declare class TinyBig extends Big {
7
7
  constructor(value: string | number | TinyBig | Big);
8
8
  /**
9
9
  * Used anytime you're passing in "value" to ethers or web3
10
10
  * For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
11
+ *
12
+ * @returns the TinyBig represented as a hex string
13
+ * @example
14
+ * ```javascript
15
+ * tinyBig(293).toHexString();
16
+ * // '0x125'
17
+ * ```
18
+ * @example
19
+ * ```javascript
20
+ * tinyBig(681365874).toHexString();
21
+ * // '0x289cd172'
11
22
  */
12
23
  toHexString(): string;
13
24
  toNumber(): number;
14
25
  toString(): string;
15
26
  /**
16
- * @param {String} str
17
- * @param {String} padChar
18
- * @param {Number} length
27
+ * Eithers pads or shortens a string to a specified length
28
+ *
29
+ * @param str the string to pad or chop
30
+ * @param padChar the character to pad the string with
31
+ * @param length the desired length of the given string
32
+ * @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
33
+ * @example
34
+ * ```javascript
35
+ * padAndChop('essential-eth', 'a', 8);
36
+ * // 'tial-eth'
37
+ * ```
38
+ * @example
39
+ * ```javascript
40
+ * padAndChop('essential-eth', 'A', 20);
41
+ * // 'AAAAAAAessential-eth'
42
+ * ```
19
43
  */
20
44
  private padAndChop;
21
45
  toTwos(bitCount: number): Big;
@@ -23,6 +47,8 @@ export declare class TinyBig extends Big {
23
47
  /**
24
48
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
25
49
  *
50
+ * @param value the value to initiate the TinyBig with
51
+ * @returns an initiated {@link TinyBig}
26
52
  * @example
27
53
  * ```javascript
28
54
  * tinyBig(10).times(3).toNumber()
@@ -5,18 +5,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.tinyBig = exports.TinyBig = void 0;
7
7
  const big_js_1 = __importDefault(require("big.js"));
8
+ const hex_to_decimal_1 = require("../../classes/utils/hex-to-decimal");
8
9
  const helpers_1 = require("./helpers");
9
10
  /**
10
11
  * A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
11
- * * This is the return type of every operation on ether, wei, etc.
12
+ * This is the return type of every operation on ether, wei, etc.
12
13
  */
13
14
  class TinyBig extends big_js_1.default {
14
15
  constructor(value) {
16
+ if (typeof value === 'string' && value.startsWith('0x')) {
17
+ value = (0, hex_to_decimal_1.hexToDecimal)(value);
18
+ }
15
19
  super(value);
16
20
  /**
17
- * @param {String} str
18
- * @param {String} padChar
19
- * @param {Number} length
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
+ * ```
20
37
  */
21
38
  this.padAndChop = (str, padChar, length) => {
22
39
  return (Array(length).fill(padChar).join('') + str).slice(length * -1);
@@ -25,6 +42,17 @@ class TinyBig extends big_js_1.default {
25
42
  /**
26
43
  * Used anytime you're passing in "value" to ethers or web3
27
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'
28
56
  */
29
57
  toHexString() {
30
58
  return `0x${BigInt(this.toString()).toString(16)}`;
@@ -59,6 +87,8 @@ exports.TinyBig = TinyBig;
59
87
  /**
60
88
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
61
89
  *
90
+ * @param value the value to initiate the TinyBig with
91
+ * @returns an initiated {@link TinyBig}
62
92
  * @example
63
93
  * ```javascript
64
94
  * tinyBig(10).times(3).toNumber()
@@ -1,12 +1,16 @@
1
+ import { TinyBig } from './../shared/tiny-big/tiny-big';
1
2
  import { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
2
3
  declare type Modify<T, R> = Omit<T, keyof R> & R;
3
4
  export declare type BlockResponse = Modify<RPCBlock, {
4
- gasLimit: number;
5
- gasUsed: number;
5
+ baseFeePerGas: TinyBig;
6
+ difficulty: TinyBig;
7
+ gasLimit: TinyBig;
8
+ gasUsed: TinyBig;
9
+ nonce: TinyBig;
6
10
  number: number;
7
- size: number;
8
- timestamp: number;
9
- baseFeePerGas: number;
11
+ size: TinyBig;
12
+ timestamp: TinyBig;
13
+ totalDifficulty: TinyBig;
10
14
  transactions: Array<string | BlockTransactionResponse>;
11
15
  }>;
12
16
  /** Exact response from backend */
@@ -29,9 +33,9 @@ export interface RPCBlock {
29
33
  stateRoot: string;
30
34
  timestamp: string;
31
35
  totalDifficulty: string;
32
- transactions: Array<string> | Array<RPCTransaction>;
36
+ transactions: Array<string | RPCTransaction>;
33
37
  transactionsRoot: string;
34
- uncles: unknown[];
38
+ uncles: Array<string>;
35
39
  }
36
40
  export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
37
41
  export {};
@@ -0,0 +1,16 @@
1
+ import { BlockTag } from './Block.types';
2
+ export interface EventFilter {
3
+ address?: string;
4
+ topics?: Array<string | Array<string> | null>;
5
+ }
6
+ /**
7
+ * @param fromBlock block as starting point for range, inclusive
8
+ * @param toBlock block as ending point for range, inclusive
9
+ */
10
+ export interface Filter extends EventFilter {
11
+ fromBlock?: BlockTag;
12
+ toBlock?: BlockTag;
13
+ }
14
+ export interface FilterByBlockHash extends EventFilter {
15
+ blockHash?: string;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });