@ckb-ccc/core 0.1.1 → 1.0.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/CHANGELOG.md +12 -0
- package/dist/barrel.d.ts +1 -1
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +1 -1
- package/dist/bytes/index.d.ts +14 -0
- package/dist/bytes/index.d.ts.map +1 -1
- package/dist/bytes/index.js +29 -0
- package/dist/ckb/advanced.d.ts +0 -1
- package/dist/ckb/advanced.d.ts.map +1 -1
- package/dist/ckb/advanced.js +0 -1
- package/dist/ckb/script.d.ts +17 -58
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/script.js +31 -78
- package/dist/ckb/transaction.d.ts +114 -260
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +162 -358
- package/dist/molecule/barrel.d.ts +4 -0
- package/dist/molecule/barrel.d.ts.map +1 -0
- package/dist/molecule/barrel.js +3 -0
- package/dist/molecule/codec.d.ts.map +1 -1
- package/dist/molecule/codec.js +6 -3
- package/dist/molecule/entity.d.ts +98 -0
- package/dist/molecule/entity.d.ts.map +1 -0
- package/dist/molecule/entity.js +113 -0
- package/dist/molecule/index.d.ts +1 -2
- package/dist/molecule/index.d.ts.map +1 -1
- package/dist/molecule/index.js +1 -2
- package/dist/molecule/predefined.d.ts +13 -20
- package/dist/molecule/predefined.d.ts.map +1 -1
- package/dist/molecule/predefined.js +14 -54
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist.commonjs/address/address.advanced.js +28 -23
- package/dist.commonjs/address/advanced.js +17 -1
- package/dist.commonjs/address/index.js +15 -11
- package/dist.commonjs/advanced.js +31 -2
- package/dist.commonjs/advancedBarrel.js +21 -5
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +28 -12
- package/dist.commonjs/bytes/advanced.js +2 -1
- package/dist.commonjs/bytes/index.d.ts +14 -0
- package/dist.commonjs/bytes/index.d.ts.map +1 -1
- package/dist.commonjs/bytes/index.js +42 -7
- package/dist.commonjs/ckb/advanced.d.ts +0 -1
- package/dist.commonjs/ckb/advanced.d.ts.map +1 -1
- package/dist.commonjs/ckb/advanced.js +18 -3
- package/dist.commonjs/ckb/index.js +19 -3
- package/dist.commonjs/ckb/script.advanced.js +6 -3
- package/dist.commonjs/ckb/script.d.ts +17 -58
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.js +49 -90
- package/dist.commonjs/ckb/transaction.advanced.js +6 -3
- package/dist.commonjs/ckb/transaction.d.ts +114 -260
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +249 -434
- package/dist.commonjs/ckb/transactionLumos.js +2 -1
- package/dist.commonjs/client/advanced.js +22 -6
- package/dist.commonjs/client/cache/advanced.js +17 -1
- package/dist.commonjs/client/cache/cache.js +7 -3
- package/dist.commonjs/client/cache/index.js +18 -2
- package/dist.commonjs/client/cache/memory.advanced.js +28 -21
- package/dist.commonjs/client/cache/memory.js +23 -19
- package/dist.commonjs/client/client.js +25 -21
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +25 -22
- package/dist.commonjs/client/clientPublicMainnet.js +15 -8
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +25 -22
- package/dist.commonjs/client/clientPublicTestnet.js +15 -8
- package/dist.commonjs/client/clientTypes.advanced.js +6 -3
- package/dist.commonjs/client/clientTypes.js +43 -29
- package/dist.commonjs/client/index.js +22 -6
- package/dist.commonjs/client/jsonRpc/advanced.js +18 -2
- package/dist.commonjs/client/jsonRpc/index.js +41 -37
- package/dist.commonjs/client/jsonRpc/transformers.js +61 -57
- package/dist.commonjs/client/jsonRpc/types.js +2 -1
- package/dist.commonjs/client/transports/advanced.js +25 -8
- package/dist.commonjs/client/transports/http.js +5 -1
- package/dist.commonjs/client/transports/transport.js +2 -1
- package/dist.commonjs/client/transports/webSocket.js +10 -3
- package/dist.commonjs/fixedPoint/index.js +9 -4
- package/dist.commonjs/hasher/advanced.js +4 -1
- package/dist.commonjs/hasher/hasher.js +2 -1
- package/dist.commonjs/hasher/hasherCkb.js +20 -14
- package/dist.commonjs/hasher/hasherKeecak256.js +11 -7
- package/dist.commonjs/hasher/index.js +19 -3
- package/dist.commonjs/hex/index.js +6 -3
- package/dist.commonjs/index.js +31 -2
- package/dist.commonjs/keystore/index.js +25 -21
- package/dist.commonjs/molecule/barrel.d.ts +4 -0
- package/dist.commonjs/molecule/barrel.d.ts.map +1 -0
- package/dist.commonjs/molecule/barrel.js +19 -0
- package/dist.commonjs/molecule/codec.d.ts.map +1 -1
- package/dist.commonjs/molecule/codec.js +69 -51
- package/dist.commonjs/molecule/entity.d.ts +98 -0
- package/dist.commonjs/molecule/entity.d.ts.map +1 -0
- package/dist.commonjs/molecule/entity.js +118 -0
- package/dist.commonjs/molecule/index.d.ts +1 -2
- package/dist.commonjs/molecule/index.d.ts.map +1 -1
- package/dist.commonjs/molecule/index.js +27 -2
- package/dist.commonjs/molecule/predefined.d.ts +13 -20
- package/dist.commonjs/molecule/predefined.d.ts.map +1 -1
- package/dist.commonjs/molecule/predefined.js +54 -91
- package/dist.commonjs/num/index.js +29 -17
- package/dist.commonjs/signer/btc/index.js +19 -3
- package/dist.commonjs/signer/btc/signerBtc.js +24 -20
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +8 -4
- package/dist.commonjs/signer/btc/verify.js +26 -17
- package/dist.commonjs/signer/ckb/index.js +21 -5
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +20 -16
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +24 -20
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +12 -8
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +16 -12
- package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -5
- package/dist.commonjs/signer/doge/index.js +20 -4
- package/dist.commonjs/signer/doge/signerDoge.js +26 -19
- package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +6 -2
- package/dist.commonjs/signer/doge/signerDogePrivateKey.js +17 -13
- package/dist.commonjs/signer/doge/verify.js +15 -12
- package/dist.commonjs/signer/dummy/alwaysError.js +6 -2
- package/dist.commonjs/signer/dummy/dummy.js +7 -3
- package/dist.commonjs/signer/dummy/index.js +19 -3
- package/dist.commonjs/signer/dummy/openLink.js +6 -2
- package/dist.commonjs/signer/evm/index.js +19 -3
- package/dist.commonjs/signer/evm/signerEvm.js +35 -31
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +8 -4
- package/dist.commonjs/signer/evm/verify.js +7 -4
- package/dist.commonjs/signer/index.js +23 -7
- package/dist.commonjs/signer/nostr/index.js +18 -2
- package/dist.commonjs/signer/nostr/signerNostr.js +25 -21
- package/dist.commonjs/signer/nostr/verify.js +16 -12
- package/dist.commonjs/signer/signer/index.js +25 -19
- package/dist.commonjs/utils/index.d.ts +3 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +12 -6
- package/package.json +1 -2
- package/src/barrel.ts +1 -1
- package/src/bytes/index.ts +34 -0
- package/src/ckb/advanced.ts +0 -1
- package/src/ckb/script.ts +22 -85
- package/src/ckb/transaction.ts +134 -412
- package/src/molecule/barrel.ts +3 -0
- package/src/molecule/codec.ts +9 -5
- package/src/molecule/entity.ts +163 -0
- package/src/molecule/index.ts +1 -2
- package/src/molecule/predefined.ts +20 -69
- package/src/utils/index.ts +5 -0
- package/dist/ckb/molecule.advanced/generated.d.ts +0 -355
- package/dist/ckb/molecule.advanced/generated.d.ts.map +0 -1
- package/dist/ckb/molecule.advanced/generated.js +0 -1468
- package/dist/ckb/molecule.advanced/index.d.ts +0 -6
- package/dist/ckb/molecule.advanced/index.d.ts.map +0 -1
- package/dist/ckb/molecule.advanced/index.js +0 -7
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +0 -355
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts.map +0 -1
- package/dist.commonjs/ckb/molecule.advanced/generated.js +0 -1468
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +0 -6
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +0 -1
- package/dist.commonjs/ckb/molecule.advanced/index.js +0 -7
- package/src/ckb/molecule.advanced/blockchain.mol +0 -118
- package/src/ckb/molecule.advanced/generated.d.ts +0 -444
- package/src/ckb/molecule.advanced/generated.js +0 -1804
- package/src/ckb/molecule.advanced/index.ts +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../../src/molecule/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/molecule/codec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAA0B,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,GAAG,EAIH,OAAO,EAER,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI;IACtD,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,KAAK,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO,CAAC;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AACF,qBAAa,KAAK,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS;aAE7B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,KAAK;aACvC,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,OAAO;aACzC,UAAU,CAAC,E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ec) {
|
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
58
|
const decodedArray = [];
|
|
59
|
-
for (let offset =
|
|
59
|
+
for (let offset = 4; offset < byteLength; offset += itemByteLength) {
|
|
60
60
|
decodedArray.push(itemCodec.decode(value.slice(offset, offset + itemByteLength)));
|
|
61
61
|
}
|
|
62
62
|
return decodedArray;
|
|
@@ -97,12 +97,15 @@ export function dynItemVec(itemCodec) {
|
|
|
97
97
|
},
|
|
98
98
|
decode(buffer) {
|
|
99
99
|
const value = bytesFrom(buffer);
|
|
100
|
+
if (value.byteLength < 4) {
|
|
101
|
+
throw new Error(`dynItemVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`);
|
|
102
|
+
}
|
|
100
103
|
const byteLength = uint32From(value.slice(0, 4));
|
|
101
104
|
if (byteLength !== value.byteLength) {
|
|
102
105
|
throw new Error(`dynItemVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`);
|
|
103
106
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
107
|
+
if (byteLength === 4) {
|
|
108
|
+
return [];
|
|
106
109
|
}
|
|
107
110
|
const offset = uint32From(value.slice(4, 8));
|
|
108
111
|
const itemCount = (offset - 4) / 4;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Bytes, BytesLike } from "../bytes/index.js";
|
|
2
|
+
import { Hex } from "../hex/index.js";
|
|
3
|
+
import { Codec } from "./codec.js";
|
|
4
|
+
/**
|
|
5
|
+
* The base class of CCC to create a serializable instance
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class Entity {
|
|
9
|
+
static Base<SubTypeLike, SubType = SubTypeLike>(): (abstract new () => {
|
|
10
|
+
/**
|
|
11
|
+
* Convert the entity to bytes
|
|
12
|
+
* @public
|
|
13
|
+
* @returns The bytes representation of the entity
|
|
14
|
+
*/
|
|
15
|
+
toBytes(): Bytes;
|
|
16
|
+
/**
|
|
17
|
+
* Create a clone of the entity
|
|
18
|
+
* @public
|
|
19
|
+
* @returns A clone of the entity
|
|
20
|
+
*/
|
|
21
|
+
clone(): SubType;
|
|
22
|
+
/**
|
|
23
|
+
* Check if the entity is equal to another entity
|
|
24
|
+
* @public
|
|
25
|
+
* @param other - The other entity to compare with
|
|
26
|
+
* @returns True if the entities are equal, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
eq(other: SubTypeLike | SubType): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate the hash of the entity
|
|
31
|
+
* @public
|
|
32
|
+
* @returns The hash of the entity
|
|
33
|
+
*/
|
|
34
|
+
hash(): Hex;
|
|
35
|
+
}) & {
|
|
36
|
+
/**
|
|
37
|
+
* The bytes length of the entity, if it is fixed, otherwise undefined
|
|
38
|
+
* @public
|
|
39
|
+
* @static
|
|
40
|
+
*/
|
|
41
|
+
byteLength?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Encode the entity into bytes
|
|
44
|
+
* @public
|
|
45
|
+
* @static
|
|
46
|
+
* @param _ - The entity to encode
|
|
47
|
+
* @returns The encoded bytes
|
|
48
|
+
* @throws Will throw an error if the entity is not serializable
|
|
49
|
+
*/
|
|
50
|
+
encode(_: SubTypeLike): Bytes;
|
|
51
|
+
/**
|
|
52
|
+
* Decode the entity from bytes
|
|
53
|
+
* @public
|
|
54
|
+
* @static
|
|
55
|
+
* @param _ - The bytes to decode
|
|
56
|
+
* @returns The decoded entity
|
|
57
|
+
* @throws Will throw an error if the entity is not serializable
|
|
58
|
+
*/
|
|
59
|
+
decode(_: BytesLike): SubType;
|
|
60
|
+
/**
|
|
61
|
+
* Create an entity from bytes
|
|
62
|
+
* @public
|
|
63
|
+
* @static
|
|
64
|
+
* @param _ - The bytes to create the entity from
|
|
65
|
+
* @returns The created entity
|
|
66
|
+
* @throws Will throw an error if the entity is not serializable
|
|
67
|
+
*/
|
|
68
|
+
fromBytes(_bytes: BytesLike): SubType;
|
|
69
|
+
/**
|
|
70
|
+
* Create an entity from a serializable object
|
|
71
|
+
* @public
|
|
72
|
+
* @static
|
|
73
|
+
* @param _ - The serializable object to create the entity from
|
|
74
|
+
* @returns The created entity
|
|
75
|
+
* @throws Will throw an error if the entity is not serializable
|
|
76
|
+
*/
|
|
77
|
+
from(_: SubTypeLike): SubType;
|
|
78
|
+
};
|
|
79
|
+
abstract toBytes(): Bytes;
|
|
80
|
+
abstract hash(): Hex;
|
|
81
|
+
abstract clone(): Entity;
|
|
82
|
+
}
|
|
83
|
+
export declare function codec<Encodable, TypeLike extends Encodable, Decoded extends TypeLike, Type extends object & TypeLike, ConstructorType extends {
|
|
84
|
+
new (...args: any[]): Type;
|
|
85
|
+
from(decoded: TypeLike): Type;
|
|
86
|
+
byteLength?: number;
|
|
87
|
+
encode(encodable: TypeLike): Bytes;
|
|
88
|
+
decode(bytesLike: BytesLike): TypeLike;
|
|
89
|
+
fromBytes(bytes: BytesLike): Type;
|
|
90
|
+
}>(codec: Codec<Encodable, Decoded>): (Constructor: ConstructorType) => {
|
|
91
|
+
new (...args: any[]): {};
|
|
92
|
+
byteLength: number | undefined;
|
|
93
|
+
encode(encodable: TypeLike): Bytes;
|
|
94
|
+
decode(bytesLike: BytesLike): Type;
|
|
95
|
+
fromBytes(bytes: BytesLike): Type;
|
|
96
|
+
from(decoded: TypeLike): Type;
|
|
97
|
+
} & ConstructorType;
|
|
98
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/molecule/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAW,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;GAGG;AACH,8BAAsB,MAAM;IAC1B,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,WAAW;QA6D1C;;;;WAIG;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3
|
+
/**
|
|
4
|
+
* The base class of CCC to create a serializable instance
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class Entity {
|
|
8
|
+
static Base() {
|
|
9
|
+
class Impl {
|
|
10
|
+
/**
|
|
11
|
+
* Encode the entity into bytes
|
|
12
|
+
* @public
|
|
13
|
+
* @static
|
|
14
|
+
* @param _ - The entity to encode
|
|
15
|
+
* @returns The encoded bytes
|
|
16
|
+
* @throws Will throw an error if the entity is not serializable
|
|
17
|
+
*/
|
|
18
|
+
static encode(_) {
|
|
19
|
+
throw new Error("encode not implemented, use @ccc.mol.codec to decorate your type");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decode the entity from bytes
|
|
23
|
+
* @public
|
|
24
|
+
* @static
|
|
25
|
+
* @param _ - The bytes to decode
|
|
26
|
+
* @returns The decoded entity
|
|
27
|
+
* @throws Will throw an error if the entity is not serializable
|
|
28
|
+
*/
|
|
29
|
+
static decode(_) {
|
|
30
|
+
throw new Error("decode not implemented, use @ccc.mol.codec to decorate your type");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create an entity from bytes
|
|
34
|
+
* @public
|
|
35
|
+
* @static
|
|
36
|
+
* @param _ - The bytes to create the entity from
|
|
37
|
+
* @returns The created entity
|
|
38
|
+
* @throws Will throw an error if the entity is not serializable
|
|
39
|
+
*/
|
|
40
|
+
static fromBytes(_bytes) {
|
|
41
|
+
throw new Error("fromBytes not implemented, use @ccc.mol.codec to decorate your type");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create an entity from a serializable object
|
|
45
|
+
* @public
|
|
46
|
+
* @static
|
|
47
|
+
* @param _ - The serializable object to create the entity from
|
|
48
|
+
* @returns The created entity
|
|
49
|
+
* @throws Will throw an error if the entity is not serializable
|
|
50
|
+
*/
|
|
51
|
+
static from(_) {
|
|
52
|
+
throw new Error("from not implemented");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Convert the entity to bytes
|
|
56
|
+
* @public
|
|
57
|
+
* @returns The bytes representation of the entity
|
|
58
|
+
*/
|
|
59
|
+
toBytes() {
|
|
60
|
+
return this.constructor.encode(this);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a clone of the entity
|
|
64
|
+
* @public
|
|
65
|
+
* @returns A clone of the entity
|
|
66
|
+
*/
|
|
67
|
+
clone() {
|
|
68
|
+
return this.constructor.fromBytes(this.toBytes());
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if the entity is equal to another entity
|
|
72
|
+
* @public
|
|
73
|
+
* @param other - The other entity to compare with
|
|
74
|
+
* @returns True if the entities are equal, false otherwise
|
|
75
|
+
*/
|
|
76
|
+
eq(other) {
|
|
77
|
+
if (this === other) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return bytesEq(this.toBytes(),
|
|
81
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any */
|
|
82
|
+
(this.constructor?.from(other) ?? other).toBytes());
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Calculate the hash of the entity
|
|
86
|
+
* @public
|
|
87
|
+
* @returns The hash of the entity
|
|
88
|
+
*/
|
|
89
|
+
hash() {
|
|
90
|
+
return hashCkb(this.toBytes());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return Impl;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function codec(codec) {
|
|
97
|
+
return function (Constructor) {
|
|
98
|
+
var _a;
|
|
99
|
+
return _a = class Extended extends Constructor {
|
|
100
|
+
static encode(encodable) {
|
|
101
|
+
return codec.encode(encodable);
|
|
102
|
+
}
|
|
103
|
+
static decode(bytesLike) {
|
|
104
|
+
return Constructor.from(codec.decode(bytesLike));
|
|
105
|
+
}
|
|
106
|
+
static fromBytes(bytes) {
|
|
107
|
+
return Constructor.from(codec.decode(bytes));
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
_a.byteLength = codec.byteLength,
|
|
111
|
+
_a;
|
|
112
|
+
};
|
|
113
|
+
}
|
package/dist/molecule/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/molecule/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/molecule/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC"}
|
package/dist/molecule/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./predefined.js";
|
|
1
|
+
export * as mol from "./barrel.js";
|
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import * as ckb from "../ckb/index.js";
|
|
2
1
|
import { Hex, HexLike } from "../hex/index.js";
|
|
3
2
|
import { Codec } from "./codec.js";
|
|
4
3
|
export declare const Uint8: Codec<import("../barrel.js").NumLike, number>;
|
|
4
|
+
export declare const Uint8Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
5
|
+
export declare const Uint8Vec: Codec<import("../barrel.js").NumLike[], number[]>;
|
|
5
6
|
export declare const Uint16LE: Codec<import("../barrel.js").NumLike, number>;
|
|
6
7
|
export declare const Uint16BE: Codec<import("../barrel.js").NumLike, number>;
|
|
7
8
|
export declare const Uint16: Codec<import("../barrel.js").NumLike, number>;
|
|
9
|
+
export declare const Uint16Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
10
|
+
export declare const Uint16Vec: Codec<import("../barrel.js").NumLike[], number[]>;
|
|
8
11
|
export declare const Uint32LE: Codec<import("../barrel.js").NumLike, number>;
|
|
9
12
|
export declare const Uint32BE: Codec<import("../barrel.js").NumLike, number>;
|
|
10
13
|
export declare const Uint32: Codec<import("../barrel.js").NumLike, number>;
|
|
14
|
+
export declare const Uint32Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
15
|
+
export declare const Uint32Vec: Codec<import("../barrel.js").NumLike[], number[]>;
|
|
11
16
|
export declare const Uint64LE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
12
17
|
export declare const Uint64BE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
13
18
|
export declare const Uint64: Codec<import("../barrel.js").NumLike, bigint>;
|
|
19
|
+
export declare const Uint64Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
20
|
+
export declare const Uint64Vec: Codec<import("../barrel.js").NumLike[], bigint[]>;
|
|
14
21
|
export declare const Uint128LE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
15
22
|
export declare const Uint128BE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
16
23
|
export declare const Uint128: Codec<import("../barrel.js").NumLike, bigint>;
|
|
24
|
+
export declare const Uint128Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
25
|
+
export declare const Uint128Vec: Codec<import("../barrel.js").NumLike[], bigint[]>;
|
|
17
26
|
export declare const Uint256LE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
18
27
|
export declare const Uint256BE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
19
28
|
export declare const Uint256: Codec<import("../barrel.js").NumLike, bigint>;
|
|
29
|
+
export declare const Uint256Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
30
|
+
export declare const Uint256Vec: Codec<import("../barrel.js").NumLike[], bigint[]>;
|
|
20
31
|
export declare const Uint512LE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
21
32
|
export declare const Uint512BE: Codec<import("../barrel.js").NumLike, bigint>;
|
|
22
33
|
export declare const Uint512: Codec<import("../barrel.js").NumLike, bigint>;
|
|
23
|
-
export declare const Uint8Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
24
|
-
export declare const Uint16Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
25
|
-
export declare const Uint32Opt: Codec<import("../barrel.js").NumLike | null | undefined, number | undefined>;
|
|
26
|
-
export declare const Uint64Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
27
|
-
export declare const Uint128Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
28
|
-
export declare const Uint256Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
29
34
|
export declare const Uint512Opt: Codec<import("../barrel.js").NumLike | null | undefined, bigint | undefined>;
|
|
35
|
+
export declare const Uint512Vec: Codec<import("../barrel.js").NumLike[], bigint[]>;
|
|
30
36
|
export declare const Bytes: Codec<HexLike, Hex>;
|
|
31
37
|
export declare const BytesOpt: Codec<import("../bytes/index.js").BytesLike | null | undefined, `0x${string}` | undefined>;
|
|
32
38
|
export declare const BytesVec: Codec<import("../bytes/index.js").BytesLike[], `0x${string}`[]>;
|
|
@@ -36,17 +42,4 @@ export declare const Byte32Vec: Codec<import("../bytes/index.js").BytesLike[], `
|
|
|
36
42
|
export declare const String: Codec<string, string>;
|
|
37
43
|
export declare const StringVec: Codec<string[], string[]>;
|
|
38
44
|
export declare const StringOpt: Codec<string | null | undefined, string | undefined>;
|
|
39
|
-
export declare const Hash: Codec<import("../bytes/index.js").BytesLike, `0x${string}`>;
|
|
40
|
-
export declare const HashType: Codec<ckb.HashTypeLike, ckb.HashType>;
|
|
41
|
-
export declare const Script: Codec<ckb.ScriptLike, ckb.Script>;
|
|
42
|
-
export declare const ScriptOpt: Codec<ckb.ScriptLike | null | undefined, ckb.Script | undefined>;
|
|
43
|
-
export declare const OutPoint: Codec<ckb.OutPointLike, ckb.OutPoint>;
|
|
44
|
-
export declare const CellInput: Codec<ckb.CellInputLike, ckb.CellInput>;
|
|
45
|
-
export declare const CellInputVec: Codec<ckb.CellInputLike[], ckb.CellInput[]>;
|
|
46
|
-
export declare const CellOutput: Codec<ckb.CellOutputLike, ckb.CellOutput>;
|
|
47
|
-
export declare const CellOutputVec: Codec<ckb.CellOutputLike[], ckb.CellOutput[]>;
|
|
48
|
-
export declare const DepType: Codec<ckb.DepTypeLike, ckb.DepType>;
|
|
49
|
-
export declare const CellDep: Codec<ckb.CellDepLike, ckb.CellDep>;
|
|
50
|
-
export declare const CellDepVec: Codec<ckb.CellDepLike[], ckb.CellDep[]>;
|
|
51
|
-
export declare const Transaction: Codec<ckb.TransactionLike, ckb.Transaction>;
|
|
52
45
|
//# sourceMappingURL=predefined.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predefined.d.ts","sourceRoot":"","sources":["../../src/molecule/predefined.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"predefined.d.ts","sourceRoot":"","sources":["../../src/molecule/predefined.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAW,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAW,KAAK,EAAoC,MAAM,YAAY,CAAC;AAE9E,eAAO,MAAM,KAAK,+CAAsB,CAAC;AACzC,eAAO,MAAM,QAAQ,8EAAgB,CAAC;AACtC,eAAO,MAAM,QAAQ,mDAAgB,CAAC;AAEtC,eAAO,MAAM,QAAQ,+CAAsB,CAAC;AAC5C,eAAO,MAAM,QAAQ,+CAAgB,CAAC;AACtC,eAAO,MAAM,MAAM,+CAAW,CAAC;AAC/B,eAAO,MAAM,SAAS,8EAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,mDAAiB,CAAC;AAExC,eAAO,MAAM,QAAQ,+CAAsB,CAAC;AAC5C,eAAO,MAAM,QAAQ,+CAAgB,CAAC;AACtC,eAAO,MAAM,MAAM,+CAAW,CAAC;AAC/B,eAAO,MAAM,SAAS,8EAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,mDAAiB,CAAC;AAExC,eAAO,MAAM,QAAQ,+CAAgB,CAAC;AACtC,eAAO,MAAM,QAAQ,+CAAU,CAAC;AAChC,eAAO,MAAM,MAAM,+CAAW,CA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byteVec, Codec, option,
|
|
3
|
+
import { byteVec, Codec, option, uint, uintNumber, vector } from "./codec.js";
|
|
5
4
|
export const Uint8 = uintNumber(1, true);
|
|
5
|
+
export const Uint8Opt = option(Uint8);
|
|
6
|
+
export const Uint8Vec = vector(Uint8);
|
|
6
7
|
export const Uint16LE = uintNumber(2, true);
|
|
7
8
|
export const Uint16BE = uintNumber(2);
|
|
8
9
|
export const Uint16 = Uint16LE;
|
|
10
|
+
export const Uint16Opt = option(Uint16);
|
|
11
|
+
export const Uint16Vec = vector(Uint16);
|
|
9
12
|
export const Uint32LE = uintNumber(4, true);
|
|
10
13
|
export const Uint32BE = uintNumber(4);
|
|
11
14
|
export const Uint32 = Uint32LE;
|
|
15
|
+
export const Uint32Opt = option(Uint32);
|
|
16
|
+
export const Uint32Vec = vector(Uint32);
|
|
12
17
|
export const Uint64LE = uint(8, true);
|
|
13
18
|
export const Uint64BE = uint(8);
|
|
14
19
|
export const Uint64 = Uint64LE;
|
|
20
|
+
export const Uint64Opt = option(Uint64);
|
|
21
|
+
export const Uint64Vec = vector(Uint64);
|
|
15
22
|
export const Uint128LE = uint(16, true);
|
|
16
23
|
export const Uint128BE = uint(16);
|
|
17
24
|
export const Uint128 = Uint128LE;
|
|
25
|
+
export const Uint128Opt = option(Uint128);
|
|
26
|
+
export const Uint128Vec = vector(Uint128);
|
|
18
27
|
export const Uint256LE = uint(32, true);
|
|
19
28
|
export const Uint256BE = uint(32);
|
|
20
29
|
export const Uint256 = Uint256LE;
|
|
30
|
+
export const Uint256Opt = option(Uint256);
|
|
31
|
+
export const Uint256Vec = vector(Uint256);
|
|
21
32
|
export const Uint512LE = uint(64, true);
|
|
22
33
|
export const Uint512BE = uint(64);
|
|
23
34
|
export const Uint512 = Uint512LE;
|
|
24
|
-
export const Uint8Opt = option(Uint8);
|
|
25
|
-
export const Uint16Opt = option(Uint16);
|
|
26
|
-
export const Uint32Opt = option(Uint32);
|
|
27
|
-
export const Uint64Opt = option(Uint64);
|
|
28
|
-
export const Uint128Opt = option(Uint128);
|
|
29
|
-
export const Uint256Opt = option(Uint256);
|
|
30
35
|
export const Uint512Opt = option(Uint512);
|
|
36
|
+
export const Uint512Vec = vector(Uint512);
|
|
31
37
|
export const Bytes = byteVec({
|
|
32
38
|
encode: (value) => bytesFrom(value),
|
|
33
39
|
decode: (buffer) => hexFrom(buffer),
|
|
@@ -47,49 +53,3 @@ export const String = byteVec({
|
|
|
47
53
|
});
|
|
48
54
|
export const StringVec = vector(String);
|
|
49
55
|
export const StringOpt = option(String);
|
|
50
|
-
export const Hash = Byte32;
|
|
51
|
-
export const HashType = Codec.from({
|
|
52
|
-
byteLength: 1,
|
|
53
|
-
encode: ckb.hashTypeToBytes,
|
|
54
|
-
decode: ckb.hashTypeFromBytes,
|
|
55
|
-
});
|
|
56
|
-
export const Script = table({
|
|
57
|
-
codeHash: Hash,
|
|
58
|
-
hashType: HashType,
|
|
59
|
-
args: Bytes,
|
|
60
|
-
}).map({ outMap: ckb.Script.from });
|
|
61
|
-
export const ScriptOpt = option(Script);
|
|
62
|
-
export const OutPoint = struct({
|
|
63
|
-
txHash: Hash,
|
|
64
|
-
index: Uint32,
|
|
65
|
-
}).map({ outMap: ckb.OutPoint.from });
|
|
66
|
-
export const CellInput = struct({
|
|
67
|
-
previousOutput: OutPoint,
|
|
68
|
-
since: Uint64,
|
|
69
|
-
}).map({ outMap: ckb.CellInput.from });
|
|
70
|
-
export const CellInputVec = vector(CellInput);
|
|
71
|
-
export const CellOutput = table({
|
|
72
|
-
capacity: Uint64,
|
|
73
|
-
lock: Script,
|
|
74
|
-
type: ScriptOpt,
|
|
75
|
-
}).map({ outMap: ckb.CellOutput.from });
|
|
76
|
-
export const CellOutputVec = vector(CellOutput);
|
|
77
|
-
export const DepType = Codec.from({
|
|
78
|
-
byteLength: 1,
|
|
79
|
-
encode: ckb.depTypeToBytes,
|
|
80
|
-
decode: ckb.depTypeFromBytes,
|
|
81
|
-
});
|
|
82
|
-
export const CellDep = struct({
|
|
83
|
-
outPoint: OutPoint,
|
|
84
|
-
depType: DepType,
|
|
85
|
-
}).map({ outMap: ckb.CellDep.from });
|
|
86
|
-
export const CellDepVec = vector(CellDep);
|
|
87
|
-
export const Transaction = table({
|
|
88
|
-
version: Uint32,
|
|
89
|
-
cellDeps: CellDepVec,
|
|
90
|
-
headerDeps: Byte32Vec,
|
|
91
|
-
inputs: CellInputVec,
|
|
92
|
-
outputs: CellOutputVec,
|
|
93
|
-
outputsData: BytesVec,
|
|
94
|
-
witnesses: BytesVec,
|
|
95
|
-
}).map({ outMap: ckb.Transaction.from });
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export declare function reduceAsync<T>(values: T[], accumulator: (a: T, b: T) =>
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function reduceAsync<T, V>(values: V[], accumulator: (a: T, b: V, i: number, values: V[]) => Promise<T | undefined | null | void> | T | undefined | null | void, init: T | Promise<T>): Promise<T>;
|
|
85
85
|
export declare function sleep(ms: NumLike): Promise<unknown>;
|
|
86
|
+
export type Constructor<T> = {
|
|
87
|
+
new (...args: any[]): T;
|
|
88
|
+
};
|
|
86
89
|
/**
|
|
87
90
|
* @public
|
|
88
91
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAW,MAAM,iBAAiB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,GACf,SAAS,CAAC;AACb;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS,CAAC;AAChF;;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I,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAAC;AAqCd,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,oBAEhC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAE3B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDRESS_BECH32_LIMIT = exports.AddressFormat = void 0;
|
|
4
|
+
exports.addressPayloadFromString = addressPayloadFromString;
|
|
5
|
+
exports.addressFromPayload = addressFromPayload;
|
|
6
|
+
const bech32_1 = require("bech32");
|
|
7
|
+
const index_js_1 = require("../ckb/index.js");
|
|
8
|
+
const index_js_2 = require("../client/index.js");
|
|
9
|
+
const index_js_3 = require("../hex/index.js");
|
|
5
10
|
/**
|
|
6
11
|
* Parses an address string into an address information object.
|
|
7
12
|
*
|
|
@@ -18,11 +23,11 @@ import { hexFrom } from "../hex/index.js";
|
|
|
18
23
|
* console.log(addressInfo.payload); // Outputs the payload array
|
|
19
24
|
* ```
|
|
20
25
|
*/
|
|
21
|
-
|
|
26
|
+
function addressPayloadFromString(address) {
|
|
22
27
|
// Try parse full format address
|
|
23
28
|
try {
|
|
24
|
-
const { words, prefix } = bech32m.decode(address, ADDRESS_BECH32_LIMIT);
|
|
25
|
-
const [formatType, ...payload] = bech32m.fromWords(words);
|
|
29
|
+
const { words, prefix } = bech32_1.bech32m.decode(address, exports.ADDRESS_BECH32_LIMIT);
|
|
30
|
+
const [formatType, ...payload] = bech32_1.bech32m.fromWords(words);
|
|
26
31
|
if (formatType === AddressFormat.Full) {
|
|
27
32
|
return { prefix, format: AddressFormat.Full, payload };
|
|
28
33
|
}
|
|
@@ -30,8 +35,8 @@ export function addressPayloadFromString(address) {
|
|
|
30
35
|
catch (_) { }
|
|
31
36
|
// Try parse legacy 2019 format address
|
|
32
37
|
try {
|
|
33
|
-
const { prefix, words } = bech32.decode(address, ADDRESS_BECH32_LIMIT);
|
|
34
|
-
const [formatType, ...payload] = bech32.fromWords(words);
|
|
38
|
+
const { prefix, words } = bech32_1.bech32.decode(address, exports.ADDRESS_BECH32_LIMIT);
|
|
39
|
+
const [formatType, ...payload] = bech32_1.bech32.fromWords(words);
|
|
35
40
|
if ([
|
|
36
41
|
AddressFormat.FullData,
|
|
37
42
|
AddressFormat.FullType,
|
|
@@ -61,15 +66,15 @@ export function addressPayloadFromString(address) {
|
|
|
61
66
|
* console.log(address.prefix); // Outputs the address prefix
|
|
62
67
|
* ```
|
|
63
68
|
*/
|
|
64
|
-
|
|
69
|
+
async function addressFromPayload(prefix, format, payload, client) {
|
|
65
70
|
if (format === AddressFormat.Full) {
|
|
66
71
|
if (payload.length < 32 + 1) {
|
|
67
|
-
throw new Error(`Invalid full address without enough payload ${hexFrom(payload)}`);
|
|
72
|
+
throw new Error(`Invalid full address without enough payload ${(0, index_js_3.hexFrom)(payload)}`);
|
|
68
73
|
}
|
|
69
74
|
return {
|
|
70
75
|
script: {
|
|
71
76
|
codeHash: payload.slice(0, 32),
|
|
72
|
-
hashType: hashTypeFromBytes(payload.slice(32, 33)),
|
|
77
|
+
hashType: (0, index_js_1.hashTypeFromBytes)(payload.slice(32, 33)),
|
|
73
78
|
args: payload.slice(33),
|
|
74
79
|
},
|
|
75
80
|
prefix,
|
|
@@ -77,7 +82,7 @@ export async function addressFromPayload(prefix, format, payload, client) {
|
|
|
77
82
|
}
|
|
78
83
|
if (format === AddressFormat.FullData) {
|
|
79
84
|
if (payload.length < 32) {
|
|
80
|
-
throw new Error(`Invalid full data address without enough payload ${hexFrom(payload)}`);
|
|
85
|
+
throw new Error(`Invalid full data address without enough payload ${(0, index_js_3.hexFrom)(payload)}`);
|
|
81
86
|
}
|
|
82
87
|
return {
|
|
83
88
|
script: {
|
|
@@ -90,7 +95,7 @@ export async function addressFromPayload(prefix, format, payload, client) {
|
|
|
90
95
|
}
|
|
91
96
|
if (format === AddressFormat.FullType) {
|
|
92
97
|
if (payload.length < 32) {
|
|
93
|
-
throw new Error(`Invalid full type address without enough payload ${hexFrom(payload)}`);
|
|
98
|
+
throw new Error(`Invalid full type address without enough payload ${(0, index_js_3.hexFrom)(payload)}`);
|
|
94
99
|
}
|
|
95
100
|
return {
|
|
96
101
|
script: {
|
|
@@ -103,22 +108,22 @@ export async function addressFromPayload(prefix, format, payload, client) {
|
|
|
103
108
|
}
|
|
104
109
|
// format === AddressFormat.Short
|
|
105
110
|
if (payload.length !== 21) {
|
|
106
|
-
throw new Error(`Invalid short address without enough payload ${hexFrom(payload)}`);
|
|
111
|
+
throw new Error(`Invalid short address without enough payload ${(0, index_js_3.hexFrom)(payload)}`);
|
|
107
112
|
}
|
|
108
113
|
const script = [
|
|
109
|
-
KnownScript.Secp256k1Blake160,
|
|
110
|
-
KnownScript.Secp256k1Multisig,
|
|
111
|
-
KnownScript.AnyoneCanPay,
|
|
114
|
+
index_js_2.KnownScript.Secp256k1Blake160,
|
|
115
|
+
index_js_2.KnownScript.Secp256k1Multisig,
|
|
116
|
+
index_js_2.KnownScript.AnyoneCanPay,
|
|
112
117
|
][payload[0]];
|
|
113
118
|
if (script === undefined) {
|
|
114
|
-
throw new Error(`Invalid short address with unknown script ${hexFrom(payload)}`);
|
|
119
|
+
throw new Error(`Invalid short address with unknown script ${(0, index_js_3.hexFrom)(payload)}`);
|
|
115
120
|
}
|
|
116
121
|
return {
|
|
117
|
-
script: await Script.fromKnownScript(client, script, payload.slice(1)),
|
|
122
|
+
script: await index_js_1.Script.fromKnownScript(client, script, payload.slice(1)),
|
|
118
123
|
prefix,
|
|
119
124
|
};
|
|
120
125
|
}
|
|
121
|
-
|
|
126
|
+
var AddressFormat;
|
|
122
127
|
(function (AddressFormat) {
|
|
123
128
|
/**
|
|
124
129
|
* full version identifies the hashType
|
|
@@ -139,5 +144,5 @@ export var AddressFormat;
|
|
|
139
144
|
* full version with hashType = "Type", deprecated
|
|
140
145
|
*/
|
|
141
146
|
AddressFormat[AddressFormat["FullType"] = 4] = "FullType";
|
|
142
|
-
})(AddressFormat || (AddressFormat = {}));
|
|
143
|
-
|
|
147
|
+
})(AddressFormat || (exports.AddressFormat = AddressFormat = {}));
|
|
148
|
+
exports.ADDRESS_BECH32_LIMIT = 1023;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./address.advanced.js"), exports);
|