@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"}
|
|
@@ -14,11 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
|
|
20
|
-
if (mol.hasValue()) {
|
|
21
|
-
return mol.value();
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
17
|
+
__exportStar(require("./codec.js"), exports);
|
|
18
|
+
__exportStar(require("./entity.js"), exports);
|
|
19
|
+
__exportStar(require("./predefined.js"), exports);
|
|
@@ -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,M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AAS,EAAE,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,EACxC,SAAS,EAAE,MAAM,GAChB,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAsCzC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAClB,UAAU,EAAE,MAAM,EAClB,YAAY,UAAQ,GACnB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAkBrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,YAAY,UAAQ,GACnB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAOxB"}
|
|
@@ -71,7 +71,7 @@ function fixedItemVec(itemCodec) {
|
|
|
71
71
|
}
|
|
72
72
|
try {
|
|
73
73
|
const decodedArray = [];
|
|
74
|
-
for (let offset =
|
|
74
|
+
for (let offset = 4; offset < byteLength; offset += itemByteLength) {
|
|
75
75
|
decodedArray.push(itemCodec.decode(value.slice(offset, offset + itemByteLength)));
|
|
76
76
|
}
|
|
77
77
|
return decodedArray;
|
|
@@ -112,12 +112,15 @@ function dynItemVec(itemCodec) {
|
|
|
112
112
|
},
|
|
113
113
|
decode(buffer) {
|
|
114
114
|
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
115
|
+
if (value.byteLength < 4) {
|
|
116
|
+
throw new Error(`dynItemVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`);
|
|
117
|
+
}
|
|
115
118
|
const byteLength = uint32From(value.slice(0, 4));
|
|
116
119
|
if (byteLength !== value.byteLength) {
|
|
117
120
|
throw new Error(`dynItemVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`);
|
|
118
121
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
122
|
+
if (byteLength === 4) {
|
|
123
|
+
return [];
|
|
121
124
|
}
|
|
122
125
|
const offset = uint32From(value.slice(4, 8));
|
|
123
126
|
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;mBACQ,KAAK;QAMhB;;;;WAIG;iBACM,OAAO;QAMhB;;;;;WAKG;kBACO,WAAW,GAAG,OAAO,GAAG,OAAO;QAezC;;;;WAIG;gBACK,GAAG;;QA3GX;;;;WAIG;qBACiB,MAAM;QAC1B;;;;;;;WAOG;kBACc,WAAW,GAAG,KAAK;QAKpC;;;;;;;WAOG;kBACc,SAAS,GAAG,OAAO;QAMpC;;;;;;;WAOG;0BACsB,SAAS,GAAG,OAAO;QAM5C;;;;;;;WAOG;gBACY,WAAW,GAAG,OAAO;;IA4DxC,QAAQ,CAAC,OAAO,IAAI,KAAK;IACzB,QAAQ,CAAC,IAAI,IAAI,GAAG;IACpB,QAAQ,CAAC,KAAK,IAAI,MAAM;CACzB;AAED,wBAAgB,KAAK,CACnB,SAAS,EACT,QAAQ,SAAS,SAAS,EAC1B,OAAO,SAAS,QAAQ,EACxB,IAAI,SAAS,MAAM,GAAG,QAAQ,EAC9B,eAAe,SAAS;IAEtB,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IACnC,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACnC,EACD,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,iBACF,eAAe;kBAR7B,GAAG,EAAE;;sBAWQ,QAAQ,GAAG,KAAK;sBAGhB,SAAS,GAAG,IAAI;qBAIjB,SAAS,GAAG,IAAI;kBAjB5B,QAAQ,GAAG,IAAI;oBAsBhC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Entity = void 0;
|
|
4
|
+
exports.codec = codec;
|
|
5
|
+
const index_js_1 = require("../bytes/index.js");
|
|
6
|
+
const index_js_2 = require("../hasher/index.js");
|
|
7
|
+
/**
|
|
8
|
+
* The base class of CCC to create a serializable instance
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class Entity {
|
|
12
|
+
static Base() {
|
|
13
|
+
class Impl {
|
|
14
|
+
/**
|
|
15
|
+
* Encode the entity into bytes
|
|
16
|
+
* @public
|
|
17
|
+
* @static
|
|
18
|
+
* @param _ - The entity to encode
|
|
19
|
+
* @returns The encoded bytes
|
|
20
|
+
* @throws Will throw an error if the entity is not serializable
|
|
21
|
+
*/
|
|
22
|
+
static encode(_) {
|
|
23
|
+
throw new Error("encode not implemented, use @ccc.mol.codec to decorate your type");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Decode the entity from bytes
|
|
27
|
+
* @public
|
|
28
|
+
* @static
|
|
29
|
+
* @param _ - The bytes to decode
|
|
30
|
+
* @returns The decoded entity
|
|
31
|
+
* @throws Will throw an error if the entity is not serializable
|
|
32
|
+
*/
|
|
33
|
+
static decode(_) {
|
|
34
|
+
throw new Error("decode not implemented, use @ccc.mol.codec to decorate your type");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create an entity from bytes
|
|
38
|
+
* @public
|
|
39
|
+
* @static
|
|
40
|
+
* @param _ - The bytes to create the entity from
|
|
41
|
+
* @returns The created entity
|
|
42
|
+
* @throws Will throw an error if the entity is not serializable
|
|
43
|
+
*/
|
|
44
|
+
static fromBytes(_bytes) {
|
|
45
|
+
throw new Error("fromBytes not implemented, use @ccc.mol.codec to decorate your type");
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create an entity from a serializable object
|
|
49
|
+
* @public
|
|
50
|
+
* @static
|
|
51
|
+
* @param _ - The serializable object to create the entity from
|
|
52
|
+
* @returns The created entity
|
|
53
|
+
* @throws Will throw an error if the entity is not serializable
|
|
54
|
+
*/
|
|
55
|
+
static from(_) {
|
|
56
|
+
throw new Error("from not implemented");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Convert the entity to bytes
|
|
60
|
+
* @public
|
|
61
|
+
* @returns The bytes representation of the entity
|
|
62
|
+
*/
|
|
63
|
+
toBytes() {
|
|
64
|
+
return this.constructor.encode(this);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a clone of the entity
|
|
68
|
+
* @public
|
|
69
|
+
* @returns A clone of the entity
|
|
70
|
+
*/
|
|
71
|
+
clone() {
|
|
72
|
+
return this.constructor.fromBytes(this.toBytes());
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if the entity is equal to another entity
|
|
76
|
+
* @public
|
|
77
|
+
* @param other - The other entity to compare with
|
|
78
|
+
* @returns True if the entities are equal, false otherwise
|
|
79
|
+
*/
|
|
80
|
+
eq(other) {
|
|
81
|
+
if (this === other) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return (0, index_js_1.bytesEq)(this.toBytes(),
|
|
85
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any */
|
|
86
|
+
(this.constructor?.from(other) ?? other).toBytes());
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Calculate the hash of the entity
|
|
90
|
+
* @public
|
|
91
|
+
* @returns The hash of the entity
|
|
92
|
+
*/
|
|
93
|
+
hash() {
|
|
94
|
+
return (0, index_js_2.hashCkb)(this.toBytes());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return Impl;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.Entity = Entity;
|
|
101
|
+
function codec(codec) {
|
|
102
|
+
return function (Constructor) {
|
|
103
|
+
var _a;
|
|
104
|
+
return _a = class Extended extends Constructor {
|
|
105
|
+
static encode(encodable) {
|
|
106
|
+
return codec.encode(encodable);
|
|
107
|
+
}
|
|
108
|
+
static decode(bytesLike) {
|
|
109
|
+
return Constructor.from(codec.decode(bytesLike));
|
|
110
|
+
}
|
|
111
|
+
static fromBytes(bytes) {
|
|
112
|
+
return Constructor.from(codec.decode(bytes));
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
_a.byteLength = codec.byteLength,
|
|
116
|
+
_a;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -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"}
|
|
@@ -10,9 +10,18 @@ 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
|
|
14
|
-
|
|
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
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
15
24
|
};
|
|
16
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
exports.mol = void 0;
|
|
27
|
+
exports.mol = __importStar(require("./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,CAAC;AAC/B,eAAO,MAAM,SAAS,8EAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,mDAAiB,CAAC;AAExC,eAAO,MAAM,SAAS,+CAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,+CAAW,CAAC;AAClC,eAAO,MAAM,OAAO,+CAAY,CAAC;AACjC,eAAO,MAAM,UAAU,8EAAkB,CAAC;AAC1C,eAAO,MAAM,UAAU,mDAAkB,CAAC;AAE1C,eAAO,MAAM,SAAS,+CAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,+CAAW,CAAC;AAClC,eAAO,MAAM,OAAO,+CAAY,CAAC;AACjC,eAAO,MAAM,UAAU,8EAAkB,CAAC;AAC1C,eAAO,MAAM,UAAU,mDAAkB,CAAC;AAE1C,eAAO,MAAM,SAAS,+CAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,+CAAW,CAAC;AAClC,eAAO,MAAM,OAAO,+CAAY,CAAC;AACjC,eAAO,MAAM,UAAU,8EAAkB,CAAC;AAC1C,eAAO,MAAM,UAAU,mDAAkB,CAAC;AAE1C,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,CAGpC,CAAC;AACH,eAAO,MAAM,QAAQ,4FAAgB,CAAC;AACtC,eAAO,MAAM,QAAQ,iEAAgB,CAAC;AAEtC,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,GAAG,CAIrC,CAAC;AACH,eAAO,MAAM,SAAS,4FAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,iEAAiB,CAAC;AAExC,eAAO,MAAM,MAAM,uBAGjB,CAAC;AACH,eAAO,MAAM,SAAS,2BAAiB,CAAC;AACxC,eAAO,MAAM,SAAS,sDAAiB,CAAC"}
|
|
@@ -1,59 +1,42 @@
|
|
|
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 __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
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
3
|
+
exports.StringOpt = exports.StringVec = exports.String = exports.Byte32Vec = exports.Byte32Opt = exports.Byte32 = exports.BytesVec = exports.BytesOpt = exports.Bytes = exports.Uint512Vec = exports.Uint512Opt = exports.Uint512 = exports.Uint512BE = exports.Uint512LE = exports.Uint256Vec = exports.Uint256Opt = exports.Uint256 = exports.Uint256BE = exports.Uint256LE = exports.Uint128Vec = exports.Uint128Opt = exports.Uint128 = exports.Uint128BE = exports.Uint128LE = exports.Uint64Vec = exports.Uint64Opt = exports.Uint64 = exports.Uint64BE = exports.Uint64LE = exports.Uint32Vec = exports.Uint32Opt = exports.Uint32 = exports.Uint32BE = exports.Uint32LE = exports.Uint16Vec = exports.Uint16Opt = exports.Uint16 = exports.Uint16BE = exports.Uint16LE = exports.Uint8Vec = exports.Uint8Opt = exports.Uint8 = void 0;
|
|
27
4
|
const index_js_1 = require("../bytes/index.js");
|
|
28
|
-
const ckb = __importStar(require("../ckb/index.js"));
|
|
29
5
|
const index_js_2 = require("../hex/index.js");
|
|
30
6
|
const codec_js_1 = require("./codec.js");
|
|
31
7
|
exports.Uint8 = (0, codec_js_1.uintNumber)(1, true);
|
|
8
|
+
exports.Uint8Opt = (0, codec_js_1.option)(exports.Uint8);
|
|
9
|
+
exports.Uint8Vec = (0, codec_js_1.vector)(exports.Uint8);
|
|
32
10
|
exports.Uint16LE = (0, codec_js_1.uintNumber)(2, true);
|
|
33
11
|
exports.Uint16BE = (0, codec_js_1.uintNumber)(2);
|
|
34
12
|
exports.Uint16 = exports.Uint16LE;
|
|
13
|
+
exports.Uint16Opt = (0, codec_js_1.option)(exports.Uint16);
|
|
14
|
+
exports.Uint16Vec = (0, codec_js_1.vector)(exports.Uint16);
|
|
35
15
|
exports.Uint32LE = (0, codec_js_1.uintNumber)(4, true);
|
|
36
16
|
exports.Uint32BE = (0, codec_js_1.uintNumber)(4);
|
|
37
17
|
exports.Uint32 = exports.Uint32LE;
|
|
18
|
+
exports.Uint32Opt = (0, codec_js_1.option)(exports.Uint32);
|
|
19
|
+
exports.Uint32Vec = (0, codec_js_1.vector)(exports.Uint32);
|
|
38
20
|
exports.Uint64LE = (0, codec_js_1.uint)(8, true);
|
|
39
21
|
exports.Uint64BE = (0, codec_js_1.uint)(8);
|
|
40
22
|
exports.Uint64 = exports.Uint64LE;
|
|
23
|
+
exports.Uint64Opt = (0, codec_js_1.option)(exports.Uint64);
|
|
24
|
+
exports.Uint64Vec = (0, codec_js_1.vector)(exports.Uint64);
|
|
41
25
|
exports.Uint128LE = (0, codec_js_1.uint)(16, true);
|
|
42
26
|
exports.Uint128BE = (0, codec_js_1.uint)(16);
|
|
43
27
|
exports.Uint128 = exports.Uint128LE;
|
|
28
|
+
exports.Uint128Opt = (0, codec_js_1.option)(exports.Uint128);
|
|
29
|
+
exports.Uint128Vec = (0, codec_js_1.vector)(exports.Uint128);
|
|
44
30
|
exports.Uint256LE = (0, codec_js_1.uint)(32, true);
|
|
45
31
|
exports.Uint256BE = (0, codec_js_1.uint)(32);
|
|
46
32
|
exports.Uint256 = exports.Uint256LE;
|
|
33
|
+
exports.Uint256Opt = (0, codec_js_1.option)(exports.Uint256);
|
|
34
|
+
exports.Uint256Vec = (0, codec_js_1.vector)(exports.Uint256);
|
|
47
35
|
exports.Uint512LE = (0, codec_js_1.uint)(64, true);
|
|
48
36
|
exports.Uint512BE = (0, codec_js_1.uint)(64);
|
|
49
37
|
exports.Uint512 = exports.Uint512LE;
|
|
50
|
-
exports.Uint8Opt = (0, codec_js_1.option)(exports.Uint8);
|
|
51
|
-
exports.Uint16Opt = (0, codec_js_1.option)(exports.Uint16);
|
|
52
|
-
exports.Uint32Opt = (0, codec_js_1.option)(exports.Uint32);
|
|
53
|
-
exports.Uint64Opt = (0, codec_js_1.option)(exports.Uint64);
|
|
54
|
-
exports.Uint128Opt = (0, codec_js_1.option)(exports.Uint128);
|
|
55
|
-
exports.Uint256Opt = (0, codec_js_1.option)(exports.Uint256);
|
|
56
38
|
exports.Uint512Opt = (0, codec_js_1.option)(exports.Uint512);
|
|
39
|
+
exports.Uint512Vec = (0, codec_js_1.vector)(exports.Uint512);
|
|
57
40
|
exports.Bytes = (0, codec_js_1.byteVec)({
|
|
58
41
|
encode: (value) => (0, index_js_1.bytesFrom)(value),
|
|
59
42
|
decode: (buffer) => (0, index_js_2.hexFrom)(buffer),
|
|
@@ -73,49 +56,3 @@ exports.String = (0, codec_js_1.byteVec)({
|
|
|
73
56
|
});
|
|
74
57
|
exports.StringVec = (0, codec_js_1.vector)(exports.String);
|
|
75
58
|
exports.StringOpt = (0, codec_js_1.option)(exports.String);
|
|
76
|
-
exports.Hash = exports.Byte32;
|
|
77
|
-
exports.HashType = codec_js_1.Codec.from({
|
|
78
|
-
byteLength: 1,
|
|
79
|
-
encode: ckb.hashTypeToBytes,
|
|
80
|
-
decode: ckb.hashTypeFromBytes,
|
|
81
|
-
});
|
|
82
|
-
exports.Script = (0, codec_js_1.table)({
|
|
83
|
-
codeHash: exports.Hash,
|
|
84
|
-
hashType: exports.HashType,
|
|
85
|
-
args: exports.Bytes,
|
|
86
|
-
}).map({ outMap: ckb.Script.from });
|
|
87
|
-
exports.ScriptOpt = (0, codec_js_1.option)(exports.Script);
|
|
88
|
-
exports.OutPoint = (0, codec_js_1.struct)({
|
|
89
|
-
txHash: exports.Hash,
|
|
90
|
-
index: exports.Uint32,
|
|
91
|
-
}).map({ outMap: ckb.OutPoint.from });
|
|
92
|
-
exports.CellInput = (0, codec_js_1.struct)({
|
|
93
|
-
previousOutput: exports.OutPoint,
|
|
94
|
-
since: exports.Uint64,
|
|
95
|
-
}).map({ outMap: ckb.CellInput.from });
|
|
96
|
-
exports.CellInputVec = (0, codec_js_1.vector)(exports.CellInput);
|
|
97
|
-
exports.CellOutput = (0, codec_js_1.table)({
|
|
98
|
-
capacity: exports.Uint64,
|
|
99
|
-
lock: exports.Script,
|
|
100
|
-
type: exports.ScriptOpt,
|
|
101
|
-
}).map({ outMap: ckb.CellOutput.from });
|
|
102
|
-
exports.CellOutputVec = (0, codec_js_1.vector)(exports.CellOutput);
|
|
103
|
-
exports.DepType = codec_js_1.Codec.from({
|
|
104
|
-
byteLength: 1,
|
|
105
|
-
encode: ckb.depTypeToBytes,
|
|
106
|
-
decode: ckb.depTypeFromBytes,
|
|
107
|
-
});
|
|
108
|
-
exports.CellDep = (0, codec_js_1.struct)({
|
|
109
|
-
outPoint: exports.OutPoint,
|
|
110
|
-
depType: exports.DepType,
|
|
111
|
-
}).map({ outMap: ckb.CellDep.from });
|
|
112
|
-
exports.CellDepVec = (0, codec_js_1.vector)(exports.CellDep);
|
|
113
|
-
exports.Transaction = (0, codec_js_1.table)({
|
|
114
|
-
version: exports.Uint32,
|
|
115
|
-
cellDeps: exports.CellDepVec,
|
|
116
|
-
headerDeps: exports.Byte32Vec,
|
|
117
|
-
inputs: exports.CellInputVec,
|
|
118
|
-
outputs: exports.CellOutputVec,
|
|
119
|
-
outputsData: exports.BytesVec,
|
|
120
|
-
witnesses: exports.BytesVec,
|
|
121
|
-
}).map({ outMap: ckb.Transaction.from });
|
|
@@ -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;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;AACrE;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAC1B,KAAK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,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAEpD"}
|
package/package.json
CHANGED
package/src/barrel.ts
CHANGED
|
@@ -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";
|
package/src/bytes/index.ts
CHANGED
|
@@ -118,3 +118,37 @@ export function bytesFrom(
|
|
|
118
118
|
}
|
|
119
119
|
return new Uint8Array(bytes);
|
|
120
120
|
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Compares two byte-like values for equality.
|
|
124
|
+
* @public
|
|
125
|
+
*
|
|
126
|
+
* @param a - The first byte-like value to compare.
|
|
127
|
+
* @param b - The second byte-like value to compare.
|
|
128
|
+
* @returns A boolean indicating whether the two byte-like values are equal.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* bytesEq([1], Uint8Array.from([1])) // true
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export function bytesEq(a: BytesLike, b: BytesLike): boolean {
|
|
136
|
+
if (a === b) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const x = bytesFrom(a);
|
|
141
|
+
const y = bytesFrom(b);
|
|
142
|
+
|
|
143
|
+
if (x.length !== y.length) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < x.length; i++) {
|
|
148
|
+
if (x[i] !== y[i]) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return true;
|
|
154
|
+
}
|
package/src/ckb/advanced.ts
CHANGED