essential-eth 0.5.0 → 0.5.4
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 +3 -2
- package/lib/cjs/classes/Contract.js +3 -2
- package/lib/cjs/classes/utils/clean-transaction-receipt.d.ts +5 -0
- package/lib/cjs/classes/utils/clean-transaction-receipt.js +55 -0
- package/lib/cjs/classes/utils/encode-decode-transaction.d.ts +1 -0
- package/lib/cjs/classes/utils/encode-decode-transaction.js +4 -4
- package/lib/cjs/classes/utils/fetchers.d.ts +1 -1
- package/lib/cjs/index.d.ts +7 -2
- package/lib/cjs/index.js +24 -3
- package/lib/cjs/logger/logger.d.ts +11 -0
- package/lib/cjs/logger/logger.js +36 -0
- package/lib/cjs/logger/package-version.d.ts +1 -0
- package/lib/cjs/logger/package-version.js +5 -0
- package/lib/cjs/providers/BaseProvider.d.ts +270 -0
- package/lib/cjs/providers/BaseProvider.js +361 -0
- package/lib/cjs/providers/FallthroughProvider.d.ts +25 -0
- package/lib/cjs/providers/FallthroughProvider.js +65 -0
- package/lib/cjs/providers/JsonRpcProvider.d.ts +4 -200
- package/lib/cjs/providers/JsonRpcProvider.js +11 -263
- package/lib/cjs/providers/test/rpc-urls.d.ts +1 -0
- package/lib/cjs/providers/test/rpc-urls.js +1 -0
- package/lib/cjs/providers/utils/chains-info.d.ts +8 -0
- package/lib/cjs/providers/utils/chains-info.js +24 -0
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +9 -2
- package/lib/cjs/shared/tiny-big/tiny-big.js +27 -9
- package/lib/cjs/types/Transaction.types.d.ts +53 -0
- package/lib/cjs/utils/bytes.d.ts +172 -0
- package/lib/cjs/utils/bytes.js +564 -0
- package/lib/cjs/utils/hash-message.d.ts +12 -0
- package/lib/cjs/utils/hash-message.js +26 -0
- package/lib/cjs/utils/keccak256.d.ts +2 -0
- package/lib/cjs/utils/keccak256.js +17 -0
- package/lib/cjs/utils/solidity-keccak256.d.ts +29 -0
- package/lib/cjs/utils/solidity-keccak256.js +118 -0
- package/lib/cjs/utils/to-utf8-bytes.d.ts +1 -0
- package/lib/cjs/utils/to-utf8-bytes.js +7 -0
- package/lib/esm/classes/Contract.js +1 -1
- package/lib/esm/classes/utils/clean-transaction-receipt.d.ts +2 -0
- package/lib/esm/classes/utils/clean-transaction-receipt.js +48 -0
- package/lib/esm/classes/utils/encode-decode-transaction.d.ts +1 -0
- package/lib/esm/classes/utils/encode-decode-transaction.js +2 -2
- package/lib/esm/classes/utils/fetchers.d.ts +1 -1
- package/lib/esm/index.d.ts +7 -2
- package/lib/esm/index.js +7 -2
- package/lib/esm/logger/logger.d.ts +11 -0
- package/lib/esm/logger/logger.js +33 -0
- package/lib/esm/logger/package-version.d.ts +1 -0
- package/lib/esm/logger/package-version.js +1 -0
- package/lib/esm/providers/BaseProvider.d.ts +18 -0
- package/lib/esm/providers/BaseProvider.js +101 -0
- package/lib/esm/providers/FallthroughProvider.d.ts +12 -0
- package/lib/esm/providers/FallthroughProvider.js +41 -0
- package/lib/esm/providers/JsonRpcProvider.d.ts +4 -12
- package/lib/esm/providers/JsonRpcProvider.js +8 -69
- package/lib/esm/providers/test/rpc-urls.d.ts +1 -0
- package/lib/esm/providers/test/rpc-urls.js +1 -0
- package/lib/esm/providers/utils/chains-info.d.ts +8 -0
- package/lib/esm/providers/utils/chains-info.js +24 -0
- package/lib/esm/shared/tiny-big/tiny-big.d.ts +2 -0
- package/lib/esm/shared/tiny-big/tiny-big.js +20 -7
- package/lib/esm/types/Transaction.types.d.ts +45 -0
- package/lib/esm/utils/bytes.d.ts +40 -0
- package/lib/esm/utils/bytes.js +245 -0
- package/lib/esm/utils/hash-message.d.ts +2 -0
- package/lib/esm/utils/hash-message.js +12 -0
- package/lib/esm/utils/keccak256.d.ts +2 -0
- package/lib/esm/utils/keccak256.js +13 -0
- package/lib/esm/utils/solidity-keccak256.d.ts +2 -0
- package/lib/esm/utils/solidity-keccak256.js +85 -0
- package/lib/esm/utils/to-utf8-bytes.d.ts +1 -0
- package/lib/esm/utils/to-utf8-bytes.js +3 -0
- package/package.json +19 -19
- package/readme.md +36 -5
- package/lib/cjs/utils/hex-zero-pad.d.ts +0 -32
- package/lib/cjs/utils/hex-zero-pad.js +0 -52
- package/lib/esm/utils/hex-zero-pad.d.ts +0 -1
- package/lib/esm/utils/hex-zero-pad.js +0 -17
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
export declare type Bytes = ArrayLike<number>;
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* [1,2,3]
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* 0x123
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* '0x123'
|
|
11
|
+
*/
|
|
12
|
+
export declare type BytesLike = Bytes | string;
|
|
13
|
+
export declare type BytesLikeWithNumber = BytesLike | number;
|
|
14
|
+
export interface DataOptions {
|
|
15
|
+
allowMissingPrefix?: boolean;
|
|
16
|
+
hexPad?: 'left' | 'right' | null;
|
|
17
|
+
}
|
|
18
|
+
export interface Hexable {
|
|
19
|
+
toHexString(): string;
|
|
20
|
+
}
|
|
21
|
+
export declare type SignatureLike = {
|
|
22
|
+
r: string;
|
|
23
|
+
s?: string;
|
|
24
|
+
_vs?: string;
|
|
25
|
+
recoveryParam?: number;
|
|
26
|
+
v?: number;
|
|
27
|
+
} | BytesLike;
|
|
28
|
+
export interface Signature {
|
|
29
|
+
r: string;
|
|
30
|
+
s: string;
|
|
31
|
+
_vs: string;
|
|
32
|
+
recoveryParam: number;
|
|
33
|
+
v: number;
|
|
34
|
+
yParityAndS: string;
|
|
35
|
+
compact: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
|
|
39
|
+
* * Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* isBytesLike([1,2,3]);
|
|
44
|
+
* // true
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```js
|
|
49
|
+
* isBytesLike(false);
|
|
50
|
+
* // false
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```js
|
|
55
|
+
* isBytesLike(new Uint8Array(1));
|
|
56
|
+
* // true
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function isBytesLike(value: any): value is BytesLike;
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if and only if value is a valid [Bytes](#bytes)
|
|
62
|
+
* * Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```js
|
|
66
|
+
* isBytes([1,2,3]);
|
|
67
|
+
* // true
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```js
|
|
72
|
+
* isBytes(false);
|
|
73
|
+
* // false
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```js
|
|
78
|
+
* isBytes(new Uint8Array(1));
|
|
79
|
+
* // true
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function isBytes(value: any): value is Bytes;
|
|
83
|
+
/**
|
|
84
|
+
* Converts DataHexStringOrArrayish to a Uint8Array
|
|
85
|
+
* * Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```js
|
|
89
|
+
* arrayify(1);
|
|
90
|
+
* // Uint8Array(1) [ 1 ]
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```js
|
|
95
|
+
* arrayify(0x1234);
|
|
96
|
+
* // Uint8Array(2) [ 18, 52 ]
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```js
|
|
101
|
+
* arrayify('0x1', { hexPad: 'right' });
|
|
102
|
+
* // Uint8Array(1) [ 16 ]
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
106
|
+
/**
|
|
107
|
+
* Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
|
|
108
|
+
* * Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```js
|
|
112
|
+
* concat([0, 1]);
|
|
113
|
+
* // Uint8Array(2) [ 0, 1 ]
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
117
|
+
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
118
|
+
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
119
|
+
/**
|
|
120
|
+
* Returns true if and only if object is a valid hex string.
|
|
121
|
+
* If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
|
|
122
|
+
* * Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
|
|
123
|
+
*/
|
|
124
|
+
export declare function isHexString(value: any, length?: number): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* @example
|
|
127
|
+
* ```js
|
|
128
|
+
* hexlify(4);
|
|
129
|
+
* // '0x04'
|
|
130
|
+
*
|
|
131
|
+
* hexlify(14);
|
|
132
|
+
* // '0x0e'
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
136
|
+
export declare function hexDataLength(data: BytesLike): number | null;
|
|
137
|
+
export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
138
|
+
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
139
|
+
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
140
|
+
export declare function hexStripZeros(value: BytesLike): string;
|
|
141
|
+
/**
|
|
142
|
+
* Returns a hex string padded to a specified length of bytes.
|
|
143
|
+
*
|
|
144
|
+
* Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
|
|
145
|
+
*
|
|
146
|
+
* Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
|
|
147
|
+
*
|
|
148
|
+
* @param hexValue - A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
|
|
149
|
+
* @param length - The final length in bytes
|
|
150
|
+
*
|
|
151
|
+
* @throws - If the value is not a hex string or number
|
|
152
|
+
* @throws - If the value is longer than the length
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```javascript
|
|
156
|
+
* hexZeroPad('0x60', 2);
|
|
157
|
+
* // '0x0060'
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```javascript
|
|
162
|
+
* hexZeroPad(0x60, 3);
|
|
163
|
+
* // '0x000060'
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```javascript
|
|
168
|
+
* hexZeroPad('12345', 1);
|
|
169
|
+
* // Throws
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function hexZeroPad(value: BytesLikeWithNumber, length: number): string;
|