@chainflip/utils 0.2.1 → 0.4.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/dist/math.cjs +33 -0
- package/dist/math.d.cts +4 -0
- package/dist/math.d.ts +4 -0
- package/dist/math.js +7 -0
- package/dist/ss58.cjs +9 -2
- package/dist/ss58.d.cts +2 -1
- package/dist/ss58.d.ts +2 -1
- package/dist/ss58.js +4 -1
- package/package.json +1 -1
package/dist/math.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/math.ts
|
|
21
|
+
var math_exports = {};
|
|
22
|
+
__export(math_exports, {
|
|
23
|
+
average: () => average,
|
|
24
|
+
sum: () => sum
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(math_exports);
|
|
27
|
+
var sum = (arr) => arr.reduce((a, b) => a + b, 0);
|
|
28
|
+
var average = (arr) => sum(arr) / arr.length;
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
average,
|
|
32
|
+
sum
|
|
33
|
+
});
|
package/dist/math.d.cts
ADDED
package/dist/math.d.ts
ADDED
package/dist/math.js
ADDED
package/dist/ss58.cjs
CHANGED
|
@@ -21,7 +21,8 @@ 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
|
|
24
|
+
encode: () => encode2,
|
|
25
|
+
toPublicKey: () => toPublicKey
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(ss58_exports);
|
|
27
28
|
|
|
@@ -642,6 +643,10 @@ var BLAKE2b = class extends BLAKE {
|
|
|
642
643
|
var blake2b = /* @__PURE__ */ wrapConstructorWithOpts((opts) => new BLAKE2b(opts));
|
|
643
644
|
|
|
644
645
|
// src/bytes.ts
|
|
646
|
+
var bytesToHex = (input) => {
|
|
647
|
+
const bytes2 = new Uint8Array(input);
|
|
648
|
+
return `0x${Array.from(bytes2).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
649
|
+
};
|
|
645
650
|
var hexToBytes = (input) => {
|
|
646
651
|
assert(/^0x[\da-f]*$/i.test(input) && input.length % 2 === 0, "Invalid hex string");
|
|
647
652
|
const hex = input.slice(2);
|
|
@@ -745,10 +750,12 @@ var encode2 = ({
|
|
|
745
750
|
const checksum = computeChecksum(new Uint8Array([...prefixBytes, ...data]));
|
|
746
751
|
return encode([...prefixBytes, ...data, ...checksum]);
|
|
747
752
|
};
|
|
753
|
+
var toPublicKey = (address) => bytesToHex(decode2(address).data);
|
|
748
754
|
// Annotate the CommonJS export names for ESM import in node:
|
|
749
755
|
0 && (module.exports = {
|
|
750
756
|
decode,
|
|
751
|
-
encode
|
|
757
|
+
encode,
|
|
758
|
+
toPublicKey
|
|
752
759
|
});
|
|
753
760
|
/*! Bundled license information:
|
|
754
761
|
|
package/dist/ss58.d.cts
CHANGED
package/dist/ss58.d.ts
CHANGED
package/dist/ss58.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
encode
|
|
4
4
|
} from "./chunk-UPA7KLTI.js";
|
|
5
5
|
import {
|
|
6
|
+
bytesToHex,
|
|
6
7
|
hexToBytes
|
|
7
8
|
} from "./chunk-D7RIA7SA.js";
|
|
8
9
|
import {
|
|
@@ -669,9 +670,11 @@ var encode2 = ({
|
|
|
669
670
|
const checksum = computeChecksum(new Uint8Array([...prefixBytes, ...data]));
|
|
670
671
|
return encode([...prefixBytes, ...data, ...checksum]);
|
|
671
672
|
};
|
|
673
|
+
var toPublicKey = (address) => bytesToHex(decode2(address).data);
|
|
672
674
|
export {
|
|
673
675
|
decode2 as decode,
|
|
674
|
-
encode2 as encode
|
|
676
|
+
encode2 as encode,
|
|
677
|
+
toPublicKey
|
|
675
678
|
};
|
|
676
679
|
/*! Bundled license information:
|
|
677
680
|
|