WXL
3 天以前 4d9da000fbe74d344e0e4580b138e79d4ad98ede
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Key = void 0;
const encoding_1 = require("./encoding");
const bech32_1 = __importDefault(require("bech32"));
class Key {
    value;
    constructor(value) {
        this.value = value;
    }
    static from(value) {
        return new Key(value);
    }
    static fromHex(value) {
        return new Key((0, encoding_1.fromHex)(value));
    }
    static fromBase64(value) {
        return new Key((0, encoding_1.fromBase64)(value));
    }
    static fromBigInt(value) {
        return new Key((0, encoding_1.fromBigInt)(value));
    }
    toHex() {
        return (0, encoding_1.toHex)(this.value);
    }
    toPrefixedHex() {
        return `0x${this.toHex()}`;
    }
    toBase64() {
        return (0, encoding_1.toBase64)(this.value);
    }
    toBigInt() {
        return (0, encoding_1.toBigInt)(this.value);
    }
    toBech32(prefix, limit) {
        return bech32_1.default.encode(prefix, bech32_1.default.toWords(this.value), limit);
    }
    slice(start, end) {
        return Key.from(this.value.slice(start, end));
    }
    concat(key) {
        return Key.from(new Uint8Array([...this.value, ...key.value]));
    }
}
exports.Key = Key;
//# sourceMappingURL=key.js.map