essential-eth 0.4.9 → 0.5.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 (56) hide show
  1. package/lib/cjs/classes/utils/clean-block.d.ts +3 -3
  2. package/lib/cjs/classes/utils/clean-block.js +3 -2
  3. package/lib/cjs/classes/utils/clean-transaction.d.ts +3 -3
  4. package/lib/cjs/classes/utils/clean-transaction.js +10 -6
  5. package/lib/cjs/classes/utils/fetchers.d.ts +3 -3
  6. package/lib/cjs/index.d.ts +6 -3
  7. package/lib/cjs/index.js +7 -1
  8. package/lib/cjs/providers/JsonRpcProvider.d.ts +198 -3
  9. package/lib/cjs/providers/JsonRpcProvider.js +222 -19
  10. package/lib/cjs/providers/test/rpc-urls.d.ts +7 -0
  11. package/lib/cjs/providers/test/rpc-urls.js +8 -1
  12. package/lib/cjs/providers/utils/chains-info.d.ts +10 -0
  13. package/lib/cjs/providers/utils/chains-info.js +31 -1
  14. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +6 -0
  15. package/lib/cjs/shared/tiny-big/tiny-big.js +13 -1
  16. package/lib/cjs/types/Block.types.d.ts +9 -19
  17. package/lib/cjs/types/Transaction.types.d.ts +23 -14
  18. package/lib/cjs/utils/ether-to-gwei.d.ts +26 -0
  19. package/lib/cjs/utils/ether-to-gwei.js +34 -0
  20. package/lib/cjs/utils/ether-to-wei.d.ts +4 -2
  21. package/lib/cjs/utils/ether-to-wei.js +4 -2
  22. package/lib/cjs/utils/gwei-to-ether.d.ts +26 -0
  23. package/lib/cjs/utils/gwei-to-ether.js +34 -0
  24. package/lib/cjs/utils/hex-zero-pad.d.ts +32 -0
  25. package/lib/cjs/utils/hex-zero-pad.js +52 -0
  26. package/lib/cjs/utils/is-address.d.ts +19 -0
  27. package/lib/cjs/utils/is-address.js +19 -0
  28. package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
  29. package/lib/cjs/utils/to-checksum-address.js +2 -2
  30. package/lib/cjs/utils/wei-to-ether.d.ts +12 -12
  31. package/lib/cjs/utils/wei-to-ether.js +11 -11
  32. package/lib/esm/classes/utils/clean-block.d.ts +2 -2
  33. package/lib/esm/classes/utils/clean-block.js +2 -1
  34. package/lib/esm/classes/utils/clean-transaction.d.ts +2 -2
  35. package/lib/esm/classes/utils/clean-transaction.js +10 -6
  36. package/lib/esm/classes/utils/fetchers.d.ts +3 -3
  37. package/lib/esm/index.d.ts +6 -3
  38. package/lib/esm/index.js +4 -1
  39. package/lib/esm/providers/JsonRpcProvider.d.ts +6 -2
  40. package/lib/esm/providers/JsonRpcProvider.js +29 -18
  41. package/lib/esm/providers/test/rpc-urls.d.ts +7 -0
  42. package/lib/esm/providers/test/rpc-urls.js +7 -0
  43. package/lib/esm/providers/utils/chains-info.d.ts +10 -0
  44. package/lib/esm/providers/utils/chains-info.js +31 -1
  45. package/lib/esm/shared/tiny-big/tiny-big.js +7 -1
  46. package/lib/esm/types/Block.types.d.ts +8 -19
  47. package/lib/esm/types/Transaction.types.d.ts +22 -14
  48. package/lib/esm/utils/ether-to-gwei.d.ts +3 -0
  49. package/lib/esm/utils/ether-to-gwei.js +7 -0
  50. package/lib/esm/utils/gwei-to-ether.d.ts +3 -0
  51. package/lib/esm/utils/gwei-to-ether.js +7 -0
  52. package/lib/esm/utils/hex-zero-pad.d.ts +1 -0
  53. package/lib/esm/utils/hex-zero-pad.js +17 -0
  54. package/lib/esm/utils/wei-to-ether.d.ts +1 -1
  55. package/package.json +7 -7
  56. package/readme.md +302 -62
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fakeUrls = void 0;
3
+ exports.rpcUrls = exports.fakeUrls = void 0;
4
4
  exports.fakeUrls = {
5
5
  notRPCButRealHttp: 'https://httpstat.us/200',
6
6
  };
7
+ exports.rpcUrls = {
8
+ mainnet: `${process.env.RPC_ORIGIN}/api/eth`,
9
+ gno: `${process.env.RPC_ORIGIN}/api/gno`,
10
+ bnb: `${process.env.RPC_ORIGIN}/api/bnb`,
11
+ arb1: `${process.env.RPC_ORIGIN}/api/arb1`,
12
+ gor: `${process.env.RPC_ORIGIN}/api/gor`,
13
+ };
@@ -66,7 +66,9 @@ declare const _default: {
66
66
  "76": string[];
67
67
  "77": string[];
68
68
  "78": string[];
69
+ "79": string[];
69
70
  "80": string[];
71
+ "81": string[];
70
72
  "82": string[];
71
73
  "83": string[];
72
74
  "85": string[];
@@ -123,6 +125,7 @@ declare const _default: {
123
125
  "262": string[];
124
126
  "269": string[];
125
127
  "288": string[];
128
+ "300": string[];
126
129
  "321": string[];
127
130
  "322": string[];
128
131
  "333": string[];
@@ -146,6 +149,7 @@ declare const _default: {
146
149
  "600": string[];
147
150
  "666": string[];
148
151
  "686": string[];
152
+ "700": string[];
149
153
  "707": string[];
150
154
  "708": string[];
151
155
  "721": string[];
@@ -169,6 +173,7 @@ declare const _default: {
169
173
  "999": string[];
170
174
  "1001": string[];
171
175
  "1007": string[];
176
+ "1008": string[];
172
177
  "1010": string[];
173
178
  "1012": string[];
174
179
  "1022": string[];
@@ -197,6 +202,7 @@ declare const _default: {
197
202
  "1688": string[];
198
203
  "1856": string[];
199
204
  "1898": string[];
205
+ "1984": string[];
200
206
  "1987": string[];
201
207
  "2001": string[];
202
208
  "2020": string[];
@@ -205,6 +211,8 @@ declare const _default: {
205
211
  "2025": string[];
206
212
  "2100": string[];
207
213
  "2101": string[];
214
+ "2152": string[];
215
+ "2153": string[];
208
216
  "2213": string[];
209
217
  "2221": string[];
210
218
  "2559": string[];
@@ -259,6 +267,7 @@ declare const _default: {
259
267
  "16000": string[];
260
268
  "16001": string[];
261
269
  "19845": string[];
270
+ "21337": string[];
262
271
  "21816": string[];
263
272
  "24484": string[];
264
273
  "24734": string[];
@@ -288,6 +297,7 @@ declare const _default: {
288
297
  "62320": string[];
289
298
  "63000": string[];
290
299
  "63001": string[];
300
+ "69420": string[];
291
301
  "70000": string[];
292
302
  "70001": string[];
293
303
  "70002": string[];
@@ -208,9 +208,15 @@ exports.default = {
208
208
  "78": [
209
209
  "primuschain"
210
210
  ],
211
+ "79": [
212
+ "zenith"
213
+ ],
211
214
  "80": [
212
215
  "GeneChain"
213
216
  ],
217
+ "81": [
218
+ "VIL"
219
+ ],
214
220
  "82": [
215
221
  "Meter"
216
222
  ],
@@ -379,6 +385,9 @@ exports.default = {
379
385
  "288": [
380
386
  "Boba"
381
387
  ],
388
+ "300": [
389
+ "ogc"
390
+ ],
382
391
  "321": [
383
392
  "kcs"
384
393
  ],
@@ -448,6 +457,9 @@ exports.default = {
448
457
  "686": [
449
458
  "kar"
450
459
  ],
460
+ "700": [
461
+ "SNS"
462
+ ],
451
463
  "707": [
452
464
  "bcs"
453
465
  ],
@@ -517,6 +529,9 @@ exports.default = {
517
529
  "1007": [
518
530
  "tnew"
519
531
  ],
532
+ "1008": [
533
+ "eun"
534
+ ],
520
535
  "1010": [
521
536
  "EVC"
522
537
  ],
@@ -581,7 +596,7 @@ exports.default = {
581
596
  "mrock"
582
597
  ],
583
598
  "1337": [
584
- "cennz-a"
599
+ "cennz-old"
585
600
  ],
586
601
  "1618": [
587
602
  "cate"
@@ -601,6 +616,9 @@ exports.default = {
601
616
  "1898": [
602
617
  "boya"
603
618
  ],
619
+ "1984": [
620
+ "euntest"
621
+ ],
604
622
  "1987": [
605
623
  "egem"
606
624
  ],
@@ -625,6 +643,12 @@ exports.default = {
625
643
  "2101": [
626
644
  "esp"
627
645
  ],
646
+ "2152": [
647
+ "fra"
648
+ ],
649
+ "2153": [
650
+ "findora-testnet"
651
+ ],
628
652
  "2213": [
629
653
  "evanesco"
630
654
  ],
@@ -787,6 +811,9 @@ exports.default = {
787
811
  "19845": [
788
812
  "btcix"
789
813
  ],
814
+ "21337": [
815
+ "cennz-a"
816
+ ],
790
817
  "21816": [
791
818
  "oml"
792
819
  ],
@@ -874,6 +901,9 @@ exports.default = {
874
901
  "63001": [
875
902
  "ecs-testnet"
876
903
  ],
904
+ "69420": [
905
+ "cndr"
906
+ ],
877
907
  "70000": [
878
908
  "TKM0"
879
909
  ],
@@ -15,5 +15,11 @@ export declare class TinyBig extends Big {
15
15
  }
16
16
  /**
17
17
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
18
+ *
19
+ * @example
20
+ * ```javascript
21
+ * tinyBig(10).times(3).toNumber()
22
+ * // 30
23
+ * ```
18
24
  */
19
25
  export declare function tinyBig(value: string | number | TinyBig | Big): TinyBig;
@@ -12,7 +12,13 @@ const helpers_1 = require("./helpers");
12
12
  */
13
13
  class TinyBig extends big_js_1.default {
14
14
  constructor(value) {
15
- super(value);
15
+ try {
16
+ super(value);
17
+ }
18
+ catch (e) {
19
+ console.error(`TinyBig cannot parse value (value=${value})`);
20
+ throw e;
21
+ }
16
22
  }
17
23
  /**
18
24
  * Used anytime you're passing in "value" to ethers or web3
@@ -34,6 +40,12 @@ class TinyBig extends big_js_1.default {
34
40
  exports.TinyBig = TinyBig;
35
41
  /**
36
42
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
43
+ *
44
+ * @example
45
+ * ```javascript
46
+ * tinyBig(10).times(3).toNumber()
47
+ * // 30
48
+ * ```
37
49
  */
38
50
  function tinyBig(value) {
39
51
  return new TinyBig(value);
@@ -1,27 +1,15 @@
1
- import { RPCTransaction, Transaction } from './Transaction.types';
2
- export interface Block {
3
- baseFeePerGas: string;
4
- difficulty: number;
5
- extraData: string;
1
+ import { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
2
+ declare type Modify<T, R> = Omit<T, keyof R> & R;
3
+ export declare type BlockResponse = Modify<RPCBlock, {
6
4
  gasLimit: number;
7
5
  gasUsed: number;
8
- hash: string;
9
- logsBloom: string;
10
- miner: string;
11
- mixHash: string;
12
- nonce: string;
13
6
  number: number;
14
- parentHash: string;
15
- receiptsRoot: string;
16
- sha3Uncles: string;
17
7
  size: number;
18
- stateRoot: string;
19
8
  timestamp: number;
20
- totalDifficulty: number;
21
- transactions: string[] | Transaction[];
22
- transactionsRoot: string;
23
- uncles: unknown[];
24
- }
9
+ baseFeePerGas: number;
10
+ transactions: Array<string | BlockTransactionResponse>;
11
+ }>;
12
+ /** Exact response from backend */
25
13
  export interface RPCBlock {
26
14
  baseFeePerGas: string;
27
15
  difficulty: string;
@@ -45,3 +33,5 @@ export interface RPCBlock {
45
33
  transactionsRoot: string;
46
34
  uncles: unknown[];
47
35
  }
36
+ export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
37
+ export {};
@@ -1,23 +1,31 @@
1
- export interface Transaction {
2
- blockHash: string;
1
+ import { TinyBig } from '../shared/tiny-big/tiny-big';
2
+ declare type Modify<T, R> = Omit<T, keyof R> & R;
3
+ export interface RPCTransaction extends RPCBlockTransaction {
4
+ maxFeePerGas: string;
5
+ maxPriorityFeePerGas: string;
6
+ }
7
+ export declare type TransactionResponse = Modify<RPCTransaction, {
3
8
  blockNumber: number;
4
- from: string;
5
- gas: number;
6
- gasPrice: string;
7
- hash: string;
8
- input: string;
9
+ chainId: number;
9
10
  nonce: number;
10
- r: string;
11
- s: string;
12
- to: string;
13
11
  transactionIndex: number;
14
12
  type: number;
15
- v: string;
16
- value: string;
17
- }
18
- export interface RPCTransaction {
13
+ v: number;
14
+ value: TinyBig;
15
+ gasPrice: TinyBig;
16
+ gas: TinyBig;
17
+ gasLimit: TinyBig;
18
+ } & {
19
+ maxFeePerGas: TinyBig;
20
+ maxPriorityFeePerGas: TinyBig;
21
+ confirmations: number;
22
+ }>;
23
+ export declare type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
24
+ /** What JSONRPC responds with in getBlock transaction array */
25
+ export interface RPCBlockTransaction {
19
26
  blockHash: string;
20
27
  blockNumber: string;
28
+ chainId: string;
21
29
  from: string;
22
30
  gas: string;
23
31
  gasPrice: string;
@@ -32,3 +40,4 @@ export interface RPCTransaction {
32
40
  v: string;
33
41
  value: string;
34
42
  }
43
+ export {};
@@ -0,0 +1,26 @@
1
+ import Big from 'big.js';
2
+ import { 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
+ * @example
11
+ * ```javascript
12
+ * etherToGwei('1000').toString()
13
+ * // '1000000000000'
14
+ * etherToGwei(1000).toString()
15
+ * // '1000000000000'
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * etherToGwei('1000').toNumber()
21
+ * // 1000000000000
22
+ * etherToGwei(1000).toNumber()
23
+ * // 1000000000000
24
+ * ```
25
+ */
26
+ export declare function etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig;
@@ -0,0 +1,34 @@
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
+ * @example
14
+ * ```javascript
15
+ * etherToGwei('1000').toString()
16
+ * // '1000000000000'
17
+ * etherToGwei(1000).toString()
18
+ * // '1000000000000'
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * etherToGwei('1000').toNumber()
24
+ * // 1000000000000
25
+ * etherToGwei(1000).toNumber()
26
+ * // 1000000000000
27
+ * ```
28
+ */
29
+ function etherToGwei(etherQuantity) {
30
+ (0, validate_type_1.validateType)(etherQuantity, ['string', 'number', 'object']);
31
+ const result = (0, tiny_big_1.tinyBig)(etherQuantity).times('1000000000');
32
+ return (0, tiny_big_1.tinyBig)(result);
33
+ }
34
+ exports.etherToGwei = etherToGwei;
@@ -1,9 +1,11 @@
1
1
  import Big from 'big.js';
2
2
  import { TinyBig } from '../shared/tiny-big/tiny-big';
3
3
  /**
4
- * Similar to ["parseEther" in ethers.js](https://docs.ethers.io/v4/api-utils.html#ether-strings-and-wei)
4
+ * Convert Ether to Wei
5
5
  *
6
- * Similar to ["toWei" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html?highlight=towei#towei)
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)
7
9
  *
8
10
  * @example
9
11
  * ```javascript
@@ -4,9 +4,11 @@ exports.etherToWei = void 0;
4
4
  const tiny_big_1 = require("../shared/tiny-big/tiny-big");
5
5
  const validate_type_1 = require("../shared/validate-type");
6
6
  /**
7
- * Similar to ["parseEther" in ethers.js](https://docs.ethers.io/v4/api-utils.html#ether-strings-and-wei)
7
+ * Convert Ether to Wei
8
8
  *
9
- * Similar to ["toWei" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html?highlight=towei#towei)
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)
10
12
  *
11
13
  * @example
12
14
  * ```javascript
@@ -0,0 +1,26 @@
1
+ import Big from 'big.js';
2
+ import { 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
+ * @example
11
+ * ```javascript
12
+ * gweiToEther('1000000000000').toString()
13
+ * // '1000'
14
+ * gweiToEther(1000000000000).toString()
15
+ * // '1000'
16
+ * ```
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * gweiToEther('1000000000000').toNumber()
21
+ * // 1000
22
+ * gweiToEther(1000000000000).toNumber()
23
+ * // 1000
24
+ * ```
25
+ */
26
+ export declare function gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig;
@@ -0,0 +1,34 @@
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
+ * @example
14
+ * ```javascript
15
+ * gweiToEther('1000000000000').toString()
16
+ * // '1000'
17
+ * gweiToEther(1000000000000).toString()
18
+ * // '1000'
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * gweiToEther('1000000000000').toNumber()
24
+ * // 1000
25
+ * gweiToEther(1000000000000).toNumber()
26
+ * // 1000
27
+ * ```
28
+ */
29
+ function gweiToEther(gweiQuantity) {
30
+ (0, validate_type_1.validateType)(gweiQuantity, ['string', 'number', 'object']);
31
+ const result = (0, tiny_big_1.tinyBig)(gweiQuantity).div('1000000000');
32
+ return (0, tiny_big_1.tinyBig)(result);
33
+ }
34
+ exports.gweiToEther = gweiToEther;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Returns a hex string padded to a specified length of bytes.
3
+ *
4
+ * Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
5
+ *
6
+ * Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
7
+ *
8
+ * @param hexValue - A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
9
+ * @param length - The final length in bytes
10
+ *
11
+ * @throws - If the value is not a hex string or number
12
+ * @throws - If the value is longer than the length
13
+ *
14
+ * @example
15
+ * ```javascript
16
+ * hexZeroPad('0x60', 2);
17
+ * // '0x0060'
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```javascript
22
+ * hexZeroPad(0x60, 3);
23
+ * // '0x000060'
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```javascript
28
+ * hexZeroPad('12345', 1);
29
+ * // Throws
30
+ * ```
31
+ */
32
+ export declare function hexZeroPad(hexValue: string | number, length: number): string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hexZeroPad = void 0;
4
+ const validate_type_1 = require("../shared/validate-type");
5
+ /**
6
+ * Returns a hex string padded to a specified length of bytes.
7
+ *
8
+ * Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
9
+ *
10
+ * Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
11
+ *
12
+ * @param hexValue - A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
13
+ * @param length - The final length in bytes
14
+ *
15
+ * @throws - If the value is not a hex string or number
16
+ * @throws - If the value is longer than the length
17
+ *
18
+ * @example
19
+ * ```javascript
20
+ * hexZeroPad('0x60', 2);
21
+ * // '0x0060'
22
+ * ```
23
+ *
24
+ * @example
25
+ * ```javascript
26
+ * hexZeroPad(0x60, 3);
27
+ * // '0x000060'
28
+ * ```
29
+ *
30
+ * @example
31
+ * ```javascript
32
+ * hexZeroPad('12345', 1);
33
+ * // Throws
34
+ * ```
35
+ */
36
+ function hexZeroPad(hexValue, length) {
37
+ (0, validate_type_1.validateType)(hexValue, ['string', 'number']);
38
+ let val;
39
+ if (typeof hexValue === 'string') {
40
+ if (!hexValue.startsWith('0x'))
41
+ throw new Error(`value is not a hex string or number. Consider prepending with "0x" (value="${hexValue}")`);
42
+ val = hexValue.substring(2);
43
+ }
44
+ else {
45
+ val = hexValue.toString(16);
46
+ }
47
+ if (val.length > length * 2) {
48
+ throw new Error(`value is longer than length (hexValue=${hexValue}, length=${length})`);
49
+ }
50
+ return `0x${val.padStart(length * 2, '0')}`;
51
+ }
52
+ exports.hexZeroPad = hexZeroPad;
@@ -1,5 +1,24 @@
1
1
  /**
2
2
  * Returns a boolean as to whether the input is a valid address.
3
3
  * Does NOT support ICAP addresses
4
+ *
5
+ * @example
6
+ * ```javascript
7
+ * isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
8
+ * // true
9
+ * ```
10
+ *
11
+ * @example
12
+ * ```javascript
13
+ * isAddress('bad');
14
+ * // false
15
+ * ```
16
+ *
17
+ * @example
18
+ * ```javascript
19
+ * // Does NOT support ENS.
20
+ * isAddress('vitalik.eth');
21
+ * // false
22
+ * ```
4
23
  */
5
24
  export declare function isAddress(address: string): boolean;
@@ -6,6 +6,25 @@ const validate_type_1 = require("../shared/validate-type");
6
6
  /**
7
7
  * Returns a boolean as to whether the input is a valid address.
8
8
  * Does NOT support ICAP addresses
9
+ *
10
+ * @example
11
+ * ```javascript
12
+ * isAddress('0xc0deaf6bd3f0c6574a6a625ef2f22f62a5150eab');
13
+ * // true
14
+ * ```
15
+ *
16
+ * @example
17
+ * ```javascript
18
+ * isAddress('bad');
19
+ * // false
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```javascript
24
+ * // Does NOT support ENS.
25
+ * isAddress('vitalik.eth');
26
+ * // false
27
+ * ```
9
28
  */
10
29
  function isAddress(address) {
11
30
  (0, validate_type_1.validateType)(address, ['string']);
@@ -10,8 +10,8 @@
10
10
  * // '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
11
11
  * ```
12
12
  *
13
- * Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v4/api-utils.html#utils-getaddress)
13
+ * Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v5/api/utils/address/#utils-getAddress)
14
14
  *
15
- * Similar to ["toChecksumAddress" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html#tochecksumaddress)
15
+ * Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#tochecksumaddress)
16
16
  */
17
17
  export declare function toChecksumAddress(address: string): string;
@@ -15,9 +15,9 @@ const validate_type_1 = require("../shared/validate-type");
15
15
  * // '0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359'
16
16
  * ```
17
17
  *
18
- * Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v4/api-utils.html#utils-getaddress)
18
+ * Similar to ["getAddress" in ethers.js](https://docs.ethers.io/v5/api/utils/address/#utils-getAddress)
19
19
  *
20
- * Similar to ["toChecksumAddress" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html#tochecksumaddress)
20
+ * Similar to ["toChecksumAddress" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#tochecksumaddress)
21
21
  */
22
22
  function toChecksumAddress(address) {
23
23
  (0, validate_type_1.validateType)(address, ['string']);
@@ -1,26 +1,26 @@
1
1
  import Big from 'big.js';
2
- import { TinyBig } from './../shared/tiny-big/tiny-big';
2
+ import { TinyBig } from '../shared/tiny-big/tiny-big';
3
3
  /**
4
- * Convert from Ether to Wei
4
+ * Convert from Wei to Ether
5
5
  *
6
- * Similar to ["formatEther" in ethers.js](https://docs.ethers.io/v4/api-utils.html#ether-strings-and-wei)
6
+ * Similar to ["formatEther" in ethers.js](https://docs.ethers.io/v5/api/utils/display-logic/#utils-formatEther)
7
7
  *
8
- * Similar to ["fromWei" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html#fromwei)
8
+ * Similar to ["fromWei" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#fromwei)
9
9
  *
10
10
  * @example
11
11
  * ```javascript
12
- * etherToWei('1000').toString()
13
- * // '1000000000000000000000'
14
- * etherToWei(1000).toString()
15
- * '1000000000000000000000'
12
+ * weiToEther('1000000000000000000000').toString()
13
+ * // '1000'
14
+ * weiToEther(1000000000000000000000).toString()
15
+ * // '1000'
16
16
  * ```
17
17
  *
18
18
  * @example
19
19
  * ```javascript
20
- * etherToWei('1000').toNumber()
21
- * // 1000000000000000000000
22
- * etherToWei(1000).toNumber()
23
- * // 1000000000000000000000
20
+ * weiToEther('1000000000000000000000').toNumber()
21
+ * // 1000
22
+ * weiToEther(1000000000000000000000).toNumber()
23
+ * // 1000
24
24
  * ```
25
25
  */
26
26
  export declare function weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig;