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.
- package/3xg6ulq8.cjs +1 -0
- package/LICENSE +14 -0
- package/README.md +72 -0
- package/lib/commonjs/chunk_response_parser.d.ts +14 -0
- package/lib/commonjs/chunk_response_parser.js +66 -0
- package/lib/commonjs/chunk_response_parser.js.map +1 -0
- package/lib/commonjs/converters.d.ts +280 -0
- package/lib/commonjs/converters.js +624 -0
- package/lib/commonjs/converters.js.map +1 -0
- package/lib/commonjs/event_emitter.d.ts +10 -0
- package/lib/commonjs/event_emitter.js +44 -0
- package/lib/commonjs/event_emitter.js.map +1 -0
- package/lib/commonjs/formatter.d.ts +43 -0
- package/lib/commonjs/formatter.js +320 -0
- package/lib/commonjs/formatter.js.map +1 -0
- package/lib/commonjs/hash.d.ts +93 -0
- package/lib/commonjs/hash.js +347 -0
- package/lib/commonjs/hash.js.map +1 -0
- package/lib/commonjs/index.d.ts +18 -0
- package/lib/commonjs/index.js +63 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/json_rpc.d.ts +21 -0
- package/lib/commonjs/json_rpc.js +96 -0
- package/lib/commonjs/json_rpc.js.map +1 -0
- package/lib/commonjs/objects.d.ts +7 -0
- package/lib/commonjs/objects.js +62 -0
- package/lib/commonjs/objects.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/promise_helpers.d.ts +47 -0
- package/lib/commonjs/promise_helpers.js +155 -0
- package/lib/commonjs/promise_helpers.js.map +1 -0
- package/lib/commonjs/random.d.ts +28 -0
- package/lib/commonjs/random.js +55 -0
- package/lib/commonjs/random.js.map +1 -0
- package/lib/commonjs/socket_provider.d.ts +128 -0
- package/lib/commonjs/socket_provider.js +356 -0
- package/lib/commonjs/socket_provider.js.map +1 -0
- package/lib/commonjs/string_manipulation.d.ts +80 -0
- package/lib/commonjs/string_manipulation.js +147 -0
- package/lib/commonjs/string_manipulation.js.map +1 -0
- package/lib/commonjs/uint8array.d.ts +6 -0
- package/lib/commonjs/uint8array.js +59 -0
- package/lib/commonjs/uint8array.js.map +1 -0
- package/lib/commonjs/uuid.d.ts +11 -0
- package/lib/commonjs/uuid.js +57 -0
- package/lib/commonjs/uuid.js.map +1 -0
- package/lib/commonjs/validation.d.ts +82 -0
- package/lib/commonjs/validation.js +163 -0
- package/lib/commonjs/validation.js.map +1 -0
- package/lib/commonjs/web3_deferred_promise.d.ts +67 -0
- package/lib/commonjs/web3_deferred_promise.js +141 -0
- package/lib/commonjs/web3_deferred_promise.js.map +1 -0
- package/lib/commonjs/web3_eip1193_provider.d.ts +15 -0
- package/lib/commonjs/web3_eip1193_provider.js +109 -0
- package/lib/commonjs/web3_eip1193_provider.js.map +1 -0
- package/lib/esm/chunk_response_parser.js +62 -0
- package/lib/esm/chunk_response_parser.js.map +1 -0
- package/lib/esm/converters.js +603 -0
- package/lib/esm/converters.js.map +1 -0
- package/lib/esm/event_emitter.js +37 -0
- package/lib/esm/event_emitter.js.map +1 -0
- package/lib/esm/formatter.js +313 -0
- package/lib/esm/formatter.js.map +1 -0
- package/lib/esm/hash.js +336 -0
- package/lib/esm/hash.js.map +1 -0
- package/lib/esm/index.js +34 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/json_rpc.js +81 -0
- package/lib/esm/json_rpc.js.map +1 -0
- package/lib/esm/objects.js +58 -0
- package/lib/esm/objects.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/promise_helpers.js +146 -0
- package/lib/esm/promise_helpers.js.map +1 -0
- package/lib/esm/random.js +50 -0
- package/lib/esm/random.js.map +1 -0
- package/lib/esm/socket_provider.js +329 -0
- package/lib/esm/socket_provider.js.map +1 -0
- package/lib/esm/string_manipulation.js +140 -0
- package/lib/esm/string_manipulation.js.map +1 -0
- package/lib/esm/uint8array.js +53 -0
- package/lib/esm/uint8array.js.map +1 -0
- package/lib/esm/uuid.js +53 -0
- package/lib/esm/uuid.js.map +1 -0
- package/lib/esm/validation.js +158 -0
- package/lib/esm/validation.js.map +1 -0
- package/lib/esm/web3_deferred_promise.js +137 -0
- package/lib/esm/web3_deferred_promise.js.map +1 -0
- package/lib/esm/web3_eip1193_provider.js +105 -0
- package/lib/esm/web3_eip1193_provider.js.map +1 -0
- package/lib/types/chunk_response_parser.d.ts +15 -0
- package/lib/types/chunk_response_parser.d.ts.map +1 -0
- package/lib/types/converters.d.ts +281 -0
- package/lib/types/converters.d.ts.map +1 -0
- package/lib/types/event_emitter.d.ts +11 -0
- package/lib/types/event_emitter.d.ts.map +1 -0
- package/lib/types/formatter.d.ts +44 -0
- package/lib/types/formatter.d.ts.map +1 -0
- package/lib/types/hash.d.ts +94 -0
- package/lib/types/hash.d.ts.map +1 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/json_rpc.d.ts +22 -0
- package/lib/types/json_rpc.d.ts.map +1 -0
- package/lib/types/objects.d.ts +8 -0
- package/lib/types/objects.d.ts.map +1 -0
- package/lib/types/promise_helpers.d.ts +48 -0
- package/lib/types/promise_helpers.d.ts.map +1 -0
- package/lib/types/random.d.ts +29 -0
- package/lib/types/random.d.ts.map +1 -0
- package/lib/types/socket_provider.d.ts +129 -0
- package/lib/types/socket_provider.d.ts.map +1 -0
- package/lib/types/string_manipulation.d.ts +81 -0
- package/lib/types/string_manipulation.d.ts.map +1 -0
- package/lib/types/uint8array.d.ts +7 -0
- package/lib/types/uint8array.d.ts.map +1 -0
- package/lib/types/uuid.d.ts +12 -0
- package/lib/types/uuid.d.ts.map +1 -0
- package/lib/types/validation.d.ts +83 -0
- package/lib/types/validation.d.ts.map +1 -0
- package/lib/types/web3_deferred_promise.d.ts +68 -0
- package/lib/types/web3_deferred_promise.d.ts.map +1 -0
- package/lib/types/web3_eip1193_provider.d.ts +16 -0
- package/lib/types/web3_eip1193_provider.d.ts.map +1 -0
- package/package.json +57 -0
- package/src/chunk_response_parser.ts +99 -0
- package/src/converters.ts +713 -0
- package/src/event_emitter.ts +37 -0
- package/src/formatter.ts +402 -0
- package/src/hash.ts +398 -0
- package/src/index.ts +36 -0
- package/src/json_rpc.ts +130 -0
- package/src/objects.ts +65 -0
- package/src/promise_helpers.ts +170 -0
- package/src/random.ts +53 -0
- package/src/socket_provider.ts +581 -0
- package/src/string_manipulation.ts +166 -0
- package/src/uint8array.ts +59 -0
- package/src/uuid.ts +59 -0
- package/src/validation.ts +193 -0
- package/src/web3_deferred_promise.ts +149 -0
- package/src/web3_eip1193_provider.ts +116 -0
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
This file is part of web3.js.
|
|
4
|
+
|
|
5
|
+
web3.js is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
web3.js is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Lesser General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.toBool = exports.toChecksumAddress = exports.toWei = exports.fromWei = exports.toBigInt = exports.toNumber = exports.toHex = exports.toAscii = exports.hexToAscii = exports.fromAscii = exports.asciiToHex = exports.hexToString = exports.utf8ToBytes = exports.toUtf8 = exports.hexToUtf8 = exports.stringToHex = exports.fromUtf8 = exports.utf8ToHex = exports.hexToNumberString = exports.fromDecimal = exports.numberToHex = exports.toDecimal = exports.hexToNumber = exports.hexToBytes = exports.bytesToHex = exports.bytesToUint8Array = exports.ethUnitMap = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* @module Utils
|
|
22
|
+
*/
|
|
23
|
+
const keccak_js_1 = require("ethereum-cryptography/keccak.js");
|
|
24
|
+
const utils_js_1 = require("ethereum-cryptography/utils.js");
|
|
25
|
+
const web3_validator_1 = require("web3-validator");
|
|
26
|
+
const web3_errors_1 = require("web3-errors");
|
|
27
|
+
const uint8array_js_1 = require("./uint8array.js");
|
|
28
|
+
// Ref: https://ethdocs.org/en/latest/ether.html
|
|
29
|
+
// Note: this could be simplified using ** operator, but babel does not handle it well (https://github.com/babel/babel/issues/13109)
|
|
30
|
+
/** @internal */
|
|
31
|
+
exports.ethUnitMap = {
|
|
32
|
+
noether: BigInt(0),
|
|
33
|
+
wei: BigInt(1),
|
|
34
|
+
kwei: BigInt(1000),
|
|
35
|
+
Kwei: BigInt(1000),
|
|
36
|
+
babbage: BigInt(1000),
|
|
37
|
+
femtoether: BigInt(1000),
|
|
38
|
+
mwei: BigInt(1000000),
|
|
39
|
+
Mwei: BigInt(1000000),
|
|
40
|
+
lovelace: BigInt(1000000),
|
|
41
|
+
picoether: BigInt(1000000),
|
|
42
|
+
gwei: BigInt(1000000000),
|
|
43
|
+
Gwei: BigInt(1000000000),
|
|
44
|
+
shannon: BigInt(1000000000),
|
|
45
|
+
nanoether: BigInt(1000000000),
|
|
46
|
+
nano: BigInt(1000000000),
|
|
47
|
+
szabo: BigInt(1000000000000),
|
|
48
|
+
microether: BigInt(1000000000000),
|
|
49
|
+
micro: BigInt(1000000000000),
|
|
50
|
+
finney: BigInt(1000000000000000),
|
|
51
|
+
milliether: BigInt(1000000000000000),
|
|
52
|
+
milli: BigInt(1000000000000000),
|
|
53
|
+
ether: BigInt('1000000000000000000'),
|
|
54
|
+
kether: BigInt('1000000000000000000000'),
|
|
55
|
+
grand: BigInt('1000000000000000000000'),
|
|
56
|
+
mether: BigInt('1000000000000000000000000'),
|
|
57
|
+
gether: BigInt('1000000000000000000000000000'),
|
|
58
|
+
tether: BigInt('1000000000000000000000000000000'),
|
|
59
|
+
};
|
|
60
|
+
const PrecisionLossWarning = 'Warning: Using type `number` with values that are large or contain many decimals may cause loss of precision, it is recommended to use type `string` or `BigInt` when using conversion methods';
|
|
61
|
+
/**
|
|
62
|
+
* Convert a value from bytes to Uint8Array
|
|
63
|
+
* @param data - Data to be converted
|
|
64
|
+
* @returns - The Uint8Array representation of the input data
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* console.log(web3.utils.bytesToUint8Array("0xab")));
|
|
69
|
+
* > Uint8Array(1) [ 171 ]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
const bytesToUint8Array = (data) => {
|
|
73
|
+
web3_validator_1.validator.validate(['bytes'], [data]);
|
|
74
|
+
if ((0, uint8array_js_1.isUint8Array)(data)) {
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(data)) {
|
|
78
|
+
return new Uint8Array(data);
|
|
79
|
+
}
|
|
80
|
+
if (typeof data === 'string') {
|
|
81
|
+
return web3_validator_1.utils.hexToUint8Array(data);
|
|
82
|
+
}
|
|
83
|
+
throw new web3_errors_1.InvalidBytesError(data);
|
|
84
|
+
};
|
|
85
|
+
exports.bytesToUint8Array = bytesToUint8Array;
|
|
86
|
+
/**
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
const { uint8ArrayToHexString } = web3_validator_1.utils;
|
|
90
|
+
/**
|
|
91
|
+
* Convert a byte array to a hex string
|
|
92
|
+
* @param bytes - Byte array to be converted
|
|
93
|
+
* @returns - The hex string representation of the input byte array
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* console.log(web3.utils.bytesToHex(new Uint8Array([72, 12])));
|
|
98
|
+
* > "0x480c"
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
const bytesToHex = (bytes) => uint8ArrayToHexString((0, exports.bytesToUint8Array)(bytes));
|
|
102
|
+
exports.bytesToHex = bytesToHex;
|
|
103
|
+
/**
|
|
104
|
+
* Convert a hex string to a byte array
|
|
105
|
+
* @param hex - Hex string to be converted
|
|
106
|
+
* @returns - The byte array representation of the input hex string
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* console.log(web3.utils.hexToBytes('0x74657374'));
|
|
111
|
+
* > Uint8Array(4) [ 116, 101, 115, 116 ]
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
const hexToBytes = (bytes) => {
|
|
115
|
+
if (typeof bytes === 'string' && bytes.slice(0, 2).toLowerCase() !== '0x') {
|
|
116
|
+
return (0, exports.bytesToUint8Array)(`0x${bytes}`);
|
|
117
|
+
}
|
|
118
|
+
return (0, exports.bytesToUint8Array)(bytes);
|
|
119
|
+
};
|
|
120
|
+
exports.hexToBytes = hexToBytes;
|
|
121
|
+
/**
|
|
122
|
+
* Converts value to it's number representation
|
|
123
|
+
* @param value - Hex string to be converted
|
|
124
|
+
* @returns - The number representation of the input value
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* conoslle.log(web3.utils.hexToNumber('0xa'));
|
|
129
|
+
* > 10
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
const hexToNumber = (value) => {
|
|
133
|
+
web3_validator_1.validator.validate(['hex'], [value]);
|
|
134
|
+
// To avoid duplicate code and circular dependency we will
|
|
135
|
+
// use `hexToNumber` implementation from `web3-validator`
|
|
136
|
+
return web3_validator_1.utils.hexToNumber(value);
|
|
137
|
+
};
|
|
138
|
+
exports.hexToNumber = hexToNumber;
|
|
139
|
+
/**
|
|
140
|
+
* Converts value to it's number representation @alias `hexToNumber`
|
|
141
|
+
*/
|
|
142
|
+
exports.toDecimal = exports.hexToNumber;
|
|
143
|
+
/**
|
|
144
|
+
* Converts value to it's hex representation
|
|
145
|
+
* @param value - Value to be converted
|
|
146
|
+
* @param hexstrict - Add padding to converted value if odd, to make it hexstrict
|
|
147
|
+
* @returns - The hex representation of the input value
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* console.log(web3.utils.numberToHex(10));
|
|
152
|
+
* > "0xa"
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
const numberToHex = (value, hexstrict) => {
|
|
156
|
+
if (typeof value !== 'bigint')
|
|
157
|
+
web3_validator_1.validator.validate(['int'], [value]);
|
|
158
|
+
// To avoid duplicate code and circular dependency we will
|
|
159
|
+
// use `numberToHex` implementation from `web3-validator`
|
|
160
|
+
let updatedValue = web3_validator_1.utils.numberToHex(value);
|
|
161
|
+
if (hexstrict) {
|
|
162
|
+
if (!updatedValue.startsWith('-') && updatedValue.length % 2 === 1) {
|
|
163
|
+
// To avoid duplicate a circular dependency we will not be using the padLeft method
|
|
164
|
+
updatedValue = '0x0'.concat(updatedValue.slice(2));
|
|
165
|
+
}
|
|
166
|
+
else if (updatedValue.length % 2 === 0 && updatedValue.startsWith('-'))
|
|
167
|
+
updatedValue = '-0x0'.concat(updatedValue.slice(3));
|
|
168
|
+
}
|
|
169
|
+
return updatedValue;
|
|
170
|
+
};
|
|
171
|
+
exports.numberToHex = numberToHex;
|
|
172
|
+
/**
|
|
173
|
+
* Converts value to it's hex representation @alias `numberToHex`
|
|
174
|
+
*
|
|
175
|
+
*/
|
|
176
|
+
exports.fromDecimal = exports.numberToHex;
|
|
177
|
+
/**
|
|
178
|
+
* Converts value to it's decimal representation in string
|
|
179
|
+
* @param value - Hex string to be converted
|
|
180
|
+
* @returns - The decimal representation of the input value
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* console.log(web3.utils.hexToNumberString('0xa'));
|
|
185
|
+
* > "10"
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
const hexToNumberString = (data) => (0, exports.hexToNumber)(data).toString();
|
|
189
|
+
exports.hexToNumberString = hexToNumberString;
|
|
190
|
+
/**
|
|
191
|
+
* Should be called to get hex representation (prefixed by 0x) of utf8 string
|
|
192
|
+
* @param str - Utf8 string to be converted
|
|
193
|
+
* @returns - The hex representation of the input string
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* console.log(utf8ToHex('web3.js'));
|
|
198
|
+
* > "0x776562332e6a73"
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
const utf8ToHex = (str) => {
|
|
203
|
+
web3_validator_1.validator.validate(['string'], [str]);
|
|
204
|
+
// To be compatible with 1.x trim null character
|
|
205
|
+
// eslint-disable-next-line no-control-regex
|
|
206
|
+
let strWithoutNullCharacter = str.replace(/^(?:\u0000)/, '');
|
|
207
|
+
// eslint-disable-next-line no-control-regex
|
|
208
|
+
strWithoutNullCharacter = strWithoutNullCharacter.replace(/(?:\u0000)$/, '');
|
|
209
|
+
return (0, exports.bytesToHex)(new TextEncoder().encode(strWithoutNullCharacter));
|
|
210
|
+
};
|
|
211
|
+
exports.utf8ToHex = utf8ToHex;
|
|
212
|
+
/**
|
|
213
|
+
* @alias utf8ToHex
|
|
214
|
+
*/
|
|
215
|
+
exports.fromUtf8 = exports.utf8ToHex;
|
|
216
|
+
/**
|
|
217
|
+
* @alias utf8ToHex
|
|
218
|
+
*/
|
|
219
|
+
exports.stringToHex = exports.utf8ToHex;
|
|
220
|
+
/**
|
|
221
|
+
* Should be called to get utf8 from it's hex representation
|
|
222
|
+
* @param str - Hex string to be converted
|
|
223
|
+
* @returns - Utf8 string
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* console.log(web3.utils.hexToUtf8('0x48656c6c6f20576f726c64'));
|
|
228
|
+
* > Hello World
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
const hexToUtf8 = (str) => (0, utils_js_1.bytesToUtf8)((0, exports.hexToBytes)(str));
|
|
232
|
+
exports.hexToUtf8 = hexToUtf8;
|
|
233
|
+
/**
|
|
234
|
+
* @alias hexToUtf8
|
|
235
|
+
*/
|
|
236
|
+
const toUtf8 = (input) => {
|
|
237
|
+
if (typeof input === 'string') {
|
|
238
|
+
return (0, exports.hexToUtf8)(input);
|
|
239
|
+
}
|
|
240
|
+
web3_validator_1.validator.validate(['bytes'], [input]);
|
|
241
|
+
return (0, utils_js_1.bytesToUtf8)(input);
|
|
242
|
+
};
|
|
243
|
+
exports.toUtf8 = toUtf8;
|
|
244
|
+
exports.utf8ToBytes = utils_js_1.utf8ToBytes;
|
|
245
|
+
/**
|
|
246
|
+
* @alias hexToUtf8
|
|
247
|
+
*/
|
|
248
|
+
exports.hexToString = exports.hexToUtf8;
|
|
249
|
+
/**
|
|
250
|
+
* Should be called to get hex representation (prefixed by 0x) of ascii string
|
|
251
|
+
* @param str - String to be converted to hex
|
|
252
|
+
* @returns - Hex string
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* console.log(web3.utils.asciiToHex('Hello World'));
|
|
257
|
+
* > 0x48656c6c6f20576f726c64
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
const asciiToHex = (str) => {
|
|
261
|
+
web3_validator_1.validator.validate(['string'], [str]);
|
|
262
|
+
let hexString = '';
|
|
263
|
+
for (let i = 0; i < str.length; i += 1) {
|
|
264
|
+
const hexCharCode = str.charCodeAt(i).toString(16);
|
|
265
|
+
// might need a leading 0
|
|
266
|
+
hexString += hexCharCode.length % 2 !== 0 ? `0${hexCharCode}` : hexCharCode;
|
|
267
|
+
}
|
|
268
|
+
return `0x${hexString}`;
|
|
269
|
+
};
|
|
270
|
+
exports.asciiToHex = asciiToHex;
|
|
271
|
+
/**
|
|
272
|
+
* @alias asciiToHex
|
|
273
|
+
*/
|
|
274
|
+
exports.fromAscii = exports.asciiToHex;
|
|
275
|
+
/**
|
|
276
|
+
* Should be called to get ascii from it's hex representation
|
|
277
|
+
* @param str - Hex string to be converted to ascii
|
|
278
|
+
* @returns - Ascii string
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* console.log(web3.utils.hexToAscii('0x48656c6c6f20576f726c64'));
|
|
283
|
+
* > Hello World
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
const hexToAscii = (str) => {
|
|
287
|
+
const decoder = new TextDecoder('ascii');
|
|
288
|
+
return decoder.decode((0, exports.hexToBytes)(str));
|
|
289
|
+
};
|
|
290
|
+
exports.hexToAscii = hexToAscii;
|
|
291
|
+
/**
|
|
292
|
+
* @alias hexToAscii
|
|
293
|
+
*/
|
|
294
|
+
exports.toAscii = exports.hexToAscii;
|
|
295
|
+
/**
|
|
296
|
+
* Auto converts any given value into it's hex representation.
|
|
297
|
+
* @param value - Value to be converted to hex
|
|
298
|
+
* @param returnType - If true, it will return the type of the value
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* console.log(web3.utils.toHex(10));
|
|
303
|
+
* > 0xa
|
|
304
|
+
*
|
|
305
|
+
* console.log(web3.utils.toHex('0x123', true));
|
|
306
|
+
* > bytes
|
|
307
|
+
*```
|
|
308
|
+
*/
|
|
309
|
+
const toHex = (value, returnType) => {
|
|
310
|
+
if (typeof value === 'string' && (0, web3_validator_1.isAddress)(value)) {
|
|
311
|
+
return returnType ? 'address' : `0x${value.toLowerCase().replace(/^0x/i, '')}`;
|
|
312
|
+
}
|
|
313
|
+
if (typeof value === 'boolean') {
|
|
314
|
+
// eslint-disable-next-line no-nested-ternary
|
|
315
|
+
return returnType ? 'bool' : value ? '0x01' : '0x00';
|
|
316
|
+
}
|
|
317
|
+
if (typeof value === 'number') {
|
|
318
|
+
// eslint-disable-next-line no-nested-ternary
|
|
319
|
+
return returnType ? (value < 0 ? 'int256' : 'uint256') : (0, exports.numberToHex)(value);
|
|
320
|
+
}
|
|
321
|
+
if (typeof value === 'bigint') {
|
|
322
|
+
return returnType ? 'bigint' : (0, exports.numberToHex)(value);
|
|
323
|
+
}
|
|
324
|
+
if ((0, uint8array_js_1.isUint8Array)(value)) {
|
|
325
|
+
return returnType ? 'bytes' : (0, exports.bytesToHex)(value);
|
|
326
|
+
}
|
|
327
|
+
if (typeof value === 'object' && !!value) {
|
|
328
|
+
return returnType ? 'string' : (0, exports.utf8ToHex)(JSON.stringify(value));
|
|
329
|
+
}
|
|
330
|
+
if (typeof value === 'string') {
|
|
331
|
+
if (value.startsWith('-0x') || value.startsWith('-0X')) {
|
|
332
|
+
return returnType ? 'int256' : (0, exports.numberToHex)(value);
|
|
333
|
+
}
|
|
334
|
+
if ((0, web3_validator_1.isHexStrict)(value)) {
|
|
335
|
+
return returnType ? 'bytes' : value;
|
|
336
|
+
}
|
|
337
|
+
if ((0, web3_validator_1.isHex)(value) && !(0, web3_validator_1.isInt)(value) && !(0, web3_validator_1.isUInt)(value)) {
|
|
338
|
+
return returnType ? 'bytes' : `0x${value}`;
|
|
339
|
+
}
|
|
340
|
+
if ((0, web3_validator_1.isHex)(value) && !(0, web3_validator_1.isInt)(value) && (0, web3_validator_1.isUInt)(value)) {
|
|
341
|
+
// This condition seems problematic because meeting
|
|
342
|
+
// both conditions `!isInt(value) && isUInt(value)` should be impossible.
|
|
343
|
+
// But a value pass for those conditions: "101611154195520776335741463917853444671577865378275924493376429267637792638729"
|
|
344
|
+
// Note that according to the docs: it is supposed to be treated as a string (https://docs.web3js.org/guides/web3_upgrade_guide/x/web3_utils_migration_guide#conversion-to-hex)
|
|
345
|
+
// In short, the strange is that isInt(value) is false but isUInt(value) is true for the value above.
|
|
346
|
+
// TODO: isUInt(value) should be investigated.
|
|
347
|
+
// However, if `toHex('101611154195520776335741463917853444671577865378275924493376429267637792638729', true)` is called, it will return `true`.
|
|
348
|
+
// But, if `toHex('101611154195520776335741463917853444671577865378275924493376429267637792638729')` is called, it will throw inside `numberToHex`.
|
|
349
|
+
return returnType ? 'uint' : (0, exports.numberToHex)(value);
|
|
350
|
+
}
|
|
351
|
+
if (!Number.isFinite(value)) {
|
|
352
|
+
return returnType ? 'string' : (0, exports.utf8ToHex)(value);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
throw new web3_errors_1.HexProcessingError(value);
|
|
356
|
+
};
|
|
357
|
+
exports.toHex = toHex;
|
|
358
|
+
/**
|
|
359
|
+
* Converts any given value into it's number representation, if possible, else into it's bigint representation.
|
|
360
|
+
* @param value - The value to convert
|
|
361
|
+
* @returns - Returns the value in number or bigint representation
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* console.log(web3.utils.toNumber(1));
|
|
366
|
+
* > 1
|
|
367
|
+
* console.log(web3.utils.toNumber(Number.MAX_SAFE_INTEGER));
|
|
368
|
+
* > 9007199254740991
|
|
369
|
+
*
|
|
370
|
+
* console.log(web3.utils.toNumber(BigInt(Number.MAX_SAFE_INTEGER)));
|
|
371
|
+
* > 9007199254740991
|
|
372
|
+
*
|
|
373
|
+
* console.log(web3.utils.toNumber(BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1)));
|
|
374
|
+
* > 9007199254740992n
|
|
375
|
+
*
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
const toNumber = (value) => {
|
|
379
|
+
if (typeof value === 'number') {
|
|
380
|
+
if (value > 1e20) {
|
|
381
|
+
console.warn(PrecisionLossWarning);
|
|
382
|
+
// JavaScript converts numbers >= 10^21 to scientific notation when coerced to strings,
|
|
383
|
+
// leading to potential parsing errors and incorrect representations.
|
|
384
|
+
// For instance, String(10000000000000000000000) yields '1e+22'.
|
|
385
|
+
// Using BigInt prevents this
|
|
386
|
+
return BigInt(value);
|
|
387
|
+
}
|
|
388
|
+
return value;
|
|
389
|
+
}
|
|
390
|
+
if (typeof value === 'bigint') {
|
|
391
|
+
return value >= Number.MIN_SAFE_INTEGER && value <= Number.MAX_SAFE_INTEGER
|
|
392
|
+
? Number(value)
|
|
393
|
+
: value;
|
|
394
|
+
}
|
|
395
|
+
if (typeof value === 'string' && (0, web3_validator_1.isHexStrict)(value)) {
|
|
396
|
+
return (0, exports.hexToNumber)(value);
|
|
397
|
+
}
|
|
398
|
+
try {
|
|
399
|
+
return (0, exports.toNumber)(BigInt(value));
|
|
400
|
+
}
|
|
401
|
+
catch (_a) {
|
|
402
|
+
throw new web3_errors_1.InvalidNumberError(value);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
exports.toNumber = toNumber;
|
|
406
|
+
/**
|
|
407
|
+
* Auto converts any given value into it's bigint representation
|
|
408
|
+
*
|
|
409
|
+
* @param value - The value to convert
|
|
410
|
+
* @returns - Returns the value in bigint representation
|
|
411
|
+
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* console.log(web3.utils.toBigInt(1));
|
|
415
|
+
* > 1n
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
const toBigInt = (value) => {
|
|
419
|
+
if (typeof value === 'number') {
|
|
420
|
+
return BigInt(value);
|
|
421
|
+
}
|
|
422
|
+
if (typeof value === 'bigint') {
|
|
423
|
+
return value;
|
|
424
|
+
}
|
|
425
|
+
// isHex passes for dec, too
|
|
426
|
+
if (typeof value === 'string' && (0, web3_validator_1.isHex)(value)) {
|
|
427
|
+
if (value.startsWith('-')) {
|
|
428
|
+
return -BigInt(value.substring(1));
|
|
429
|
+
}
|
|
430
|
+
return BigInt(value);
|
|
431
|
+
}
|
|
432
|
+
throw new web3_errors_1.InvalidNumberError(value);
|
|
433
|
+
};
|
|
434
|
+
exports.toBigInt = toBigInt;
|
|
435
|
+
/**
|
|
436
|
+
* Takes a number of wei and converts it to any other ether unit.
|
|
437
|
+
* @param number - The value in wei
|
|
438
|
+
* @param unit - The unit to convert to
|
|
439
|
+
* @returns - Returns the converted value in the given unit
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* console.log(web3.utils.fromWei("1", "ether"));
|
|
444
|
+
* > 0.000000000000000001
|
|
445
|
+
*
|
|
446
|
+
* console.log(web3.utils.fromWei("1", "shannon"));
|
|
447
|
+
* > 0.000000001
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
const fromWei = (number, unit) => {
|
|
451
|
+
let denomination;
|
|
452
|
+
if (typeof unit === 'string') {
|
|
453
|
+
denomination = exports.ethUnitMap[unit];
|
|
454
|
+
if (!denomination) {
|
|
455
|
+
throw new web3_errors_1.InvalidUnitError(unit);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
if (unit < 0 || !Number.isInteger(unit)) {
|
|
460
|
+
throw new web3_errors_1.InvalidIntegerError(unit);
|
|
461
|
+
}
|
|
462
|
+
denomination = (0, web3_validator_1.bigintPower)(BigInt(10), BigInt(unit));
|
|
463
|
+
}
|
|
464
|
+
// value in wei would always be integer
|
|
465
|
+
// 13456789, 1234
|
|
466
|
+
const value = String((0, exports.toNumber)(number));
|
|
467
|
+
// count number of zeros in denomination
|
|
468
|
+
// 1000000 -> 6
|
|
469
|
+
const numberOfZerosInDenomination = denomination.toString().length - 1;
|
|
470
|
+
if (numberOfZerosInDenomination <= 0) {
|
|
471
|
+
return value.toString();
|
|
472
|
+
}
|
|
473
|
+
// pad the value with required zeros
|
|
474
|
+
// 13456789 -> 13456789, 1234 -> 001234
|
|
475
|
+
const zeroPaddedValue = value.padStart(numberOfZerosInDenomination, '0');
|
|
476
|
+
// get the integer part of value by counting number of zeros from start
|
|
477
|
+
// 13456789 -> '13'
|
|
478
|
+
// 001234 -> ''
|
|
479
|
+
const integer = zeroPaddedValue.slice(0, -numberOfZerosInDenomination);
|
|
480
|
+
// get the fraction part of value by counting number of zeros backward
|
|
481
|
+
// 13456789 -> '456789'
|
|
482
|
+
// 001234 -> '001234'
|
|
483
|
+
const fraction = zeroPaddedValue.slice(-numberOfZerosInDenomination).replace(/\.?0+$/, '');
|
|
484
|
+
if (integer === '') {
|
|
485
|
+
return `0.${fraction}`;
|
|
486
|
+
}
|
|
487
|
+
if (fraction === '') {
|
|
488
|
+
return integer;
|
|
489
|
+
}
|
|
490
|
+
const updatedValue = `${integer}.${fraction}`;
|
|
491
|
+
return updatedValue.slice(0, integer.length + numberOfZerosInDenomination + 1);
|
|
492
|
+
};
|
|
493
|
+
exports.fromWei = fromWei;
|
|
494
|
+
/**
|
|
495
|
+
* Takes a number of a unit and converts it to wei.
|
|
496
|
+
*
|
|
497
|
+
* @param number - The number to convert.
|
|
498
|
+
* @param unit - {@link EtherUnits} The unit of the number passed.
|
|
499
|
+
* @returns The number converted to wei.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* console.log(web3.utils.toWei("0.001", "ether"));
|
|
504
|
+
* > 1000000000000000 //(wei)
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
507
|
+
// todo in 1.x unit defaults to 'ether'
|
|
508
|
+
const toWei = (number, unit) => {
|
|
509
|
+
web3_validator_1.validator.validate(['number'], [number]);
|
|
510
|
+
let denomination;
|
|
511
|
+
if (typeof unit === 'string') {
|
|
512
|
+
denomination = exports.ethUnitMap[unit];
|
|
513
|
+
if (!denomination) {
|
|
514
|
+
throw new web3_errors_1.InvalidUnitError(unit);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
if (unit < 0 || !Number.isInteger(unit)) {
|
|
519
|
+
throw new web3_errors_1.InvalidIntegerError(unit);
|
|
520
|
+
}
|
|
521
|
+
denomination = (0, web3_validator_1.bigintPower)(BigInt(10), BigInt(unit));
|
|
522
|
+
}
|
|
523
|
+
let parsedNumber = number;
|
|
524
|
+
if (typeof parsedNumber === 'number') {
|
|
525
|
+
if (parsedNumber < 1e-15) {
|
|
526
|
+
console.warn(PrecisionLossWarning);
|
|
527
|
+
}
|
|
528
|
+
if (parsedNumber > 1e20) {
|
|
529
|
+
console.warn(PrecisionLossWarning);
|
|
530
|
+
parsedNumber = BigInt(parsedNumber);
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
// in case there is a decimal point, we need to convert it to string
|
|
534
|
+
parsedNumber = parsedNumber.toLocaleString('fullwide', {
|
|
535
|
+
useGrouping: false,
|
|
536
|
+
maximumFractionDigits: 20,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
// if value is decimal e.g. 24.56 extract `integer` and `fraction` part
|
|
541
|
+
// to avoid `fraction` to be null use `concat` with empty string
|
|
542
|
+
const [integer, fraction] = String(typeof parsedNumber === 'string' && !(0, web3_validator_1.isHexStrict)(parsedNumber)
|
|
543
|
+
? parsedNumber
|
|
544
|
+
: (0, exports.toNumber)(parsedNumber))
|
|
545
|
+
.split('.')
|
|
546
|
+
.concat('');
|
|
547
|
+
// join the value removing `.` from
|
|
548
|
+
// 24.56 -> 2456
|
|
549
|
+
const value = BigInt(`${integer}${fraction}`);
|
|
550
|
+
// multiply value with denomination
|
|
551
|
+
// 2456 * 1000000 -> 2456000000
|
|
552
|
+
const updatedValue = value * denomination;
|
|
553
|
+
// check if whole number was passed in
|
|
554
|
+
const decimals = fraction.length;
|
|
555
|
+
if (decimals === 0) {
|
|
556
|
+
return updatedValue.toString();
|
|
557
|
+
}
|
|
558
|
+
// trim the value to remove extra zeros
|
|
559
|
+
return updatedValue.toString().slice(0, -decimals);
|
|
560
|
+
};
|
|
561
|
+
exports.toWei = toWei;
|
|
562
|
+
/**
|
|
563
|
+
* Will convert an upper or lowercase Ethereum address to a checksum address.
|
|
564
|
+
* @param address - An address string
|
|
565
|
+
* @returns The checksum address
|
|
566
|
+
* @example
|
|
567
|
+
* ```ts
|
|
568
|
+
* web3.utils.toChecksumAddress('0xc1912fee45d61c87cc5ea59dae31190fffff232d');
|
|
569
|
+
* > "0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d"
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
const toChecksumAddress = (address) => {
|
|
573
|
+
if (!(0, web3_validator_1.isAddress)(address, false)) {
|
|
574
|
+
throw new web3_errors_1.InvalidAddressError(address);
|
|
575
|
+
}
|
|
576
|
+
const lowerCaseAddress = address.toLowerCase().replace(/^0x/i, '');
|
|
577
|
+
// calling `Uint8Array.from` because `noble-hashes` checks with `instanceof Uint8Array` that fails in some edge cases:
|
|
578
|
+
// https://github.com/paulmillr/noble-hashes/issues/25#issuecomment-1750106284
|
|
579
|
+
const hash = web3_validator_1.utils.uint8ArrayToHexString((0, keccak_js_1.keccak256)(web3_validator_1.utils.ensureIfUint8Array((0, exports.utf8ToBytes)(lowerCaseAddress))));
|
|
580
|
+
if ((0, web3_validator_1.isNullish)(hash) ||
|
|
581
|
+
hash === '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470')
|
|
582
|
+
return ''; // // EIP-1052 if hash is equal to c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470, keccak was given empty data
|
|
583
|
+
let checksumAddress = '0x';
|
|
584
|
+
const addressHash = hash.replace(/^0x/i, '');
|
|
585
|
+
for (let i = 0; i < lowerCaseAddress.length; i += 1) {
|
|
586
|
+
// If ith character is 8 to f then make it uppercase
|
|
587
|
+
if (parseInt(addressHash[i], 16) > 7) {
|
|
588
|
+
checksumAddress += lowerCaseAddress[i].toUpperCase();
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
checksumAddress += lowerCaseAddress[i];
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return checksumAddress;
|
|
595
|
+
};
|
|
596
|
+
exports.toChecksumAddress = toChecksumAddress;
|
|
597
|
+
const toBool = (value) => {
|
|
598
|
+
if (typeof value === 'boolean') {
|
|
599
|
+
return value;
|
|
600
|
+
}
|
|
601
|
+
if (typeof value === 'number' && (value === 0 || value === 1)) {
|
|
602
|
+
return Boolean(value);
|
|
603
|
+
}
|
|
604
|
+
if (typeof value === 'bigint' && (value === BigInt(0) || value === BigInt(1))) {
|
|
605
|
+
return Boolean(value);
|
|
606
|
+
}
|
|
607
|
+
if (typeof value === 'string' &&
|
|
608
|
+
!(0, web3_validator_1.isHexStrict)(value) &&
|
|
609
|
+
(value === '1' || value === '0' || value === 'false' || value === 'true')) {
|
|
610
|
+
if (value === 'true') {
|
|
611
|
+
return true;
|
|
612
|
+
}
|
|
613
|
+
if (value === 'false') {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
return Boolean(Number(value));
|
|
617
|
+
}
|
|
618
|
+
if (typeof value === 'string' && (0, web3_validator_1.isHexStrict)(value) && (value === '0x1' || value === '0x0')) {
|
|
619
|
+
return Boolean((0, exports.toNumber)(value));
|
|
620
|
+
}
|
|
621
|
+
throw new web3_errors_1.InvalidBooleanError(value);
|
|
622
|
+
};
|
|
623
|
+
exports.toBool = toBool;
|
|
624
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../src/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;EAeE;;;AAEF;;GAEG;AAEH,+DAA4D;AAC5D,6DAA2F;AAE3F,mDAWwB;AAExB,6CAQqB;AACrB,mDAA+C;AAE/C,gDAAgD;AAChD,oIAAoI;AACpI,gBAAgB;AACH,QAAA,UAAU,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC;IAC1B,IAAI,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CAAC;SACZ;QACD,IAAI,KAAK,KAAK,OAAO,EAAE;YACtB,OAAO,KAAK,CAAC;SACb;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KAC9B;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,4BAAW,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE;QAC5F,OAAO,OAAO,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC;KAChC;IAED,MAAM,IAAI,iCAAmB,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC,CAAC;AAhCW,QAAA,MAAM,UAgCjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
}
|