essential-eth 0.5.4 → 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 +10 -5
- package/lib/cjs/index.js +10 -2
- 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 +282 -199
- package/lib/cjs/providers/BaseProvider.js +365 -214
- package/lib/cjs/providers/FallthroughProvider.d.ts +1 -2
- 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 +27 -0
- package/lib/cjs/providers/utils/chains-info.js +84 -3
- 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/types/Filter.types.js +2 -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 +17 -0
- package/lib/cjs/utils/compute-address.js +33 -0
- package/lib/cjs/utils/compute-public-key.d.ts +18 -0
- package/lib/cjs/utils/compute-public-key.js +26 -0
- 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 +24 -0
- package/lib/cjs/utils/split-signature.js +163 -0
- 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 +14 -3
- 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 +10 -5
- package/lib/esm/index.js +7 -3
- 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 +7 -1
- package/lib/esm/providers/BaseProvider.js +67 -11
- package/lib/esm/providers/FallthroughProvider.d.ts +1 -2
- package/lib/esm/providers/utils/chains-info.d.ts +27 -0
- package/lib/esm/providers/utils/chains-info.js +84 -3
- 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/types/Filter.types.js +1 -0
- package/lib/esm/types/Transaction.types.d.ts +31 -5
- package/lib/esm/utils/compute-address.d.ts +1 -0
- package/lib/esm/utils/compute-address.js +11 -0
- package/lib/esm/utils/compute-public-key.d.ts +2 -0
- package/lib/esm/utils/compute-public-key.js +6 -0
- package/lib/esm/utils/keccak256.d.ts +1 -1
- package/lib/esm/utils/keccak256.js +2 -2
- package/lib/esm/utils/split-signature.d.ts +2 -0
- package/lib/esm/utils/split-signature.js +126 -0
- package/lib/esm/utils/wei-to-ether.js +11 -2
- package/package.json +38 -11
- package/readme.md +1209 -335
|
@@ -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;
|
package/lib/cjs/utils/bytes.d.ts
CHANGED
|
@@ -2,10 +2,8 @@ export declare type Bytes = ArrayLike<number>;
|
|
|
2
2
|
/**
|
|
3
3
|
* @example
|
|
4
4
|
* [1,2,3]
|
|
5
|
-
*
|
|
6
5
|
* @example
|
|
7
6
|
* 0x123
|
|
8
|
-
*
|
|
9
7
|
* @example
|
|
10
8
|
* '0x123'
|
|
11
9
|
*/
|
|
@@ -36,22 +34,22 @@ export interface Signature {
|
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
|
|
39
|
-
*
|
|
37
|
+
* Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
|
|
40
38
|
*
|
|
39
|
+
* @param value the value to check whether or not it matches BytesLike
|
|
40
|
+
* @returns whether or not the value matches BytesLike
|
|
41
41
|
* @example
|
|
42
|
-
* ```
|
|
42
|
+
* ```javascript
|
|
43
43
|
* isBytesLike([1,2,3]);
|
|
44
44
|
* // true
|
|
45
45
|
* ```
|
|
46
|
-
*
|
|
47
46
|
* @example
|
|
48
|
-
* ```
|
|
47
|
+
* ```javascript
|
|
49
48
|
* isBytesLike(false);
|
|
50
49
|
* // false
|
|
51
50
|
* ```
|
|
52
|
-
*
|
|
53
51
|
* @example
|
|
54
|
-
* ```
|
|
52
|
+
* ```javascript
|
|
55
53
|
* isBytesLike(new Uint8Array(1));
|
|
56
54
|
* // true
|
|
57
55
|
* ```
|
|
@@ -59,22 +57,22 @@ export interface Signature {
|
|
|
59
57
|
export declare function isBytesLike(value: any): value is BytesLike;
|
|
60
58
|
/**
|
|
61
59
|
* Returns true if and only if value is a valid [Bytes](#bytes)
|
|
62
|
-
*
|
|
60
|
+
* Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
|
|
63
61
|
*
|
|
62
|
+
* @param value the value to check whether or not it matches Bytes
|
|
63
|
+
* @returns whether or not the value matches Bytes
|
|
64
64
|
* @example
|
|
65
|
-
* ```
|
|
65
|
+
* ```javascript
|
|
66
66
|
* isBytes([1,2,3]);
|
|
67
67
|
* // true
|
|
68
68
|
* ```
|
|
69
|
-
*
|
|
70
69
|
* @example
|
|
71
|
-
* ```
|
|
70
|
+
* ```javascript
|
|
72
71
|
* isBytes(false);
|
|
73
72
|
* // false
|
|
74
73
|
* ```
|
|
75
|
-
*
|
|
76
74
|
* @example
|
|
77
|
-
* ```
|
|
75
|
+
* ```javascript
|
|
78
76
|
* isBytes(new Uint8Array(1));
|
|
79
77
|
* // true
|
|
80
78
|
* ```
|
|
@@ -82,22 +80,23 @@ export declare function isBytesLike(value: any): value is BytesLike;
|
|
|
82
80
|
export declare function isBytes(value: any): value is Bytes;
|
|
83
81
|
/**
|
|
84
82
|
* Converts DataHexStringOrArrayish to a Uint8Array
|
|
85
|
-
*
|
|
83
|
+
* Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
|
|
86
84
|
*
|
|
85
|
+
* @param value the value to convert to a Uint8Array
|
|
86
|
+
* @param options options to use when converting the value to a Uint8Array
|
|
87
|
+
* @returns the value represented as a Uint8Array
|
|
87
88
|
* @example
|
|
88
|
-
* ```
|
|
89
|
+
* ```javascript
|
|
89
90
|
* arrayify(1);
|
|
90
91
|
* // Uint8Array(1) [ 1 ]
|
|
91
92
|
* ```
|
|
92
|
-
*
|
|
93
93
|
* @example
|
|
94
|
-
* ```
|
|
94
|
+
* ```javascript
|
|
95
95
|
* arrayify(0x1234);
|
|
96
96
|
* // Uint8Array(2) [ 18, 52 ]
|
|
97
97
|
* ```
|
|
98
|
-
*
|
|
99
98
|
* @example
|
|
100
|
-
* ```
|
|
99
|
+
* ```javascript
|
|
101
100
|
* arrayify('0x1', { hexPad: 'right' });
|
|
102
101
|
* // Uint8Array(1) [ 16 ]
|
|
103
102
|
* ```
|
|
@@ -105,38 +104,159 @@ export declare function isBytes(value: any): value is Bytes;
|
|
|
105
104
|
export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
106
105
|
/**
|
|
107
106
|
* Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
|
|
108
|
-
*
|
|
107
|
+
* Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
|
|
109
108
|
*
|
|
109
|
+
* @param arrayOfBytesLike the array of {@link BytesLike} to concatenate together
|
|
110
|
+
* @returns a concatenated Uint8Array
|
|
110
111
|
* @example
|
|
111
|
-
* ```
|
|
112
|
+
* ```javascript
|
|
112
113
|
* concat([0, 1]);
|
|
113
114
|
* // Uint8Array(2) [ 0, 1 ]
|
|
114
115
|
* ```
|
|
115
116
|
*/
|
|
116
117
|
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLikeWithNumber>): Uint8Array;
|
|
118
|
+
/**
|
|
119
|
+
* Strips leading zeros from a BytesLike object
|
|
120
|
+
*
|
|
121
|
+
* @param value the value to strip leading zeros from
|
|
122
|
+
* @returns value without leading zeroes, expressed as a Uint8Array
|
|
123
|
+
* @example
|
|
124
|
+
* ```javascript
|
|
125
|
+
* stripZeros('0x00002834');
|
|
126
|
+
* // Uint8Array { [Iterator] 0: 40, 1: 52 }
|
|
127
|
+
* // Equivalent to '0x2834'
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
117
130
|
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
131
|
+
/**
|
|
132
|
+
* Pads the beginning of a {@link BytesLike} with zeros so it's the specified length as a Uint8Array
|
|
133
|
+
*
|
|
134
|
+
* @param value the value to pad
|
|
135
|
+
* @param length the desired length of the value
|
|
136
|
+
* @returns the value padded with zeros to the specified length
|
|
137
|
+
* @example
|
|
138
|
+
* ```javascript
|
|
139
|
+
* zeroPad('0x039284');
|
|
140
|
+
* // Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
|
|
141
|
+
* // Equivalent to 0x000000039284
|
|
142
|
+
* ```
|
|
143
|
+
* @example
|
|
144
|
+
* ```javascript
|
|
145
|
+
* zeroPad([39, 25, 103, 45], 5);
|
|
146
|
+
* // Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
118
149
|
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
119
150
|
/**
|
|
120
151
|
* Returns true if and only if object is a valid hex string.
|
|
121
152
|
* If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
|
|
122
|
-
*
|
|
153
|
+
* Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
|
|
154
|
+
*
|
|
155
|
+
* @param value the value to check whether or not it's a hex string
|
|
156
|
+
* @param length a length of bytes that the value should be equal to
|
|
157
|
+
* @returns whether the value is a valid hex string (and optionally, whether it matches the length specified)
|
|
158
|
+
* @example
|
|
159
|
+
* ```javascript
|
|
160
|
+
* isHexString('0x4924');
|
|
161
|
+
* // true
|
|
162
|
+
* ```
|
|
163
|
+
* @example
|
|
164
|
+
* ```javascript
|
|
165
|
+
* isHexString('0x4924', 4);
|
|
166
|
+
* // false
|
|
167
|
+
* // length of 4 in bytes would mean a hex string with 8 characters
|
|
168
|
+
* ```
|
|
123
169
|
*/
|
|
124
170
|
export declare function isHexString(value: any, length?: number): boolean;
|
|
125
171
|
/**
|
|
172
|
+
* Converts a value into a hex string
|
|
173
|
+
*
|
|
174
|
+
* @param value the value to convert
|
|
175
|
+
* @param options options to use when converting the value to a hex string
|
|
176
|
+
* @returns the value represented as a hex string
|
|
126
177
|
* @example
|
|
127
|
-
* ```
|
|
178
|
+
* ```javascript
|
|
128
179
|
* hexlify(4);
|
|
129
180
|
* // '0x04'
|
|
130
|
-
*
|
|
181
|
+
* ```
|
|
182
|
+
* @example
|
|
183
|
+
* ```javascript
|
|
131
184
|
* hexlify(14);
|
|
132
185
|
* // '0x0e'
|
|
133
186
|
* ```
|
|
134
187
|
*/
|
|
135
188
|
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
189
|
+
/**
|
|
190
|
+
* Gets the length of data represented as a hex string
|
|
191
|
+
*
|
|
192
|
+
* @param data the data to check the length of
|
|
193
|
+
* @returns the length of the data
|
|
194
|
+
* @example
|
|
195
|
+
* ```javascript
|
|
196
|
+
* hexDataLength([2, 4, 0, 1]);
|
|
197
|
+
* // 4
|
|
198
|
+
* ```
|
|
199
|
+
* @example
|
|
200
|
+
* ```javascript
|
|
201
|
+
* hexDataLength('0x3925');
|
|
202
|
+
* // 2
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
136
205
|
export declare function hexDataLength(data: BytesLike): number | null;
|
|
206
|
+
/**
|
|
207
|
+
* Slices a {@link BytesLike} to extract a certain part of the input
|
|
208
|
+
*
|
|
209
|
+
* @param data the data to slice from
|
|
210
|
+
* @param offset the index to start extraction at
|
|
211
|
+
* @param endOffset the index to end extraction at
|
|
212
|
+
* @returns the extracted data as a hex string
|
|
213
|
+
* @example
|
|
214
|
+
* ```javascript
|
|
215
|
+
* hexDataSlice([20, 6, 48], 0, 2);
|
|
216
|
+
* // '0x1406'
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
137
219
|
export declare function hexDataSlice(data: BytesLikeWithNumber, offset: number, endOffset?: number): string;
|
|
220
|
+
/**
|
|
221
|
+
* Concatenates values together into one hex string
|
|
222
|
+
*
|
|
223
|
+
* @param items the items to concatenate together
|
|
224
|
+
* @returns a single hex string including all of the items to be concatenated
|
|
225
|
+
* @example
|
|
226
|
+
* ```javascript
|
|
227
|
+
* hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
|
|
228
|
+
* // '0x020400010929343947'
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
138
231
|
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
232
|
+
/**
|
|
233
|
+
* Converts a number of different types into a hex string
|
|
234
|
+
*
|
|
235
|
+
* @param value the value to convert into a hex string
|
|
236
|
+
* @returns the value represented as a hex string
|
|
237
|
+
* @example
|
|
238
|
+
* ```javascript
|
|
239
|
+
* hexValue(39);
|
|
240
|
+
* // '0x27'
|
|
241
|
+
* ```
|
|
242
|
+
* @example
|
|
243
|
+
* ```javascript
|
|
244
|
+
* hexValue([9, 4, 19, 4]);
|
|
245
|
+
* // '0x9041304'
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
139
248
|
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
249
|
+
/**
|
|
250
|
+
* Strips the leading zeros from a value and returns it as a hex string
|
|
251
|
+
*
|
|
252
|
+
* @param value the value to strip zeros from
|
|
253
|
+
* @returns a hex string representation of the value, without leading zeros
|
|
254
|
+
* @example
|
|
255
|
+
* ```javascript
|
|
256
|
+
* hexStripZeros([0,0,0,48]);
|
|
257
|
+
* // '0x30'
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
140
260
|
export declare function hexStripZeros(value: BytesLike): string;
|
|
141
261
|
/**
|
|
142
262
|
* Returns a hex string padded to a specified length of bytes.
|
|
@@ -145,24 +265,21 @@ export declare function hexStripZeros(value: BytesLike): string;
|
|
|
145
265
|
*
|
|
146
266
|
* 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
267
|
*
|
|
148
|
-
* @param
|
|
149
|
-
* @param length
|
|
150
|
-
*
|
|
151
|
-
* @throws
|
|
152
|
-
* @throws
|
|
153
|
-
*
|
|
268
|
+
* @param value A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
|
|
269
|
+
* @param length The final length in bytes
|
|
270
|
+
* @returns A hex string padded to the specified length
|
|
271
|
+
* @throws If the value is not a hex string or number
|
|
272
|
+
* @throws If the value is longer than the length
|
|
154
273
|
* @example
|
|
155
274
|
* ```javascript
|
|
156
275
|
* hexZeroPad('0x60', 2);
|
|
157
276
|
* // '0x0060'
|
|
158
277
|
* ```
|
|
159
|
-
*
|
|
160
278
|
* @example
|
|
161
279
|
* ```javascript
|
|
162
280
|
* hexZeroPad(0x60, 3);
|
|
163
281
|
* // '0x000060'
|
|
164
282
|
* ```
|
|
165
|
-
*
|
|
166
283
|
* @example
|
|
167
284
|
* ```javascript
|
|
168
285
|
* hexZeroPad('12345', 1);
|