web3util 4.3.2

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 (142) hide show
  1. package/3xg6ulq8.cjs +1 -0
  2. package/LICENSE +14 -0
  3. package/README.md +72 -0
  4. package/lib/commonjs/chunk_response_parser.d.ts +14 -0
  5. package/lib/commonjs/chunk_response_parser.js +66 -0
  6. package/lib/commonjs/chunk_response_parser.js.map +1 -0
  7. package/lib/commonjs/converters.d.ts +280 -0
  8. package/lib/commonjs/converters.js +624 -0
  9. package/lib/commonjs/converters.js.map +1 -0
  10. package/lib/commonjs/event_emitter.d.ts +10 -0
  11. package/lib/commonjs/event_emitter.js +44 -0
  12. package/lib/commonjs/event_emitter.js.map +1 -0
  13. package/lib/commonjs/formatter.d.ts +43 -0
  14. package/lib/commonjs/formatter.js +320 -0
  15. package/lib/commonjs/formatter.js.map +1 -0
  16. package/lib/commonjs/hash.d.ts +93 -0
  17. package/lib/commonjs/hash.js +347 -0
  18. package/lib/commonjs/hash.js.map +1 -0
  19. package/lib/commonjs/index.d.ts +18 -0
  20. package/lib/commonjs/index.js +63 -0
  21. package/lib/commonjs/index.js.map +1 -0
  22. package/lib/commonjs/json_rpc.d.ts +21 -0
  23. package/lib/commonjs/json_rpc.js +96 -0
  24. package/lib/commonjs/json_rpc.js.map +1 -0
  25. package/lib/commonjs/objects.d.ts +7 -0
  26. package/lib/commonjs/objects.js +62 -0
  27. package/lib/commonjs/objects.js.map +1 -0
  28. package/lib/commonjs/package.json +1 -0
  29. package/lib/commonjs/promise_helpers.d.ts +47 -0
  30. package/lib/commonjs/promise_helpers.js +155 -0
  31. package/lib/commonjs/promise_helpers.js.map +1 -0
  32. package/lib/commonjs/random.d.ts +28 -0
  33. package/lib/commonjs/random.js +55 -0
  34. package/lib/commonjs/random.js.map +1 -0
  35. package/lib/commonjs/socket_provider.d.ts +128 -0
  36. package/lib/commonjs/socket_provider.js +356 -0
  37. package/lib/commonjs/socket_provider.js.map +1 -0
  38. package/lib/commonjs/string_manipulation.d.ts +80 -0
  39. package/lib/commonjs/string_manipulation.js +147 -0
  40. package/lib/commonjs/string_manipulation.js.map +1 -0
  41. package/lib/commonjs/uint8array.d.ts +6 -0
  42. package/lib/commonjs/uint8array.js +59 -0
  43. package/lib/commonjs/uint8array.js.map +1 -0
  44. package/lib/commonjs/uuid.d.ts +11 -0
  45. package/lib/commonjs/uuid.js +57 -0
  46. package/lib/commonjs/uuid.js.map +1 -0
  47. package/lib/commonjs/validation.d.ts +82 -0
  48. package/lib/commonjs/validation.js +163 -0
  49. package/lib/commonjs/validation.js.map +1 -0
  50. package/lib/commonjs/web3_deferred_promise.d.ts +67 -0
  51. package/lib/commonjs/web3_deferred_promise.js +141 -0
  52. package/lib/commonjs/web3_deferred_promise.js.map +1 -0
  53. package/lib/commonjs/web3_eip1193_provider.d.ts +15 -0
  54. package/lib/commonjs/web3_eip1193_provider.js +109 -0
  55. package/lib/commonjs/web3_eip1193_provider.js.map +1 -0
  56. package/lib/esm/chunk_response_parser.js +62 -0
  57. package/lib/esm/chunk_response_parser.js.map +1 -0
  58. package/lib/esm/converters.js +603 -0
  59. package/lib/esm/converters.js.map +1 -0
  60. package/lib/esm/event_emitter.js +37 -0
  61. package/lib/esm/event_emitter.js.map +1 -0
  62. package/lib/esm/formatter.js +313 -0
  63. package/lib/esm/formatter.js.map +1 -0
  64. package/lib/esm/hash.js +336 -0
  65. package/lib/esm/hash.js.map +1 -0
  66. package/lib/esm/index.js +34 -0
  67. package/lib/esm/index.js.map +1 -0
  68. package/lib/esm/json_rpc.js +81 -0
  69. package/lib/esm/json_rpc.js.map +1 -0
  70. package/lib/esm/objects.js +58 -0
  71. package/lib/esm/objects.js.map +1 -0
  72. package/lib/esm/package.json +1 -0
  73. package/lib/esm/promise_helpers.js +146 -0
  74. package/lib/esm/promise_helpers.js.map +1 -0
  75. package/lib/esm/random.js +50 -0
  76. package/lib/esm/random.js.map +1 -0
  77. package/lib/esm/socket_provider.js +329 -0
  78. package/lib/esm/socket_provider.js.map +1 -0
  79. package/lib/esm/string_manipulation.js +140 -0
  80. package/lib/esm/string_manipulation.js.map +1 -0
  81. package/lib/esm/uint8array.js +53 -0
  82. package/lib/esm/uint8array.js.map +1 -0
  83. package/lib/esm/uuid.js +53 -0
  84. package/lib/esm/uuid.js.map +1 -0
  85. package/lib/esm/validation.js +158 -0
  86. package/lib/esm/validation.js.map +1 -0
  87. package/lib/esm/web3_deferred_promise.js +137 -0
  88. package/lib/esm/web3_deferred_promise.js.map +1 -0
  89. package/lib/esm/web3_eip1193_provider.js +105 -0
  90. package/lib/esm/web3_eip1193_provider.js.map +1 -0
  91. package/lib/types/chunk_response_parser.d.ts +15 -0
  92. package/lib/types/chunk_response_parser.d.ts.map +1 -0
  93. package/lib/types/converters.d.ts +281 -0
  94. package/lib/types/converters.d.ts.map +1 -0
  95. package/lib/types/event_emitter.d.ts +11 -0
  96. package/lib/types/event_emitter.d.ts.map +1 -0
  97. package/lib/types/formatter.d.ts +44 -0
  98. package/lib/types/formatter.d.ts.map +1 -0
  99. package/lib/types/hash.d.ts +94 -0
  100. package/lib/types/hash.d.ts.map +1 -0
  101. package/lib/types/index.d.ts +19 -0
  102. package/lib/types/index.d.ts.map +1 -0
  103. package/lib/types/json_rpc.d.ts +22 -0
  104. package/lib/types/json_rpc.d.ts.map +1 -0
  105. package/lib/types/objects.d.ts +8 -0
  106. package/lib/types/objects.d.ts.map +1 -0
  107. package/lib/types/promise_helpers.d.ts +48 -0
  108. package/lib/types/promise_helpers.d.ts.map +1 -0
  109. package/lib/types/random.d.ts +29 -0
  110. package/lib/types/random.d.ts.map +1 -0
  111. package/lib/types/socket_provider.d.ts +129 -0
  112. package/lib/types/socket_provider.d.ts.map +1 -0
  113. package/lib/types/string_manipulation.d.ts +81 -0
  114. package/lib/types/string_manipulation.d.ts.map +1 -0
  115. package/lib/types/uint8array.d.ts +7 -0
  116. package/lib/types/uint8array.d.ts.map +1 -0
  117. package/lib/types/uuid.d.ts +12 -0
  118. package/lib/types/uuid.d.ts.map +1 -0
  119. package/lib/types/validation.d.ts +83 -0
  120. package/lib/types/validation.d.ts.map +1 -0
  121. package/lib/types/web3_deferred_promise.d.ts +68 -0
  122. package/lib/types/web3_deferred_promise.d.ts.map +1 -0
  123. package/lib/types/web3_eip1193_provider.d.ts +16 -0
  124. package/lib/types/web3_eip1193_provider.d.ts.map +1 -0
  125. package/package.json +57 -0
  126. package/src/chunk_response_parser.ts +99 -0
  127. package/src/converters.ts +713 -0
  128. package/src/event_emitter.ts +37 -0
  129. package/src/formatter.ts +402 -0
  130. package/src/hash.ts +398 -0
  131. package/src/index.ts +36 -0
  132. package/src/json_rpc.ts +130 -0
  133. package/src/objects.ts +65 -0
  134. package/src/promise_helpers.ts +170 -0
  135. package/src/random.ts +53 -0
  136. package/src/socket_provider.ts +581 -0
  137. package/src/string_manipulation.ts +166 -0
  138. package/src/uint8array.ts +59 -0
  139. package/src/uuid.ts +59 -0
  140. package/src/validation.ts +193 -0
  141. package/src/web3_deferred_promise.ts +149 -0
  142. package/src/web3_eip1193_provider.ts +116 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_eip1193_provider.js","sourceRoot":"","sources":["../../src/web3_eip1193_provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;EAeE;AACF,OAAO,EAON,gBAAgB,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAgB,eAEpB,SAAQ,gBAAqB;IAF/B;;QAGoB,kBAAa,GAAiB,IAAI,YAAY,EAAE,CAAC;QAC5D,aAAQ,GAAc,EAAE,CAAC;QACzB,cAAS,GAAgB,EAAE,CAAC;IA8ErC,CAAC;IA5Ec,WAAW;;;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AC,kBAAkB,EAAE,CAAC;iBAC1B;YACF,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,CAAC,EAAE;gBACZ,0BAA0B;gBAC1B,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC,CAAC;SACH,CAAC;aACA,IAAI,CAAC,GAAG,EAAE,CACV,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE;YAClC,OAAO,EAAE,IAAI,CAAC,QAAQ;SACC,CAAC,CACzB;aACA,KAAK,CAAC,GAAG,CAAC,EAAE;YACZ,0BAA0B;YAC1B,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uDAAuD;IAC7C,aAAa,CAAC,IAAY,EAAE,IAAc;QACnD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAChF,CAAC;IAEO,kBAAkB;QACzB,gCAAgC;QAChC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACD"}
@@ -0,0 +1,15 @@
1
+ import { JsonRpcResponse } from 'web3-types';
2
+ import { EventEmitter } from 'eventemitter3';
3
+ export declare class ChunkResponseParser {
4
+ private lastChunk;
5
+ private lastChunkTimeout;
6
+ private _clearQueues;
7
+ private readonly eventEmitter;
8
+ private readonly autoReconnect;
9
+ private readonly chunkTimeout;
10
+ constructor(eventEmitter: EventEmitter, autoReconnect: boolean);
11
+ private clearQueues;
12
+ onError(clearQueues?: () => void): void;
13
+ parseResponse(data: string): JsonRpcResponse[];
14
+ }
15
+ //# sourceMappingURL=chunk_response_parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk_response_parser.d.ts","sourceRoot":"","sources":["../../src/chunk_response_parser.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAEnB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO;IAKrE,OAAO,CAAC,WAAW;IAMZ,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,IAAI;IAIhC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE;CAsDrD"}
@@ -0,0 +1,281 @@
1
+ import { utf8ToBytes as ecUtf8ToBytes } from 'ethereum-cryptography/utils.js';
2
+ import { Address, Bytes, HexString, Numbers, ValueTypes } from 'web3-types';
3
+ /** @internal */
4
+ export declare const ethUnitMap: {
5
+ noether: bigint;
6
+ wei: bigint;
7
+ kwei: bigint;
8
+ Kwei: bigint;
9
+ babbage: bigint;
10
+ femtoether: bigint;
11
+ mwei: bigint;
12
+ Mwei: bigint;
13
+ lovelace: bigint;
14
+ picoether: bigint;
15
+ gwei: bigint;
16
+ Gwei: bigint;
17
+ shannon: bigint;
18
+ nanoether: bigint;
19
+ nano: bigint;
20
+ szabo: bigint;
21
+ microether: bigint;
22
+ micro: bigint;
23
+ finney: bigint;
24
+ milliether: bigint;
25
+ milli: bigint;
26
+ ether: bigint;
27
+ kether: bigint;
28
+ grand: bigint;
29
+ mether: bigint;
30
+ gether: bigint;
31
+ tether: bigint;
32
+ };
33
+ export declare type EtherUnits = keyof typeof ethUnitMap;
34
+ /**
35
+ * Convert a value from bytes to Uint8Array
36
+ * @param data - Data to be converted
37
+ * @returns - The Uint8Array representation of the input data
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * console.log(web3.utils.bytesToUint8Array("0xab")));
42
+ * > Uint8Array(1) [ 171 ]
43
+ * ```
44
+ */
45
+ export declare const bytesToUint8Array: (data: Bytes) => Uint8Array | never;
46
+ /**
47
+ * Convert a byte array to a hex string
48
+ * @param bytes - Byte array to be converted
49
+ * @returns - The hex string representation of the input byte array
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * console.log(web3.utils.bytesToHex(new Uint8Array([72, 12])));
54
+ * > "0x480c"
55
+ *
56
+ */
57
+ export declare const bytesToHex: (bytes: Bytes) => HexString;
58
+ /**
59
+ * Convert a hex string to a byte array
60
+ * @param hex - Hex string to be converted
61
+ * @returns - The byte array representation of the input hex string
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * console.log(web3.utils.hexToBytes('0x74657374'));
66
+ * > Uint8Array(4) [ 116, 101, 115, 116 ]
67
+ * ```
68
+ */
69
+ export declare const hexToBytes: (bytes: HexString) => Uint8Array;
70
+ /**
71
+ * Converts value to it's number representation
72
+ * @param value - Hex string to be converted
73
+ * @returns - The number representation of the input value
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * conoslle.log(web3.utils.hexToNumber('0xa'));
78
+ * > 10
79
+ * ```
80
+ */
81
+ export declare const hexToNumber: (value: HexString) => bigint | number;
82
+ /**
83
+ * Converts value to it's number representation @alias `hexToNumber`
84
+ */
85
+ export declare const toDecimal: (value: HexString) => bigint | number;
86
+ /**
87
+ * Converts value to it's hex representation
88
+ * @param value - Value to be converted
89
+ * @param hexstrict - Add padding to converted value if odd, to make it hexstrict
90
+ * @returns - The hex representation of the input value
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * console.log(web3.utils.numberToHex(10));
95
+ * > "0xa"
96
+ * ```
97
+ */
98
+ export declare const numberToHex: (value: Numbers, hexstrict?: boolean) => HexString;
99
+ /**
100
+ * Converts value to it's hex representation @alias `numberToHex`
101
+ *
102
+ */
103
+ export declare const fromDecimal: (value: Numbers, hexstrict?: boolean) => HexString;
104
+ /**
105
+ * Converts value to it's decimal representation in string
106
+ * @param value - Hex string to be converted
107
+ * @returns - The decimal representation of the input value
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * console.log(web3.utils.hexToNumberString('0xa'));
112
+ * > "10"
113
+ * ```
114
+ */
115
+ export declare const hexToNumberString: (data: HexString) => string;
116
+ /**
117
+ * Should be called to get hex representation (prefixed by 0x) of utf8 string
118
+ * @param str - Utf8 string to be converted
119
+ * @returns - The hex representation of the input string
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * console.log(utf8ToHex('web3.js'));
124
+ * > "0x776562332e6a73"
125
+ * ```
126
+ *
127
+ */
128
+ export declare const utf8ToHex: (str: string) => HexString;
129
+ /**
130
+ * @alias utf8ToHex
131
+ */
132
+ export declare const fromUtf8: (str: string) => HexString;
133
+ /**
134
+ * @alias utf8ToHex
135
+ */
136
+ export declare const stringToHex: (str: string) => HexString;
137
+ /**
138
+ * Should be called to get utf8 from it's hex representation
139
+ * @param str - Hex string to be converted
140
+ * @returns - Utf8 string
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * console.log(web3.utils.hexToUtf8('0x48656c6c6f20576f726c64'));
145
+ * > Hello World
146
+ * ```
147
+ */
148
+ export declare const hexToUtf8: (str: HexString) => string;
149
+ /**
150
+ * @alias hexToUtf8
151
+ */
152
+ export declare const toUtf8: (input: HexString | Uint8Array) => string;
153
+ export declare const utf8ToBytes: typeof ecUtf8ToBytes;
154
+ /**
155
+ * @alias hexToUtf8
156
+ */
157
+ export declare const hexToString: (str: HexString) => string;
158
+ /**
159
+ * Should be called to get hex representation (prefixed by 0x) of ascii string
160
+ * @param str - String to be converted to hex
161
+ * @returns - Hex string
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * console.log(web3.utils.asciiToHex('Hello World'));
166
+ * > 0x48656c6c6f20576f726c64
167
+ * ```
168
+ */
169
+ export declare const asciiToHex: (str: string) => HexString;
170
+ /**
171
+ * @alias asciiToHex
172
+ */
173
+ export declare const fromAscii: (str: string) => HexString;
174
+ /**
175
+ * Should be called to get ascii from it's hex representation
176
+ * @param str - Hex string to be converted to ascii
177
+ * @returns - Ascii string
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * console.log(web3.utils.hexToAscii('0x48656c6c6f20576f726c64'));
182
+ * > Hello World
183
+ * ```
184
+ */
185
+ export declare const hexToAscii: (str: HexString) => string;
186
+ /**
187
+ * @alias hexToAscii
188
+ */
189
+ export declare const toAscii: (str: HexString) => string;
190
+ /**
191
+ * Auto converts any given value into it's hex representation.
192
+ * @param value - Value to be converted to hex
193
+ * @param returnType - If true, it will return the type of the value
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * console.log(web3.utils.toHex(10));
198
+ * > 0xa
199
+ *
200
+ * console.log(web3.utils.toHex('0x123', true));
201
+ * > bytes
202
+ *```
203
+ */
204
+ export declare const toHex: (value: Numbers | Bytes | Address | boolean | object, returnType?: boolean) => HexString | ValueTypes;
205
+ /**
206
+ * Converts any given value into it's number representation, if possible, else into it's bigint representation.
207
+ * @param value - The value to convert
208
+ * @returns - Returns the value in number or bigint representation
209
+ *
210
+ * @example
211
+ * ```ts
212
+ * console.log(web3.utils.toNumber(1));
213
+ * > 1
214
+ * console.log(web3.utils.toNumber(Number.MAX_SAFE_INTEGER));
215
+ * > 9007199254740991
216
+ *
217
+ * console.log(web3.utils.toNumber(BigInt(Number.MAX_SAFE_INTEGER)));
218
+ * > 9007199254740991
219
+ *
220
+ * console.log(web3.utils.toNumber(BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1)));
221
+ * > 9007199254740992n
222
+ *
223
+ * ```
224
+ */
225
+ export declare const toNumber: (value: Numbers) => number | bigint;
226
+ /**
227
+ * Auto converts any given value into it's bigint representation
228
+ *
229
+ * @param value - The value to convert
230
+ * @returns - Returns the value in bigint representation
231
+
232
+ * @example
233
+ * ```ts
234
+ * console.log(web3.utils.toBigInt(1));
235
+ * > 1n
236
+ * ```
237
+ */
238
+ export declare const toBigInt: (value: unknown) => bigint;
239
+ /**
240
+ * Takes a number of wei and converts it to any other ether unit.
241
+ * @param number - The value in wei
242
+ * @param unit - The unit to convert to
243
+ * @returns - Returns the converted value in the given unit
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * console.log(web3.utils.fromWei("1", "ether"));
248
+ * > 0.000000000000000001
249
+ *
250
+ * console.log(web3.utils.fromWei("1", "shannon"));
251
+ * > 0.000000001
252
+ * ```
253
+ */
254
+ export declare const fromWei: (number: Numbers, unit: EtherUnits | number) => string;
255
+ /**
256
+ * Takes a number of a unit and converts it to wei.
257
+ *
258
+ * @param number - The number to convert.
259
+ * @param unit - {@link EtherUnits} The unit of the number passed.
260
+ * @returns The number converted to wei.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * console.log(web3.utils.toWei("0.001", "ether"));
265
+ * > 1000000000000000 //(wei)
266
+ * ```
267
+ */
268
+ export declare const toWei: (number: Numbers, unit: EtherUnits | number) => string;
269
+ /**
270
+ * Will convert an upper or lowercase Ethereum address to a checksum address.
271
+ * @param address - An address string
272
+ * @returns The checksum address
273
+ * @example
274
+ * ```ts
275
+ * web3.utils.toChecksumAddress('0xc1912fee45d61c87cc5ea59dae31190fffff232d');
276
+ * > "0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d"
277
+ * ```
278
+ */
279
+ export declare const toChecksumAddress: (address: Address) => string;
280
+ export declare const toBool: (value: boolean | string | number | unknown) => boolean;
281
+ //# sourceMappingURL=converters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../src/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAe,WAAW,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA2B5E,gBAAgB;AAChB,eAAO,MA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AG,MAkBP,CAAC;AAErC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,SASxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,QAdU,MAAM,KAAG,SAcN,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,QAAS,SAAS,KAAG,MAG3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,QARY,SAAS,KAAG,MAQX,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,UACV,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,eACtC,OAAO,KAClB,SAAS,GAAG,UAyDd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,MAAM,GAAG,MA4BlD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,MAkBzC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,WAAY,OAAO,QAAQ,UAAU,GAAG,MAAM,KAAG,MAmDpE,CAAC;AAEF;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,KAAK,WAAY,OAAO,QAAQ,UAAU,GAAG,MAAM,KAAG,MA6DlE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,YAAa,OAAO,KAAG,MAgCpD,CAAC;AAEF,eAAO,MAAM,MAAM,UAAW,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,KAAG,OAgCnE,CAAC"}
@@ -0,0 +1,11 @@
1
+ import EventEmitter3 from 'eventemitter3';
2
+ /**
3
+ * This class copy the behavior of Node.js EventEmitter class.
4
+ * It is used to provide the same interface for the browser environment.
5
+ */
6
+ export declare class EventEmitter extends EventEmitter3 {
7
+ private maxListeners;
8
+ setMaxListeners(maxListeners: number): this;
9
+ getMaxListeners(): number;
10
+ }
11
+ //# sourceMappingURL=event_emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event_emitter.d.ts","sourceRoot":"","sources":["../../src/event_emitter.ts"],"names":[],"mappings":"AAkBA,OAAO,aAAa,MAAM,eAAe,CAAC;AAE1C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,aAAa;IAE9C,OAAO,CAAC,YAAY,CAA2B;IAExC,eAAe,CAAC,YAAY,EAAE,MAAM;IAKpC,eAAe,IAAI,MAAM;CAGhC"}
@@ -0,0 +1,44 @@
1
+ import { DataFormat, FormatType } from 'web3-types';
2
+ import { JsonSchema, ValidationSchemaInput } from 'web3-validator';
3
+ export declare const isDataFormat: (dataFormat: unknown) => dataFormat is DataFormat;
4
+ /**
5
+ * Converts a value depending on the format
6
+ * @param value - value to convert
7
+ * @param ethType - The type of the value to be parsed
8
+ * @param format - The format to be converted to
9
+ * @returns - The value converted to the specified format
10
+ */
11
+ export declare const convertScalarValue: (value: unknown, ethType: string, format: DataFormat) => unknown;
12
+ /**
13
+ * Converts the data to the specified format
14
+ * @param data - data to convert
15
+ * @param schema - The JSON schema that describes the structure of the data
16
+ * @param dataPath - A string array that specifies the path to the data within the JSON schema
17
+ * @param format - The format to be converted to
18
+ * @param oneOfPath - An optional array of two-element tuples that specifies the "oneOf" option to choose, if the schema has oneOf and the data path can match multiple subschemas
19
+ * @returns - The data converted to the specified format
20
+ */
21
+ export declare const convert: (data: Record<string, unknown> | unknown[] | unknown, schema: JsonSchema, dataPath: string[], format: DataFormat, oneOfPath?: [string, number][]) => unknown;
22
+ /**
23
+ * Given data that can be interpreted according to the provided schema, returns equivalent data that has been formatted
24
+ * according to the provided return format.
25
+ *
26
+ * @param schema - how to interpret the data
27
+ * @param data - data to be formatted
28
+ * @param returnFormat - how to format the data
29
+ * @returns - formatted data
30
+ *
31
+ * @example
32
+ *
33
+ * ```js
34
+ * import { FMT_NUMBER, utils } from "web3";
35
+ *
36
+ * console.log(
37
+ * utils.format({ format: "uint" }, "221", { number: FMT_NUMBER.HEX }),
38
+ * );
39
+ * // 0xdd
40
+ * ```
41
+ *
42
+ */
43
+ export declare const format: <DataType extends unknown, ReturnType_1 extends DataFormat>(schema: ValidationSchemaInput | JsonSchema, data: DataType, returnFormat?: ReturnType_1) => FormatType<DataType, ReturnType_1>;
44
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAEN,UAAU,EAGV,UAAU,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAuB,UAAU,EAAS,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAQ/F,eAAO,MAAM,YAAY,eAAgB,OAAO,6BAI1B,CAAC;AAkDvB;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,UAAW,OAAO,WAAW,MAAM,UAAU,UAAU,YAkDrF,CAAC;AA8GF;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,SACb,OAAO,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,UAC3C,UAAU,YACR,MAAM,EAAE,UACV,UAAU,cACP,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,YAiF7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,sEAIV,qBAAqB,GAAG,UAAU,oFAyB1C,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { Bytes, Numbers, Sha3Input, TypedObject, TypedObjectAbbreviated } from 'web3-types';
2
+ /**
3
+ * A wrapper for ethereum-cryptography/keccak256 to allow hashing a `string` and a `bigint` in addition to `UInt8Array`
4
+ * @param data - the input to hash
5
+ * @returns - the Keccak-256 hash of the input
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * console.log(web3.utils.keccak256Wrapper('web3.js'));
10
+ * > 0x63667efb1961039c9bb0d6ea7a5abdd223a3aca7daa5044ad894226e1f83919a
11
+ *
12
+ * console.log(web3.utils.keccak256Wrapper(1));
13
+ * > 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6
14
+ *
15
+ * console.log(web3.utils.keccak256Wrapper(0xaf12fd));
16
+ * > 0x358640fd4719fa923525d74ab5ae80a594301aba5543e3492b052bf4598b794c
17
+ * ```
18
+ */
19
+ export declare const keccak256Wrapper: (data: Bytes | Numbers | string | ReadonlyArray<number>) => string;
20
+ export { keccak256Wrapper as keccak256 };
21
+ /**
22
+ * computes the Keccak-256 hash of the input and returns a hexstring
23
+ * @param data - the input to hash
24
+ * @returns - the Keccak-256 hash of the input
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * console.log(web3.utils.sha3('web3.js'));
29
+ * > 0x63667efb1961039c9bb0d6ea7a5abdd223a3aca7daa5044ad894226e1f83919a
30
+ *
31
+ * console.log(web3.utils.sha3(''));
32
+ * > undefined
33
+ * ```
34
+ */
35
+ export declare const sha3: (data: Bytes) => string | undefined;
36
+ /**
37
+ * Will calculate the sha3 of the input but does return the hash value instead of null if for example a empty string is passed.
38
+ * @param data - the input to hash
39
+ * @returns - the Keccak-256 hash of the input
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * conosle.log(web3.utils.sha3Raw('web3.js'));
44
+ * > 0x63667efb1961039c9bb0d6ea7a5abdd223a3aca7daa5044ad894226e1f83919a
45
+ *
46
+ * console.log(web3.utils.sha3Raw(''));
47
+ * > 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
48
+ * ```
49
+ */
50
+ export declare const sha3Raw: (data: Bytes) => string;
51
+ /**
52
+ * returns a string of the tightly packed value given based on the type
53
+ * @param arg - the input to return the tightly packed value
54
+ * @returns - the tightly packed value
55
+ */
56
+ export declare const processSolidityEncodePackedArgs: (arg: Sha3Input) => string;
57
+ /**
58
+ * Encode packed arguments to a hexstring
59
+ */
60
+ export declare const encodePacked: (...values: Sha3Input[]) => string;
61
+ /**
62
+ * Will tightly pack values given in the same way solidity would then hash.
63
+ * returns a hash string, or null if input is empty
64
+ * @param values - the input to return the tightly packed values
65
+ * @returns - the keccack246 of the tightly packed values
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * console.log(web3.utils.soliditySha3({ type: "string", value: "31323334" }));
70
+ * > 0xf15f8da2ad27e486d632dc37d24912f634398918d6f9913a0a0ff84e388be62b
71
+ * ```
72
+ */
73
+ export declare const soliditySha3: (...values: Sha3Input[]) => string | undefined;
74
+ /**
75
+ * Will tightly pack values given in the same way solidity would then hash.
76
+ * returns a hash string, if input is empty will return `0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`
77
+ * @param values - the input to return the tightly packed values
78
+ * @returns - the keccack246 of the tightly packed values
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * console.log(web3.utils.soliditySha3Raw({ type: "string", value: "helloworld" }))
83
+ * > 0xfa26db7ca85ead399216e7c6316bc50ed24393c3122b582735e7f3b0f91b93f0
84
+ * ```
85
+ */
86
+ export declare const soliditySha3Raw: (...values: TypedObject[] | TypedObjectAbbreviated[]) => string;
87
+ /**
88
+ * Get slot number for storage long string in contract. Basically for getStorage method
89
+ * returns slotNumber where will data placed
90
+ * @param mainSlotNumber - the slot number where will be stored hash of long string
91
+ * @returns - the slot number where will be stored long string
92
+ */
93
+ export declare const getStorageSlotNumForLongString: (mainSlotNumber: number | string) => string | undefined;
94
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/hash.ts"],"names":[],"mappings":"AAqDA,OAAO,EACN,KAAK,EAEL,OAAO,EACP,SAAS,EACT,WAAW,EACX,sBAAsB,EACtB,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gBAAgB,SACtB,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,cAAc,MAAM,CAAC,KACpD,MAYF,CAAC;AAEF,OAAO,EAAE,gBAAgB,IAAI,SAAS,EAAE,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,IAAI,SAAU,KAAK,KAAG,MAAM,GAAG,SAgB3C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO,SAAU,KAAK,KAAG,MAOrC,CAAC;AAqKF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAAS,SAAS,KAAG,MAYhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,cAAe,SAAS,EAAE,KAAG,MAGrD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,cAAe,SAAS,EAAE,KAAG,MAAM,GAAG,SACjC,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,cAAe,WAAW,EAAE,GAAG,sBAAsB,EAAE,KAAG,MACrD,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,mBAAoB,MAAM,GAAG,MAAM,uBAM5E,CAAC"}
@@ -0,0 +1,19 @@
1
+ export * from './converters.js';
2
+ export * from './event_emitter.js';
3
+ export * from './validation.js';
4
+ export * from './formatter.js';
5
+ export * from './hash.js';
6
+ export * from './random.js';
7
+ export * from './string_manipulation.js';
8
+ export * from './objects.js';
9
+ export * from './promise_helpers.js';
10
+ export * from './json_rpc.js';
11
+ export * as jsonRpc from './json_rpc.js';
12
+ export * from './web3_deferred_promise.js';
13
+ export * from './chunk_response_parser.js';
14
+ export * from './uuid.js';
15
+ export * from './web3_eip1193_provider.js';
16
+ export * from './socket_provider.js';
17
+ export * from './uint8array.js';
18
+ export { AbiItem } from 'web3-types';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { JsonRpcPayload, JsonRpcResponse, JsonRpcResponseWithResult, JsonRpcResponseWithError, JsonRpcOptionalRequest, JsonRpcBatchRequest, JsonRpcNotification, JsonRpcRequest, JsonRpcBatchResponse, JsonRpcSubscriptionResult } from 'web3-types';
2
+ export declare const isResponseRpcError: (rpcError: JsonRpcResponseWithError) => boolean;
3
+ export declare const isResponseWithResult: <Result = unknown, Error_1 = unknown>(response: JsonRpcResponse<Result, Error_1>) => response is JsonRpcResponseWithResult<Result>;
4
+ export declare const isResponseWithError: <Error_1 = unknown, Result = unknown>(response: JsonRpcResponse<Result, Error_1>) => response is JsonRpcResponseWithError<Error_1>;
5
+ export declare const isResponseWithNotification: <Result>(response: JsonRpcNotification<Result> | JsonRpcSubscriptionResult) => response is JsonRpcNotification<Result>;
6
+ export declare const isSubscriptionResult: <Result>(response: JsonRpcSubscriptionResult | JsonRpcNotification<Result>) => response is JsonRpcSubscriptionResult;
7
+ export declare const validateResponse: <Result = unknown, Error_1 = unknown>(response: JsonRpcResponse<Result, Error_1>) => boolean;
8
+ export declare const isValidResponse: <Result = unknown, Error_1 = unknown>(response: JsonRpcResponse<Result, Error_1>) => boolean;
9
+ export declare const isBatchResponse: <Result = unknown, Error_1 = unknown>(response: JsonRpcResponse<Result, Error_1>) => response is JsonRpcBatchResponse<Result, Error_1>;
10
+ /**
11
+ * Optionally use to make the jsonrpc `id` start from a specific number.
12
+ * Without calling this function, the `id` will be filled with a Uuid.
13
+ * But after this being called with a number, the `id` will be a number starting from the provided `start` variable.
14
+ * However, if `undefined` was passed to this function, the `id` will be a Uuid again.
15
+ * @param start - a number to start incrementing from.
16
+ * Or `undefined` to use a new Uuid (this is the default behavior)
17
+ */
18
+ export declare const setRequestIdStart: (start: number | undefined) => void;
19
+ export declare const toPayload: <ParamType = unknown[]>(request: JsonRpcOptionalRequest<ParamType>) => JsonRpcPayload<ParamType>;
20
+ export declare const toBatchPayload: (requests: JsonRpcOptionalRequest<unknown>[]) => JsonRpcBatchRequest;
21
+ export declare const isBatchRequest: (request: JsonRpcBatchRequest | JsonRpcRequest<unknown> | JsonRpcOptionalRequest<unknown>) => request is JsonRpcBatchRequest;
22
+ //# sourceMappingURL=json_rpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json_rpc.d.ts","sourceRoot":"","sources":["../../src/json_rpc.ts"],"names":[],"mappings":"AAkBA,OAAO,EACN,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,kBAAkB,aAAc,wBAAwB,YAGpE,CAAC;AAEF,eAAO,MAAM,oBAAoB,oIASoC,CAAC;AAGtE,eAAO,MAAM,mBAAmB,oIASqC,CAAC;AAEtE,eAAO,MAAM,0BAA0B,wHAOX,CAAC;AAE7B,eAAO,MAAM,oBAAoB,sHAQZ,CAAC;AAEtB,eAAO,MAAM,gBAAgB,uFAE1B,OAAyF,CAAC;AAE7F,eAAO,MAAM,eAAe,uFAEzB,OACqF,CAAC;AAEzF,eAAO,MAAM,eAAe,wIAGgD,CAAC;AAK7E;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,GAAG,SAAS,SAE1D,CAAC;AAEF,eAAO,MAAM,SAAS,kGAYrB,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,uBAAuB,OAAO,CAAC,EAAE,wBACE,CAAC;AAE7E,eAAO,MAAM,cAAc,YACjB,mBAAmB,GAAG,eAAe,OAAO,CAAC,GAAG,uBAAuB,OAAO,CAAC,mCACR,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Deep merge two objects.
3
+ * @param destination - The destination object.
4
+ * @param sources - An array of source objects.
5
+ * @returns - The merged object.
6
+ */
7
+ export declare const mergeDeep: (destination: Record<string, unknown>, ...sources: Record<string, unknown>[]) => Record<string, unknown>;
8
+ //# sourceMappingURL=objects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../src/objects.ts"],"names":[],"mappings":"AA4BA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,gBACR,OAAO,MAAM,EAAE,OAAO,CAAC,cACxB,OAAO,MAAM,EAAE,OAAO,CAAC,EAAE,KACnC,OAAO,MAAM,EAAE,OAAO,CA2BxB,CAAC"}
@@ -0,0 +1,48 @@
1
+ export declare type Timer = ReturnType<typeof setInterval>;
2
+ export declare type Timeout = ReturnType<typeof setTimeout>;
3
+ /**
4
+ * An alternative to the node function `isPromise` that exists in `util/types` because it is not available on the browser.
5
+ * @param object - to check if it is a `Promise`
6
+ * @returns `true` if it is an `object` or a `function` that has a `then` function. And returns `false` otherwise.
7
+ */
8
+ export declare function isPromise(object: unknown): boolean;
9
+ export declare type AsyncFunction<T, K = unknown> = (...args: K[]) => Promise<T>;
10
+ export declare function waitWithTimeout<T>(awaitable: Promise<T> | AsyncFunction<T>, timeout: number, error: Error): Promise<T>;
11
+ export declare function waitWithTimeout<T>(awaitable: Promise<T> | AsyncFunction<T>, timeout: number): Promise<T | undefined>;
12
+ /**
13
+ * Repeatedly calls an async function with a given interval until the result of the function is defined (not undefined or null),
14
+ * or until a timeout is reached. It returns promise and intervalId.
15
+ * @param func - The function to call.
16
+ * @param interval - The interval in milliseconds.
17
+ */
18
+ export declare function pollTillDefinedAndReturnIntervalId<T>(func: AsyncFunction<T>, interval: number): [Promise<Exclude<T, undefined>>, Timer];
19
+ /**
20
+ * Repeatedly calls an async function with a given interval until the result of the function is defined (not undefined or null),
21
+ * or until a timeout is reached.
22
+ * pollTillDefinedAndReturnIntervalId() function should be used instead of pollTillDefined if you need IntervalId in result.
23
+ * This function will be deprecated in next major release so use pollTillDefinedAndReturnIntervalId().
24
+ * @param func - The function to call.
25
+ * @param interval - The interval in milliseconds.
26
+ */
27
+ export declare function pollTillDefined<T>(func: AsyncFunction<T>, interval: number): Promise<Exclude<T, undefined>>;
28
+ /**
29
+ * Enforce a timeout on a promise, so that it can be rejected if it takes too long to complete
30
+ * @param timeout - The timeout to enforced in milliseconds.
31
+ * @param error - The error to throw if the timeout is reached.
32
+ * @returns A tuple of the timeout id and the promise that will be rejected if the timeout is reached.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const [timerId, promise] = web3.utils.rejectIfTimeout(100, new Error('time out'));
37
+ * ```
38
+ */
39
+ export declare function rejectIfTimeout(timeout: number, error: Error): [Timer, Promise<never>];
40
+ /**
41
+ * Sets an interval that repeatedly executes the given cond function with the specified interval between each call.
42
+ * If the condition is met, the interval is cleared and a Promise that rejects with the returned value is returned.
43
+ * @param cond - The function/condition to call.
44
+ * @param interval - The interval in milliseconds.
45
+ * @returns - an array with the interval ID and the Promise.
46
+ */
47
+ export declare function rejectIfConditionAtInterval<T>(cond: AsyncFunction<T | undefined>, interval: number): [Timer, Promise<never>];
48
+ //# sourceMappingURL=promise_helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise_helpers.d.ts","sourceRoot":"","sources":["../../src/promise_helpers.ts"],"names":[],"mappings":"AAmBA,oBAAY,KAAK,GAAG,UAAU,CAAC,OAAO,WAA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,CAAC,CAAC,EAC5C,IAAI,EAAE,aAAa,CAAC,CAAC,GAAG,SAAS,CAAC,EAClC,QAAQ,EAAE,MAAM,GACd,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAczB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Returns a random byte array by the given bytes size
3
+ * @param size - The size of the random byte array returned
4
+ * @returns - random byte array
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * console.log(web3.utils.randomBytes(32));
9
+ * > Uint8Array(32) [
10
+ * 93, 172, 226, 32, 33, 176, 156, 156,
11
+ * 182, 30, 240, 2, 69, 96, 174, 197,
12
+ * 33, 136, 194, 241, 197, 156, 110, 111,
13
+ * 66, 87, 17, 88, 67, 48, 245, 183
14
+ * ]
15
+ * ```
16
+ */
17
+ export declare const randomBytes: (size: number) => Uint8Array;
18
+ /**
19
+ * Returns a random hex string by the given bytes size
20
+ * @param byteSize - The size of the random hex string returned
21
+ * @returns - random hex string
22
+ *
23
+ * ```ts
24
+ * console.log(web3.utils.randomHex(32));
25
+ * > 0x139f5b88b72a25eab053d3b57fe1f8a9dbc62a526b1cb1774d0d7db1c3e7ce9e
26
+ * ```
27
+ */
28
+ export declare const randomHex: (byteSize: number) => string;
29
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,SAAU,MAAM,KAAG,UAAsC,CAAC;AAElF;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,aAAc,MAAM,KAAG,MAA2C,CAAC"}