@chainflip/utils 0.7.1 → 0.7.2-assethub.1
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/dist/assertion.js +2 -2
- package/dist/async.cjs +1 -1
- package/dist/async.d.cts +1 -1
- package/dist/async.d.ts +1 -1
- package/dist/async.js +1 -1
- package/dist/base58.cjs +9 -21
- package/dist/base58.d.cts +2 -6
- package/dist/base58.d.ts +2 -6
- package/dist/base58.js +4 -6
- package/dist/bytes.cjs +3 -15
- package/dist/bytes.d.cts +3 -6
- package/dist/bytes.d.ts +3 -6
- package/dist/bytes.js +5 -7
- package/dist/{chunk-W23CNAUU.js → chunk-4RHM5374.js} +3 -14
- package/dist/{chunk-HBIFE4XN.js → chunk-CZNX6EUV.js} +1 -7
- package/dist/{chunk-ZHIKNZLU.js → chunk-MYP3UYWE.js} +1 -1
- package/dist/chunk-O4WBUIAN.js +14 -0
- package/dist/guard.cjs +0 -9
- package/dist/guard.d.cts +8 -11
- package/dist/guard.d.ts +8 -11
- package/dist/guard.js +1 -7
- package/dist/number.cjs +0 -59
- package/dist/number.d.cts +1 -7
- package/dist/number.d.ts +1 -7
- package/dist/number.js +0 -34
- package/dist/ss58.cjs +66 -143
- package/dist/ss58.d.cts +3 -5
- package/dist/ss58.d.ts +3 -5
- package/dist/ss58.js +37 -109
- package/dist/string.cjs +0 -21
- package/dist/string.d.cts +2 -8
- package/dist/string.d.ts +2 -8
- package/dist/string.js +0 -18
- package/dist/types.d.cts +1 -36
- package/dist/types.d.ts +1 -36
- package/package.json +15 -15
- package/dist/chainflip.cjs +0 -192
- package/dist/chainflip.d.cts +0 -122
- package/dist/chainflip.d.ts +0 -122
- package/dist/chainflip.js +0 -30
- package/dist/chunk-HOUVS5DD.js +0 -15
- package/dist/chunk-YOAHWTE7.js +0 -156
- package/dist/consts.cjs +0 -209
- package/dist/consts.d.cts +0 -29
- package/dist/consts.d.ts +0 -29
- package/dist/consts.js +0 -175
- package/dist/date.cjs +0 -137
- package/dist/date.d.cts +0 -26
- package/dist/date.d.ts +0 -26
- package/dist/date.js +0 -101
- package/dist/math.cjs +0 -33
- package/dist/math.d.cts +0 -4
- package/dist/math.d.ts +0 -4
- package/dist/math.js +0 -7
- package/dist/tickMath.cjs +0 -165
- package/dist/tickMath.d.cts +0 -15
- package/dist/tickMath.d.ts +0 -15
- package/dist/tickMath.js +0 -33
- package/dist/url.cjs +0 -39
- package/dist/url.d.cts +0 -6
- package/dist/url.d.ts +0 -6
- package/dist/url.js +0 -14
package/dist/ss58.cjs
CHANGED
|
@@ -21,47 +21,59 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var ss58_exports = {};
|
|
22
22
|
__export(ss58_exports, {
|
|
23
23
|
decode: () => decode2,
|
|
24
|
-
encode: () => encode2
|
|
25
|
-
toPublicKey: () => toPublicKey
|
|
24
|
+
encode: () => encode2
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(ss58_exports);
|
|
28
27
|
|
|
29
|
-
//
|
|
30
|
-
|
|
28
|
+
// src/guard.ts
|
|
29
|
+
var createIsGuard = (type) => (value) => typeof value === type;
|
|
30
|
+
var isString = createIsGuard("string");
|
|
31
|
+
var isNumber = createIsGuard("number");
|
|
32
|
+
var isBigInt = createIsGuard("bigint");
|
|
33
|
+
var isBoolean = createIsGuard("boolean");
|
|
34
|
+
var isSymbol = createIsGuard("symbol");
|
|
35
|
+
var isObject = createIsGuard("object");
|
|
36
|
+
var isUndefined = createIsGuard("undefined");
|
|
37
|
+
|
|
38
|
+
// src/assertion.ts
|
|
39
|
+
function assert(condition, message = "assertion failed", Constructor = Error) {
|
|
40
|
+
if (!condition) {
|
|
41
|
+
throw new Constructor(message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_assert.js
|
|
46
|
+
function number(n) {
|
|
31
47
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
32
|
-
throw new Error(
|
|
48
|
+
throw new Error(`positive integer expected, not ${n}`);
|
|
33
49
|
}
|
|
34
50
|
function isBytes(a) {
|
|
35
|
-
return a instanceof Uint8Array ||
|
|
51
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
36
52
|
}
|
|
37
|
-
function
|
|
53
|
+
function bytes(b, ...lengths) {
|
|
38
54
|
if (!isBytes(b))
|
|
39
55
|
throw new Error("Uint8Array expected");
|
|
40
56
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
41
|
-
throw new Error(
|
|
57
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
42
58
|
}
|
|
43
|
-
function
|
|
59
|
+
function exists(instance, checkFinished = true) {
|
|
44
60
|
if (instance.destroyed)
|
|
45
61
|
throw new Error("Hash instance has been destroyed");
|
|
46
62
|
if (checkFinished && instance.finished)
|
|
47
63
|
throw new Error("Hash#digest() has already been called");
|
|
48
64
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
65
|
+
function output(out, instance) {
|
|
66
|
+
bytes(out);
|
|
51
67
|
const min = instance.outputLen;
|
|
52
68
|
if (out.length < min) {
|
|
53
|
-
throw new Error(
|
|
69
|
+
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
54
70
|
}
|
|
55
71
|
}
|
|
56
72
|
|
|
57
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
62
|
-
function byteSwap(word) {
|
|
63
|
-
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
64
|
-
}
|
|
73
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/utils.js
|
|
74
|
+
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
75
|
+
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
76
|
+
var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
65
77
|
var byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
66
78
|
function byteSwap32(arr) {
|
|
67
79
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -70,13 +82,13 @@ function byteSwap32(arr) {
|
|
|
70
82
|
}
|
|
71
83
|
function utf8ToBytes(str) {
|
|
72
84
|
if (typeof str !== "string")
|
|
73
|
-
throw new Error(
|
|
85
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
74
86
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
75
87
|
}
|
|
76
88
|
function toBytes(data) {
|
|
77
89
|
if (typeof data === "string")
|
|
78
90
|
data = utf8ToBytes(data);
|
|
79
|
-
|
|
91
|
+
bytes(data);
|
|
80
92
|
return data;
|
|
81
93
|
}
|
|
82
94
|
var Hash = class {
|
|
@@ -85,6 +97,7 @@ var Hash = class {
|
|
|
85
97
|
return this._cloneInto();
|
|
86
98
|
}
|
|
87
99
|
};
|
|
100
|
+
var toStr = {}.toString;
|
|
88
101
|
function wrapConstructorWithOpts(hashCons) {
|
|
89
102
|
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
90
103
|
const tmp = hashCons({});
|
|
@@ -94,7 +107,7 @@ function wrapConstructorWithOpts(hashCons) {
|
|
|
94
107
|
return hashC;
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
110
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_blake.js
|
|
98
111
|
var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
99
112
|
0,
|
|
100
113
|
1,
|
|
@@ -287,72 +300,7 @@ var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
|
287
300
|
11,
|
|
288
301
|
7,
|
|
289
302
|
5,
|
|
290
|
-
3
|
|
291
|
-
// Blake1, unused in others
|
|
292
|
-
11,
|
|
293
|
-
8,
|
|
294
|
-
12,
|
|
295
|
-
0,
|
|
296
|
-
5,
|
|
297
|
-
2,
|
|
298
|
-
15,
|
|
299
|
-
13,
|
|
300
|
-
10,
|
|
301
|
-
14,
|
|
302
|
-
3,
|
|
303
|
-
6,
|
|
304
|
-
7,
|
|
305
|
-
1,
|
|
306
|
-
9,
|
|
307
|
-
4,
|
|
308
|
-
7,
|
|
309
|
-
9,
|
|
310
|
-
3,
|
|
311
|
-
1,
|
|
312
|
-
13,
|
|
313
|
-
12,
|
|
314
|
-
11,
|
|
315
|
-
14,
|
|
316
|
-
2,
|
|
317
|
-
6,
|
|
318
|
-
5,
|
|
319
|
-
10,
|
|
320
|
-
4,
|
|
321
|
-
0,
|
|
322
|
-
15,
|
|
323
|
-
8,
|
|
324
|
-
9,
|
|
325
|
-
0,
|
|
326
|
-
5,
|
|
327
|
-
7,
|
|
328
|
-
2,
|
|
329
|
-
4,
|
|
330
|
-
10,
|
|
331
|
-
15,
|
|
332
|
-
14,
|
|
333
|
-
1,
|
|
334
|
-
11,
|
|
335
|
-
12,
|
|
336
|
-
6,
|
|
337
|
-
8,
|
|
338
|
-
3,
|
|
339
|
-
13,
|
|
340
|
-
2,
|
|
341
|
-
12,
|
|
342
|
-
6,
|
|
343
|
-
10,
|
|
344
|
-
0,
|
|
345
|
-
11,
|
|
346
|
-
8,
|
|
347
|
-
3,
|
|
348
|
-
4,
|
|
349
|
-
13,
|
|
350
|
-
7,
|
|
351
|
-
5,
|
|
352
|
-
15,
|
|
353
|
-
14,
|
|
354
|
-
1,
|
|
355
|
-
9
|
|
303
|
+
3
|
|
356
304
|
]);
|
|
357
305
|
var BLAKE = class extends Hash {
|
|
358
306
|
constructor(blockLen, outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
@@ -363,22 +311,21 @@ var BLAKE = class extends Hash {
|
|
|
363
311
|
this.pos = 0;
|
|
364
312
|
this.finished = false;
|
|
365
313
|
this.destroyed = false;
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
314
|
+
number(blockLen);
|
|
315
|
+
number(outputLen);
|
|
316
|
+
number(keyLen);
|
|
369
317
|
if (outputLen < 0 || outputLen > keyLen)
|
|
370
318
|
throw new Error("outputLen bigger than keyLen");
|
|
371
319
|
if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
|
|
372
|
-
throw new Error(
|
|
320
|
+
throw new Error(`key must be up 1..${keyLen} byte long or undefined`);
|
|
373
321
|
if (opts.salt !== void 0 && opts.salt.length !== saltLen)
|
|
374
|
-
throw new Error(
|
|
322
|
+
throw new Error(`salt must be ${saltLen} byte long or undefined`);
|
|
375
323
|
if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
|
|
376
|
-
throw new Error(
|
|
377
|
-
this.buffer = new Uint8Array(blockLen);
|
|
378
|
-
this.buffer32 = u32(this.buffer);
|
|
324
|
+
throw new Error(`personalization must be ${persLen} byte long or undefined`);
|
|
325
|
+
this.buffer32 = u32(this.buffer = new Uint8Array(blockLen));
|
|
379
326
|
}
|
|
380
327
|
update(data) {
|
|
381
|
-
|
|
328
|
+
exists(this);
|
|
382
329
|
const { blockLen, buffer, buffer32 } = this;
|
|
383
330
|
data = toBytes(data);
|
|
384
331
|
const len = data.length;
|
|
@@ -415,8 +362,8 @@ var BLAKE = class extends Hash {
|
|
|
415
362
|
return this;
|
|
416
363
|
}
|
|
417
364
|
digestInto(out) {
|
|
418
|
-
|
|
419
|
-
|
|
365
|
+
exists(this);
|
|
366
|
+
output(out, this);
|
|
420
367
|
const { pos, buffer32 } = this;
|
|
421
368
|
this.finished = true;
|
|
422
369
|
this.buffer.subarray(pos).fill(0);
|
|
@@ -449,7 +396,7 @@ var BLAKE = class extends Hash {
|
|
|
449
396
|
}
|
|
450
397
|
};
|
|
451
398
|
|
|
452
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
399
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_u64.js
|
|
453
400
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
454
401
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
455
402
|
function fromBig(n, le = false) {
|
|
@@ -515,7 +462,7 @@ var u64 = {
|
|
|
515
462
|
};
|
|
516
463
|
var u64_default = u64;
|
|
517
464
|
|
|
518
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
465
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/blake2b.js
|
|
519
466
|
var B2B_IV = /* @__PURE__ */ new Uint32Array([
|
|
520
467
|
4089235720,
|
|
521
468
|
1779033703,
|
|
@@ -694,41 +641,19 @@ var BLAKE2b = class extends BLAKE {
|
|
|
694
641
|
};
|
|
695
642
|
var blake2b = /* @__PURE__ */ wrapConstructorWithOpts((opts) => new BLAKE2b(opts));
|
|
696
643
|
|
|
697
|
-
// src/guard.ts
|
|
698
|
-
var createIsGuard = (type) => (value) => typeof value === type;
|
|
699
|
-
var isString = createIsGuard("string");
|
|
700
|
-
var isNumber = createIsGuard("number");
|
|
701
|
-
var isBigInt = createIsGuard("bigint");
|
|
702
|
-
var isBoolean = createIsGuard("boolean");
|
|
703
|
-
var isSymbol = createIsGuard("symbol");
|
|
704
|
-
var isObject = createIsGuard("object");
|
|
705
|
-
var isUndefined = createIsGuard("undefined");
|
|
706
|
-
|
|
707
|
-
// src/assertion.ts
|
|
708
|
-
function assert(condition, message = "assertion failed", Constructor = Error) {
|
|
709
|
-
if (!condition) {
|
|
710
|
-
throw new Constructor(message);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
|
|
714
644
|
// src/bytes.ts
|
|
715
|
-
var bytesToHex = (input) => {
|
|
716
|
-
const bytes = new Uint8Array(input);
|
|
717
|
-
return `0x${Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
718
|
-
};
|
|
719
645
|
var hexToBytes = (input) => {
|
|
720
646
|
assert(/^0x[\da-f]*$/i.test(input) && input.length % 2 === 0, "Invalid hex string");
|
|
721
647
|
const hex = input.slice(2);
|
|
722
|
-
const
|
|
648
|
+
const bytes2 = new Uint8Array(hex.length / 2);
|
|
723
649
|
for (let i = 0; i < hex.length; i += 2) {
|
|
724
|
-
|
|
650
|
+
bytes2[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
725
651
|
}
|
|
726
|
-
return
|
|
652
|
+
return bytes2;
|
|
727
653
|
};
|
|
728
|
-
var convertBase = (
|
|
729
|
-
const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
|
|
654
|
+
var convertBase = (bytes2, fromBase, toBase) => {
|
|
730
655
|
const result = [];
|
|
731
|
-
for (const byte of
|
|
656
|
+
for (const byte of bytes2) {
|
|
732
657
|
let carry = byte;
|
|
733
658
|
for (let i = 0; i < result.length; i += 1) {
|
|
734
659
|
carry += result[i] * fromBase;
|
|
@@ -741,24 +666,24 @@ var convertBase = (inputBytes, fromBase, toBase) => {
|
|
|
741
666
|
}
|
|
742
667
|
}
|
|
743
668
|
let leadingZeros = 0;
|
|
744
|
-
while (
|
|
669
|
+
while (bytes2[leadingZeros] === 0) {
|
|
745
670
|
leadingZeros += 1;
|
|
746
671
|
result.push(0);
|
|
747
672
|
}
|
|
748
673
|
return result.reverse();
|
|
749
674
|
};
|
|
750
|
-
var encodeBytesWithCharset = (
|
|
751
|
-
var decodeBytesWithCharset = (input,
|
|
752
|
-
assert(new RegExp(`^[${
|
|
753
|
-
const charMap = Object.fromEntries([...
|
|
754
|
-
const
|
|
755
|
-
return new Uint8Array(convertBase(
|
|
675
|
+
var encodeBytesWithCharset = (bytes2, charset2) => convertBase(bytes2, 256, charset2.length).map((charCode) => charset2.charAt(charCode)).join("");
|
|
676
|
+
var decodeBytesWithCharset = (input, charset2) => {
|
|
677
|
+
assert(new RegExp(`^[${charset2}]*$`).test(input), "Invalid input");
|
|
678
|
+
const charMap = Object.fromEntries([...charset2].map((char, index) => [char, index]));
|
|
679
|
+
const bytes2 = input.split("").map((char) => charMap[char]);
|
|
680
|
+
return new Uint8Array(convertBase(bytes2, charset2.length, 256));
|
|
756
681
|
};
|
|
757
682
|
|
|
758
683
|
// src/base58.ts
|
|
759
|
-
var
|
|
760
|
-
var encode = (
|
|
761
|
-
var decode = (input) => decodeBytesWithCharset(input,
|
|
684
|
+
var charset = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
685
|
+
var encode = (bytes2) => encodeBytesWithCharset(bytes2, charset);
|
|
686
|
+
var decode = (input) => decodeBytesWithCharset(input, charset);
|
|
762
687
|
|
|
763
688
|
// src/ss58.ts
|
|
764
689
|
var CHECKSUM_BYTE_LENGTH = 2;
|
|
@@ -780,7 +705,7 @@ var decode2 = (input) => {
|
|
|
780
705
|
ss58Format = (decodedBytes[0] & 63) << 2 | decodedBytes[1] >> 6 | (decodedBytes[1] & 63) << 8;
|
|
781
706
|
} else {
|
|
782
707
|
ss58FormatLen = 1;
|
|
783
|
-
|
|
708
|
+
ss58Format = decodedBytes[0];
|
|
784
709
|
}
|
|
785
710
|
assert(!RESERVED_PREFIXES.includes(ss58Format), `Reserved prefix: ${ss58Format}`);
|
|
786
711
|
const checksumBytes = decodedBytes.slice(-CHECKSUM_BYTE_LENGTH);
|
|
@@ -820,12 +745,10 @@ var encode2 = ({
|
|
|
820
745
|
const checksum = computeChecksum(new Uint8Array([...prefixBytes, ...data]));
|
|
821
746
|
return encode([...prefixBytes, ...data, ...checksum]);
|
|
822
747
|
};
|
|
823
|
-
var toPublicKey = (address) => bytesToHex(decode2(address).data);
|
|
824
748
|
// Annotate the CommonJS export names for ESM import in node:
|
|
825
749
|
0 && (module.exports = {
|
|
826
750
|
decode,
|
|
827
|
-
encode
|
|
828
|
-
toPublicKey
|
|
751
|
+
encode
|
|
829
752
|
});
|
|
830
753
|
/*! Bundled license information:
|
|
831
754
|
|
package/dist/ss58.d.cts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './chainflip.cjs';
|
|
1
|
+
import { HexString } from './types.cjs';
|
|
3
2
|
|
|
4
3
|
declare const decode: (input: string) => {
|
|
5
4
|
data: Uint8Array;
|
|
6
5
|
ss58Format: number;
|
|
7
6
|
};
|
|
8
7
|
declare const encode: ({ data: input, ss58Format, }: {
|
|
9
|
-
data:
|
|
8
|
+
data: Uint8Array | HexString;
|
|
10
9
|
ss58Format: number;
|
|
11
10
|
}) => string;
|
|
12
|
-
declare const toPublicKey: (address: string) => HexString;
|
|
13
11
|
|
|
14
|
-
export { decode, encode
|
|
12
|
+
export { decode, encode };
|
package/dist/ss58.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './chainflip.js';
|
|
1
|
+
import { HexString } from './types.js';
|
|
3
2
|
|
|
4
3
|
declare const decode: (input: string) => {
|
|
5
4
|
data: Uint8Array;
|
|
6
5
|
ss58Format: number;
|
|
7
6
|
};
|
|
8
7
|
declare const encode: ({ data: input, ss58Format, }: {
|
|
9
|
-
data:
|
|
8
|
+
data: Uint8Array | HexString;
|
|
10
9
|
ss58Format: number;
|
|
11
10
|
}) => string;
|
|
12
|
-
declare const toPublicKey: (address: string) => HexString;
|
|
13
11
|
|
|
14
|
-
export { decode, encode
|
|
12
|
+
export { decode, encode };
|
package/dist/ss58.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decode,
|
|
3
3
|
encode
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-O4WBUIAN.js";
|
|
5
5
|
import {
|
|
6
|
-
bytesToHex,
|
|
7
6
|
hexToBytes
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4RHM5374.js";
|
|
9
8
|
import {
|
|
10
9
|
assert
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-MYP3UYWE.js";
|
|
11
|
+
import "./chunk-CZNX6EUV.js";
|
|
13
12
|
|
|
14
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
15
|
-
function
|
|
13
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_assert.js
|
|
14
|
+
function number(n) {
|
|
16
15
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
17
|
-
throw new Error(
|
|
16
|
+
throw new Error(`positive integer expected, not ${n}`);
|
|
18
17
|
}
|
|
19
18
|
function isBytes(a) {
|
|
20
|
-
return a instanceof Uint8Array ||
|
|
19
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
21
20
|
}
|
|
22
|
-
function
|
|
21
|
+
function bytes(b, ...lengths) {
|
|
23
22
|
if (!isBytes(b))
|
|
24
23
|
throw new Error("Uint8Array expected");
|
|
25
24
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
26
|
-
throw new Error(
|
|
25
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
27
26
|
}
|
|
28
|
-
function
|
|
27
|
+
function exists(instance, checkFinished = true) {
|
|
29
28
|
if (instance.destroyed)
|
|
30
29
|
throw new Error("Hash instance has been destroyed");
|
|
31
30
|
if (checkFinished && instance.finished)
|
|
32
31
|
throw new Error("Hash#digest() has already been called");
|
|
33
32
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
33
|
+
function output(out, instance) {
|
|
34
|
+
bytes(out);
|
|
36
35
|
const min = instance.outputLen;
|
|
37
36
|
if (out.length < min) {
|
|
38
|
-
throw new Error(
|
|
37
|
+
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
47
|
-
function byteSwap(word) {
|
|
48
|
-
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
49
|
-
}
|
|
41
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/utils.js
|
|
42
|
+
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
43
|
+
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
44
|
+
var byteSwap = (word) => word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
50
45
|
var byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
51
46
|
function byteSwap32(arr) {
|
|
52
47
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -55,13 +50,13 @@ function byteSwap32(arr) {
|
|
|
55
50
|
}
|
|
56
51
|
function utf8ToBytes(str) {
|
|
57
52
|
if (typeof str !== "string")
|
|
58
|
-
throw new Error(
|
|
53
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
59
54
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
60
55
|
}
|
|
61
56
|
function toBytes(data) {
|
|
62
57
|
if (typeof data === "string")
|
|
63
58
|
data = utf8ToBytes(data);
|
|
64
|
-
|
|
59
|
+
bytes(data);
|
|
65
60
|
return data;
|
|
66
61
|
}
|
|
67
62
|
var Hash = class {
|
|
@@ -70,6 +65,7 @@ var Hash = class {
|
|
|
70
65
|
return this._cloneInto();
|
|
71
66
|
}
|
|
72
67
|
};
|
|
68
|
+
var toStr = {}.toString;
|
|
73
69
|
function wrapConstructorWithOpts(hashCons) {
|
|
74
70
|
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
75
71
|
const tmp = hashCons({});
|
|
@@ -79,7 +75,7 @@ function wrapConstructorWithOpts(hashCons) {
|
|
|
79
75
|
return hashC;
|
|
80
76
|
}
|
|
81
77
|
|
|
82
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
78
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_blake.js
|
|
83
79
|
var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
84
80
|
0,
|
|
85
81
|
1,
|
|
@@ -272,72 +268,7 @@ var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
|
272
268
|
11,
|
|
273
269
|
7,
|
|
274
270
|
5,
|
|
275
|
-
3
|
|
276
|
-
// Blake1, unused in others
|
|
277
|
-
11,
|
|
278
|
-
8,
|
|
279
|
-
12,
|
|
280
|
-
0,
|
|
281
|
-
5,
|
|
282
|
-
2,
|
|
283
|
-
15,
|
|
284
|
-
13,
|
|
285
|
-
10,
|
|
286
|
-
14,
|
|
287
|
-
3,
|
|
288
|
-
6,
|
|
289
|
-
7,
|
|
290
|
-
1,
|
|
291
|
-
9,
|
|
292
|
-
4,
|
|
293
|
-
7,
|
|
294
|
-
9,
|
|
295
|
-
3,
|
|
296
|
-
1,
|
|
297
|
-
13,
|
|
298
|
-
12,
|
|
299
|
-
11,
|
|
300
|
-
14,
|
|
301
|
-
2,
|
|
302
|
-
6,
|
|
303
|
-
5,
|
|
304
|
-
10,
|
|
305
|
-
4,
|
|
306
|
-
0,
|
|
307
|
-
15,
|
|
308
|
-
8,
|
|
309
|
-
9,
|
|
310
|
-
0,
|
|
311
|
-
5,
|
|
312
|
-
7,
|
|
313
|
-
2,
|
|
314
|
-
4,
|
|
315
|
-
10,
|
|
316
|
-
15,
|
|
317
|
-
14,
|
|
318
|
-
1,
|
|
319
|
-
11,
|
|
320
|
-
12,
|
|
321
|
-
6,
|
|
322
|
-
8,
|
|
323
|
-
3,
|
|
324
|
-
13,
|
|
325
|
-
2,
|
|
326
|
-
12,
|
|
327
|
-
6,
|
|
328
|
-
10,
|
|
329
|
-
0,
|
|
330
|
-
11,
|
|
331
|
-
8,
|
|
332
|
-
3,
|
|
333
|
-
4,
|
|
334
|
-
13,
|
|
335
|
-
7,
|
|
336
|
-
5,
|
|
337
|
-
15,
|
|
338
|
-
14,
|
|
339
|
-
1,
|
|
340
|
-
9
|
|
271
|
+
3
|
|
341
272
|
]);
|
|
342
273
|
var BLAKE = class extends Hash {
|
|
343
274
|
constructor(blockLen, outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
@@ -348,22 +279,21 @@ var BLAKE = class extends Hash {
|
|
|
348
279
|
this.pos = 0;
|
|
349
280
|
this.finished = false;
|
|
350
281
|
this.destroyed = false;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
282
|
+
number(blockLen);
|
|
283
|
+
number(outputLen);
|
|
284
|
+
number(keyLen);
|
|
354
285
|
if (outputLen < 0 || outputLen > keyLen)
|
|
355
286
|
throw new Error("outputLen bigger than keyLen");
|
|
356
287
|
if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
|
|
357
|
-
throw new Error(
|
|
288
|
+
throw new Error(`key must be up 1..${keyLen} byte long or undefined`);
|
|
358
289
|
if (opts.salt !== void 0 && opts.salt.length !== saltLen)
|
|
359
|
-
throw new Error(
|
|
290
|
+
throw new Error(`salt must be ${saltLen} byte long or undefined`);
|
|
360
291
|
if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
|
|
361
|
-
throw new Error(
|
|
362
|
-
this.buffer = new Uint8Array(blockLen);
|
|
363
|
-
this.buffer32 = u32(this.buffer);
|
|
292
|
+
throw new Error(`personalization must be ${persLen} byte long or undefined`);
|
|
293
|
+
this.buffer32 = u32(this.buffer = new Uint8Array(blockLen));
|
|
364
294
|
}
|
|
365
295
|
update(data) {
|
|
366
|
-
|
|
296
|
+
exists(this);
|
|
367
297
|
const { blockLen, buffer, buffer32 } = this;
|
|
368
298
|
data = toBytes(data);
|
|
369
299
|
const len = data.length;
|
|
@@ -400,8 +330,8 @@ var BLAKE = class extends Hash {
|
|
|
400
330
|
return this;
|
|
401
331
|
}
|
|
402
332
|
digestInto(out) {
|
|
403
|
-
|
|
404
|
-
|
|
333
|
+
exists(this);
|
|
334
|
+
output(out, this);
|
|
405
335
|
const { pos, buffer32 } = this;
|
|
406
336
|
this.finished = true;
|
|
407
337
|
this.buffer.subarray(pos).fill(0);
|
|
@@ -434,7 +364,7 @@ var BLAKE = class extends Hash {
|
|
|
434
364
|
}
|
|
435
365
|
};
|
|
436
366
|
|
|
437
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
367
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/_u64.js
|
|
438
368
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
439
369
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
440
370
|
function fromBig(n, le = false) {
|
|
@@ -500,7 +430,7 @@ var u64 = {
|
|
|
500
430
|
};
|
|
501
431
|
var u64_default = u64;
|
|
502
432
|
|
|
503
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
433
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.4.0/node_modules/@noble/hashes/esm/blake2b.js
|
|
504
434
|
var B2B_IV = /* @__PURE__ */ new Uint32Array([
|
|
505
435
|
4089235720,
|
|
506
436
|
1779033703,
|
|
@@ -699,7 +629,7 @@ var decode2 = (input) => {
|
|
|
699
629
|
ss58Format = (decodedBytes[0] & 63) << 2 | decodedBytes[1] >> 6 | (decodedBytes[1] & 63) << 8;
|
|
700
630
|
} else {
|
|
701
631
|
ss58FormatLen = 1;
|
|
702
|
-
|
|
632
|
+
ss58Format = decodedBytes[0];
|
|
703
633
|
}
|
|
704
634
|
assert(!RESERVED_PREFIXES.includes(ss58Format), `Reserved prefix: ${ss58Format}`);
|
|
705
635
|
const checksumBytes = decodedBytes.slice(-CHECKSUM_BYTE_LENGTH);
|
|
@@ -739,11 +669,9 @@ var encode2 = ({
|
|
|
739
669
|
const checksum = computeChecksum(new Uint8Array([...prefixBytes, ...data]));
|
|
740
670
|
return encode([...prefixBytes, ...data, ...checksum]);
|
|
741
671
|
};
|
|
742
|
-
var toPublicKey = (address) => bytesToHex(decode2(address).data);
|
|
743
672
|
export {
|
|
744
673
|
decode2 as decode,
|
|
745
|
-
encode2 as encode
|
|
746
|
-
toPublicKey
|
|
674
|
+
encode2 as encode
|
|
747
675
|
};
|
|
748
676
|
/*! Bundled license information:
|
|
749
677
|
|