@ocap/util 1.27.16 → 1.28.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/esm/bn.d.ts +8 -6
- package/esm/bn.js +11 -7
- package/esm/constant.d.ts +4 -1
- package/esm/constant.js +5 -1
- package/esm/create-sorted-list.d.ts +4 -1
- package/esm/create-sorted-list.js +8 -3
- package/esm/curve.d.ts +85 -55
- package/esm/curve.js +132 -127
- package/esm/error.d.ts +12 -9
- package/esm/error.js +24 -17
- package/esm/get-list-field.d.ts +4 -1
- package/esm/get-list-field.js +7 -2
- package/esm/get-related-addr.d.ts +4 -1
- package/esm/get-related-addr.js +5 -1
- package/esm/index.d.ts +47 -44
- package/esm/index.js +364 -469
- package/esm/lodash.d.ts +12 -0
- package/esm/md5.d.ts +4 -1
- package/esm/md5.js +7 -3
- package/esm/ready.d.ts +13 -9
- package/esm/ready.js +33 -36
- package/esm/retry.d.ts +16 -9
- package/esm/retry.js +26 -27
- package/esm/tsfixme.d.ts +3 -0
- package/esm/url.d.ts +16 -12
- package/esm/url.js +67 -92
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/bn.d.ts +8 -6
- package/lib/bn.js +12 -12
- package/lib/constant.d.ts +4 -1
- package/lib/constant.js +6 -4
- package/lib/create-sorted-list.d.ts +4 -1
- package/lib/create-sorted-list.js +11 -10
- package/lib/curve.d.ts +84 -55
- package/lib/curve.js +139 -137
- package/lib/error.d.ts +12 -9
- package/lib/error.js +25 -21
- package/lib/get-list-field.d.ts +4 -1
- package/lib/get-list-field.js +9 -9
- package/lib/get-related-addr.d.ts +4 -1
- package/lib/get-related-addr.js +5 -4
- package/lib/index.d.ts +47 -44
- package/lib/index.js +386 -506
- package/lib/lodash.d.ts +12 -0
- package/lib/md5.d.ts +4 -1
- package/lib/md5.js +9 -10
- package/lib/ready.d.ts +13 -9
- package/lib/ready.js +34 -42
- package/lib/retry.d.ts +16 -9
- package/lib/retry.js +27 -30
- package/lib/tsfixme.d.ts +3 -0
- package/lib/url.d.ts +16 -12
- package/lib/url.js +69 -118
- package/package.json +23 -9
package/lib/index.js
CHANGED
|
@@ -1,592 +1,472 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports.toBuffer = toBuffer;
|
|
35
|
-
exports.toBase58 = toBase58;
|
|
36
|
-
exports.fromBase58 = fromBase58;
|
|
37
|
-
exports.toBase64 = toBase64;
|
|
38
|
-
exports.fromBase64 = fromBase64;
|
|
39
|
-
exports.toAddress = toAddress;
|
|
40
|
-
exports.toDid = toDid;
|
|
41
|
-
exports.isSameDid = isSameDid;
|
|
42
|
-
exports.formatTxType = formatTxType;
|
|
43
|
-
const isBoolean_1 = __importDefault(require("lodash/isBoolean"));
|
|
44
|
-
const isString_1 = __importDefault(require("lodash/isString"));
|
|
45
|
-
const isNumber_1 = __importDefault(require("lodash/isNumber"));
|
|
46
|
-
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
47
|
-
const upperFirst_1 = __importDefault(require("lodash/upperFirst"));
|
|
48
|
-
const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
49
|
-
const isNull_1 = __importDefault(require("lodash/isNull"));
|
|
50
|
-
const padEnd_1 = __importDefault(require("lodash/padEnd"));
|
|
51
|
-
exports.rightPad = padEnd_1.default;
|
|
52
|
-
const padStart_1 = __importDefault(require("lodash/padStart"));
|
|
53
|
-
exports.leftPad = padStart_1.default;
|
|
54
|
-
const bs58_1 = __importDefault(require("bs58"));
|
|
55
|
-
const base64_url_1 = __importDefault(require("base64-url"));
|
|
56
|
-
const utf8 = __importStar(require("utf8"));
|
|
57
|
-
const bn_1 = require("./bn");
|
|
58
|
-
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return bn_1.BN; } });
|
|
59
|
-
const DID_PREFIX = 'did:abt:';
|
|
60
|
-
const zero = new bn_1.BN(0);
|
|
61
|
-
const negative1 = new bn_1.BN(-1);
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_bn = require('./bn.js');
|
|
3
|
+
let bn_js = require("bn.js");
|
|
4
|
+
bn_js = require_rolldown_runtime.__toESM(bn_js);
|
|
5
|
+
let lodash_isBoolean = require("lodash/isBoolean");
|
|
6
|
+
lodash_isBoolean = require_rolldown_runtime.__toESM(lodash_isBoolean);
|
|
7
|
+
let lodash_isString = require("lodash/isString");
|
|
8
|
+
lodash_isString = require_rolldown_runtime.__toESM(lodash_isString);
|
|
9
|
+
let lodash_isNumber = require("lodash/isNumber");
|
|
10
|
+
lodash_isNumber = require_rolldown_runtime.__toESM(lodash_isNumber);
|
|
11
|
+
let lodash_isObject = require("lodash/isObject");
|
|
12
|
+
lodash_isObject = require_rolldown_runtime.__toESM(lodash_isObject);
|
|
13
|
+
let lodash_upperFirst = require("lodash/upperFirst");
|
|
14
|
+
lodash_upperFirst = require_rolldown_runtime.__toESM(lodash_upperFirst);
|
|
15
|
+
let lodash_camelCase = require("lodash/camelCase");
|
|
16
|
+
lodash_camelCase = require_rolldown_runtime.__toESM(lodash_camelCase);
|
|
17
|
+
let lodash_isNull = require("lodash/isNull");
|
|
18
|
+
lodash_isNull = require_rolldown_runtime.__toESM(lodash_isNull);
|
|
19
|
+
let lodash_padEnd = require("lodash/padEnd");
|
|
20
|
+
lodash_padEnd = require_rolldown_runtime.__toESM(lodash_padEnd);
|
|
21
|
+
let lodash_padStart = require("lodash/padStart");
|
|
22
|
+
lodash_padStart = require_rolldown_runtime.__toESM(lodash_padStart);
|
|
23
|
+
let bs58 = require("bs58");
|
|
24
|
+
bs58 = require_rolldown_runtime.__toESM(bs58);
|
|
25
|
+
let base64_url = require("base64-url");
|
|
26
|
+
base64_url = require_rolldown_runtime.__toESM(base64_url);
|
|
27
|
+
let utf8 = require("utf8");
|
|
28
|
+
utf8 = require_rolldown_runtime.__toESM(utf8);
|
|
29
|
+
|
|
30
|
+
//#region src/index.ts
|
|
31
|
+
const DID_PREFIX = "did:abt:";
|
|
32
|
+
const zero = new require_bn.BN(0);
|
|
33
|
+
const negative1 = new require_bn.BN(-1);
|
|
62
34
|
const base58btc = {
|
|
63
|
-
|
|
64
|
-
|
|
35
|
+
encode: (v) => `z${bs58.default.encode(v)}`,
|
|
36
|
+
decode: (v) => bs58.default.decode(v.slice(1))
|
|
65
37
|
};
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
38
|
const isBase58btc = (data) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
catch (err) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
39
|
+
if (typeof data !== "string") return false;
|
|
40
|
+
if (data[0] === "z") try {
|
|
41
|
+
base58btc.decode(data);
|
|
42
|
+
return true;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
81
47
|
};
|
|
82
|
-
exports.isBase58btc = isBase58btc;
|
|
83
48
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
49
|
+
* Returns a BN object, converts a number value to a BN
|
|
50
|
+
* @param {string|number|BN} `arg` input a string number, hex string number, number, BigNumber or BN object
|
|
51
|
+
* @return {BN} `output` BN object of the number
|
|
52
|
+
* @throws if the argument is not an array, object that isn't a bignumber, not a string number or number
|
|
53
|
+
*/
|
|
89
54
|
const numberToBN = (arg) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if ((stringArg.match(/^-?[0-9]+$/) || stringArg === '') && isHexPrefixed === false) {
|
|
106
|
-
return new bn_1.BN(stringArg, 10).mul(multiplier);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if ((0, exports.isBN)(arg)) {
|
|
110
|
-
return new bn_1.BN(arg.toString(10), 10);
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`[number-to-bn] while converting number ${JSON.stringify(arg)} to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.`);
|
|
55
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
56
|
+
let multiplier = new require_bn.BN(1);
|
|
57
|
+
const formattedString = String(arg).toLowerCase().trim();
|
|
58
|
+
const isHexPrefixed$1 = formattedString.substr(0, 2) === "0x" || formattedString.substr(0, 3) === "-0x";
|
|
59
|
+
let stringArg = stripHexPrefix(formattedString);
|
|
60
|
+
if (stringArg.substr(0, 1) === "-") {
|
|
61
|
+
stringArg = stripHexPrefix(stringArg.slice(1));
|
|
62
|
+
multiplier = new require_bn.BN(-1, 10);
|
|
63
|
+
}
|
|
64
|
+
stringArg = stringArg === "" ? "0" : stringArg;
|
|
65
|
+
if (!stringArg.match(/^-?[0-9]+$/) && stringArg.match(/^[0-9A-Fa-f]+$/) || stringArg.match(/^[a-fA-F]+$/) || isHexPrefixed$1 === true && stringArg.match(/^[0-9A-Fa-f]+$/)) return new require_bn.BN(stringArg, 16).mul(multiplier);
|
|
66
|
+
if ((stringArg.match(/^-?[0-9]+$/) || stringArg === "") && isHexPrefixed$1 === false) return new require_bn.BN(stringArg, 10).mul(multiplier);
|
|
67
|
+
}
|
|
68
|
+
if (isBN(arg)) return new require_bn.BN(arg.toString(10), 10);
|
|
69
|
+
throw new Error(`[number-to-bn] while converting number ${JSON.stringify(arg)} to BN.js instance, error: invalid number value. Value must be an integer, hex string, BN or BigNumber instance. Note, decimals are not supported.`);
|
|
113
70
|
};
|
|
114
|
-
exports.numberToBN = numberToBN;
|
|
115
71
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
72
|
+
* Returns a `boolean` on whether or not the `string` starts with '0x'
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @static
|
|
76
|
+
* @param {String} str the string input value
|
|
77
|
+
* @return {Boolean} a boolean if it is or is not hex prefixed
|
|
78
|
+
* @throws if the str input is not a string
|
|
79
|
+
*/
|
|
124
80
|
const isHexPrefixed = (str) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
return str.slice(0, 2).toLowerCase() === '0x';
|
|
81
|
+
if (typeof str !== "string") throw new Error("[is-hex-prefixed] value must be type string");
|
|
82
|
+
return str.slice(0, 2).toLowerCase() === "0x";
|
|
129
83
|
};
|
|
130
|
-
exports.isHexPrefixed = isHexPrefixed;
|
|
131
84
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
85
|
+
* Removes '0x' from a given `String` if present
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
* @static
|
|
89
|
+
*/
|
|
137
90
|
const stripHexPrefix = (str) => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
return str;
|
|
91
|
+
if (typeof str === "string") return isHexPrefixed(str) ? str.slice(2) : str;
|
|
92
|
+
return str;
|
|
142
93
|
};
|
|
143
|
-
exports.stripHexPrefix = stripHexPrefix;
|
|
144
94
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const isBN = (object) => object instanceof
|
|
154
|
-
object instanceof bn_1.BaseBN ||
|
|
155
|
-
// constructor validation only work for node cause browser bundle will obfuscated code
|
|
156
|
-
(object && object.constructor && object.constructor.name === 'BN');
|
|
157
|
-
exports.isBN = isBN;
|
|
95
|
+
* Returns true if object is BN, otherwise false
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
* @static
|
|
99
|
+
* @method isBN
|
|
100
|
+
* @param {Object} object
|
|
101
|
+
* @returns {Boolean}
|
|
102
|
+
*/
|
|
103
|
+
const isBN = (object) => object instanceof require_bn.BN || object instanceof bn_js.default || object && object.constructor && object.constructor.name === "BN";
|
|
158
104
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const isBigNumber = (object) => object && object.constructor && object.constructor.name ===
|
|
168
|
-
exports.isBigNumber = isBigNumber;
|
|
105
|
+
* Returns true if object is BigNumber, otherwise false
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
* @static
|
|
109
|
+
* @method isBigNumber
|
|
110
|
+
* @param {Object} object
|
|
111
|
+
* @returns {Boolean}
|
|
112
|
+
*/
|
|
113
|
+
const isBigNumber = (object) => object && object.constructor && object.constructor.name === "BigNumber";
|
|
169
114
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const isHexStrict = (hex) => ((0,
|
|
179
|
-
exports.isHexStrict = isHexStrict;
|
|
115
|
+
* Check if string is HEX, requires a 0x in front
|
|
116
|
+
*
|
|
117
|
+
* @public
|
|
118
|
+
* @static
|
|
119
|
+
* @method isHexStrict
|
|
120
|
+
* @param {String} hex to be checked
|
|
121
|
+
* @returns {Boolean}
|
|
122
|
+
*/
|
|
123
|
+
const isHexStrict = (hex) => ((0, lodash_isString.default)(hex) || (0, lodash_isNumber.default)(hex)) && /^(-)?0x[0-9a-f]*$/i.test(hex);
|
|
180
124
|
/**
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const isHex = (hex) => ((0,
|
|
190
|
-
exports.isHex = isHex;
|
|
125
|
+
* Check if string is HEX
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @static
|
|
129
|
+
* @method isHex
|
|
130
|
+
* @param {String} hex to be checked
|
|
131
|
+
* @returns {Boolean}
|
|
132
|
+
*/
|
|
133
|
+
const isHex = (hex) => ((0, lodash_isString.default)(hex) || (0, lodash_isNumber.default)(hex)) && /^(-0x|0x|0X|-0X)?[0-9a-f]*$/i.test(hex);
|
|
191
134
|
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
135
|
+
* Takes an input and transforms it into an BN
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
* @static
|
|
139
|
+
* @method toBN
|
|
140
|
+
* @param {Number|String|BN} num, string, HEX string or BN
|
|
141
|
+
* @returns {BN} BN
|
|
142
|
+
*/
|
|
200
143
|
const toBN = (num, base = 10) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
throw new Error(`${error} Given value: "${num}"`);
|
|
210
|
-
}
|
|
144
|
+
try {
|
|
145
|
+
if (typeof num === "number" && num > 0) return new require_bn.BN(Number(num).toLocaleString("fullwide", { useGrouping: false }), base);
|
|
146
|
+
return numberToBN(num);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error(`${error} Given value: "${num}"`);
|
|
149
|
+
}
|
|
211
150
|
};
|
|
212
|
-
exports.toBN = toBN;
|
|
213
151
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
152
|
+
* Should be called to get hex representation (prefixed by 0x) of utf8 string
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
* @static
|
|
156
|
+
* @method utf8ToHex
|
|
157
|
+
* @param {String} str
|
|
158
|
+
* @returns {String} hex representation of input string
|
|
159
|
+
*/
|
|
222
160
|
const utf8ToHex = (str) => {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const n = code.toString(16);
|
|
235
|
-
hex += n.length < 2 ? `0${n}` : n;
|
|
236
|
-
}
|
|
237
|
-
return `0x${hex}`;
|
|
161
|
+
str = utf8.encode(str);
|
|
162
|
+
let hex = "";
|
|
163
|
+
str = str.replace(/^(?:\u0000)*/, "");
|
|
164
|
+
str = str.split("").reverse().join("");
|
|
165
|
+
str = str.replace(/^(?:\u0000)*/, "");
|
|
166
|
+
str = str.split("").reverse().join("");
|
|
167
|
+
for (let i = 0; i < str.length; i++) {
|
|
168
|
+
const n = str.charCodeAt(i).toString(16);
|
|
169
|
+
hex += n.length < 2 ? `0${n}` : n;
|
|
170
|
+
}
|
|
171
|
+
return `0x${hex}`;
|
|
238
172
|
};
|
|
239
|
-
exports.utf8ToHex = utf8ToHex;
|
|
240
173
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
174
|
+
* Should be called to get utf8 from it's hex representation
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
* @static
|
|
178
|
+
* @method hexToUtf8
|
|
179
|
+
* @param {String} hex
|
|
180
|
+
* @returns {String} ascii string representation of hex value
|
|
181
|
+
*/
|
|
249
182
|
const hexToUtf8 = (hex) => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
str += String.fromCharCode(code);
|
|
265
|
-
// }
|
|
266
|
-
}
|
|
267
|
-
return utf8.decode(str);
|
|
183
|
+
if (!isHexStrict(hex)) throw new Error(`The parameter "${hex}" must be a valid HEX string.`);
|
|
184
|
+
let str = "";
|
|
185
|
+
let code = 0;
|
|
186
|
+
hex = hex.replace(/^0x/i, "");
|
|
187
|
+
hex = hex.replace(/^(?:00)*/, "");
|
|
188
|
+
hex = hex.split("").reverse().join("");
|
|
189
|
+
hex = hex.replace(/^(?:00)*/, "");
|
|
190
|
+
hex = hex.split("").reverse().join("");
|
|
191
|
+
const l = hex.length;
|
|
192
|
+
for (let i = 0; i < l; i += 2) {
|
|
193
|
+
code = parseInt(hex.substr(i, 2), 16);
|
|
194
|
+
str += String.fromCharCode(code);
|
|
195
|
+
}
|
|
196
|
+
return utf8.decode(str);
|
|
268
197
|
};
|
|
269
|
-
exports.hexToUtf8 = hexToUtf8;
|
|
270
198
|
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
199
|
+
* Converts value to number representation
|
|
200
|
+
*
|
|
201
|
+
* @public
|
|
202
|
+
* @static
|
|
203
|
+
* @method hexToNumber
|
|
204
|
+
* @param {String|Number|BN} value
|
|
205
|
+
* @returns {Number}
|
|
206
|
+
*/
|
|
279
207
|
const hexToNumber = (value) => {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
return (0, exports.toBN)(value).toNumber();
|
|
208
|
+
if (!value) return 0;
|
|
209
|
+
return toBN(value).toNumber();
|
|
284
210
|
};
|
|
285
|
-
exports.hexToNumber = hexToNumber;
|
|
286
211
|
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
212
|
+
* Converts value to hex representation
|
|
213
|
+
*
|
|
214
|
+
* @public
|
|
215
|
+
* @static
|
|
216
|
+
* @method numberToHex
|
|
217
|
+
* @param {String|Number|BN} value
|
|
218
|
+
* @returns {String}
|
|
219
|
+
*/
|
|
295
220
|
const numberToHex = (value) => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
throw new Error(`Given input "${value}" is not a number.`);
|
|
302
|
-
}
|
|
303
|
-
const num = (0, exports.toBN)(value);
|
|
304
|
-
const result = num.toString(16);
|
|
305
|
-
return num.lt(new bn_1.BN(0)) ? `-0x${result.substr(1)}` : `0x${result}`;
|
|
221
|
+
if ((0, lodash_isNull.default)(value) || typeof value === "undefined") return value;
|
|
222
|
+
if (!isFinite(value) && !isHex(value)) throw new Error(`Given input "${value}" is not a number.`);
|
|
223
|
+
const num = toBN(value);
|
|
224
|
+
const result = num.toString(16);
|
|
225
|
+
return num.lt(new require_bn.BN(0)) ? `-0x${result.substr(1)}` : `0x${result}`;
|
|
306
226
|
};
|
|
307
|
-
exports.numberToHex = numberToHex;
|
|
308
227
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
228
|
+
* Convert a byte array to a hex string
|
|
229
|
+
* Note: Implementation from crypto-js
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
* @static
|
|
233
|
+
* @method bytesToHex
|
|
234
|
+
* @param {Array} bytes
|
|
235
|
+
* @returns {String} the hex string
|
|
236
|
+
*/
|
|
318
237
|
const bytesToHex = (bytes) => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
238
|
+
const hex = [];
|
|
239
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
240
|
+
hex.push((bytes[i] >>> 4).toString(16));
|
|
241
|
+
hex.push((bytes[i] & 15).toString(16));
|
|
242
|
+
}
|
|
243
|
+
return `0x${hex.join("")}`;
|
|
325
244
|
};
|
|
326
|
-
exports.bytesToHex = bytesToHex;
|
|
327
245
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
246
|
+
* Convert a hex string to a byte array
|
|
247
|
+
* Note: Implementation from crypto-js
|
|
248
|
+
*
|
|
249
|
+
* @public
|
|
250
|
+
* @static
|
|
251
|
+
* @method hexToBytes
|
|
252
|
+
* @param {String} hex
|
|
253
|
+
* @returns {Array} the byte array
|
|
254
|
+
*/
|
|
337
255
|
const hexToBytes = (hex) => {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (let c = 0; c < hex.length; c += 2) {
|
|
346
|
-
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
347
|
-
}
|
|
348
|
-
return bytes;
|
|
256
|
+
hex = hex.toString(16);
|
|
257
|
+
if (!isHex(hex)) throw new Error(`Given value "${hex}" is not a valid hex string.`);
|
|
258
|
+
hex = hex.replace(/^0x/i, "");
|
|
259
|
+
hex = hex.length % 2 ? `0${hex}` : hex;
|
|
260
|
+
const bytes = [];
|
|
261
|
+
for (let c = 0; c < hex.length; c += 2) bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
262
|
+
return bytes;
|
|
349
263
|
};
|
|
350
|
-
exports.hexToBytes = hexToBytes;
|
|
351
264
|
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
265
|
+
* Auto converts any given value into it's hex representation.
|
|
266
|
+
* And even stringify objects before.
|
|
267
|
+
*
|
|
268
|
+
* @public
|
|
269
|
+
* @static
|
|
270
|
+
* @method toHex
|
|
271
|
+
* @param {String|Number|BN|Object|TypedArray|Buffer} value
|
|
272
|
+
* @param {Boolean} returnType
|
|
273
|
+
* @returns {String}
|
|
274
|
+
*/
|
|
362
275
|
const toHex = (value, returnType = false) => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if ((0, isObject_1.default)(value) && !(0, exports.isBigNumber)(value) && !(0, exports.isBN)(value)) {
|
|
374
|
-
return returnType ? 'string' : (0, exports.utf8ToHex)(JSON.stringify(value));
|
|
375
|
-
}
|
|
376
|
-
// if its a negative number, pass it through numberToHex
|
|
377
|
-
if (typeof value === 'string') {
|
|
378
|
-
if (value.indexOf('-0x') === 0 || value.indexOf('-0X') === 0) {
|
|
379
|
-
return returnType ? 'int256' : (0, exports.numberToHex)(value);
|
|
380
|
-
}
|
|
381
|
-
if (value.indexOf('0x') === 0 || value.indexOf('0X') === 0) {
|
|
382
|
-
return returnType ? 'bytes' : value;
|
|
383
|
-
}
|
|
384
|
-
// TODO: some edge case may be not properly handled here
|
|
385
|
-
return returnType ? 'string' : (0, exports.utf8ToHex)(value);
|
|
386
|
-
}
|
|
387
|
-
// eslint-disable-next-line no-nested-ternary
|
|
388
|
-
return returnType ? (+value < 0 ? 'int256' : 'uint256') : (0, exports.numberToHex)(value);
|
|
276
|
+
if (isUint8Array(value) || Buffer.isBuffer(value)) return returnType ? "bytes" : bytesToHex(value);
|
|
277
|
+
if (isBase58btc(value)) return returnType ? "bytes" : bytesToHex(base58btc.decode(value));
|
|
278
|
+
if ((0, lodash_isBoolean.default)(value)) return returnType ? "bool" : value ? "0x01" : "0x00";
|
|
279
|
+
if ((0, lodash_isObject.default)(value) && !isBigNumber(value) && !isBN(value)) return returnType ? "string" : utf8ToHex(JSON.stringify(value));
|
|
280
|
+
if (typeof value === "string") {
|
|
281
|
+
if (value.indexOf("-0x") === 0 || value.indexOf("-0X") === 0) return returnType ? "int256" : numberToHex(value);
|
|
282
|
+
if (value.indexOf("0x") === 0 || value.indexOf("0X") === 0) return returnType ? "bytes" : value;
|
|
283
|
+
return returnType ? "string" : utf8ToHex(value);
|
|
284
|
+
}
|
|
285
|
+
return returnType ? +value < 0 ? "int256" : "uint256" : numberToHex(value);
|
|
389
286
|
};
|
|
390
|
-
exports.toHex = toHex;
|
|
391
287
|
const numberToString = (arg) => {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (arg.toPrecision) {
|
|
406
|
-
return String(arg.toPrecision());
|
|
407
|
-
}
|
|
408
|
-
return arg.toString(10);
|
|
409
|
-
}
|
|
410
|
-
throw new Error(`while converting number to string, invalid number value '${arg}' type ${typeof arg}.`);
|
|
288
|
+
if (typeof arg === "string") {
|
|
289
|
+
if (!arg.match(/^-?[0-9.]+$/)) throw new Error(`Invalid value '${arg}' while converting to string, should be a number matching (^-?[0-9.]+).`);
|
|
290
|
+
return arg;
|
|
291
|
+
}
|
|
292
|
+
if (typeof arg === "number") {
|
|
293
|
+
if (Number.isInteger(arg) && arg > 0) return Number(arg).toLocaleString("fullwide", { useGrouping: false });
|
|
294
|
+
return String(arg);
|
|
295
|
+
}
|
|
296
|
+
if (typeof arg === "object" && arg.toString && (arg.toTwos || arg.dividedToIntegerBy)) {
|
|
297
|
+
if (arg.toPrecision) return String(arg.toPrecision());
|
|
298
|
+
return arg.toString(10);
|
|
299
|
+
}
|
|
300
|
+
throw new Error(`while converting number to string, invalid number value '${arg}' type ${typeof arg}.`);
|
|
411
301
|
};
|
|
412
|
-
exports.numberToString = numberToString;
|
|
413
302
|
/**
|
|
414
|
-
|
|
415
|
-
|
|
303
|
+
* Format a big number to human readable number, such as 1_0000_0000_0000_000 => 1 Token
|
|
304
|
+
*/
|
|
416
305
|
const fromUnitToToken = (input, decimal = 18, optionsInput = {}) => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
|
|
432
|
-
}
|
|
433
|
-
let whole = unit.div(base).toString(10);
|
|
434
|
-
if (options.commify) {
|
|
435
|
-
whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
436
|
-
}
|
|
437
|
-
let value = `${whole}${fraction === '0' ? '' : `.${fraction}`}`;
|
|
438
|
-
if (negative) {
|
|
439
|
-
value = `-${value}`;
|
|
440
|
-
}
|
|
441
|
-
return value;
|
|
306
|
+
let unit = toBN(input);
|
|
307
|
+
const negative = unit.lt(zero);
|
|
308
|
+
const base = toBN(`1${"0".repeat(decimal)}`, 10);
|
|
309
|
+
const baseLength = base.toString(10).length - 1 || 1;
|
|
310
|
+
const options = optionsInput || {};
|
|
311
|
+
if (negative) unit = unit.mul(negative1);
|
|
312
|
+
let fraction = unit.mod(base).toString(10);
|
|
313
|
+
while (fraction.length < baseLength) fraction = `0${fraction}`;
|
|
314
|
+
if (!options.pad) fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1];
|
|
315
|
+
let whole = unit.div(base).toString(10);
|
|
316
|
+
if (options.commify) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
317
|
+
let value = `${whole}${fraction === "0" ? "" : `.${fraction}`}`;
|
|
318
|
+
if (negative) value = `-${value}`;
|
|
319
|
+
return value;
|
|
442
320
|
};
|
|
443
|
-
exports.fromUnitToToken = fromUnitToToken;
|
|
444
321
|
/**
|
|
445
|
-
|
|
446
|
-
|
|
322
|
+
* Convert human readable token number to big number instance
|
|
323
|
+
*/
|
|
447
324
|
const fromTokenToUnit = (input, decimal = 18) => {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
whole = '0';
|
|
468
|
-
}
|
|
469
|
-
if (!fraction) {
|
|
470
|
-
fraction = '0';
|
|
471
|
-
}
|
|
472
|
-
if (fraction.length > baseLength) {
|
|
473
|
-
throw new Error(`error converting token ${input} to unit, too many decimal places`);
|
|
474
|
-
}
|
|
475
|
-
while (fraction.length < baseLength) {
|
|
476
|
-
fraction += '0';
|
|
477
|
-
}
|
|
478
|
-
whole = new bn_1.BN(whole);
|
|
479
|
-
fraction = new bn_1.BN(fraction);
|
|
480
|
-
let unit = whole.mul(base).add(fraction);
|
|
481
|
-
if (negative) {
|
|
482
|
-
unit = unit.mul(negative1);
|
|
483
|
-
}
|
|
484
|
-
return new bn_1.BN(unit.toString(10), 10);
|
|
325
|
+
let token = numberToString(input);
|
|
326
|
+
const base = toBN(`1${"0".repeat(decimal)}`, 10);
|
|
327
|
+
const baseLength = base.toString(10).length - 1 || 1;
|
|
328
|
+
const negative = token.substring(0, 1) === "-";
|
|
329
|
+
if (negative) token = token.substring(1);
|
|
330
|
+
if (token === ".") throw new Error(`error converting token ${input} to unit, invalid value`);
|
|
331
|
+
const comps = token.split(".");
|
|
332
|
+
if (comps.length > 2) throw new Error(`error converting token ${input} to unit, too many decimal points`);
|
|
333
|
+
let whole = comps[0];
|
|
334
|
+
let fraction = comps[1];
|
|
335
|
+
if (!whole) whole = "0";
|
|
336
|
+
if (!fraction) fraction = "0";
|
|
337
|
+
if (fraction.length > baseLength) throw new Error(`error converting token ${input} to unit, too many decimal places`);
|
|
338
|
+
while (fraction.length < baseLength) fraction += "0";
|
|
339
|
+
whole = new require_bn.BN(whole);
|
|
340
|
+
fraction = new require_bn.BN(fraction);
|
|
341
|
+
let unit = whole.mul(base).add(fraction);
|
|
342
|
+
if (negative) unit = unit.mul(negative1);
|
|
343
|
+
return new require_bn.BN(unit.toString(10), 10);
|
|
485
344
|
};
|
|
486
|
-
exports.fromTokenToUnit = fromTokenToUnit;
|
|
487
345
|
/**
|
|
488
|
-
|
|
489
|
-
|
|
346
|
+
* Validates if a value is an Uint8Array.
|
|
347
|
+
*/
|
|
490
348
|
function isUint8Array(value) {
|
|
491
|
-
|
|
349
|
+
return Object.prototype.toString.call(value) === "[object Uint8Array]";
|
|
492
350
|
}
|
|
493
351
|
/**
|
|
494
|
-
|
|
495
|
-
|
|
352
|
+
* Generate a random UUID
|
|
353
|
+
*/
|
|
496
354
|
function UUID() {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
});
|
|
355
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
356
|
+
const r = Math.random() * 16 | 0;
|
|
357
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
358
|
+
});
|
|
502
359
|
}
|
|
503
360
|
/**
|
|
504
|
-
|
|
505
|
-
|
|
361
|
+
* Check if a string is valid UUID
|
|
362
|
+
*/
|
|
506
363
|
function isUUID(str) {
|
|
507
|
-
|
|
364
|
+
return /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/.test(str);
|
|
508
365
|
}
|
|
509
366
|
/**
|
|
510
|
-
|
|
511
|
-
|
|
367
|
+
* Convert input to Uint8Array on best effort, base64 node supported
|
|
368
|
+
*/
|
|
512
369
|
function toUint8Array(v) {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
else if ((0, exports.isBase58btc)(v)) {
|
|
527
|
-
vb = new Uint8Array(base58btc.decode(v));
|
|
528
|
-
}
|
|
529
|
-
else if (typeof v === 'string') {
|
|
530
|
-
vb = new Uint8Array((0, exports.hexToBytes)((0, exports.toHex)(v)));
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
throw new Error(`Unsupported input type ${typeof v} detected for toBuffer, only Uint8Array/Buffer/Hex/Base58 are supported`);
|
|
534
|
-
}
|
|
535
|
-
return vb;
|
|
370
|
+
let vb = null;
|
|
371
|
+
if ([
|
|
372
|
+
null,
|
|
373
|
+
void 0,
|
|
374
|
+
""
|
|
375
|
+
].includes(v)) vb = new Uint8Array();
|
|
376
|
+
else if (Buffer.isBuffer(v)) vb = new Uint8Array(v);
|
|
377
|
+
else if (isHexStrict(v)) vb = new Uint8Array(hexToBytes(v));
|
|
378
|
+
else if (isUint8Array(v)) vb = new Uint8Array(v);
|
|
379
|
+
else if (isBase58btc(v)) vb = new Uint8Array(base58btc.decode(v));
|
|
380
|
+
else if (typeof v === "string") vb = new Uint8Array(hexToBytes(toHex(v)));
|
|
381
|
+
else throw new Error(`Unsupported input type ${typeof v} detected for toBuffer, only Uint8Array/Buffer/Hex/Base58 are supported`);
|
|
382
|
+
return vb;
|
|
536
383
|
}
|
|
537
384
|
/**
|
|
538
|
-
|
|
539
|
-
|
|
385
|
+
* Convert input to Buffer on best effort, base64 not supported
|
|
386
|
+
*/
|
|
540
387
|
function toBuffer(v) {
|
|
541
|
-
|
|
388
|
+
return Buffer.from(toUint8Array(v));
|
|
542
389
|
}
|
|
543
390
|
/**
|
|
544
|
-
|
|
545
|
-
|
|
391
|
+
* Convert input to base58btc format on best effort
|
|
392
|
+
*/
|
|
546
393
|
function toBase58(v) {
|
|
547
|
-
|
|
548
|
-
|
|
394
|
+
const buf = base58btc.encode(toUint8Array(v));
|
|
395
|
+
return Buffer.from(buf).toString("utf-8");
|
|
549
396
|
}
|
|
550
397
|
/**
|
|
551
|
-
|
|
552
|
-
|
|
398
|
+
* Decode base58 string
|
|
399
|
+
*/
|
|
553
400
|
function fromBase58(v) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
return Buffer.from(base58btc.decode(v));
|
|
401
|
+
if (isBase58btc(v) === false) throw new Error("fromBase58 expect strict base58 encoded string as input");
|
|
402
|
+
return Buffer.from(base58btc.decode(v));
|
|
558
403
|
}
|
|
559
404
|
/**
|
|
560
|
-
|
|
561
|
-
|
|
405
|
+
* Convert input to base64 format
|
|
406
|
+
*/
|
|
562
407
|
function toBase64(v, escape = true) {
|
|
563
|
-
|
|
564
|
-
|
|
408
|
+
const encoded = base64_url.default.encode(toBuffer(v));
|
|
409
|
+
return escape ? base64_url.default.escape(encoded) : encoded;
|
|
565
410
|
}
|
|
566
411
|
/**
|
|
567
|
-
|
|
568
|
-
|
|
412
|
+
* Decode base64(base64_url) string to buffer
|
|
413
|
+
*/
|
|
569
414
|
function fromBase64(v) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
return Buffer.from(base64_url_1.default.unescape(v), 'base64');
|
|
415
|
+
if (typeof v !== "string") throw new Error("fromBase64 requires input to be a string");
|
|
416
|
+
return Buffer.from(base64_url.default.unescape(v), "base64");
|
|
574
417
|
}
|
|
575
418
|
/**
|
|
576
|
-
|
|
577
|
-
|
|
419
|
+
* Convert did to address: remove `did:abt:` prefix
|
|
420
|
+
*/
|
|
578
421
|
function toAddress(did) {
|
|
579
|
-
|
|
422
|
+
return did.replace(DID_PREFIX, "");
|
|
580
423
|
}
|
|
581
424
|
/**
|
|
582
|
-
|
|
583
|
-
|
|
425
|
+
* Convert address to did: prepend `did:abt:` prefix
|
|
426
|
+
*/
|
|
584
427
|
function toDid(address) {
|
|
585
|
-
|
|
428
|
+
return `${DID_PREFIX}${toAddress(address)}`;
|
|
586
429
|
}
|
|
587
430
|
function isSameDid(a, b) {
|
|
588
|
-
|
|
431
|
+
return toAddress(a).toLowerCase() === toAddress(b).toLowerCase();
|
|
589
432
|
}
|
|
590
433
|
function formatTxType(type) {
|
|
591
|
-
|
|
434
|
+
return (0, lodash_upperFirst.default)((0, lodash_camelCase.default)(type));
|
|
592
435
|
}
|
|
436
|
+
|
|
437
|
+
//#endregion
|
|
438
|
+
exports.BN = require_bn.BN;
|
|
439
|
+
exports.UUID = UUID;
|
|
440
|
+
exports.bytesToHex = bytesToHex;
|
|
441
|
+
exports.formatTxType = formatTxType;
|
|
442
|
+
exports.fromBase58 = fromBase58;
|
|
443
|
+
exports.fromBase64 = fromBase64;
|
|
444
|
+
exports.fromTokenToUnit = fromTokenToUnit;
|
|
445
|
+
exports.fromUnitToToken = fromUnitToToken;
|
|
446
|
+
exports.hexToBytes = hexToBytes;
|
|
447
|
+
exports.hexToNumber = hexToNumber;
|
|
448
|
+
exports.hexToUtf8 = hexToUtf8;
|
|
449
|
+
exports.isBN = isBN;
|
|
450
|
+
exports.isBase58btc = isBase58btc;
|
|
451
|
+
exports.isBigNumber = isBigNumber;
|
|
452
|
+
exports.isHex = isHex;
|
|
453
|
+
exports.isHexPrefixed = isHexPrefixed;
|
|
454
|
+
exports.isHexStrict = isHexStrict;
|
|
455
|
+
exports.isSameDid = isSameDid;
|
|
456
|
+
exports.isUUID = isUUID;
|
|
457
|
+
exports.isUint8Array = isUint8Array;
|
|
458
|
+
exports.leftPad = lodash_padStart.default;
|
|
459
|
+
exports.numberToBN = numberToBN;
|
|
460
|
+
exports.numberToHex = numberToHex;
|
|
461
|
+
exports.numberToString = numberToString;
|
|
462
|
+
exports.rightPad = lodash_padEnd.default;
|
|
463
|
+
exports.stripHexPrefix = stripHexPrefix;
|
|
464
|
+
exports.toAddress = toAddress;
|
|
465
|
+
exports.toBN = toBN;
|
|
466
|
+
exports.toBase58 = toBase58;
|
|
467
|
+
exports.toBase64 = toBase64;
|
|
468
|
+
exports.toBuffer = toBuffer;
|
|
469
|
+
exports.toDid = toDid;
|
|
470
|
+
exports.toHex = toHex;
|
|
471
|
+
exports.toUint8Array = toUint8Array;
|
|
472
|
+
exports.utf8ToHex = utf8ToHex;
|