essential-eth 0.4.11 → 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.
- package/lib/cjs/classes/Contract.d.ts +3 -2
- package/lib/cjs/classes/Contract.js +3 -2
- package/lib/cjs/classes/utils/clean-block.d.ts +3 -3
- package/lib/cjs/classes/utils/clean-block.js +3 -2
- package/lib/cjs/classes/utils/clean-transaction.d.ts +3 -3
- package/lib/cjs/classes/utils/clean-transaction.js +10 -6
- 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 +6 -3
- package/lib/cjs/index.js +19 -1
- 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 +261 -0
- package/lib/cjs/providers/BaseProvider.js +340 -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 +7 -33
- package/lib/cjs/providers/JsonRpcProvider.js +11 -93
- 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 +14 -0
- package/lib/cjs/providers/utils/chains-info.js +42 -0
- package/lib/cjs/shared/tiny-big/tiny-big.d.ts +9 -2
- package/lib/cjs/shared/tiny-big/tiny-big.js +26 -2
- package/lib/cjs/types/Block.types.d.ts +8 -19
- package/lib/cjs/types/Transaction.types.d.ts +23 -14
- package/lib/cjs/utils/bytes.d.ts +171 -0
- package/lib/cjs/utils/bytes.js +564 -0
- package/lib/cjs/utils/solidity-keccak256.d.ts +30 -0
- package/lib/cjs/utils/solidity-keccak256.js +125 -0
- package/lib/esm/classes/Contract.js +1 -1
- package/lib/esm/classes/utils/clean-block.d.ts +2 -2
- package/lib/esm/classes/utils/clean-block.js +2 -1
- package/lib/esm/classes/utils/clean-transaction.d.ts +2 -2
- package/lib/esm/classes/utils/clean-transaction.js +10 -6
- 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 +6 -3
- package/lib/esm/index.js +4 -1
- 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 +17 -0
- package/lib/esm/providers/BaseProvider.js +88 -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 -9
- package/lib/esm/providers/JsonRpcProvider.js +8 -67
- 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 +14 -0
- package/lib/esm/providers/utils/chains-info.js +42 -0
- package/lib/esm/shared/tiny-big/tiny-big.d.ts +2 -0
- package/lib/esm/shared/tiny-big/tiny-big.js +19 -0
- package/lib/esm/types/Block.types.d.ts +7 -19
- package/lib/esm/types/Transaction.types.d.ts +22 -14
- package/lib/esm/utils/bytes.d.ts +39 -0
- package/lib/esm/utils/bytes.js +245 -0
- package/lib/esm/utils/solidity-keccak256.d.ts +3 -0
- package/lib/esm/utils/solidity-keccak256.js +91 -0
- package/package.json +19 -19
- package/readme.md +251 -61
|
@@ -61,12 +61,15 @@ 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[];
|
|
67
68
|
"77": string[];
|
|
68
69
|
"78": string[];
|
|
70
|
+
"79": string[];
|
|
69
71
|
"80": string[];
|
|
72
|
+
"81": string[];
|
|
70
73
|
"82": string[];
|
|
71
74
|
"83": string[];
|
|
72
75
|
"85": string[];
|
|
@@ -147,6 +150,7 @@ declare const _default: {
|
|
|
147
150
|
"600": string[];
|
|
148
151
|
"666": string[];
|
|
149
152
|
"686": string[];
|
|
153
|
+
"700": string[];
|
|
150
154
|
"707": string[];
|
|
151
155
|
"708": string[];
|
|
152
156
|
"721": string[];
|
|
@@ -208,9 +212,13 @@ declare const _default: {
|
|
|
208
212
|
"2025": string[];
|
|
209
213
|
"2100": string[];
|
|
210
214
|
"2101": string[];
|
|
215
|
+
"2152": string[];
|
|
216
|
+
"2153": string[];
|
|
211
217
|
"2213": string[];
|
|
212
218
|
"2221": string[];
|
|
219
|
+
"2223": string[];
|
|
213
220
|
"2559": string[];
|
|
221
|
+
"2569": string[];
|
|
214
222
|
"3000": string[];
|
|
215
223
|
"3001": string[];
|
|
216
224
|
"3331": string[];
|
|
@@ -228,6 +236,8 @@ declare const _default: {
|
|
|
228
236
|
"4918": string[];
|
|
229
237
|
"5197": string[];
|
|
230
238
|
"5315": string[];
|
|
239
|
+
"5551": string[];
|
|
240
|
+
"5553": string[];
|
|
231
241
|
"5700": string[];
|
|
232
242
|
"5777": string[];
|
|
233
243
|
"5851": string[];
|
|
@@ -290,8 +300,10 @@ declare const _default: {
|
|
|
290
300
|
"60002": string[];
|
|
291
301
|
"60103": string[];
|
|
292
302
|
"62320": string[];
|
|
303
|
+
"62621": string[];
|
|
293
304
|
"63000": string[];
|
|
294
305
|
"63001": string[];
|
|
306
|
+
"69420": string[];
|
|
295
307
|
"70000": string[];
|
|
296
308
|
"70001": string[];
|
|
297
309
|
"70002": string[];
|
|
@@ -334,6 +346,7 @@ declare const _default: {
|
|
|
334
346
|
"333999": string[];
|
|
335
347
|
"421611": string[];
|
|
336
348
|
"444900": string[];
|
|
349
|
+
"512512": string[];
|
|
337
350
|
"666666": string[];
|
|
338
351
|
"888888": string[];
|
|
339
352
|
"955305": string[];
|
|
@@ -345,6 +358,7 @@ declare const _default: {
|
|
|
345
358
|
"11155111": string[];
|
|
346
359
|
"13371337": string[];
|
|
347
360
|
"18289463": string[];
|
|
361
|
+
"20180430": string[];
|
|
348
362
|
"20181205": string[];
|
|
349
363
|
"28945486": string[];
|
|
350
364
|
"35855456": string[];
|
|
@@ -193,6 +193,9 @@ exports.default = {
|
|
|
193
193
|
"69": [
|
|
194
194
|
"okov"
|
|
195
195
|
],
|
|
196
|
+
"70": [
|
|
197
|
+
"hsc"
|
|
198
|
+
],
|
|
196
199
|
"71": [
|
|
197
200
|
"cfxtest"
|
|
198
201
|
],
|
|
@@ -208,9 +211,15 @@ exports.default = {
|
|
|
208
211
|
"78": [
|
|
209
212
|
"primuschain"
|
|
210
213
|
],
|
|
214
|
+
"79": [
|
|
215
|
+
"zenith"
|
|
216
|
+
],
|
|
211
217
|
"80": [
|
|
212
218
|
"GeneChain"
|
|
213
219
|
],
|
|
220
|
+
"81": [
|
|
221
|
+
"VIL"
|
|
222
|
+
],
|
|
214
223
|
"82": [
|
|
215
224
|
"Meter"
|
|
216
225
|
],
|
|
@@ -451,6 +460,9 @@ exports.default = {
|
|
|
451
460
|
"686": [
|
|
452
461
|
"kar"
|
|
453
462
|
],
|
|
463
|
+
"700": [
|
|
464
|
+
"SNS"
|
|
465
|
+
],
|
|
454
466
|
"707": [
|
|
455
467
|
"bcs"
|
|
456
468
|
],
|
|
@@ -634,15 +646,27 @@ exports.default = {
|
|
|
634
646
|
"2101": [
|
|
635
647
|
"esp"
|
|
636
648
|
],
|
|
649
|
+
"2152": [
|
|
650
|
+
"fra"
|
|
651
|
+
],
|
|
652
|
+
"2153": [
|
|
653
|
+
"findora-testnet"
|
|
654
|
+
],
|
|
637
655
|
"2213": [
|
|
638
656
|
"evanesco"
|
|
639
657
|
],
|
|
640
658
|
"2221": [
|
|
641
659
|
"kava"
|
|
642
660
|
],
|
|
661
|
+
"2223": [
|
|
662
|
+
"VChain"
|
|
663
|
+
],
|
|
643
664
|
"2559": [
|
|
644
665
|
"ktoc"
|
|
645
666
|
],
|
|
667
|
+
"2569": [
|
|
668
|
+
"tpc"
|
|
669
|
+
],
|
|
646
670
|
"3000": [
|
|
647
671
|
"cennz-r"
|
|
648
672
|
],
|
|
@@ -694,6 +718,12 @@ exports.default = {
|
|
|
694
718
|
"5315": [
|
|
695
719
|
"UZMI"
|
|
696
720
|
],
|
|
721
|
+
"5551": [
|
|
722
|
+
"Nahmii"
|
|
723
|
+
],
|
|
724
|
+
"5553": [
|
|
725
|
+
"Nahmii testnet"
|
|
726
|
+
],
|
|
697
727
|
"5700": [
|
|
698
728
|
"tsys"
|
|
699
729
|
],
|
|
@@ -880,12 +910,18 @@ exports.default = {
|
|
|
880
910
|
"62320": [
|
|
881
911
|
"BKLV"
|
|
882
912
|
],
|
|
913
|
+
"62621": [
|
|
914
|
+
"mtv"
|
|
915
|
+
],
|
|
883
916
|
"63000": [
|
|
884
917
|
"ecs"
|
|
885
918
|
],
|
|
886
919
|
"63001": [
|
|
887
920
|
"ecs-testnet"
|
|
888
921
|
],
|
|
922
|
+
"69420": [
|
|
923
|
+
"cndr"
|
|
924
|
+
],
|
|
889
925
|
"70000": [
|
|
890
926
|
"TKM0"
|
|
891
927
|
],
|
|
@@ -1012,6 +1048,9 @@ exports.default = {
|
|
|
1012
1048
|
"444900": [
|
|
1013
1049
|
"wlkt"
|
|
1014
1050
|
],
|
|
1051
|
+
"512512": [
|
|
1052
|
+
"cmp"
|
|
1053
|
+
],
|
|
1015
1054
|
"666666": [
|
|
1016
1055
|
"vpioneer"
|
|
1017
1056
|
],
|
|
@@ -1045,6 +1084,9 @@ exports.default = {
|
|
|
1045
1084
|
"18289463": [
|
|
1046
1085
|
"ilt"
|
|
1047
1086
|
],
|
|
1087
|
+
"20180430": [
|
|
1088
|
+
"spectrum"
|
|
1089
|
+
],
|
|
1048
1090
|
"20181205": [
|
|
1049
1091
|
"qki"
|
|
1050
1092
|
],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Big from 'big.js';
|
|
2
2
|
/**
|
|
3
|
-
* A wrapper around big.js which expands scientific notation and creates a "toHexString" function.
|
|
4
|
-
* This is the return type of every operation on ether, wei, etc.
|
|
3
|
+
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
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);
|
|
@@ -12,6 +12,13 @@ export declare class TinyBig extends Big {
|
|
|
12
12
|
toHexString(): string;
|
|
13
13
|
toNumber(): number;
|
|
14
14
|
toString(): string;
|
|
15
|
+
/**
|
|
16
|
+
* @param {String} str
|
|
17
|
+
* @param {String} padChar
|
|
18
|
+
* @param {Number} length
|
|
19
|
+
*/
|
|
20
|
+
private padAndChop;
|
|
21
|
+
toTwos(bitCount: number): Big;
|
|
15
22
|
}
|
|
16
23
|
/**
|
|
17
24
|
* Helper factory function so that you don't have to type "new" when instantiating a new TinyBig
|
|
@@ -7,12 +7,20 @@ exports.tinyBig = exports.TinyBig = void 0;
|
|
|
7
7
|
const big_js_1 = __importDefault(require("big.js"));
|
|
8
8
|
const helpers_1 = require("./helpers");
|
|
9
9
|
/**
|
|
10
|
-
* A wrapper around big.js which expands scientific notation and creates a "toHexString" function.
|
|
11
|
-
* This is the return type of every operation on ether, wei, etc.
|
|
10
|
+
* A wrapper around [big.js](https://github.com/MikeMcl/big.js) which expands scientific notation and creates a "toHexString" function.
|
|
11
|
+
* * This is the return type of every operation on ether, wei, etc.
|
|
12
12
|
*/
|
|
13
13
|
class TinyBig extends big_js_1.default {
|
|
14
14
|
constructor(value) {
|
|
15
15
|
super(value);
|
|
16
|
+
/**
|
|
17
|
+
* @param {String} str
|
|
18
|
+
* @param {String} padChar
|
|
19
|
+
* @param {Number} length
|
|
20
|
+
*/
|
|
21
|
+
this.padAndChop = (str, padChar, length) => {
|
|
22
|
+
return (Array(length).fill(padChar).join('') + str).slice(length * -1);
|
|
23
|
+
};
|
|
16
24
|
}
|
|
17
25
|
/**
|
|
18
26
|
* Used anytime you're passing in "value" to ethers or web3
|
|
@@ -30,6 +38,22 @@ class TinyBig extends big_js_1.default {
|
|
|
30
38
|
}
|
|
31
39
|
return (0, helpers_1.scientificStrToDecimalStr)(super.toString());
|
|
32
40
|
}
|
|
41
|
+
toTwos(bitCount) {
|
|
42
|
+
let binaryStr;
|
|
43
|
+
if (this.gte(0)) {
|
|
44
|
+
const twosComp = this.toNumber().toString(2);
|
|
45
|
+
binaryStr = this.padAndChop(twosComp, '0', bitCount || twosComp.length);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
binaryStr = this.plus(Math.pow(2, bitCount)).toNumber().toString(2);
|
|
49
|
+
if (Number(binaryStr) < 0) {
|
|
50
|
+
throw new Error('Cannot calculate twos complement');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const binary = `0b${binaryStr}`;
|
|
54
|
+
const decimal = Number(binary);
|
|
55
|
+
return tinyBig(decimal);
|
|
56
|
+
}
|
|
33
57
|
}
|
|
34
58
|
exports.TinyBig = TinyBig;
|
|
35
59
|
/**
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
difficulty: number;
|
|
5
|
-
extraData: string;
|
|
1
|
+
import { BlockTransactionResponse, RPCTransaction } from './Transaction.types';
|
|
2
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
3
|
+
export declare type BlockResponse = Modify<RPCBlock, {
|
|
6
4
|
gasLimit: number;
|
|
7
5
|
gasUsed: number;
|
|
8
|
-
hash: string;
|
|
9
|
-
logsBloom: string;
|
|
10
|
-
miner: string;
|
|
11
|
-
mixHash: string;
|
|
12
|
-
nonce: string;
|
|
13
6
|
number: number;
|
|
14
|
-
parentHash: string;
|
|
15
|
-
receiptsRoot: string;
|
|
16
|
-
sha3Uncles: string;
|
|
17
7
|
size: number;
|
|
18
|
-
stateRoot: string;
|
|
19
8
|
timestamp: number;
|
|
20
|
-
|
|
21
|
-
transactions: string
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
9
|
+
baseFeePerGas: number;
|
|
10
|
+
transactions: Array<string | BlockTransactionResponse>;
|
|
11
|
+
}>;
|
|
12
|
+
/** Exact response from backend */
|
|
25
13
|
export interface RPCBlock {
|
|
26
14
|
baseFeePerGas: string;
|
|
27
15
|
difficulty: string;
|
|
@@ -46,3 +34,4 @@ export interface RPCBlock {
|
|
|
46
34
|
uncles: unknown[];
|
|
47
35
|
}
|
|
48
36
|
export declare type BlockTag = 'latest' | 'earliest' | 'pending' | number | string;
|
|
37
|
+
export {};
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TinyBig } from '../shared/tiny-big/tiny-big';
|
|
2
|
+
declare type Modify<T, R> = Omit<T, keyof R> & R;
|
|
3
|
+
export interface RPCTransaction extends RPCBlockTransaction {
|
|
4
|
+
maxFeePerGas: string;
|
|
5
|
+
maxPriorityFeePerGas: string;
|
|
6
|
+
}
|
|
7
|
+
export declare type TransactionResponse = Modify<RPCTransaction, {
|
|
3
8
|
blockNumber: number;
|
|
4
|
-
|
|
5
|
-
gas: number;
|
|
6
|
-
gasPrice: string;
|
|
7
|
-
hash: string;
|
|
8
|
-
input: string;
|
|
9
|
+
chainId: number;
|
|
9
10
|
nonce: number;
|
|
10
|
-
r: string;
|
|
11
|
-
s: string;
|
|
12
|
-
to: string;
|
|
13
11
|
transactionIndex: number;
|
|
14
12
|
type: number;
|
|
15
|
-
v:
|
|
16
|
-
value:
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
v: number;
|
|
14
|
+
value: TinyBig;
|
|
15
|
+
gasPrice: TinyBig;
|
|
16
|
+
gas: TinyBig;
|
|
17
|
+
gasLimit: TinyBig;
|
|
18
|
+
} & {
|
|
19
|
+
maxFeePerGas: TinyBig;
|
|
20
|
+
maxPriorityFeePerGas: TinyBig;
|
|
21
|
+
confirmations: number;
|
|
22
|
+
}>;
|
|
23
|
+
export declare type BlockTransactionResponse = Omit<TransactionResponse, 'maxFeePerGas' | 'maxPriorityFeePerGas'>;
|
|
24
|
+
/** What JSONRPC responds with in getBlock transaction array */
|
|
25
|
+
export interface RPCBlockTransaction {
|
|
19
26
|
blockHash: string;
|
|
20
27
|
blockNumber: string;
|
|
28
|
+
chainId: string;
|
|
21
29
|
from: string;
|
|
22
30
|
gas: string;
|
|
23
31
|
gasPrice: string;
|
|
@@ -32,3 +40,4 @@ export interface RPCTransaction {
|
|
|
32
40
|
v: string;
|
|
33
41
|
value: string;
|
|
34
42
|
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
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 | number;
|
|
13
|
+
export interface DataOptions {
|
|
14
|
+
allowMissingPrefix?: boolean;
|
|
15
|
+
hexPad?: 'left' | 'right' | null;
|
|
16
|
+
}
|
|
17
|
+
export interface Hexable {
|
|
18
|
+
toHexString(): string;
|
|
19
|
+
}
|
|
20
|
+
export declare type SignatureLike = {
|
|
21
|
+
r: string;
|
|
22
|
+
s?: string;
|
|
23
|
+
_vs?: string;
|
|
24
|
+
recoveryParam?: number;
|
|
25
|
+
v?: number;
|
|
26
|
+
} | BytesLike;
|
|
27
|
+
export interface Signature {
|
|
28
|
+
r: string;
|
|
29
|
+
s: string;
|
|
30
|
+
_vs: string;
|
|
31
|
+
recoveryParam: number;
|
|
32
|
+
v: number;
|
|
33
|
+
yParityAndS: string;
|
|
34
|
+
compact: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
|
|
38
|
+
* * Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```js
|
|
42
|
+
* isBytesLike([1,2,3]);
|
|
43
|
+
* // true
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```js
|
|
48
|
+
* isBytesLike(false);
|
|
49
|
+
* // false
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```js
|
|
54
|
+
* isBytesLike(new Uint8Array(1));
|
|
55
|
+
* // true
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function isBytesLike(value: any): value is BytesLike;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if and only if value is a valid [Bytes](#bytes)
|
|
61
|
+
* * Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```js
|
|
65
|
+
* isBytes([1,2,3]);
|
|
66
|
+
* // true
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```js
|
|
71
|
+
* isBytes(false);
|
|
72
|
+
* // false
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```js
|
|
77
|
+
* isBytes(new Uint8Array(1));
|
|
78
|
+
* // true
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function isBytes(value: any): value is Bytes;
|
|
82
|
+
/**
|
|
83
|
+
* Converts DataHexStringOrArrayish to a Uint8Array
|
|
84
|
+
* * Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```js
|
|
88
|
+
* arrayify(1);
|
|
89
|
+
* // Uint8Array(1) [ 1 ]
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* arrayify(0x1234);
|
|
95
|
+
* // Uint8Array(2) [ 18, 52 ]
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```js
|
|
100
|
+
* arrayify('0x1', { hexPad: 'right' });
|
|
101
|
+
* // Uint8Array(1) [ 16 ]
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array;
|
|
105
|
+
/**
|
|
106
|
+
* Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
|
|
107
|
+
* * Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```js
|
|
111
|
+
* concat([0, 1]);
|
|
112
|
+
* // Uint8Array(2) [ 0, 1 ]
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function concat(arrayOfBytesLike: ReadonlyArray<BytesLike>): Uint8Array;
|
|
116
|
+
export declare function stripZeros(value: BytesLike): Uint8Array;
|
|
117
|
+
export declare function zeroPad(value: BytesLike, length: number): Uint8Array;
|
|
118
|
+
/**
|
|
119
|
+
* Returns true if and only if object is a valid hex string.
|
|
120
|
+
* If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
|
|
121
|
+
* * Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
|
|
122
|
+
*/
|
|
123
|
+
export declare function isHexString(value: any, length?: number): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* @example
|
|
126
|
+
* ```js
|
|
127
|
+
* hexlify(4);
|
|
128
|
+
* // '0x04'
|
|
129
|
+
*
|
|
130
|
+
* hexlify(14);
|
|
131
|
+
* // '0x0e'
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function hexlify(value: BytesLike | Hexable | number | bigint, options?: DataOptions): string;
|
|
135
|
+
export declare function hexDataLength(data: BytesLike): number | null;
|
|
136
|
+
export declare function hexDataSlice(data: BytesLike, offset: number, endOffset?: number): string;
|
|
137
|
+
export declare function hexConcat(items: ReadonlyArray<BytesLike>): string;
|
|
138
|
+
export declare function hexValue(value: BytesLike | Hexable | number | bigint): string;
|
|
139
|
+
export declare function hexStripZeros(value: BytesLike): string;
|
|
140
|
+
/**
|
|
141
|
+
* Returns a hex string padded to a specified length of bytes.
|
|
142
|
+
*
|
|
143
|
+
* Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
|
|
144
|
+
*
|
|
145
|
+
* 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.
|
|
146
|
+
*
|
|
147
|
+
* @param hexValue - A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
|
|
148
|
+
* @param length - The final length in bytes
|
|
149
|
+
*
|
|
150
|
+
* @throws - If the value is not a hex string or number
|
|
151
|
+
* @throws - If the value is longer than the length
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```javascript
|
|
155
|
+
* hexZeroPad('0x60', 2);
|
|
156
|
+
* // '0x0060'
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```javascript
|
|
161
|
+
* hexZeroPad(0x60, 3);
|
|
162
|
+
* // '0x000060'
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```javascript
|
|
167
|
+
* hexZeroPad('12345', 1);
|
|
168
|
+
* // Throws
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export declare function hexZeroPad(value: BytesLike, length: number): string;
|