essential-eth 0.5.6 → 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 (91) 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 +3 -3
  20. package/lib/cjs/index.js +0 -1
  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 +261 -212
  24. package/lib/cjs/providers/BaseProvider.js +332 -225
  25. package/lib/cjs/providers/JsonRpcProvider.d.ts +6 -0
  26. package/lib/cjs/providers/JsonRpcProvider.js +6 -0
  27. package/lib/cjs/providers/utils/chains-info.d.ts +11 -0
  28. package/lib/cjs/providers/utils/chains-info.js +34 -1
  29. package/lib/cjs/shared/tiny-big/helpers.d.ts +16 -0
  30. package/lib/cjs/shared/tiny-big/helpers.js +27 -1
  31. package/lib/cjs/shared/tiny-big/tiny-big.d.ts +30 -4
  32. package/lib/cjs/shared/tiny-big/tiny-big.js +34 -4
  33. package/lib/cjs/types/Block.types.d.ts +11 -7
  34. package/lib/cjs/types/Filter.types.d.ts +16 -0
  35. package/lib/cjs/{providers/types.js → types/Filter.types.js} +0 -0
  36. package/lib/cjs/types/Transaction.types.d.ts +33 -6
  37. package/lib/cjs/utils/bytes.d.ts +150 -33
  38. package/lib/cjs/utils/bytes.js +179 -32
  39. package/lib/cjs/utils/compute-address.d.ts +10 -1
  40. package/lib/cjs/utils/compute-address.js +10 -1
  41. package/lib/cjs/utils/compute-public-key.d.ts +12 -3
  42. package/lib/cjs/utils/compute-public-key.js +12 -3
  43. package/lib/cjs/utils/ether-to-gwei.d.ts +2 -1
  44. package/lib/cjs/utils/ether-to-gwei.js +2 -1
  45. package/lib/cjs/utils/ether-to-wei.d.ts +2 -1
  46. package/lib/cjs/utils/ether-to-wei.js +2 -1
  47. package/lib/cjs/utils/gwei-to-ether.d.ts +2 -1
  48. package/lib/cjs/utils/gwei-to-ether.js +2 -1
  49. package/lib/cjs/utils/hash-message.d.ts +3 -1
  50. package/lib/cjs/utils/hash-message.js +3 -1
  51. package/lib/cjs/utils/is-address.d.ts +2 -2
  52. package/lib/cjs/utils/is-address.js +2 -2
  53. package/lib/cjs/utils/keccak256.d.ts +15 -1
  54. package/lib/cjs/utils/keccak256.js +16 -2
  55. package/lib/cjs/utils/solidity-keccak256.d.ts +17 -7
  56. package/lib/cjs/utils/solidity-keccak256.js +27 -7
  57. package/lib/cjs/utils/split-signature.d.ts +1 -3
  58. package/lib/cjs/utils/split-signature.js +1 -3
  59. package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
  60. package/lib/cjs/utils/to-checksum-address.js +2 -2
  61. package/lib/cjs/utils/to-utf8-bytes.d.ts +14 -0
  62. package/lib/cjs/utils/to-utf8-bytes.js +14 -0
  63. package/lib/cjs/utils/wei-to-ether.d.ts +2 -1
  64. package/lib/cjs/utils/wei-to-ether.js +2 -1
  65. package/lib/esm/classes/utils/clean-block.js +7 -8
  66. package/lib/esm/classes/utils/clean-log.d.ts +2 -0
  67. package/lib/esm/classes/utils/clean-log.js +26 -0
  68. package/lib/esm/classes/utils/clean-transaction-receipt.js +2 -16
  69. package/lib/esm/classes/utils/clean-transaction.js +1 -1
  70. package/lib/esm/classes/utils/fetchers.d.ts +1 -1
  71. package/lib/esm/classes/utils/prepare-transaction.d.ts +2 -0
  72. package/lib/esm/classes/utils/prepare-transaction.js +34 -0
  73. package/lib/esm/index.d.ts +3 -3
  74. package/lib/esm/index.js +0 -1
  75. package/lib/esm/logger/package-version.d.ts +1 -1
  76. package/lib/esm/logger/package-version.js +1 -1
  77. package/lib/esm/providers/BaseProvider.d.ts +5 -2
  78. package/lib/esm/providers/BaseProvider.js +56 -13
  79. package/lib/esm/providers/utils/chains-info.d.ts +11 -0
  80. package/lib/esm/providers/utils/chains-info.js +34 -1
  81. package/lib/esm/shared/tiny-big/tiny-big.js +4 -0
  82. package/lib/esm/types/Block.types.d.ts +11 -7
  83. package/lib/esm/types/Filter.types.d.ts +12 -0
  84. package/lib/esm/{providers/types.js → types/Filter.types.js} +0 -0
  85. package/lib/esm/types/Transaction.types.d.ts +31 -5
  86. package/lib/esm/utils/keccak256.d.ts +1 -1
  87. package/lib/esm/utils/keccak256.js +2 -2
  88. package/package.json +30 -6
  89. package/readme.md +643 -291
  90. package/lib/cjs/providers/types.d.ts +0 -7
  91. package/lib/esm/providers/types.d.ts +0 -7
@@ -0,0 +1,34 @@
1
+ import Big from 'big.js';
2
+ import { TinyBig } from '../../shared/tiny-big/tiny-big';
3
+ import { hexlify } from '../../utils/bytes';
4
+ export function prepareTransaction(transaction) {
5
+ const preparedTransaction = Object.assign({}, transaction);
6
+ Object.keys(transaction).forEach((key) => {
7
+ switch (key) {
8
+ case 'gas':
9
+ case 'gasPrice':
10
+ case 'nonce':
11
+ case 'maxFeePerGas':
12
+ case 'maxPriorityFeePerGas':
13
+ case 'value': {
14
+ const value = transaction[key];
15
+ if (value instanceof TinyBig) {
16
+ preparedTransaction[key] = value.toHexString();
17
+ }
18
+ else if (value instanceof Big) {
19
+ preparedTransaction[key] = `0x${BigInt(value.toString()).toString(16)}`;
20
+ }
21
+ else if (typeof transaction[key] === 'number')
22
+ preparedTransaction[key] =
23
+ '0x' + transaction[key].toString(16);
24
+ else
25
+ preparedTransaction[key] = transaction[key].toString();
26
+ break;
27
+ }
28
+ case 'data':
29
+ preparedTransaction[key] = hexlify(transaction[key]);
30
+ break;
31
+ }
32
+ });
33
+ return preparedTransaction;
34
+ }
@@ -4,8 +4,9 @@ import { JsonRpcProvider, jsonRpcProvider } from './providers/JsonRpcProvider';
4
4
  import { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
5
5
  import { BlockResponse, BlockTag, RPCBlock } from './types/Block.types';
6
6
  import { ContractTypes, JSONABI, JSONABIArgument } from './types/Contract.types';
7
+ import { Filter, FilterByBlockHash } from './types/Filter.types';
7
8
  import { Network } from './types/Network.types';
8
- import { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, TransactionReceipt, TransactionResponse } from './types/Transaction.types';
9
+ import { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, RPCTransactionRequest, TransactionReceipt, TransactionRequest, TransactionResponse } from './types/Transaction.types';
9
10
  import { computeAddress } from './utils/compute-address';
10
11
  import { computePublicKey } from './utils/compute-public-key';
11
12
  import { etherToGwei } from './utils/ether-to-gwei';
@@ -17,9 +18,8 @@ import { splitSignature } from './utils/split-signature';
17
18
  import { toChecksumAddress } from './utils/to-checksum-address';
18
19
  import { toUtf8Bytes } from './utils/to-utf8-bytes';
19
20
  import { weiToEther } from './utils/wei-to-ether';
20
- export * from './providers/types';
21
21
  export * from './utils/bytes';
22
22
  export * from './utils/hash-message';
23
23
  export * from './utils/keccak256';
24
24
  export * from './utils/solidity-keccak256';
25
- export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
25
+ export { etherToWei, etherToGwei, isAddress, jsonRpcProvider, JsonRpcProvider, FallthroughProvider, tinyBig, toChecksumAddress, weiToEther, gweiToEther, hashMessage, splitSignature, toUtf8Bytes, computeAddress, computePublicKey, Contract, TinyBig, BaseContract, BlockResponse, ContractTypes, Filter, FilterByBlockHash, JSONABI, JSONABIArgument, Network, TransactionResponse, RPCBlock, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, BlockTag, RPCLog, Log, BlockTransactionResponse, ConstructorOptions, };
package/lib/esm/index.js CHANGED
@@ -13,7 +13,6 @@ import { splitSignature } from './utils/split-signature';
13
13
  import { toChecksumAddress } from './utils/to-checksum-address';
14
14
  import { toUtf8Bytes } from './utils/to-utf8-bytes';
15
15
  import { weiToEther } from './utils/wei-to-ether';
16
- export * from './providers/types';
17
16
  export * from './utils/bytes';
18
17
  export * from './utils/hash-message';
19
18
  export * from './utils/keccak256';
@@ -1 +1 @@
1
- export declare const version = "0.5.6";
1
+ export declare const version = "0.5.9";
@@ -1 +1 @@
1
- export const version = '0.5.6';
1
+ export const version = '0.5.9';
@@ -1,8 +1,8 @@
1
1
  import { TinyBig } from '../shared/tiny-big/tiny-big';
2
2
  import { BlockResponse, BlockTag } from '../types/Block.types';
3
+ import { Filter, FilterByBlockHash } from '../types/Filter.types';
3
4
  import { Network } from '../types/Network.types';
4
- import { TransactionReceipt, TransactionResponse } from '../types/Transaction.types';
5
- import { TransactionRequest } from './types';
5
+ import { Log, TransactionReceipt, TransactionRequest, TransactionResponse } from '../types/Transaction.types';
6
6
  export declare abstract class BaseProvider {
7
7
  abstract selectRpcUrl(): string;
8
8
  abstract post(body: Record<string, unknown>): Promise<any>;
@@ -17,5 +17,8 @@ export declare abstract class BaseProvider {
17
17
  getBlock(timeFrame?: BlockTag, returnTransactionObjects?: boolean): Promise<BlockResponse>;
18
18
  getGasPrice(): Promise<TinyBig>;
19
19
  getBalance(address: string, blockTag?: BlockTag): Promise<TinyBig>;
20
+ getCode(address: string, blockTag?: BlockTag): Promise<string>;
20
21
  estimateGas(transaction: TransactionRequest): Promise<TinyBig>;
22
+ getLogs(filter: Filter | FilterByBlockHash): Promise<Array<Log>>;
23
+ call(transaction: TransactionRequest, blockTag?: BlockTag): Promise<string>;
21
24
  }
@@ -8,12 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { cleanBlock } from '../classes/utils/clean-block';
11
+ import { cleanLog } from '../classes/utils/clean-log';
11
12
  import { cleanTransaction } from '../classes/utils/clean-transaction';
12
13
  import { cleanTransactionReceipt } from '../classes/utils/clean-transaction-receipt';
13
14
  import { buildRPCPostBody, post } from '../classes/utils/fetchers';
14
15
  import { hexToDecimal } from '../classes/utils/hex-to-decimal';
16
+ import { prepareTransaction } from '../classes/utils/prepare-transaction';
17
+ import { logger } from '../logger/logger';
15
18
  import { tinyBig } from '../shared/tiny-big/tiny-big';
16
19
  import chainsInfo from './utils/chains-info';
20
+ function prepBlockTag(blockTag) {
21
+ return typeof blockTag === 'number'
22
+ ? tinyBig(blockTag).toHexString()
23
+ : blockTag;
24
+ }
17
25
  export class BaseProvider {
18
26
  constructor(rpcUrls) {
19
27
  this._rpcUrls = [];
@@ -64,29 +72,22 @@ export class BaseProvider {
64
72
  }
65
73
  getTransactionCount(address, blockTag = 'latest') {
66
74
  return __awaiter(this, void 0, void 0, function* () {
67
- if (typeof blockTag === 'number') {
68
- blockTag = `0x${blockTag.toString(16)}`;
69
- }
75
+ blockTag = prepBlockTag(blockTag);
70
76
  const transactionCount = (yield this.post(buildRPCPostBody('eth_getTransactionCount', [address, blockTag])));
71
77
  return Number(hexToDecimal(transactionCount));
72
78
  });
73
79
  }
74
80
  getBlock(timeFrame = 'latest', returnTransactionObjects = false) {
75
81
  return __awaiter(this, void 0, void 0, function* () {
76
- let rpcTimeFrame;
77
82
  let type = 'Number';
78
- if (typeof timeFrame === 'number') {
79
- rpcTimeFrame = `0x${timeFrame.toString(16)}`;
80
- }
81
- else if (timeFrame.startsWith('0x')) {
82
- rpcTimeFrame = timeFrame;
83
+ if (typeof timeFrame === 'string' && timeFrame.length === 66) {
83
84
  type = 'Hash';
84
85
  }
85
86
  else {
86
- rpcTimeFrame = timeFrame;
87
+ timeFrame = prepBlockTag(timeFrame);
87
88
  }
88
89
  const rpcBlock = (yield this.post(buildRPCPostBody(`eth_getBlockBy${type}`, [
89
- rpcTimeFrame,
90
+ timeFrame,
90
91
  returnTransactionObjects,
91
92
  ])));
92
93
  return cleanBlock(rpcBlock, returnTransactionObjects);
@@ -100,15 +101,57 @@ export class BaseProvider {
100
101
  }
101
102
  getBalance(address, blockTag = 'latest') {
102
103
  return __awaiter(this, void 0, void 0, function* () {
104
+ blockTag = prepBlockTag(blockTag);
103
105
  const hexBalance = (yield this.post(buildRPCPostBody('eth_getBalance', [address, blockTag])));
104
106
  return tinyBig(hexToDecimal(hexBalance));
105
107
  });
106
108
  }
109
+ getCode(address, blockTag = 'latest') {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ blockTag = prepBlockTag(blockTag);
112
+ const contractCode = (yield this.post(buildRPCPostBody('eth_getCode', [address, blockTag])));
113
+ return contractCode;
114
+ });
115
+ }
107
116
  estimateGas(transaction) {
108
117
  return __awaiter(this, void 0, void 0, function* () {
109
- const body = buildRPCPostBody('eth_estimateGas', [transaction]);
110
- const gasUsed = (yield this.post(body));
118
+ const rpcTransaction = prepareTransaction(transaction);
119
+ const gasUsed = (yield this.post(buildRPCPostBody('eth_estimateGas', [rpcTransaction])));
111
120
  return tinyBig(hexToDecimal(gasUsed));
112
121
  });
113
122
  }
123
+ getLogs(filter) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const filterByRange = filter;
126
+ if (filterByRange.fromBlock)
127
+ filterByRange.fromBlock = prepBlockTag(filterByRange.fromBlock);
128
+ if (filterByRange.toBlock)
129
+ filterByRange.toBlock = prepBlockTag(filterByRange.toBlock);
130
+ const rpcLogs = (yield this.post(buildRPCPostBody('eth_getLogs', [filter])));
131
+ const logs = rpcLogs.map((log) => cleanLog(log, false));
132
+ return logs;
133
+ });
134
+ }
135
+ call(transaction, blockTag = 'latest') {
136
+ return __awaiter(this, void 0, void 0, function* () {
137
+ if (transaction.gasPrice &&
138
+ (transaction.maxPriorityFeePerGas || transaction.maxFeePerGas)) {
139
+ logger.throwError('Cannot specify both "gasPrice" and ("maxPriorityFeePerGas" or "maxFeePerGas")', {
140
+ gasPrice: transaction.gasPrice,
141
+ maxFeePerGas: transaction.maxFeePerGas,
142
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
143
+ });
144
+ }
145
+ if (transaction.maxFeePerGas && transaction.maxPriorityFeePerGas) {
146
+ logger.throwError('Cannot specify both "maxFeePerGas" and "maxPriorityFeePerGas"', {
147
+ maxFeePerGas: transaction.maxFeePerGas,
148
+ maxPriorityFeePerGas: transaction.maxPriorityFeePerGas,
149
+ });
150
+ }
151
+ blockTag = prepBlockTag(blockTag);
152
+ const rpcTransaction = prepareTransaction(transaction);
153
+ const transactionRes = (yield this.post(buildRPCPostBody('eth_call', [rpcTransaction, blockTag])));
154
+ return transactionRes;
155
+ });
156
+ }
114
157
  }
@@ -203,6 +203,8 @@ declare const _default: {
203
203
  "1287": string[];
204
204
  "1288": string[];
205
205
  "1337": string[];
206
+ "1506": string[];
207
+ "1507": string[];
206
208
  "1618": string[];
207
209
  "1620": string[];
208
210
  "1657": string[];
@@ -243,6 +245,7 @@ declare const _default: {
243
245
  "3967": string[];
244
246
  "4002": string[];
245
247
  "4102": string[];
248
+ "4181": string[];
246
249
  "4689": string[];
247
250
  "4690": string[];
248
251
  "4918": string[];
@@ -277,6 +280,8 @@ declare const _default: {
277
280
  "10001": string[];
278
281
  "10101": string[];
279
282
  "10823": string[];
283
+ "10946": string[];
284
+ "10947": string[];
280
285
  "11111": string[];
281
286
  "11437": string[];
282
287
  "12051": string[];
@@ -290,6 +295,7 @@ declare const _default: {
290
295
  "22023": string[];
291
296
  "24484": string[];
292
297
  "24734": string[];
298
+ "26863": string[];
293
299
  "30067": string[];
294
300
  "31102": string[];
295
301
  "31337": string[];
@@ -325,6 +331,8 @@ declare const _default: {
325
331
  "70002": string[];
326
332
  "70103": string[];
327
333
  "71393": string[];
334
+ "71401": string[];
335
+ "71402": string[];
328
336
  "73799": string[];
329
337
  "78110": string[];
330
338
  "80001": string[];
@@ -361,7 +369,9 @@ declare const _default: {
361
369
  "333888": string[];
362
370
  "333999": string[];
363
371
  "421611": string[];
372
+ "432201": string[];
364
373
  "444900": string[];
374
+ "474142": string[];
365
375
  "512512": string[];
366
376
  "666666": string[];
367
377
  "888888": string[];
@@ -369,6 +379,7 @@ declare const _default: {
369
379
  "1313114": string[];
370
380
  "1313500": string[];
371
381
  "1337702": string[];
382
+ "1337802": string[];
372
383
  "2203181": string[];
373
384
  "7762959": string[];
374
385
  "11155111": string[];
@@ -615,6 +615,12 @@ export default {
615
615
  "1337": [
616
616
  "cennz-old"
617
617
  ],
618
+ "1506": [
619
+ "Sherpax"
620
+ ],
621
+ "1507": [
622
+ "Sherpax Testnet"
623
+ ],
618
624
  "1618": [
619
625
  "cate"
620
626
  ],
@@ -735,6 +741,9 @@ export default {
735
741
  "4102": [
736
742
  "aioz-testnet"
737
743
  ],
744
+ "4181": [
745
+ "PHI"
746
+ ],
738
747
  "4689": [
739
748
  "iotex-mainnet"
740
749
  ],
@@ -837,6 +846,12 @@ export default {
837
846
  "10823": [
838
847
  "CCP"
839
848
  ],
849
+ "10946": [
850
+ "quadrans"
851
+ ],
852
+ "10947": [
853
+ "quadranstestnet"
854
+ ],
840
855
  "11111": [
841
856
  "WAGMI"
842
857
  ],
@@ -876,6 +891,9 @@ export default {
876
891
  "24734": [
877
892
  "mintme"
878
893
  ],
894
+ "26863": [
895
+ "OAC"
896
+ ],
879
897
  "30067": [
880
898
  "Piece"
881
899
  ],
@@ -981,6 +999,12 @@ export default {
981
999
  "71393": [
982
1000
  "ckb"
983
1001
  ],
1002
+ "71401": [
1003
+ "gw-testnet-v1"
1004
+ ],
1005
+ "71402": [
1006
+ "gw-mainnet-v1"
1007
+ ],
984
1008
  "73799": [
985
1009
  "vt"
986
1010
  ],
@@ -1089,9 +1113,15 @@ export default {
1089
1113
  "421611": [
1090
1114
  "arb-rinkeby"
1091
1115
  ],
1116
+ "432201": [
1117
+ "Dexalot"
1118
+ ],
1092
1119
  "444900": [
1093
1120
  "wlkt"
1094
1121
  ],
1122
+ "474142": [
1123
+ "oc"
1124
+ ],
1095
1125
  "512512": [
1096
1126
  "cmp"
1097
1127
  ],
@@ -1113,6 +1143,9 @@ export default {
1113
1143
  "1337702": [
1114
1144
  "kintsugi"
1115
1145
  ],
1146
+ "1337802": [
1147
+ "kiln"
1148
+ ],
1116
1149
  "2203181": [
1117
1150
  "platondev"
1118
1151
  ],
@@ -1228,6 +1261,6 @@ export default {
1228
1261
  "mole"
1229
1262
  ],
1230
1263
  "868455272153094": [
1231
- "gw-testnet-v1"
1264
+ "gw-testnet-v1-deprecated"
1232
1265
  ]
1233
1266
  };
@@ -1,7 +1,11 @@
1
1
  import Big from 'big.js';
2
+ import { hexToDecimal } from '../../classes/utils/hex-to-decimal';
2
3
  import { scientificStrToDecimalStr } from './helpers';
3
4
  export class TinyBig extends Big {
4
5
  constructor(value) {
6
+ if (typeof value === 'string' && value.startsWith('0x')) {
7
+ value = hexToDecimal(value);
8
+ }
5
9
  super(value);
6
10
  this.padAndChop = (str, padChar, length) => {
7
11
  return (Array(length).fill(padChar).join('') + str).slice(length * -1);
@@ -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
  export interface RPCBlock {
@@ -28,9 +32,9 @@ export interface RPCBlock {
28
32
  stateRoot: string;
29
33
  timestamp: string;
30
34
  totalDifficulty: string;
31
- transactions: Array<string> | Array<RPCTransaction>;
35
+ transactions: Array<string | RPCTransaction>;
32
36
  transactionsRoot: string;
33
- uncles: unknown[];
37
+ uncles: Array<string>;
34
38
  }
35
39
  export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
36
40
  export {};
@@ -0,0 +1,12 @@
1
+ import { BlockTag } from './Block.types';
2
+ export interface EventFilter {
3
+ address?: string;
4
+ topics?: Array<string | Array<string> | null>;
5
+ }
6
+ export interface Filter extends EventFilter {
7
+ fromBlock?: BlockTag;
8
+ toBlock?: BlockTag;
9
+ }
10
+ export interface FilterByBlockHash extends EventFilter {
11
+ blockHash?: string;
12
+ }
@@ -1,4 +1,6 @@
1
+ import type Big from 'big.js';
1
2
  import { TinyBig } from '../shared/tiny-big/tiny-big';
3
+ import { BytesLike } from './../utils/bytes';
2
4
  declare type Modify<T, R> = Omit<T, keyof R> & R;
3
5
  export interface RPCTransaction extends RPCBlockTransaction {
4
6
  maxFeePerGas: string;
@@ -7,14 +9,14 @@ export interface RPCTransaction extends RPCBlockTransaction {
7
9
  export declare type TransactionResponse = Modify<RPCTransaction, {
8
10
  blockNumber: number;
9
11
  chainId: number;
10
- nonce: number;
12
+ gas: TinyBig;
13
+ gasLimit: TinyBig;
14
+ gasPrice: TinyBig;
15
+ nonce: TinyBig;
11
16
  transactionIndex: number;
12
17
  type: number;
13
18
  v: number;
14
19
  value: TinyBig;
15
- gasPrice: TinyBig;
16
- gas: TinyBig;
17
- gasLimit: TinyBig;
18
20
  } & {
19
21
  maxFeePerGas: TinyBig;
20
22
  maxPriorityFeePerGas: TinyBig;
@@ -33,7 +35,31 @@ export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
33
35
  byzantium: boolean;
34
36
  confirmations: number;
35
37
  }>;
36
- export declare type Log = Modify<Omit<RPCLog, 'removed'>, {
38
+ export interface RPCTransactionRequest {
39
+ from?: string;
40
+ to: string;
41
+ gas?: string;
42
+ gasPrice?: string;
43
+ value?: string;
44
+ data?: BytesLike;
45
+ nonce?: string;
46
+ maxPriorityFeePerGas?: string;
47
+ maxFeePerGas?: string;
48
+ }
49
+ export interface TransactionRequest {
50
+ to?: string;
51
+ from?: string;
52
+ nonce?: TinyBig | string | Big | number;
53
+ gas?: TinyBig | number | Big | string;
54
+ gasPrice?: TinyBig | Big | string | number;
55
+ data?: BytesLike;
56
+ value?: TinyBig | string | Big | number;
57
+ chainId?: number;
58
+ type?: number;
59
+ maxPriorityFeePerGas?: TinyBig | string | Big | number;
60
+ maxFeePerGas?: TinyBig | string | Big | number;
61
+ }
62
+ export declare type Log = Modify<RPCLog, {
37
63
  blockNumber: number;
38
64
  logIndex: number;
39
65
  transactionIndex: number;
@@ -1,2 +1,2 @@
1
1
  import { BytesLike } from './bytes';
2
- export declare const keccak256: (data: BytesLike) => string;
2
+ export declare function keccak256(data: BytesLike): string;
@@ -1,5 +1,5 @@
1
1
  import { Keccak } from 'sha3';
2
- export const keccak256 = (data) => {
2
+ export function keccak256(data) {
3
3
  let bufferableData;
4
4
  if (typeof data === 'string') {
5
5
  bufferableData = Buffer.from(data.replace(/^0x/, ''), 'hex');
@@ -10,4 +10,4 @@ export const keccak256 = (data) => {
10
10
  const keccak = new Keccak(256);
11
11
  const addressHash = '0x' + keccak.update(bufferableData).digest('hex');
12
12
  return addressHash;
13
- };
13
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "essential-eth",
3
3
  "description": "Ultralight JS for Ethereum",
4
- "version": "0.5.6",
4
+ "version": "0.5.9",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "main": "./lib/cjs/index.js",
@@ -14,7 +14,28 @@
14
14
  },
15
15
  "repository": "https://github.com/dawsbot/essential-eth.git",
16
16
  "author": "@dawsbot",
17
+ "size-limit": [
18
+ {
19
+ "name": "etherToWei",
20
+ "path": "src/index.ts",
21
+ "import": "{ etherToWei }",
22
+ "limit": "3.9kb"
23
+ },
24
+ {
25
+ "name": "JsonRpcProvider",
26
+ "path": "src/index.ts",
27
+ "import": "{ JsonRpcProvider }",
28
+ "limit": "22kb"
29
+ },
30
+ {
31
+ "name": "Contract",
32
+ "path": "src/index.ts",
33
+ "import": "{ Contract }",
34
+ "limit": "18kb"
35
+ }
36
+ ],
17
37
  "scripts": {
38
+ "size": "size-limit",
18
39
  "test": "npm-run-all --parallel jest compile lint",
19
40
  "test:all-node-versions": "npx trevor",
20
41
  "lint": "eslint --cache --fix .",
@@ -22,7 +43,7 @@
22
43
  "tsc:esm": "tsc -p tsconfig.json",
23
44
  "tsc:cjs": "tsc -p tsconfig-cjs.json",
24
45
  "build": "rm -rf lib && npm run compile",
25
- "build:readme": ". ./scripts/markdown-magic/build-readme.sh",
46
+ "build:readme": "bash ./scripts/markdown-magic/build-readme.sh",
26
47
  "jest": "jest",
27
48
  "build:chains-info": "npx ts-node scripts/fetch-chains-info.ts # used in getNetwork()",
28
49
  "update-deps": "sh ./scripts/pre-commit.sh",
@@ -34,6 +55,7 @@
34
55
  "doc": "typedoc"
35
56
  },
36
57
  "devDependencies": {
58
+ "@size-limit/preset-small-lib": "^7.0.8",
37
59
  "@types/body-parser": "^1.19.1",
38
60
  "@types/eslint": "^8.4.2",
39
61
  "@types/express": "^4.17.13",
@@ -41,13 +63,14 @@
41
63
  "@types/jest-dev-server": "^5.0.0",
42
64
  "@types/node": "^16.10.1",
43
65
  "@types/prettier": "^2.4.4",
44
- "@typescript-eslint/eslint-plugin": "^5.25.0",
45
- "@typescript-eslint/parser": "^5.25.0",
66
+ "@typescript-eslint/eslint-plugin": "^5.26.0",
67
+ "@typescript-eslint/parser": "^5.26.0",
46
68
  "body-parser": "^1.19.0",
47
69
  "dotenv": "^16.0.0",
48
70
  "eslint": "^8.16.0",
49
71
  "eslint-plugin-jest": "^26.2.2",
50
- "ethers": "^5.6.7",
72
+ "eslint-plugin-jsdoc": "38.0.2",
73
+ "ethers": "^5.6.8",
51
74
  "express": "^4.17.1",
52
75
  "husky": "^7.0.4",
53
76
  "jest": "^27.5.1",
@@ -58,6 +81,7 @@
58
81
  "perf_hooks": "^0.0.1",
59
82
  "prettier": "^2.6.2",
60
83
  "prettier-plugin-organize-imports": "^2.3.4",
84
+ "size-limit": "^7.0.8",
61
85
  "ts-jest": "^27.1.4",
62
86
  "ts-node": "^10.2.1",
63
87
  "typedoc": "^0.22.15",
@@ -67,7 +91,7 @@
67
91
  "dependencies": {
68
92
  "@noble/secp256k1": "^1.5.5",
69
93
  "@types/big.js": "^6.1.3",
70
- "big.js": "^6.1.1",
94
+ "big.js": "^6.2.0",
71
95
  "isomorphic-unfetch": "^3.1.0",
72
96
  "sha3": "^2.1.4"
73
97
  },