@ckb-ccc/core 0.1.2 → 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 +6 -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/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.d.ts.map +1 -1
- package/dist.commonjs/barrel.js +1 -14
- 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 +30 -0
- 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 +0 -14
- 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 +31 -102
- 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 +182 -408
- package/dist.commonjs/molecule/barrel.d.ts +4 -0
- package/dist.commonjs/molecule/barrel.d.ts.map +1 -0
- package/dist.commonjs/{ckb/molecule.advanced/index.js → molecule/barrel.js} +3 -8
- package/dist.commonjs/molecule/codec.d.ts.map +1 -1
- package/dist.commonjs/molecule/codec.js +6 -3
- 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 +13 -4
- 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 +14 -77
- package/dist.commonjs/utils/index.d.ts +3 -0
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- 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 -1535
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +0 -6
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts.map +0 -1
- 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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|
@@ -56,7 +56,7 @@ export function fixedItemVec(itemCodec) {
|
|
|
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,EAA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|
2
|
+
import { hashCkb } from "../hasher/index.js";
|
|
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,C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
import { hexFrom } from "../hex/index.js";
|
|
4
|
-
import { 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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AAS,GAAG,IAAI,GAAG,IAAI,EACvE,IAAI,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"}
|
|
@@ -6,7 +6,7 @@ export * from "./fixedPoint/index.js";
|
|
|
6
6
|
export * from "./hasher/index.js";
|
|
7
7
|
export * from "./hex/index.js";
|
|
8
8
|
export * from "./keystore/index.js";
|
|
9
|
-
export *
|
|
9
|
+
export * from "./molecule/index.js";
|
|
10
10
|
export * from "./num/index.js";
|
|
11
11
|
export * from "./signer/index.js";
|
|
12
12
|
export * from "./utils/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
|
package/dist.commonjs/barrel.js
CHANGED
|
@@ -10,23 +10,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
15
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.mol = void 0;
|
|
30
17
|
__exportStar(require("./address/index.js"), exports);
|
|
31
18
|
__exportStar(require("./bytes/index.js"), exports);
|
|
32
19
|
__exportStar(require("./ckb/index.js"), exports);
|
|
@@ -35,7 +22,7 @@ __exportStar(require("./fixedPoint/index.js"), exports);
|
|
|
35
22
|
__exportStar(require("./hasher/index.js"), exports);
|
|
36
23
|
__exportStar(require("./hex/index.js"), exports);
|
|
37
24
|
__exportStar(require("./keystore/index.js"), exports);
|
|
38
|
-
|
|
25
|
+
__exportStar(require("./molecule/index.js"), exports);
|
|
39
26
|
__exportStar(require("./num/index.js"), exports);
|
|
40
27
|
__exportStar(require("./signer/index.js"), exports);
|
|
41
28
|
__exportStar(require("./utils/index.js"), exports);
|
|
@@ -70,4 +70,18 @@ export declare function bytesTo(val: BytesLike, encoding: BytesFromEncoding): st
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export declare function bytesFrom(bytes: BytesLike, encoding?: BytesFromEncoding): Bytes;
|
|
73
|
+
/**
|
|
74
|
+
* Compares two byte-like values for equality.
|
|
75
|
+
* @public
|
|
76
|
+
*
|
|
77
|
+
* @param a - The first byte-like value to compare.
|
|
78
|
+
* @param b - The second byte-like value to compare.
|
|
79
|
+
* @returns A boolean indicating whether the two byte-like values are equal.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* bytesEq([1], Uint8Array.from([1])) // true
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function bytesEq(a: BytesLike, b: BytesLike): boolean;
|
|
73
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bytes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC;AAC/B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAOvD;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,EAChB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,KAAK,CA4BP"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bytes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC;AAC/B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAE9E;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAOvD;AAED;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAE3E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,EAChB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,KAAK,CA4BP;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAmB3D"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.bytesConcat = bytesConcat;
|
|
4
4
|
exports.bytesTo = bytesTo;
|
|
5
5
|
exports.bytesFrom = bytesFrom;
|
|
6
|
+
exports.bytesEq = bytesEq;
|
|
6
7
|
const index_js_1 = require("buffer/index.js");
|
|
7
8
|
/**
|
|
8
9
|
* Concatenates multiple byte-like arrays into a single byte array.
|
|
@@ -98,3 +99,32 @@ function bytesFrom(bytes, encoding) {
|
|
|
98
99
|
}
|
|
99
100
|
return new Uint8Array(bytes);
|
|
100
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Compares two byte-like values for equality.
|
|
104
|
+
* @public
|
|
105
|
+
*
|
|
106
|
+
* @param a - The first byte-like value to compare.
|
|
107
|
+
* @param b - The second byte-like value to compare.
|
|
108
|
+
* @returns A boolean indicating whether the two byte-like values are equal.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* bytesEq([1], Uint8Array.from([1])) // true
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
function bytesEq(a, b) {
|
|
116
|
+
if (a === b) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
const x = bytesFrom(a);
|
|
120
|
+
const y = bytesFrom(b);
|
|
121
|
+
if (x.length !== y.length) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
for (let i = 0; i < x.length; i++) {
|
|
125
|
+
if (x[i] !== y[i]) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/ckb/advanced.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../src/ckb/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
|