@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
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Codec = void 0;
|
|
5
|
+
exports.fixedItemVec = fixedItemVec;
|
|
6
|
+
exports.dynItemVec = dynItemVec;
|
|
7
|
+
exports.vector = vector;
|
|
8
|
+
exports.option = option;
|
|
9
|
+
exports.byteVec = byteVec;
|
|
10
|
+
exports.table = table;
|
|
11
|
+
exports.union = union;
|
|
12
|
+
exports.struct = struct;
|
|
13
|
+
exports.array = array;
|
|
14
|
+
exports.uint = uint;
|
|
15
|
+
exports.uintNumber = uintNumber;
|
|
16
|
+
const index_js_1 = require("../bytes/index.js");
|
|
17
|
+
const index_js_2 = require("../num/index.js");
|
|
18
|
+
class Codec {
|
|
5
19
|
constructor(encode, decode, byteLength) {
|
|
6
20
|
this.encode = encode;
|
|
7
21
|
this.decode = decode;
|
|
@@ -20,17 +34,18 @@ export class Codec {
|
|
|
20
34
|
});
|
|
21
35
|
}
|
|
22
36
|
}
|
|
37
|
+
exports.Codec = Codec;
|
|
23
38
|
function uint32To(numLike) {
|
|
24
|
-
return numToBytes(numLike, 4);
|
|
39
|
+
return (0, index_js_2.numToBytes)(numLike, 4);
|
|
25
40
|
}
|
|
26
41
|
function uint32From(bytesLike) {
|
|
27
|
-
return Number(numFromBytes(bytesLike));
|
|
42
|
+
return Number((0, index_js_2.numFromBytes)(bytesLike));
|
|
28
43
|
}
|
|
29
44
|
/**
|
|
30
45
|
* Vector with fixed size item codec
|
|
31
46
|
* @param itemCodec fixed-size vector item codec
|
|
32
47
|
*/
|
|
33
|
-
|
|
48
|
+
function fixedItemVec(itemCodec) {
|
|
34
49
|
const itemByteLength = itemCodec.byteLength;
|
|
35
50
|
if (itemByteLength === undefined) {
|
|
36
51
|
throw new Error("fixedItemVec: itemCodec requires a byte length");
|
|
@@ -38,14 +53,14 @@ export function fixedItemVec(itemCodec) {
|
|
|
38
53
|
return Codec.from({
|
|
39
54
|
encode(userDefinedItems) {
|
|
40
55
|
try {
|
|
41
|
-
return userDefinedItems.reduce((concatted, item) => bytesConcat(concatted, itemCodec.encode(item)), uint32To(userDefinedItems.length));
|
|
56
|
+
return userDefinedItems.reduce((concatted, item) => (0, index_js_1.bytesConcat)(concatted, itemCodec.encode(item)), uint32To(userDefinedItems.length));
|
|
42
57
|
}
|
|
43
58
|
catch (e) {
|
|
44
59
|
throw new Error(`fixedItemVec(${e?.toString()})`);
|
|
45
60
|
}
|
|
46
61
|
},
|
|
47
62
|
decode(buffer) {
|
|
48
|
-
const value = bytesFrom(buffer);
|
|
63
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
49
64
|
if (value.byteLength < 4) {
|
|
50
65
|
throw new Error(`fixedItemVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`);
|
|
51
66
|
}
|
|
@@ -56,7 +71,7 @@ export function fixedItemVec(itemCodec) {
|
|
|
56
71
|
}
|
|
57
72
|
try {
|
|
58
73
|
const decodedArray = [];
|
|
59
|
-
for (let offset =
|
|
74
|
+
for (let offset = 4; offset < byteLength; offset += itemByteLength) {
|
|
60
75
|
decodedArray.push(itemCodec.decode(value.slice(offset, offset + itemByteLength)));
|
|
61
76
|
}
|
|
62
77
|
return decodedArray;
|
|
@@ -71,7 +86,7 @@ export function fixedItemVec(itemCodec) {
|
|
|
71
86
|
* Vector with dynamic size item codec, you can create a recursive vector with this function
|
|
72
87
|
* @param itemCodec the vector item codec. It can be fixed-size or dynamic-size.
|
|
73
88
|
*/
|
|
74
|
-
|
|
89
|
+
function dynItemVec(itemCodec) {
|
|
75
90
|
return Codec.from({
|
|
76
91
|
encode(userDefinedItems) {
|
|
77
92
|
try {
|
|
@@ -79,30 +94,33 @@ export function dynItemVec(itemCodec) {
|
|
|
79
94
|
const encodedItem = itemCodec.encode(item);
|
|
80
95
|
const packedHeader = uint32To(offset);
|
|
81
96
|
return {
|
|
82
|
-
header: bytesConcat(header, packedHeader),
|
|
83
|
-
body: bytesConcat(body, encodedItem),
|
|
84
|
-
offset: offset + bytesFrom(encodedItem).byteLength,
|
|
97
|
+
header: (0, index_js_1.bytesConcat)(header, packedHeader),
|
|
98
|
+
body: (0, index_js_1.bytesConcat)(body, encodedItem),
|
|
99
|
+
offset: offset + (0, index_js_1.bytesFrom)(encodedItem).byteLength,
|
|
85
100
|
};
|
|
86
101
|
}, {
|
|
87
|
-
header: bytesFrom([]),
|
|
88
|
-
body: bytesFrom([]),
|
|
102
|
+
header: (0, index_js_1.bytesFrom)([]),
|
|
103
|
+
body: (0, index_js_1.bytesFrom)([]),
|
|
89
104
|
offset: 4 + userDefinedItems.length * 4,
|
|
90
105
|
});
|
|
91
106
|
const packedTotalSize = uint32To(encoded.header.byteLength + encoded.body.byteLength + 4);
|
|
92
|
-
return bytesConcat(packedTotalSize, encoded.header, encoded.body);
|
|
107
|
+
return (0, index_js_1.bytesConcat)(packedTotalSize, encoded.header, encoded.body);
|
|
93
108
|
}
|
|
94
109
|
catch (e) {
|
|
95
110
|
throw new Error(`dynItemVec(${e?.toString()})`);
|
|
96
111
|
}
|
|
97
112
|
},
|
|
98
113
|
decode(buffer) {
|
|
99
|
-
const value = bytesFrom(buffer);
|
|
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
|
+
}
|
|
100
118
|
const byteLength = uint32From(value.slice(0, 4));
|
|
101
119
|
if (byteLength !== value.byteLength) {
|
|
102
120
|
throw new Error(`dynItemVec: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`);
|
|
103
121
|
}
|
|
104
|
-
if (
|
|
105
|
-
|
|
122
|
+
if (byteLength === 4) {
|
|
123
|
+
return [];
|
|
106
124
|
}
|
|
107
125
|
const offset = uint32From(value.slice(4, 8));
|
|
108
126
|
const itemCount = (offset - 4) / 4;
|
|
@@ -128,7 +146,7 @@ export function dynItemVec(itemCodec) {
|
|
|
128
146
|
* General vector codec, if `itemCodec` is fixed size type, it will create a fixvec codec, otherwise a dynvec codec will be created.
|
|
129
147
|
* @param itemCodec
|
|
130
148
|
*/
|
|
131
|
-
|
|
149
|
+
function vector(itemCodec) {
|
|
132
150
|
if (itemCodec.byteLength !== undefined) {
|
|
133
151
|
return fixedItemVec(itemCodec);
|
|
134
152
|
}
|
|
@@ -141,11 +159,11 @@ export function vector(itemCodec) {
|
|
|
141
159
|
* - if it's not empty, just serialize the inner item (the size is same as the inner item's size).
|
|
142
160
|
* @param innerCodec
|
|
143
161
|
*/
|
|
144
|
-
|
|
162
|
+
function option(innerCodec) {
|
|
145
163
|
return Codec.from({
|
|
146
164
|
encode(userDefinedOrNull) {
|
|
147
165
|
if (!userDefinedOrNull) {
|
|
148
|
-
return bytesFrom([]);
|
|
166
|
+
return (0, index_js_1.bytesFrom)([]);
|
|
149
167
|
}
|
|
150
168
|
try {
|
|
151
169
|
return innerCodec.encode(userDefinedOrNull);
|
|
@@ -155,7 +173,7 @@ export function option(innerCodec) {
|
|
|
155
173
|
}
|
|
156
174
|
},
|
|
157
175
|
decode(buffer) {
|
|
158
|
-
const value = bytesFrom(buffer);
|
|
176
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
159
177
|
if (value.byteLength === 0) {
|
|
160
178
|
return undefined;
|
|
161
179
|
}
|
|
@@ -172,20 +190,20 @@ export function option(innerCodec) {
|
|
|
172
190
|
* Wrap the encoded value with a fixed-length buffer
|
|
173
191
|
* @param codec
|
|
174
192
|
*/
|
|
175
|
-
|
|
193
|
+
function byteVec(codec) {
|
|
176
194
|
return Codec.from({
|
|
177
195
|
encode(userDefined) {
|
|
178
196
|
try {
|
|
179
|
-
const payload = bytesFrom(codec.encode(userDefined));
|
|
197
|
+
const payload = (0, index_js_1.bytesFrom)(codec.encode(userDefined));
|
|
180
198
|
const byteLength = uint32To(payload.byteLength);
|
|
181
|
-
return bytesConcat(byteLength, payload);
|
|
199
|
+
return (0, index_js_1.bytesConcat)(byteLength, payload);
|
|
182
200
|
}
|
|
183
201
|
catch (e) {
|
|
184
202
|
throw new Error(`byteVec(${e?.toString()})`);
|
|
185
203
|
}
|
|
186
204
|
},
|
|
187
205
|
decode(buffer) {
|
|
188
|
-
const value = bytesFrom(buffer);
|
|
206
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
189
207
|
if (value.byteLength < 4) {
|
|
190
208
|
throw new Error(`byteVec: too short buffer, expected at least 4 bytes, but got ${value.byteLength}`);
|
|
191
209
|
}
|
|
@@ -206,7 +224,7 @@ export function byteVec(codec) {
|
|
|
206
224
|
* Table is a dynamic-size type. It can be considered as a dynvec but the length is fixed.
|
|
207
225
|
* @param codecLayout
|
|
208
226
|
*/
|
|
209
|
-
|
|
227
|
+
function table(codecLayout) {
|
|
210
228
|
const keys = Object.keys(codecLayout);
|
|
211
229
|
return Codec.from({
|
|
212
230
|
encode(object) {
|
|
@@ -216,24 +234,24 @@ export function table(codecLayout) {
|
|
|
216
234
|
const encodedItem = codecLayout[key].encode(object[key]);
|
|
217
235
|
const packedOffset = uint32To(result.offset);
|
|
218
236
|
return {
|
|
219
|
-
header: bytesConcat(result.header, packedOffset),
|
|
220
|
-
body: bytesConcat(result.body, encodedItem),
|
|
221
|
-
offset: result.offset + bytesFrom(encodedItem).byteLength,
|
|
237
|
+
header: (0, index_js_1.bytesConcat)(result.header, packedOffset),
|
|
238
|
+
body: (0, index_js_1.bytesConcat)(result.body, encodedItem),
|
|
239
|
+
offset: result.offset + (0, index_js_1.bytesFrom)(encodedItem).byteLength,
|
|
222
240
|
};
|
|
223
241
|
}
|
|
224
242
|
catch (e) {
|
|
225
243
|
throw new Error(`table.${key}(${e?.toString()})`);
|
|
226
244
|
}
|
|
227
245
|
}, {
|
|
228
|
-
header: bytesFrom([]),
|
|
229
|
-
body: bytesFrom([]),
|
|
246
|
+
header: (0, index_js_1.bytesFrom)([]),
|
|
247
|
+
body: (0, index_js_1.bytesFrom)([]),
|
|
230
248
|
offset: headerLength,
|
|
231
249
|
});
|
|
232
250
|
const packedTotalSize = uint32To(header.byteLength + body.byteLength + 4);
|
|
233
|
-
return bytesConcat(packedTotalSize, header, body);
|
|
251
|
+
return (0, index_js_1.bytesConcat)(packedTotalSize, header, body);
|
|
234
252
|
},
|
|
235
253
|
decode(buffer) {
|
|
236
|
-
const value = bytesFrom(buffer);
|
|
254
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
237
255
|
const byteLength = uint32From(value.slice(0, 4));
|
|
238
256
|
if (byteLength !== value.byteLength) {
|
|
239
257
|
throw new Error(`table: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`);
|
|
@@ -275,7 +293,7 @@ export function table(codecLayout) {
|
|
|
275
293
|
* // with custom id
|
|
276
294
|
* union({ cafe: Uint8, bee: Uint8 }, { cafe: 0xcafe, bee: 0xbee })
|
|
277
295
|
*/
|
|
278
|
-
|
|
296
|
+
function union(codecLayout, fields) {
|
|
279
297
|
const keys = Object.keys(codecLayout);
|
|
280
298
|
return Codec.from({
|
|
281
299
|
encode({ type, value }) {
|
|
@@ -291,14 +309,14 @@ export function union(codecLayout, fields) {
|
|
|
291
309
|
const header = uint32To(fieldId);
|
|
292
310
|
try {
|
|
293
311
|
const body = codec.encode(value);
|
|
294
|
-
return bytesConcat(header, body);
|
|
312
|
+
return (0, index_js_1.bytesConcat)(header, body);
|
|
295
313
|
}
|
|
296
314
|
catch (e) {
|
|
297
315
|
throw new Error(`union.(${typeStr})(${e?.toString()})`);
|
|
298
316
|
}
|
|
299
317
|
},
|
|
300
318
|
decode(buffer) {
|
|
301
|
-
const value = bytesFrom(buffer);
|
|
319
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
302
320
|
const fieldIndex = uint32From(value.slice(0, 4));
|
|
303
321
|
const keys = Object.keys(codecLayout);
|
|
304
322
|
const field = (() => {
|
|
@@ -328,7 +346,7 @@ export function union(codecLayout, fields) {
|
|
|
328
346
|
* The size of a struct is the sum of all fields' size.
|
|
329
347
|
* @param codecLayout a object contains all fields' codec
|
|
330
348
|
*/
|
|
331
|
-
|
|
349
|
+
function struct(codecLayout) {
|
|
332
350
|
const codecArray = Object.values(codecLayout);
|
|
333
351
|
if (codecArray.some((codec) => codec.byteLength === undefined)) {
|
|
334
352
|
throw new Error("struct: all fields must be fixed-size");
|
|
@@ -340,15 +358,15 @@ export function struct(codecLayout) {
|
|
|
340
358
|
return keys.reduce((result, key) => {
|
|
341
359
|
try {
|
|
342
360
|
const encodedItem = codecLayout[key].encode(object[key]);
|
|
343
|
-
return bytesConcat(result, encodedItem);
|
|
361
|
+
return (0, index_js_1.bytesConcat)(result, encodedItem);
|
|
344
362
|
}
|
|
345
363
|
catch (e) {
|
|
346
364
|
throw new Error(`struct.${key}(${e?.toString()})`);
|
|
347
365
|
}
|
|
348
|
-
}, bytesFrom([]));
|
|
366
|
+
}, (0, index_js_1.bytesFrom)([]));
|
|
349
367
|
},
|
|
350
368
|
decode(buffer) {
|
|
351
|
-
const value = bytesFrom(buffer);
|
|
369
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
352
370
|
const object = {};
|
|
353
371
|
let offset = 0;
|
|
354
372
|
Object.entries(codecLayout).forEach(([key, codec]) => {
|
|
@@ -372,7 +390,7 @@ export function struct(codecLayout) {
|
|
|
372
390
|
* @param itemCodec the fixed-size array item codec
|
|
373
391
|
* @param itemCount
|
|
374
392
|
*/
|
|
375
|
-
|
|
393
|
+
function array(itemCodec, itemCount) {
|
|
376
394
|
if (itemCodec.byteLength === undefined) {
|
|
377
395
|
throw new Error("array: itemCodec requires a byte length");
|
|
378
396
|
}
|
|
@@ -381,14 +399,14 @@ export function array(itemCodec, itemCount) {
|
|
|
381
399
|
byteLength,
|
|
382
400
|
encode(items) {
|
|
383
401
|
try {
|
|
384
|
-
return items.reduce((concatted, item) => bytesConcat(concatted, itemCodec.encode(item)), bytesFrom([]));
|
|
402
|
+
return items.reduce((concatted, item) => (0, index_js_1.bytesConcat)(concatted, itemCodec.encode(item)), (0, index_js_1.bytesFrom)([]));
|
|
385
403
|
}
|
|
386
404
|
catch (e) {
|
|
387
405
|
throw new Error(`array(${e?.toString()})`);
|
|
388
406
|
}
|
|
389
407
|
},
|
|
390
408
|
decode(buffer) {
|
|
391
|
-
const value = bytesFrom(buffer);
|
|
409
|
+
const value = (0, index_js_1.bytesFrom)(buffer);
|
|
392
410
|
if (value.byteLength != byteLength) {
|
|
393
411
|
throw new Error(`array: invalid buffer size, expected ${byteLength}, but got ${value.byteLength}`);
|
|
394
412
|
}
|
|
@@ -410,23 +428,23 @@ export function array(itemCodec, itemCount) {
|
|
|
410
428
|
* @param byteLength
|
|
411
429
|
* @param littleEndian
|
|
412
430
|
*/
|
|
413
|
-
|
|
431
|
+
function uint(byteLength, littleEndian = false) {
|
|
414
432
|
return Codec.from({
|
|
415
433
|
byteLength,
|
|
416
434
|
encode: (numLike) => {
|
|
417
435
|
if (littleEndian) {
|
|
418
|
-
return numToBytes(numLike, byteLength);
|
|
436
|
+
return (0, index_js_2.numToBytes)(numLike, byteLength);
|
|
419
437
|
}
|
|
420
438
|
else {
|
|
421
|
-
return numBeToBytes(numLike, byteLength);
|
|
439
|
+
return (0, index_js_2.numBeToBytes)(numLike, byteLength);
|
|
422
440
|
}
|
|
423
441
|
},
|
|
424
442
|
decode: (buffer) => {
|
|
425
443
|
if (littleEndian) {
|
|
426
|
-
return numFromBytes(buffer);
|
|
444
|
+
return (0, index_js_2.numFromBytes)(buffer);
|
|
427
445
|
}
|
|
428
446
|
else {
|
|
429
|
-
return numBeFromBytes(buffer);
|
|
447
|
+
return (0, index_js_2.numBeFromBytes)(buffer);
|
|
430
448
|
}
|
|
431
449
|
},
|
|
432
450
|
});
|
|
@@ -436,7 +454,7 @@ export function uint(byteLength, littleEndian = false) {
|
|
|
436
454
|
* @param byteLength
|
|
437
455
|
* @param littleEndian
|
|
438
456
|
*/
|
|
439
|
-
|
|
457
|
+
function uintNumber(byteLength, littleEndian = false) {
|
|
440
458
|
if (byteLength > 4) {
|
|
441
459
|
throw new Error("uintNumber: byteLength must be less than or equal to 4");
|
|
442
460
|
}
|
|
@@ -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"}
|
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|