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.
- package/lib/cjs/classes/Contract.d.ts +10 -4
- package/lib/cjs/classes/Contract.js +15 -4
- package/lib/cjs/classes/utils/clean-block.d.ts +115 -0
- package/lib/cjs/classes/utils/clean-block.js +122 -9
- package/lib/cjs/classes/utils/clean-log.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-log.js +37 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +11 -16
- package/lib/cjs/classes/utils/clean-transaction.d.ts +9 -0
- package/lib/cjs/classes/utils/clean-transaction.js +10 -1
- package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +12 -0
- package/lib/cjs/classes/utils/encode-decode-transaction.js +24 -0
- package/lib/cjs/classes/utils/fetchers.d.ts +31 -1
- package/lib/cjs/classes/utils/fetchers.js +30 -0
- package/lib/cjs/classes/utils/hex-to-decimal.d.ts +14 -1
- package/lib/cjs/classes/utils/hex-to-decimal.js +14 -1
- package/lib/cjs/classes/utils/prepare-transaction.d.ts +6 -0
- package/lib/cjs/classes/utils/prepare-transaction.js +45 -0
- package/lib/cjs/index.d.ts +3 -3
- package/lib/cjs/index.js +0 -1
- package/lib/cjs/logger/package-version.d.ts +1 -1
- package/lib/cjs/logger/package-version.js +1 -1
- package/lib/cjs/providers/BaseProvider.d.ts +261 -212
- package/lib/cjs/providers/BaseProvider.js +332 -225
- package/lib/cjs/providers/JsonRpcProvider.d.ts +6 -0
- package/lib/cjs/providers/JsonRpcProvider.js +6 -0
- package/lib/cjs/providers/utils/chains-info.d.ts +11 -0
- package/lib/cjs/providers/utils/chains-info.js +34 -1
- package/lib/cjs/shared/tiny-big/helpers.d.ts +16 -0
- package/lib/cjs/shared/tiny-big/helpers.js +27 -1
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +30 -4
- package/lib/cjs/shared/tiny-big/tiny-big.js +34 -4
- package/lib/cjs/types/Block.types.d.ts +11 -7
- package/lib/cjs/types/Filter.types.d.ts +16 -0
- package/lib/cjs/{providers/types.js → types/Filter.types.js} +0 -0
- package/lib/cjs/types/Transaction.types.d.ts +33 -6
- package/lib/cjs/utils/bytes.d.ts +150 -33
- package/lib/cjs/utils/bytes.js +179 -32
- package/lib/cjs/utils/compute-address.d.ts +10 -1
- package/lib/cjs/utils/compute-address.js +10 -1
- package/lib/cjs/utils/compute-public-key.d.ts +12 -3
- package/lib/cjs/utils/compute-public-key.js +12 -3
- package/lib/cjs/utils/ether-to-gwei.d.ts +2 -1
- package/lib/cjs/utils/ether-to-gwei.js +2 -1
- package/lib/cjs/utils/ether-to-wei.d.ts +2 -1
- package/lib/cjs/utils/ether-to-wei.js +2 -1
- package/lib/cjs/utils/gwei-to-ether.d.ts +2 -1
- package/lib/cjs/utils/gwei-to-ether.js +2 -1
- package/lib/cjs/utils/hash-message.d.ts +3 -1
- package/lib/cjs/utils/hash-message.js +3 -1
- package/lib/cjs/utils/is-address.d.ts +2 -2
- package/lib/cjs/utils/is-address.js +2 -2
- package/lib/cjs/utils/keccak256.d.ts +15 -1
- package/lib/cjs/utils/keccak256.js +16 -2
- package/lib/cjs/utils/solidity-keccak256.d.ts +17 -7
- package/lib/cjs/utils/solidity-keccak256.js +27 -7
- package/lib/cjs/utils/split-signature.d.ts +1 -3
- package/lib/cjs/utils/split-signature.js +1 -3
- package/lib/cjs/utils/to-checksum-address.d.ts +2 -2
- package/lib/cjs/utils/to-checksum-address.js +2 -2
- package/lib/cjs/utils/to-utf8-bytes.d.ts +14 -0
- package/lib/cjs/utils/to-utf8-bytes.js +14 -0
- package/lib/cjs/utils/wei-to-ether.d.ts +2 -1
- package/lib/cjs/utils/wei-to-ether.js +2 -1
- package/lib/esm/classes/utils/clean-block.js +7 -8
- package/lib/esm/classes/utils/clean-log.d.ts +2 -0
- package/lib/esm/classes/utils/clean-log.js +26 -0
- package/lib/esm/classes/utils/clean-transaction-receipt.js +2 -16
- package/lib/esm/classes/utils/clean-transaction.js +1 -1
- package/lib/esm/classes/utils/fetchers.d.ts +1 -1
- package/lib/esm/classes/utils/prepare-transaction.d.ts +2 -0
- package/lib/esm/classes/utils/prepare-transaction.js +34 -0
- package/lib/esm/index.d.ts +3 -3
- package/lib/esm/index.js +0 -1
- package/lib/esm/logger/package-version.d.ts +1 -1
- package/lib/esm/logger/package-version.js +1 -1
- package/lib/esm/providers/BaseProvider.d.ts +5 -2
- package/lib/esm/providers/BaseProvider.js +56 -13
- package/lib/esm/providers/utils/chains-info.d.ts +11 -0
- package/lib/esm/providers/utils/chains-info.js +34 -1
- package/lib/esm/shared/tiny-big/tiny-big.js +4 -0
- package/lib/esm/types/Block.types.d.ts +11 -7
- package/lib/esm/types/Filter.types.d.ts +12 -0
- package/lib/esm/{providers/types.js → types/Filter.types.js} +0 -0
- package/lib/esm/types/Transaction.types.d.ts +31 -5
- package/lib/esm/utils/keccak256.d.ts +1 -1
- package/lib/esm/utils/keccak256.js +2 -2
- package/package.json +30 -6
- package/readme.md +643 -291
- package/lib/cjs/providers/types.d.ts +0 -7
- package/lib/esm/providers/types.d.ts +0 -7
|
@@ -10,12 +10,18 @@ export declare class JsonRpcProvider extends BaseProvider {
|
|
|
10
10
|
post(body: Record<string, unknown>): Promise<any>;
|
|
11
11
|
/**
|
|
12
12
|
* @param rpcUrl The URL to your Eth node. Consider POKT or Infura
|
|
13
|
+
* @example
|
|
14
|
+
* `https://free-eth-node.com/api/eth`
|
|
15
|
+
* @example
|
|
16
|
+
* `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
|
|
13
17
|
*/
|
|
14
18
|
constructor(rpcUrl?: string);
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Helper function to avoid "new"
|
|
18
22
|
*
|
|
23
|
+
* @param rpcUrl the RPC URL to post requests to
|
|
24
|
+
* @returns an initiated {@link JsonRpcProvider}
|
|
19
25
|
* @example
|
|
20
26
|
* ```javascript
|
|
21
27
|
* jsonRpcProvider().getBlock('latest').then(block => {
|
|
@@ -17,6 +17,10 @@ class JsonRpcProvider extends BaseProvider_1.BaseProvider {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* @param rpcUrl The URL to your Eth node. Consider POKT or Infura
|
|
20
|
+
* @example
|
|
21
|
+
* `https://free-eth-node.com/api/eth`
|
|
22
|
+
* @example
|
|
23
|
+
* `https://mainnet.infura.io/v3/YOUR-PROJECT-ID`
|
|
20
24
|
*/
|
|
21
25
|
constructor(rpcUrl = 'https://free-eth-node.com/api/eth') {
|
|
22
26
|
super([rpcUrl]);
|
|
@@ -26,6 +30,8 @@ exports.JsonRpcProvider = JsonRpcProvider;
|
|
|
26
30
|
/**
|
|
27
31
|
* Helper function to avoid "new"
|
|
28
32
|
*
|
|
33
|
+
* @param rpcUrl the RPC URL to post requests to
|
|
34
|
+
* @returns an initiated {@link JsonRpcProvider}
|
|
29
35
|
* @example
|
|
30
36
|
* ```javascript
|
|
31
37
|
* jsonRpcProvider().getBlock('latest').then(block => {
|
|
@@ -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[];
|
|
@@ -619,6 +619,12 @@ exports.default = {
|
|
|
619
619
|
"1337": [
|
|
620
620
|
"cennz-old"
|
|
621
621
|
],
|
|
622
|
+
"1506": [
|
|
623
|
+
"Sherpax"
|
|
624
|
+
],
|
|
625
|
+
"1507": [
|
|
626
|
+
"Sherpax Testnet"
|
|
627
|
+
],
|
|
622
628
|
"1618": [
|
|
623
629
|
"cate"
|
|
624
630
|
],
|
|
@@ -739,6 +745,9 @@ exports.default = {
|
|
|
739
745
|
"4102": [
|
|
740
746
|
"aioz-testnet"
|
|
741
747
|
],
|
|
748
|
+
"4181": [
|
|
749
|
+
"PHI"
|
|
750
|
+
],
|
|
742
751
|
"4689": [
|
|
743
752
|
"iotex-mainnet"
|
|
744
753
|
],
|
|
@@ -841,6 +850,12 @@ exports.default = {
|
|
|
841
850
|
"10823": [
|
|
842
851
|
"CCP"
|
|
843
852
|
],
|
|
853
|
+
"10946": [
|
|
854
|
+
"quadrans"
|
|
855
|
+
],
|
|
856
|
+
"10947": [
|
|
857
|
+
"quadranstestnet"
|
|
858
|
+
],
|
|
844
859
|
"11111": [
|
|
845
860
|
"WAGMI"
|
|
846
861
|
],
|
|
@@ -880,6 +895,9 @@ exports.default = {
|
|
|
880
895
|
"24734": [
|
|
881
896
|
"mintme"
|
|
882
897
|
],
|
|
898
|
+
"26863": [
|
|
899
|
+
"OAC"
|
|
900
|
+
],
|
|
883
901
|
"30067": [
|
|
884
902
|
"Piece"
|
|
885
903
|
],
|
|
@@ -985,6 +1003,12 @@ exports.default = {
|
|
|
985
1003
|
"71393": [
|
|
986
1004
|
"ckb"
|
|
987
1005
|
],
|
|
1006
|
+
"71401": [
|
|
1007
|
+
"gw-testnet-v1"
|
|
1008
|
+
],
|
|
1009
|
+
"71402": [
|
|
1010
|
+
"gw-mainnet-v1"
|
|
1011
|
+
],
|
|
988
1012
|
"73799": [
|
|
989
1013
|
"vt"
|
|
990
1014
|
],
|
|
@@ -1093,9 +1117,15 @@ exports.default = {
|
|
|
1093
1117
|
"421611": [
|
|
1094
1118
|
"arb-rinkeby"
|
|
1095
1119
|
],
|
|
1120
|
+
"432201": [
|
|
1121
|
+
"Dexalot"
|
|
1122
|
+
],
|
|
1096
1123
|
"444900": [
|
|
1097
1124
|
"wlkt"
|
|
1098
1125
|
],
|
|
1126
|
+
"474142": [
|
|
1127
|
+
"oc"
|
|
1128
|
+
],
|
|
1099
1129
|
"512512": [
|
|
1100
1130
|
"cmp"
|
|
1101
1131
|
],
|
|
@@ -1117,6 +1147,9 @@ exports.default = {
|
|
|
1117
1147
|
"1337702": [
|
|
1118
1148
|
"kintsugi"
|
|
1119
1149
|
],
|
|
1150
|
+
"1337802": [
|
|
1151
|
+
"kiln"
|
|
1152
|
+
],
|
|
1120
1153
|
"2203181": [
|
|
1121
1154
|
"platondev"
|
|
1122
1155
|
],
|
|
@@ -1232,6 +1265,6 @@ exports.default = {
|
|
|
1232
1265
|
"mole"
|
|
1233
1266
|
],
|
|
1234
1267
|
"868455272153094": [
|
|
1235
|
-
"gw-testnet-v1"
|
|
1268
|
+
"gw-testnet-v1-deprecated"
|
|
1236
1269
|
]
|
|
1237
1270
|
};
|
|
@@ -1 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string in scientific notation formatting to string in decimal format
|
|
3
|
+
*
|
|
4
|
+
* @param scientificString a string in scientific format to convert to decimal
|
|
5
|
+
* @returns a string of a decimal number equivalent to the specified scientificString
|
|
6
|
+
* @example
|
|
7
|
+
* ```javascript
|
|
8
|
+
* scientificStrToDecimalStr('2.3e-5');
|
|
9
|
+
* // '0.000023'
|
|
10
|
+
* ```
|
|
11
|
+
* @example
|
|
12
|
+
* ```javascript
|
|
13
|
+
* scientificStrToDecimalStr('2.3e+5');
|
|
14
|
+
* // '230000'
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
export declare function scientificStrToDecimalStr(scientificString: string): string;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scientificStrToDecimalStr = void 0;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Strips both leading and trailing zeroes from a number string
|
|
6
|
+
*
|
|
7
|
+
* @param numberString the string of numbers to strip zeros from
|
|
8
|
+
* @returns a string of numbers without leading or trailing zeros
|
|
9
|
+
* @example
|
|
10
|
+
* ```javascript
|
|
11
|
+
* stripTrailingZeros('0005280');
|
|
12
|
+
* // '5280'
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
5
15
|
function stripTrailingZeroes(numberString) {
|
|
6
16
|
const isNegative = numberString.startsWith('-');
|
|
7
17
|
numberString = numberString.replace('-', '');
|
|
@@ -17,6 +27,22 @@ function stripTrailingZeroes(numberString) {
|
|
|
17
27
|
}
|
|
18
28
|
return `${isNegative ? '-' : ''}${numberString}`;
|
|
19
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts a string in scientific notation formatting to string in decimal format
|
|
32
|
+
*
|
|
33
|
+
* @param scientificString a string in scientific format to convert to decimal
|
|
34
|
+
* @returns a string of a decimal number equivalent to the specified scientificString
|
|
35
|
+
* @example
|
|
36
|
+
* ```javascript
|
|
37
|
+
* scientificStrToDecimalStr('2.3e-5');
|
|
38
|
+
* // '0.000023'
|
|
39
|
+
* ```
|
|
40
|
+
* @example
|
|
41
|
+
* ```javascript
|
|
42
|
+
* scientificStrToDecimalStr('2.3e+5');
|
|
43
|
+
* // '230000'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
20
46
|
function scientificStrToDecimalStr(scientificString) {
|
|
21
47
|
// Does not contain "e" nor "E"
|
|
22
48
|
if (!scientificString.match(/e/i /* lowercase and uppercase E */)) {
|
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
2
|
/**
|
|
3
3
|
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
4
|
-
*
|
|
4
|
+
* This is the return type of every operation on ether, wei, etc.
|
|
5
5
|
*/
|
|
6
6
|
export declare class TinyBig extends Big {
|
|
7
7
|
constructor(value: string | number | TinyBig | Big);
|
|
8
8
|
/**
|
|
9
9
|
* Used anytime you're passing in "value" to ethers or web3
|
|
10
10
|
* For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
|
|
11
|
+
*
|
|
12
|
+
* @returns the TinyBig represented as a hex string
|
|
13
|
+
* @example
|
|
14
|
+
* ```javascript
|
|
15
|
+
* tinyBig(293).toHexString();
|
|
16
|
+
* // '0x125'
|
|
17
|
+
* ```
|
|
18
|
+
* @example
|
|
19
|
+
* ```javascript
|
|
20
|
+
* tinyBig(681365874).toHexString();
|
|
21
|
+
* // '0x289cd172'
|
|
11
22
|
*/
|
|
12
23
|
toHexString(): string;
|
|
13
24
|
toNumber(): number;
|
|
14
25
|
toString(): string;
|
|
15
26
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param
|
|
27
|
+
* Eithers pads or shortens a string to a specified length
|
|
28
|
+
*
|
|
29
|
+
* @param str the string to pad or chop
|
|
30
|
+
* @param padChar the character to pad the string with
|
|
31
|
+
* @param length the desired length of the given string
|
|
32
|
+
* @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
|
|
33
|
+
* @example
|
|
34
|
+
* ```javascript
|
|
35
|
+
* padAndChop('essential-eth', 'a', 8);
|
|
36
|
+
* // 'tial-eth'
|
|
37
|
+
* ```
|
|
38
|
+
* @example
|
|
39
|
+
* ```javascript
|
|
40
|
+
* padAndChop('essential-eth', 'A', 20);
|
|
41
|
+
* // 'AAAAAAAessential-eth'
|
|
42
|
+
* ```
|
|
19
43
|
*/
|
|
20
44
|
private padAndChop;
|
|
21
45
|
toTwos(bitCount: number): Big;
|
|
@@ -23,6 +47,8 @@ export declare class TinyBig extends Big {
|
|
|
23
47
|
/**
|
|
24
48
|
* Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
|
|
25
49
|
*
|
|
50
|
+
* @param value the value to initiate the TinyBig with
|
|
51
|
+
* @returns an initiated {@link TinyBig}
|
|
26
52
|
* @example
|
|
27
53
|
* ```javascript
|
|
28
54
|
* tinyBig(10).times(3).toNumber()
|
|
@@ -5,18 +5,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.tinyBig = exports.TinyBig = void 0;
|
|
7
7
|
const big_js_1 = __importDefault(require("big.js"));
|
|
8
|
+
const hex_to_decimal_1 = require("../../classes/utils/hex-to-decimal");
|
|
8
9
|
const helpers_1 = require("./helpers");
|
|
9
10
|
/**
|
|
10
11
|
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
11
|
-
*
|
|
12
|
+
* This is the return type of every operation on ether, wei, etc.
|
|
12
13
|
*/
|
|
13
14
|
class TinyBig extends big_js_1.default {
|
|
14
15
|
constructor(value) {
|
|
16
|
+
if (typeof value === 'string' && value.startsWith('0x')) {
|
|
17
|
+
value = (0, hex_to_decimal_1.hexToDecimal)(value);
|
|
18
|
+
}
|
|
15
19
|
super(value);
|
|
16
20
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
21
|
+
* Eithers pads or shortens a string to a specified length
|
|
22
|
+
*
|
|
23
|
+
* @param str the string to pad or chop
|
|
24
|
+
* @param padChar the character to pad the string with
|
|
25
|
+
* @param length the desired length of the given string
|
|
26
|
+
* @returns a string of the desired length, either padded with the specified padChar or with the beginning of the string chopped off
|
|
27
|
+
* @example
|
|
28
|
+
* ```javascript
|
|
29
|
+
* padAndChop('essential-eth', 'a', 8);
|
|
30
|
+
* // 'tial-eth'
|
|
31
|
+
* ```
|
|
32
|
+
* @example
|
|
33
|
+
* ```javascript
|
|
34
|
+
* padAndChop('essential-eth', 'A', 20);
|
|
35
|
+
* // 'AAAAAAAessential-eth'
|
|
36
|
+
* ```
|
|
20
37
|
*/
|
|
21
38
|
this.padAndChop = (str, padChar, length) => {
|
|
22
39
|
return (Array(length).fill(padChar).join('') + str).slice(length * -1);
|
|
@@ -25,6 +42,17 @@ class TinyBig extends big_js_1.default {
|
|
|
25
42
|
/**
|
|
26
43
|
* Used anytime you're passing in "value" to ethers or web3
|
|
27
44
|
* For now, TypeScript will complain that `TinyBig` is not a `BigNumberish`. You can // @ts-ignore or call this
|
|
45
|
+
*
|
|
46
|
+
* @returns the TinyBig represented as a hex string
|
|
47
|
+
* @example
|
|
48
|
+
* ```javascript
|
|
49
|
+
* tinyBig(293).toHexString();
|
|
50
|
+
* // '0x125'
|
|
51
|
+
* ```
|
|
52
|
+
* @example
|
|
53
|
+
* ```javascript
|
|
54
|
+
* tinyBig(681365874).toHexString();
|
|
55
|
+
* // '0x289cd172'
|
|
28
56
|
*/
|
|
29
57
|
toHexString() {
|
|
30
58
|
return `0x${BigInt(this.toString()).toString(16)}`;
|
|
@@ -59,6 +87,8 @@ exports.TinyBig = TinyBig;
|
|
|
59
87
|
/**
|
|
60
88
|
* Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
|
|
61
89
|
*
|
|
90
|
+
* @param value the value to initiate the TinyBig with
|
|
91
|
+
* @returns an initiated {@link TinyBig}
|
|
62
92
|
* @example
|
|
63
93
|
* ```javascript
|
|
64
94
|
* tinyBig(10).times(3).toNumber()
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { TinyBig } from './../shared/tiny-big/tiny-big';
|
|
1
2
|
import { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
|
|
2
3
|
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
3
4
|
export declare type BlockResponse = Modify<RPCBlock, {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
baseFeePerGas: TinyBig;
|
|
6
|
+
difficulty: TinyBig;
|
|
7
|
+
gasLimit: TinyBig;
|
|
8
|
+
gasUsed: TinyBig;
|
|
9
|
+
nonce: TinyBig;
|
|
6
10
|
number: number;
|
|
7
|
-
size:
|
|
8
|
-
timestamp:
|
|
9
|
-
|
|
11
|
+
size: TinyBig;
|
|
12
|
+
timestamp: TinyBig;
|
|
13
|
+
totalDifficulty: TinyBig;
|
|
10
14
|
transactions: Array<string | BlockTransactionResponse>;
|
|
11
15
|
}>;
|
|
12
16
|
/** Exact response from backend */
|
|
@@ -29,9 +33,9 @@ export interface RPCBlock {
|
|
|
29
33
|
stateRoot: string;
|
|
30
34
|
timestamp: string;
|
|
31
35
|
totalDifficulty: string;
|
|
32
|
-
transactions: Array<string
|
|
36
|
+
transactions: Array<string | RPCTransaction>;
|
|
33
37
|
transactionsRoot: string;
|
|
34
|
-
uncles:
|
|
38
|
+
uncles: Array<string>;
|
|
35
39
|
}
|
|
36
40
|
export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
|
|
37
41
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BlockTag } from './Block.types';
|
|
2
|
+
export interface EventFilter {
|
|
3
|
+
address?: string;
|
|
4
|
+
topics?: Array<string | Array<string> | null>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @param fromBlock block as starting point for range, inclusive
|
|
8
|
+
* @param toBlock block as ending point for range, inclusive
|
|
9
|
+
*/
|
|
10
|
+
export interface Filter extends EventFilter {
|
|
11
|
+
fromBlock?: BlockTag;
|
|
12
|
+
toBlock?: BlockTag;
|
|
13
|
+
}
|
|
14
|
+
export interface FilterByBlockHash extends EventFilter {
|
|
15
|
+
blockHash?: string;
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -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
|
-
|
|
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;
|
|
@@ -22,6 +24,7 @@ export declare type TransactionResponse = Modify<RPCTransaction, {
|
|
|
22
24
|
}>;
|
|
23
25
|
/**
|
|
24
26
|
* Type that contains information from the receipt of a transaction
|
|
27
|
+
*
|
|
25
28
|
* * Similar to [`Type TransactionReceipt on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-TransactionReceipt)
|
|
26
29
|
*/
|
|
27
30
|
export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
|
|
@@ -37,11 +40,35 @@ export declare type TransactionReceipt = Modify<RPCTransactionReceipt, {
|
|
|
37
40
|
byzantium: boolean;
|
|
38
41
|
confirmations: number;
|
|
39
42
|
}>;
|
|
43
|
+
export interface RPCTransactionRequest {
|
|
44
|
+
from?: string;
|
|
45
|
+
to: string;
|
|
46
|
+
gas?: string;
|
|
47
|
+
gasPrice?: string;
|
|
48
|
+
value?: string;
|
|
49
|
+
data?: BytesLike;
|
|
50
|
+
nonce?: string;
|
|
51
|
+
maxPriorityFeePerGas?: string;
|
|
52
|
+
maxFeePerGas?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface TransactionRequest {
|
|
55
|
+
to?: string;
|
|
56
|
+
from?: string;
|
|
57
|
+
nonce?: TinyBig | string | Big | number;
|
|
58
|
+
gas?: TinyBig | number | Big | string;
|
|
59
|
+
gasPrice?: TinyBig | Big | string | number;
|
|
60
|
+
data?: BytesLike;
|
|
61
|
+
value?: TinyBig | string | Big | number;
|
|
62
|
+
chainId?: number;
|
|
63
|
+
type?: number;
|
|
64
|
+
maxPriorityFeePerGas?: TinyBig | string | Big | number;
|
|
65
|
+
maxFeePerGas?: TinyBig | string | Big | number;
|
|
66
|
+
}
|
|
40
67
|
/**
|
|
41
68
|
* Type for the logs that are included in transaction receipts
|
|
42
|
-
*
|
|
69
|
+
* Similar to [`Type Log on ethers.providers`](https://docs.ethers.io/v5/api/providers/types/#providers-Log)
|
|
43
70
|
*/
|
|
44
|
-
export declare type Log = Modify<
|
|
71
|
+
export declare type Log = Modify<RPCLog, {
|
|
45
72
|
blockNumber: number;
|
|
46
73
|
logIndex: number;
|
|
47
74
|
transactionIndex: number;
|