essential-eth 0.4.9 → 0.4.10

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 (35) hide show
  1. package/lib/cjs/index.d.ts +3 -1
  2. package/lib/cjs/index.js +5 -1
  3. package/lib/cjs/providers/JsonRpcProvider.d.ts +8 -0
  4. package/lib/cjs/providers/JsonRpcProvider.js +8 -0
  5. package/lib/cjs/providers/test/rpc-urls.d.ts +5 -0
  6. package/lib/cjs/providers/test/rpc-urls.js +6 -1
  7. package/lib/cjs/providers/utils/chains-info.d.ts +3 -0
  8. package/lib/cjs/providers/utils/chains-info.js +9 -0
  9. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +6 -0
  10. package/lib/cjs/shared/tiny-big/tiny-big.js +6 -0
  11. package/lib/cjs/utils/ether-to-gwei.d.ts +26 -0
  12. package/lib/cjs/utils/ether-to-gwei.js +34 -0
  13. package/lib/cjs/utils/ether-to-wei.d.ts +4 -2
  14. package/lib/cjs/utils/ether-to-wei.js +4 -2
  15. package/lib/cjs/utils/gwei-to-ether.d.ts +26 -0
  16. package/lib/cjs/utils/gwei-to-ether.js +34 -0
  17. package/lib/cjs/utils/is-address.d.ts +19 -0
  18. package/lib/cjs/utils/is-address.js +19 -0
  19. package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
  20. package/lib/cjs/utils/to-checksum-address.js +2 -2
  21. package/lib/cjs/utils/wei-to-ether.d.ts +12 -12
  22. package/lib/cjs/utils/wei-to-ether.js +11 -11
  23. package/lib/esm/index.d.ts +3 -1
  24. package/lib/esm/index.js +3 -1
  25. package/lib/esm/providers/test/rpc-urls.d.ts +5 -0
  26. package/lib/esm/providers/test/rpc-urls.js +5 -0
  27. package/lib/esm/providers/utils/chains-info.d.ts +3 -0
  28. package/lib/esm/providers/utils/chains-info.js +9 -0
  29. package/lib/esm/utils/ether-to-gwei.d.ts +3 -0
  30. package/lib/esm/utils/ether-to-gwei.js +7 -0
  31. package/lib/esm/utils/gwei-to-ether.d.ts +3 -0
  32. package/lib/esm/utils/gwei-to-ether.js +7 -0
  33. package/lib/esm/utils/wei-to-ether.d.ts +1 -1
  34. package/package.json +3 -3
  35. package/readme.md +50 -0
@@ -5,8 +5,10 @@ import { Block } from './types/Block.types';
5
5
  import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
6
6
  import { Network } from './types/Network.types';
7
7
  import { Transaction } from './types/Transaction.types';
8
+ import { etherToGwei } from './utils/ether-to-gwei';
8
9
  import { etherToWei } from './utils/ether-to-wei';
10
+ import { gweiToEther } from './utils/gwei-to-ether';
9
11
  import { isAddress } from './utils/is-address';
10
12
  import { toChecksumAddress } from './utils/to-checksum-address';
11
13
  import { weiToEther } from './utils/wei-to-ether';
12
- export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
14
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
package/lib/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TinyBig = exports.Contract = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToWei = void 0;
3
+ exports.TinyBig = exports.Contract = exports.gweiToEther = exports.weiToEther = exports.toChecksumAddress = exports.tinyBig = exports.JsonRpcProvider = exports.jsonRpcProvider = exports.isAddress = exports.etherToGwei = exports.etherToWei = void 0;
4
4
  const Contract_1 = require("./classes/Contract");
5
5
  Object.defineProperty(exports, "Contract", { enumerable: true, get: function () { return Contract_1.Contract; } });
6
6
  const JsonRpcProvider_1 = require("./providers/JsonRpcProvider");
@@ -9,8 +9,12 @@ Object.defineProperty(exports, "jsonRpcProvider", { enumerable: true, get: funct
9
9
  const tiny_big_1 = require("./shared/tiny-big/tiny-big");
10
10
  Object.defineProperty(exports, "tinyBig", { enumerable: true, get: function () { return tiny_big_1.tinyBig; } });
11
11
  Object.defineProperty(exports, "TinyBig", { enumerable: true, get: function () { return tiny_big_1.TinyBig; } });
12
+ const ether_to_gwei_1 = require("./utils/ether-to-gwei");
13
+ Object.defineProperty(exports, "etherToGwei", { enumerable: true, get: function () { return ether_to_gwei_1.etherToGwei; } });
12
14
  const ether_to_wei_1 = require("./utils/ether-to-wei");
13
15
  Object.defineProperty(exports, "etherToWei", { enumerable: true, get: function () { return ether_to_wei_1.etherToWei; } });
16
+ const gwei_to_ether_1 = require("./utils/gwei-to-ether");
17
+ Object.defineProperty(exports, "gweiToEther", { enumerable: true, get: function () { return gwei_to_ether_1.gweiToEther; } });
14
18
  const is_address_1 = require("./utils/is-address");
15
19
  Object.defineProperty(exports, "isAddress", { enumerable: true, get: function () { return is_address_1.isAddress; } });
16
20
  const to_checksum_address_1 = require("./utils/to-checksum-address");
@@ -24,5 +24,13 @@ export declare class JsonRpcProvider {
24
24
  }
25
25
  /**
26
26
  * Helper function to avoid "new"
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * jsonRpcProvider().getBlock('latest').then(block => {
31
+ * console.log(block.number);
32
+ * })
33
+ * // 14530496
34
+ * ```
27
35
  */
28
36
  export declare function jsonRpcProvider(rpcUrl?: string): JsonRpcProvider;
@@ -82,6 +82,14 @@ class JsonRpcProvider {
82
82
  exports.JsonRpcProvider = JsonRpcProvider;
83
83
  /**
84
84
  * Helper function to avoid "new"
85
+ *
86
+ * @example
87
+ * ```javascript
88
+ * jsonRpcProvider().getBlock('latest').then(block => {
89
+ * console.log(block.number);
90
+ * })
91
+ * // 14530496
92
+ * ```
85
93
  */
86
94
  function jsonRpcProvider(rpcUrl) {
87
95
  return new JsonRpcProvider(rpcUrl);
@@ -1,3 +1,8 @@
1
1
  export declare const fakeUrls: {
2
2
  readonly notRPCButRealHttp: "https://httpstat.us/200";
3
3
  };
4
+ export declare const rpcUrls: {
5
+ mainnet: string;
6
+ gno: string;
7
+ bnb: string;
8
+ };
@@ -1,6 +1,11 @@
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
+ };
@@ -123,6 +123,7 @@ declare const _default: {
123
123
  "262": string[];
124
124
  "269": string[];
125
125
  "288": string[];
126
+ "300": string[];
126
127
  "321": string[];
127
128
  "322": string[];
128
129
  "333": string[];
@@ -169,6 +170,7 @@ declare const _default: {
169
170
  "999": string[];
170
171
  "1001": string[];
171
172
  "1007": string[];
173
+ "1008": string[];
172
174
  "1010": string[];
173
175
  "1012": string[];
174
176
  "1022": string[];
@@ -197,6 +199,7 @@ declare const _default: {
197
199
  "1688": string[];
198
200
  "1856": string[];
199
201
  "1898": string[];
202
+ "1984": string[];
200
203
  "1987": string[];
201
204
  "2001": string[];
202
205
  "2020": string[];
@@ -379,6 +379,9 @@ exports.default = {
379
379
  "288": [
380
380
  "Boba"
381
381
  ],
382
+ "300": [
383
+ "ogc"
384
+ ],
382
385
  "321": [
383
386
  "kcs"
384
387
  ],
@@ -517,6 +520,9 @@ exports.default = {
517
520
  "1007": [
518
521
  "tnew"
519
522
  ],
523
+ "1008": [
524
+ "eun"
525
+ ],
520
526
  "1010": [
521
527
  "EVC"
522
528
  ],
@@ -601,6 +607,9 @@ exports.default = {
601
607
  "1898": [
602
608
  "boya"
603
609
  ],
610
+ "1984": [
611
+ "euntest"
612
+ ],
604
613
  "1987": [
605
614
  "egem"
606
615
  ],
@@ -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;
@@ -34,6 +34,12 @@ class TinyBig extends big_js_1.default {
34
34
  exports.TinyBig = TinyBig;
35
35
  /**
36
36
  * Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
37
+ *
38
+ * @example
39
+ * ```javascript
40
+ * tinyBig(10).times(3).toNumber()
41
+ * // 30
42
+ * ```
37
43
  */
38
44
  function tinyBig(value) {
39
45
  return new TinyBig(value);
@@ -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;
@@ -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;
@@ -4,26 +4,26 @@ exports.weiToEther = 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
- * Convert from Ether to Wei
7
+ * Convert from Wei to Ether
8
8
  *
9
- * Similar to ["formatEther" in ethers.js](https://docs.ethers.io/v4/api-utils.html#ether-strings-and-wei)
9
+ * Similar to ["formatEther" in ethers.js](https://docs.ethers.io/v5/api/utils/display-logic/#utils-formatEther)
10
10
  *
11
- * Similar to ["fromWei" in web3](https://web3js.readthedocs.io/en/v1.2.11/web3-utils.html#fromwei)
11
+ * Similar to ["fromWei" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#fromwei)
12
12
  *
13
13
  * @example
14
14
  * ```javascript
15
- * etherToWei('1000').toString()
16
- * // '1000000000000000000000'
17
- * etherToWei(1000).toString()
18
- * '1000000000000000000000'
15
+ * weiToEther('1000000000000000000000').toString()
16
+ * // '1000'
17
+ * weiToEther(1000000000000000000000).toString()
18
+ * // '1000'
19
19
  * ```
20
20
  *
21
21
  * @example
22
22
  * ```javascript
23
- * etherToWei('1000').toNumber()
24
- * // 1000000000000000000000
25
- * etherToWei(1000).toNumber()
26
- * // 1000000000000000000000
23
+ * weiToEther('1000000000000000000000').toNumber()
24
+ * // 1000
25
+ * weiToEther(1000000000000000000000).toNumber()
26
+ * // 1000
27
27
  * ```
28
28
  */
29
29
  function weiToEther(weiQuantity) {
@@ -5,8 +5,10 @@ import { Block } from './types/Block.types';
5
5
  import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
6
6
  import { Network } from './types/Network.types';
7
7
  import { Transaction } from './types/Transaction.types';
8
+ import { etherToGwei } from './utils/ether-to-gwei';
8
9
  import { etherToWei } from './utils/ether-to-wei';
10
+ import { gweiToEther } from './utils/gwei-to-ether';
9
11
  import { isAddress } from './utils/is-address';
10
12
  import { toChecksumAddress } from './utils/to-checksum-address';
11
13
  import { weiToEther } from './utils/wei-to-ether';
12
- export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
14
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, Block, ContractTypes, JSONABI, JSONABIArgument, Network, Transaction, };
package/lib/esm/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { Contract } from './classes/Contract';
2
2
  import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
3
3
  import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
4
+ import { etherToGwei } from './utils/ether-to-gwei';
4
5
  import { etherToWei } from './utils/ether-to-wei';
6
+ import { gweiToEther } from './utils/gwei-to-ether';
5
7
  import { isAddress } from './utils/is-address';
6
8
  import { toChecksumAddress } from './utils/to-checksum-address';
7
9
  import { weiToEther } from './utils/wei-to-ether';
8
- export { etherToWei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, Contract, TinyBig, };
10
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, };
@@ -1,3 +1,8 @@
1
1
  export declare const fakeUrls: {
2
2
  readonly notRPCButRealHttp: "https://httpstat.us/200";
3
3
  };
4
+ export declare const rpcUrls: {
5
+ mainnet: string;
6
+ gno: string;
7
+ bnb: string;
8
+ };
@@ -1,3 +1,8 @@
1
1
  export const fakeUrls = {
2
2
  notRPCButRealHttp: 'https://httpstat.us/200',
3
3
  };
4
+ export const rpcUrls = {
5
+ mainnet: `${process.env.RPC_ORIGIN}/api/eth`,
6
+ gno: `${process.env.RPC_ORIGIN}/api/gno`,
7
+ bnb: `${process.env.RPC_ORIGIN}/api/bnb`,
8
+ };
@@ -123,6 +123,7 @@ declare const _default: {
123
123
  "262": string[];
124
124
  "269": string[];
125
125
  "288": string[];
126
+ "300": string[];
126
127
  "321": string[];
127
128
  "322": string[];
128
129
  "333": string[];
@@ -169,6 +170,7 @@ declare const _default: {
169
170
  "999": string[];
170
171
  "1001": string[];
171
172
  "1007": string[];
173
+ "1008": string[];
172
174
  "1010": string[];
173
175
  "1012": string[];
174
176
  "1022": string[];
@@ -197,6 +199,7 @@ declare const _default: {
197
199
  "1688": string[];
198
200
  "1856": string[];
199
201
  "1898": string[];
202
+ "1984": string[];
200
203
  "1987": string[];
201
204
  "2001": string[];
202
205
  "2020": string[];
@@ -375,6 +375,9 @@ export default {
375
375
  "288": [
376
376
  "Boba"
377
377
  ],
378
+ "300": [
379
+ "ogc"
380
+ ],
378
381
  "321": [
379
382
  "kcs"
380
383
  ],
@@ -513,6 +516,9 @@ export default {
513
516
  "1007": [
514
517
  "tnew"
515
518
  ],
519
+ "1008": [
520
+ "eun"
521
+ ],
516
522
  "1010": [
517
523
  "EVC"
518
524
  ],
@@ -597,6 +603,9 @@ export default {
597
603
  "1898": [
598
604
  "boya"
599
605
  ],
606
+ "1984": [
607
+ "euntest"
608
+ ],
600
609
  "1987": [
601
610
  "egem"
602
611
  ],
@@ -0,0 +1,3 @@
1
+ import Big from 'big.js';
2
+ import { TinyBig } from '../shared/tiny-big/tiny-big';
3
+ export declare function etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig;
@@ -0,0 +1,7 @@
1
+ import { tinyBig } from '../shared/tiny-big/tiny-big';
2
+ import { validateType } from '../shared/validate-type';
3
+ export function etherToGwei(etherQuantity) {
4
+ validateType(etherQuantity, ['string', 'number', 'object']);
5
+ const result = tinyBig(etherQuantity).times('1000000000');
6
+ return tinyBig(result);
7
+ }
@@ -0,0 +1,3 @@
1
+ import Big from 'big.js';
2
+ import { TinyBig } from './../shared/tiny-big/tiny-big';
3
+ export declare function gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig;
@@ -0,0 +1,7 @@
1
+ import { tinyBig } from '../shared/tiny-big/tiny-big';
2
+ import { validateType } from '../shared/validate-type';
3
+ export function gweiToEther(gweiQuantity) {
4
+ validateType(gweiQuantity, ['string', 'number', 'object']);
5
+ const result = tinyBig(gweiQuantity).div('1000000000');
6
+ return tinyBig(result);
7
+ }
@@ -1,3 +1,3 @@
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
  export declare function weiToEther(weiQuantity: string | number | TinyBig | Big): TinyBig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "essential-eth",
3
3
  "description": "Ultralight JS library for Ethereum utilities",
4
- "version": "0.4.9",
4
+ "version": "0.4.10",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "main": "./lib/cjs/index.js",
@@ -36,8 +36,8 @@
36
36
  "@types/jest-dev-server": "^5.0.0",
37
37
  "@types/node": "^16.10.1",
38
38
  "@types/prettier": "^2.4.4",
39
- "@typescript-eslint/eslint-plugin": "^5.17.0",
40
- "@typescript-eslint/parser": "^5.17.0",
39
+ "@typescript-eslint/eslint-plugin": "^5.18.0",
40
+ "@typescript-eslint/parser": "^5.18.0",
41
41
  "body-parser": "^1.19.0",
42
42
  "dotenv": "^16.0.0",
43
43
  "eslint": "^8.12.0",
package/readme.md CHANGED
@@ -126,6 +126,56 @@ weiToEther('1000000000000000000').toNumber();
126
126
 
127
127
  <br/>
128
128
 
129
+ #### `gweiToEther`
130
+
131
+ ```typescript
132
+ gweiToEther(gweiQuantity: string | number | TinyBig | Big): TinyBig
133
+ ```
134
+
135
+ <details>
136
+ <summary>View Example</summary>
137
+
138
+ ```typescript
139
+ import { gweiToEther } from 'essential-eth';
140
+
141
+ gweiToEther(1000000000).toString();
142
+ // "1"
143
+
144
+ gweiToEther(1000000000).toNumber();
145
+ // 1
146
+ gweiToEther('1000000000').toNumber();
147
+ // 1
148
+ ```
149
+
150
+ </details>
151
+
152
+ <br/>
153
+
154
+ #### `etherToGwei`
155
+
156
+ ```typescript
157
+ etherToGwei(etherQuantity: string | number | TinyBig | Big): TinyBig
158
+ ```
159
+
160
+ <details>
161
+ <summary>View Example</summary>
162
+
163
+ ```typescript
164
+ import { etherToGwei } from 'essential-eth';
165
+
166
+ etherToGwei(0.000000001).toString();
167
+ // "1"
168
+
169
+ etherToGwei(0.000000001).toNumber();
170
+ // 1
171
+ etherToGwei('0.000000001').toNumber();
172
+ // 1
173
+ ```
174
+
175
+ </details>
176
+
177
+ <br/>
178
+
129
179
  #### `toChecksumAddress`
130
180
 
131
181
  ```typescript