essential-eth 0.5.1 โ†’ 0.5.4-alpha.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 (47) hide show
  1. package/lib/cjs/classes/Contract.d.ts +3 -2
  2. package/lib/cjs/classes/Contract.js +3 -2
  3. package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +1 -0
  4. package/lib/cjs/classes/utils/encode-decode-transaction.js +4 -4
  5. package/lib/cjs/classes/utils/fetchers.d.ts +1 -1
  6. package/lib/cjs/index.d.ts +2 -1
  7. package/lib/cjs/index.js +3 -1
  8. package/lib/cjs/logger/package-version.d.ts +1 -1
  9. package/lib/cjs/logger/package-version.js +1 -1
  10. package/lib/cjs/providers/BaseProvider.d.ts +261 -0
  11. package/lib/cjs/providers/BaseProvider.js +340 -0
  12. package/lib/cjs/providers/FallthroughProvider.d.ts +25 -0
  13. package/lib/cjs/providers/FallthroughProvider.js +65 -0
  14. package/lib/cjs/providers/JsonRpcProvider.d.ts +4 -200
  15. package/lib/cjs/providers/JsonRpcProvider.js +11 -263
  16. package/lib/cjs/providers/test/rpc-urls.d.ts +1 -0
  17. package/lib/cjs/providers/test/rpc-urls.js +1 -0
  18. package/lib/cjs/providers/utils/chains-info.d.ts +4 -0
  19. package/lib/cjs/providers/utils/chains-info.js +12 -0
  20. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +2 -2
  21. package/lib/cjs/shared/tiny-big/tiny-big.js +2 -2
  22. package/lib/cjs/utils/bytes.d.ts +82 -1
  23. package/lib/cjs/utils/bytes.js +83 -3
  24. package/lib/cjs/utils/solidity-keccak256.js +2 -2
  25. package/lib/esm/classes/Contract.js +1 -1
  26. package/lib/esm/classes/utils/encode-decode-transaction.d.ts +1 -0
  27. package/lib/esm/classes/utils/encode-decode-transaction.js +2 -2
  28. package/lib/esm/classes/utils/fetchers.d.ts +1 -1
  29. package/lib/esm/index.d.ts +2 -1
  30. package/lib/esm/index.js +2 -1
  31. package/lib/esm/logger/package-version.d.ts +1 -1
  32. package/lib/esm/logger/package-version.js +1 -1
  33. package/lib/esm/providers/BaseProvider.d.ts +17 -0
  34. package/lib/esm/providers/BaseProvider.js +88 -0
  35. package/lib/esm/providers/FallthroughProvider.d.ts +12 -0
  36. package/lib/esm/providers/FallthroughProvider.js +41 -0
  37. package/lib/esm/providers/JsonRpcProvider.d.ts +4 -12
  38. package/lib/esm/providers/JsonRpcProvider.js +8 -69
  39. package/lib/esm/providers/test/rpc-urls.d.ts +1 -0
  40. package/lib/esm/providers/test/rpc-urls.js +1 -0
  41. package/lib/esm/providers/utils/chains-info.d.ts +4 -0
  42. package/lib/esm/providers/utils/chains-info.js +12 -0
  43. package/lib/esm/utils/bytes.d.ts +1 -1
  44. package/lib/esm/utils/bytes.js +2 -2
  45. package/lib/esm/utils/solidity-keccak256.js +2 -2
  46. package/package.json +11 -9
  47. package/readme.md +32 -5
@@ -1,4 +1,5 @@
1
1
  import { Contract } from './classes/Contract';
2
+ import { FallthroughProvider } from './providers/FallthroughProvider';
2
3
  import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
3
4
  import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
4
5
  import { BlockResponse } from './types/Block.types';
@@ -13,4 +14,4 @@ import { toChecksumAddress } from './utils/to-checksum-address';
13
14
  import { weiToEther } from './utils/wei-to-ether';
14
15
  export * from './utils/bytes';
15
16
  export * from './utils/solidity-keccak256';
16
- export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, BlockResponse, ContractTypes, JSONABI, JSONABIArgument, Network, TransactionResponse, };
17
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, BlockResponse, ContractTypes, JSONABI, JSONABIArgument, Network, TransactionResponse, };
package/lib/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Contract } from './classes/Contract';
2
+ import { FallthroughProvider } from './providers/FallthroughProvider';
2
3
  import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
3
4
  import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
4
5
  import { etherToGwei } from './utils/ether-to-gwei';
@@ -9,4 +10,4 @@ import { toChecksumAddress } from './utils/to-checksum-address';
9
10
  import { weiToEther } from './utils/wei-to-ether';
10
11
  export * from './utils/bytes';
11
12
  export * from './utils/solidity-keccak256';
12
- export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, };
13
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, Contract, TinyBig, };
@@ -1 +1 @@
1
- export declare const version = "0.5.1";
1
+ export declare const version = "0.5.4-alpha.0";
@@ -1 +1 @@
1
- export const version = '0.5.1';
1
+ export const version = '0.5.4-alpha.0';
@@ -0,0 +1,17 @@
1
+ import { TinyBig } from '../shared/tiny-big/tiny-big';
2
+ import { BlockResponse, BlockTag } from '../types/Block.types';
3
+ import { Network } from '../types/Network.types';
4
+ import { TransactionResponse } from '../types/Transaction.types';
5
+ export declare abstract class BaseProvider {
6
+ abstract selectRpcUrl(): string;
7
+ abstract post(body: Record<string, unknown>): Promise<any>;
8
+ readonly _rpcUrls: string[];
9
+ protected _post: (body: Record<string, unknown>) => Promise<any>;
10
+ constructor(rpcUrls: string[]);
11
+ getNetwork(): Promise<Network>;
12
+ getTransaction(transactionHash: string): Promise<TransactionResponse>;
13
+ getTransactionCount(address: string, blockTag?: BlockTag): Promise<number>;
14
+ getBlock(timeFrame?: BlockTag, returnTransactionObjects?: boolean): Promise<BlockResponse>;
15
+ getGasPrice(): Promise<TinyBig>;
16
+ getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>;
17
+ }
@@ -0,0 +1,88 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { cleanBlock } from '../classes/utils/clean-block';
11
+ import { cleanTransaction } from '../classes/utils/clean-transaction';
12
+ import { buildRPCPostBody, post } from '../classes/utils/fetchers';
13
+ import { hexToDecimal } from '../classes/utils/hex-to-decimal';
14
+ import { tinyBig } from '../shared/tiny-big/tiny-big';
15
+ import chainsInfo from './utils/chains-info';
16
+ export class BaseProvider {
17
+ constructor(rpcUrls) {
18
+ this._rpcUrls = [];
19
+ this._post = (body) => post(this.selectRpcUrl(), body);
20
+ this._rpcUrls = rpcUrls;
21
+ }
22
+ getNetwork() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const hexChainId = (yield this.post(buildRPCPostBody('eth_chainId', [])));
25
+ const chainId = hexToDecimal(hexChainId);
26
+ const info = chainsInfo[chainId];
27
+ return {
28
+ chainId: Number(chainId),
29
+ name: info[0] || 'unknown',
30
+ ensAddress: info[1] || null,
31
+ };
32
+ });
33
+ }
34
+ getTransaction(transactionHash) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const [rpcTransaction, blockNumber] = yield Promise.all([
37
+ this.post(buildRPCPostBody('eth_getTransactionByHash', [transactionHash])),
38
+ this.getBlock('latest'),
39
+ ]);
40
+ const cleanedTransaction = cleanTransaction(rpcTransaction);
41
+ cleanedTransaction.confirmations =
42
+ blockNumber.number - cleanedTransaction.blockNumber + 1;
43
+ return cleanedTransaction;
44
+ });
45
+ }
46
+ getTransactionCount(address, blockTag = 'latest') {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ if (typeof blockTag === 'number') {
49
+ blockTag = `0x${blockTag.toString(16)}`;
50
+ }
51
+ const transactionCount = (yield this.post(buildRPCPostBody('eth_getTransactionCount', [address, blockTag])));
52
+ return Number(hexToDecimal(transactionCount));
53
+ });
54
+ }
55
+ getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ let rpcTimeFrame;
58
+ let type = 'Number';
59
+ if (typeof timeFrame === 'number') {
60
+ rpcTimeFrame = `0x${timeFrame.toString(16)}`;
61
+ }
62
+ else if (timeFrame.startsWith('0x')) {
63
+ rpcTimeFrame = timeFrame;
64
+ type = 'Hash';
65
+ }
66
+ else {
67
+ rpcTimeFrame = timeFrame;
68
+ }
69
+ const rpcBlock = (yield this.post(buildRPCPostBody(`eth_getBlockBy${type}`, [
70
+ rpcTimeFrame,
71
+ returnTransactionObjects,
72
+ ])));
73
+ return cleanBlock(rpcBlock, returnTransactionObjects);
74
+ });
75
+ }
76
+ getGasPrice() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const hexGasPrice = (yield this.post(buildRPCPostBody('eth_gasPrice', [])));
79
+ return tinyBig(hexToDecimal(hexGasPrice));
80
+ });
81
+ }
82
+ getBalance(address, blockTag = 'latest') {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ const hexBalance = (yield this.post(buildRPCPostBody('eth_getBalance', [address, blockTag])));
85
+ return tinyBig(hexToDecimal(hexBalance));
86
+ });
87
+ }
88
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseProvider } from './BaseProvider';
2
+ interface ConstructorOptions {
3
+ timeoutDuration?: number;
4
+ }
5
+ export declare class FallthroughProvider extends BaseProvider {
6
+ private rpcUrlCounter;
7
+ private readonly timeoutDuration;
8
+ selectRpcUrl(): string;
9
+ constructor(rpcUrls: string[], options?: ConstructorOptions);
10
+ post: (body: Record<string, unknown>) => Promise<any>;
11
+ }
12
+ export {};
@@ -0,0 +1,41 @@
1
+ import { logger } from '../logger/logger';
2
+ import { BaseProvider } from './BaseProvider';
3
+ const promiseTimeout = (prom, time) => Promise.race([
4
+ prom,
5
+ new Promise((_r, reject) => setTimeout(() => reject('Promise timed out'), time)),
6
+ ]);
7
+ const DEFAULT_TIMEOUT_DURATION = 8000;
8
+ export class FallthroughProvider extends BaseProvider {
9
+ constructor(rpcUrls, options = {}) {
10
+ if (!Array.isArray(rpcUrls)) {
11
+ logger.throwError('Array required', { rpcUrls });
12
+ }
13
+ if (rpcUrls.length <= 1) {
14
+ logger.throwError('More than one rpcUrl is required', { rpcUrls });
15
+ }
16
+ super(rpcUrls);
17
+ this.rpcUrlCounter = 0;
18
+ this.post = (body) => {
19
+ const genesisCount = this.rpcUrlCounter;
20
+ const recursivePostRetry = () => {
21
+ const genesisRpcUrl = this.selectRpcUrl();
22
+ const res = promiseTimeout(this._post(body), this.timeoutDuration).catch((e) => {
23
+ if (genesisRpcUrl === this.selectRpcUrl()) {
24
+ this.rpcUrlCounter =
25
+ (this.rpcUrlCounter + 1) % this._rpcUrls.length;
26
+ }
27
+ if (this.rpcUrlCounter === genesisCount) {
28
+ throw e;
29
+ }
30
+ return recursivePostRetry();
31
+ });
32
+ return res;
33
+ };
34
+ return recursivePostRetry();
35
+ };
36
+ this.timeoutDuration = options.timeoutDuration || DEFAULT_TIMEOUT_DURATION;
37
+ }
38
+ selectRpcUrl() {
39
+ return this._rpcUrls[this.rpcUrlCounter];
40
+ }
41
+ }
@@ -1,15 +1,7 @@
1
- import { TinyBig } from '../shared/tiny-big/tiny-big';
2
- import { BlockResponse, BlockTag } from '../types/Block.types';
3
- import { Network } from '../types/Network.types';
4
- import { TransactionResponse } from '../types/Transaction.types';
5
- export declare class JsonRpcProvider {
6
- readonly _rpcUrl: string;
7
- private post;
1
+ import { BaseProvider } from './BaseProvider';
2
+ export declare class JsonRpcProvider extends BaseProvider {
3
+ selectRpcUrl(): string;
4
+ post(body: Record<string, unknown>): Promise<any>;
8
5
  constructor(rpcUrl?: string);
9
- getBlock(timeFrame?: BlockTag, returnTransactionObjects?: boolean): Promise<BlockResponse>;
10
- getNetwork(): Promise<Network>;
11
- getGasPrice(): Promise<TinyBig>;
12
- getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>;
13
- getTransaction(hash: string): Promise<TransactionResponse>;
14
6
  }
15
7
  export declare function jsonRpcProvider(rpcUrl?: string): JsonRpcProvider;
@@ -1,74 +1,13 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { cleanBlock } from '../classes/utils/clean-block';
11
- import { cleanTransaction } from '../classes/utils/clean-transaction';
12
- import { buildRPCPostBody, post } from '../classes/utils/fetchers';
13
- import { hexToDecimal } from '../classes/utils/hex-to-decimal';
14
- import { tinyBig } from '../shared/tiny-big/tiny-big';
15
- import chainsInfo from './utils/chains-info';
16
- export class JsonRpcProvider {
17
- constructor(rpcUrl) {
18
- this.post = (body) => post(this._rpcUrl, body);
19
- this._rpcUrl = rpcUrl || 'https://free-eth-node.com/api/eth';
1
+ import { BaseProvider } from './BaseProvider';
2
+ export class JsonRpcProvider extends BaseProvider {
3
+ selectRpcUrl() {
4
+ return this._rpcUrls[0];
20
5
  }
21
- getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- let rpcTimeFrame;
24
- if (typeof timeFrame === 'number') {
25
- rpcTimeFrame = `0x${timeFrame.toString(16)}`;
26
- }
27
- else {
28
- rpcTimeFrame = timeFrame;
29
- }
30
- const rpcBlock = (yield this.post(buildRPCPostBody('eth_getBlockByNumber', [
31
- rpcTimeFrame,
32
- returnTransactionObjects,
33
- ])));
34
- return cleanBlock(rpcBlock, returnTransactionObjects);
35
- });
6
+ post(body) {
7
+ return this._post(body);
36
8
  }
37
- getNetwork() {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const hexChainId = (yield this.post(buildRPCPostBody('eth_chainId', [])));
40
- const chainId = hexToDecimal(hexChainId);
41
- const info = chainsInfo[chainId];
42
- return {
43
- chainId: Number(chainId),
44
- name: info[0] || 'unknown',
45
- ensAddress: info[1] || null,
46
- };
47
- });
48
- }
49
- getGasPrice() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const hexGasPrice = (yield this.post(buildRPCPostBody('eth_gasPrice', [])));
52
- return tinyBig(hexToDecimal(hexGasPrice));
53
- });
54
- }
55
- getBalance(address, blockTag = 'latest') {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const hexBalance = (yield this.post(buildRPCPostBody('eth_getBalance', [address, blockTag])));
58
- return tinyBig(hexToDecimal(hexBalance));
59
- });
60
- }
61
- getTransaction(hash) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- const [rpcTransaction, blockNumber] = yield Promise.all([
64
- this.post(buildRPCPostBody('eth_getTransactionByHash', [hash])),
65
- this.getBlock('latest'),
66
- ]);
67
- const cleanedTransaction = cleanTransaction(rpcTransaction);
68
- cleanedTransaction.confirmations =
69
- blockNumber.number - cleanedTransaction.blockNumber + 1;
70
- return cleanedTransaction;
71
- });
9
+ constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
10
+ super([rpcUrl]);
72
11
  }
73
12
  }
74
13
  export function jsonRpcProvider(rpcUrl) {
@@ -3,6 +3,7 @@ export declare const fakeUrls: {
3
3
  };
4
4
  export declare const rpcUrls: {
5
5
  mainnet: string;
6
+ matic: string;
6
7
  gno: string;
7
8
  bnb: string;
8
9
  arb1: string;
@@ -3,6 +3,7 @@ export const fakeUrls = {
3
3
  };
4
4
  export const rpcUrls = {
5
5
  mainnet: `${process.env.RPC_ORIGIN}/api/eth`,
6
+ matic: `${process.env.RPC_ORIGIN}/api/MATIC`,
6
7
  gno: `${process.env.RPC_ORIGIN}/api/gno`,
7
8
  bnb: `${process.env.RPC_ORIGIN}/api/bnb`,
8
9
  arb1: `${process.env.RPC_ORIGIN}/api/arb1`,
@@ -61,6 +61,7 @@ declare const _default: {
61
61
  "67": string[];
62
62
  "68": string[];
63
63
  "69": string[];
64
+ "70": string[];
64
65
  "71": string[];
65
66
  "74": string[];
66
67
  "76": string[];
@@ -217,6 +218,7 @@ declare const _default: {
217
218
  "2221": string[];
218
219
  "2223": string[];
219
220
  "2559": string[];
221
+ "2569": string[];
220
222
  "3000": string[];
221
223
  "3001": string[];
222
224
  "3331": string[];
@@ -298,6 +300,7 @@ declare const _default: {
298
300
  "60002": string[];
299
301
  "60103": string[];
300
302
  "62320": string[];
303
+ "62621": string[];
301
304
  "63000": string[];
302
305
  "63001": string[];
303
306
  "69420": string[];
@@ -343,6 +346,7 @@ declare const _default: {
343
346
  "333999": string[];
344
347
  "421611": string[];
345
348
  "444900": string[];
349
+ "512512": string[];
346
350
  "666666": string[];
347
351
  "888888": string[];
348
352
  "955305": string[];
@@ -189,6 +189,9 @@ export default {
189
189
  "69": [
190
190
  "okov"
191
191
  ],
192
+ "70": [
193
+ "hsc"
194
+ ],
192
195
  "71": [
193
196
  "cfxtest"
194
197
  ],
@@ -657,6 +660,9 @@ export default {
657
660
  "2559": [
658
661
  "ktoc"
659
662
  ],
663
+ "2569": [
664
+ "tpc"
665
+ ],
660
666
  "3000": [
661
667
  "cennz-r"
662
668
  ],
@@ -900,6 +906,9 @@ export default {
900
906
  "62320": [
901
907
  "BKLV"
902
908
  ],
909
+ "62621": [
910
+ "mtv"
911
+ ],
903
912
  "63000": [
904
913
  "ecs"
905
914
  ],
@@ -1035,6 +1044,9 @@ export default {
1035
1044
  "444900": [
1036
1045
  "wlkt"
1037
1046
  ],
1047
+ "512512": [
1048
+ "cmp"
1049
+ ],
1038
1050
  "666666": [
1039
1051
  "vpioneer"
1040
1052
  ],
@@ -26,7 +26,7 @@ export interface Signature {
26
26
  export declare function isBytesLike(value: any): value is BytesLike;
27
27
  export declare function isBytes(value: any): value is Bytes;
28
28
  export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
29
- export declare function concat(items: ReadonlyArray<BytesLike>): Uint8Array;
29
+ export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLike>): Uint8Array;
30
30
  export declare function stripZeros(value: BytesLike): Uint8Array;
31
31
  export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
32
32
  export declare function isHexString(value: any, length?: number): boolean;
@@ -77,8 +77,8 @@ export function arrayify(value, options) {
77
77
  }
78
78
  return logger.throwArgumentError('invalid arrayify value', 'value', value);
79
79
  }
80
- export function concat(items) {
81
- const objects = items.map((item) => arrayify(item));
80
+ export function concat(arrayOfBytesLike) {
81
+ const objects = arrayOfBytesLike.map((item) => arrayify(item));
82
82
  const length = objects.reduce((accum, item) => accum + item.length, 0);
83
83
  const result = new Uint8Array(length);
84
84
  objects.reduce((offset, object) => {
@@ -1,12 +1,12 @@
1
1
  import { Buffer } from 'buffer';
2
2
  import { Keccak } from 'sha3';
3
+ import { hexFalse } from '../classes/utils/encode-decode-transaction';
3
4
  import { logger } from '../logger/logger';
4
5
  import { tinyBig } from '../shared/tiny-big/tiny-big';
5
6
  import { arrayify, concat, hexlify, zeroPad } from './bytes';
6
7
  const regexBytes = new RegExp('^bytes([0-9]+)$');
7
8
  const regexNumber = new RegExp('^(u?int)([0-9]*)$');
8
9
  const regexArray = new RegExp('^(.*)\\[([0-9]*)\\]$');
9
- const Zeros = '0000000000000000000000000000000000000000000000000000000000000000';
10
10
  function _pack(type, value, isArray) {
11
11
  switch (type) {
12
12
  case 'address':
@@ -51,7 +51,7 @@ function _pack(type, value, isArray) {
51
51
  logger.throwArgumentError(`invalid value for ${type}`, 'value', value);
52
52
  }
53
53
  if (isArray) {
54
- return arrayify((value + Zeros).substring(0, 66));
54
+ return arrayify((value + hexFalse).substring(0, 66));
55
55
  }
56
56
  return value;
57
57
  }
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.5.1",
4
+ "version": "0.5.4-alpha.0",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "main": "./lib/cjs/index.js",
@@ -22,15 +22,16 @@
22
22
  "tsc:esm": "tsc -p tsconfig.json",
23
23
  "tsc:cjs": "tsc -p tsconfig-cjs.json",
24
24
  "build": "rm -rf lib && npm run compile",
25
- "prepublishOnly": "npm run build",
26
25
  "jest": "jest",
27
26
  "build:chains-info": "npx ts-node scripts/fetch-chains-info.ts # used in getNetwork()",
28
27
  "update-deps": "sh ./scripts/pre-commit.sh",
29
28
  "pre-commit": "run-p build:chains-info update-deps",
30
- "prepare": "husky install"
29
+ "prepare": "husky install",
30
+ "version": "npx genversion --es6 src/logger/package-version.ts && git add src/logger/package-version.ts",
31
+ "postversion": "git push --follow-tags",
32
+ "prepublishOnly": "npm run build"
31
33
  },
32
34
  "devDependencies": {
33
- "@ethersproject/keccak256": "^5.4.0",
34
35
  "@types/body-parser": "^1.19.1",
35
36
  "@types/eslint": "^8.4.1",
36
37
  "@types/express": "^4.17.13",
@@ -38,20 +39,21 @@
38
39
  "@types/jest-dev-server": "^5.0.0",
39
40
  "@types/node": "^16.10.1",
40
41
  "@types/prettier": "^2.4.4",
41
- "@typescript-eslint/eslint-plugin": "^5.20.0",
42
- "@typescript-eslint/parser": "^5.20.0",
42
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
43
+ "@typescript-eslint/parser": "^5.21.0",
43
44
  "body-parser": "^1.19.0",
44
45
  "dotenv": "^16.0.0",
45
- "eslint": "^8.13.0",
46
- "eslint-plugin-jest": "^26.1.4",
46
+ "eslint": "^8.14.0",
47
+ "eslint-plugin-jest": "^26.1.5",
47
48
  "ethers": "^5.6.4",
48
49
  "express": "^4.17.1",
49
50
  "husky": "^7.0.4",
50
51
  "jest": "^27.5.1",
51
52
  "jest-dev-server": "^6.0.3",
52
53
  "just-omit": "^2.0.1",
53
- "lint-staged": "^12.4.0",
54
+ "lint-staged": "^12.4.1",
54
55
  "npm-run-all": "^4.1.5",
56
+ "perf_hooks": "^0.0.1",
55
57
  "prettier": "^2.6.2",
56
58
  "prettier-plugin-organize-imports": "^2.3.4",
57
59
  "ts-jest": "^27.1.4",
package/readme.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="https://user-images.githubusercontent.com/3408480/163274699-ae4fb0f4-fca0-4745-bcd7-4868f80deaf6.png" title="Logo"/>
2
+ <img src="https://user-images.githubusercontent.com/3408480/163274699-ae4fb0f4-fca0-4745-bcd7-4868f80deaf6.png" height="220" title="Logo"/>
3
3
 
4
4
  </p>
5
5
  <p align="center">
@@ -8,7 +8,7 @@
8
8
  ๐Ÿชถ Essential Eth ๐Ÿชถ
9
9
  </b>
10
10
  <br/>
11
- <i>A replacement for ethers & web3 that's 50x smaller</i>
11
+ <i>A replacement for ethers & web3 that's 20x smaller</i>
12
12
  <br/>
13
13
  </p>
14
14
 
@@ -37,6 +37,10 @@
37
37
 
38
38
  <br/>
39
39
 
40
+ [![๐Ÿงช tests](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml/badge.svg)](https://github.com/Earnifi/essential-eth/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/Earnifi/essential-eth/branch/master/graph/badge.svg?token=E44EK6RWTZ)](https://codecov.io/gh/Earnifi/essential-eth) ![](https://badgen.net/bundlephobia/minzip/essential-eth) ![](https://badgen.net/bundlephobia/tree-shaking/essential-eth) ![](https://img.shields.io/npm/v/essential-eth)
41
+
42
+ <br/>
43
+
40
44
  ## Install
41
45
 
42
46
  ```sh
@@ -251,10 +255,35 @@ import { JsonRpcProvider } from 'essential-eth';
251
255
  const essentialEth = new JsonRpcProvider(
252
256
  'RPC URL HERE' /* Try POKT or Infura */,
253
257
  );
254
- // OR for very quick testing (limited to 500 requests)
258
+ // OR for very quick testing (limited to 10,000 requests)
255
259
  const essentialEth = new JsonRpcProvider();
256
260
  ```
257
261
 
262
+ <details>
263
+ <summary>Want a redundant provider that handles outages?</summary>
264
+
265
+ ```typescript
266
+ import { FallthroughProvider } from 'essential-eth';
267
+
268
+ // The FallthroughProvider handles falling through to the next valid URL.
269
+ // It's dynamic to never trust one URL again when it fails * until it has tried all other provided URLs
270
+ // The default timeout for a request is 8 seconds after which it moves to the next URL
271
+ const provider = new FallthroughProvider([
272
+ 'https://bad.com',
273
+ 'https://free-eth-node.com/api/eth',
274
+ ]);
275
+ provider.getGasPrice().toNumber();
276
+ /*
277
+ 39695942769
278
+ */
279
+ ```
280
+
281
+ </details>
282
+
283
+ <br/>
284
+
285
+ #### [`getTransactionCount(address, blockTag?): Promise<number>`](https://essential-eth.vercel.app/docs/api/classes/JsonRpcProvider#gettransactioncount)
286
+
258
287
  #### `getGasPrice`
259
288
 
260
289
  Returns the current gas price in gwei
@@ -617,8 +646,6 @@ Any function on a contract. Returns are the same as `ethers.js`, except that ins
617
646
 
618
647
  ๐Ÿงช This repo is under active development. The API is less-fully featured than `web3` and `ethers`. More functions added often!
619
648
 
620
- ![](https://badgen.net/bundlephobia/minzip/essential-eth) ![](https://badgen.net/bundlephobia/tree-shaking/essential-eth) ![](https://img.shields.io/npm/v/essential-eth) ![](https://badgen.net/bundlephobia/dependency-count/essential-eth)
621
-
622
649
  ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Breaking changes will exist between minor versions until `1.0.0` (Versions go `major.minor.patch`)
623
650
 
624
651
  <br/>