@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,8 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var Script_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ScriptOpt = exports.Script = exports.HashTypeCodec = void 0;
|
|
11
|
+
exports.hashTypeFrom = hashTypeFrom;
|
|
12
|
+
exports.hashTypeToBytes = hashTypeToBytes;
|
|
13
|
+
exports.hashTypeFromBytes = hashTypeFromBytes;
|
|
14
|
+
const index_js_1 = require("../bytes/index.js");
|
|
15
|
+
const index_js_2 = require("../hex/index.js");
|
|
16
|
+
const index_js_3 = require("../molecule/index.js");
|
|
17
|
+
const script_advanced_js_1 = require("./script.advanced.js");
|
|
18
|
+
exports.HashTypeCodec = index_js_3.mol.Codec.from({
|
|
19
|
+
byteLength: 1,
|
|
20
|
+
encode: hashTypeToBytes,
|
|
21
|
+
decode: hashTypeFromBytes,
|
|
22
|
+
});
|
|
6
23
|
/**
|
|
7
24
|
* Converts a HashTypeLike value to a HashType.
|
|
8
25
|
* @public
|
|
@@ -18,15 +35,15 @@ import { HASH_TYPES, HASH_TYPE_TO_NUM, NUM_TO_HASH_TYPE, } from "./script.advanc
|
|
|
18
35
|
* const hashType = hashTypeFrom("type"); // Outputs "type"
|
|
19
36
|
* ```
|
|
20
37
|
*/
|
|
21
|
-
|
|
38
|
+
function hashTypeFrom(val) {
|
|
22
39
|
const hashType = (() => {
|
|
23
40
|
if (typeof val === "number") {
|
|
24
|
-
return NUM_TO_HASH_TYPE[val];
|
|
41
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[val];
|
|
25
42
|
}
|
|
26
43
|
if (typeof val === "bigint") {
|
|
27
|
-
return NUM_TO_HASH_TYPE[Number(val)];
|
|
44
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[Number(val)];
|
|
28
45
|
}
|
|
29
|
-
if (!HASH_TYPES.includes(val)) {
|
|
46
|
+
if (!script_advanced_js_1.HASH_TYPES.includes(val)) {
|
|
30
47
|
return;
|
|
31
48
|
}
|
|
32
49
|
return val;
|
|
@@ -48,8 +65,8 @@ export function hashTypeFrom(val) {
|
|
|
48
65
|
* const hashTypeBytes = hashTypeToBytes("type"); // Outputs Uint8Array [0]
|
|
49
66
|
* ```
|
|
50
67
|
*/
|
|
51
|
-
|
|
52
|
-
return bytesFrom([HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
|
|
68
|
+
function hashTypeToBytes(hashType) {
|
|
69
|
+
return (0, index_js_1.bytesFrom)([script_advanced_js_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
|
|
53
70
|
}
|
|
54
71
|
/**
|
|
55
72
|
* Converts a byte-like value to a HashType.
|
|
@@ -65,13 +82,13 @@ export function hashTypeToBytes(hashType) {
|
|
|
65
82
|
* const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs "type"
|
|
66
83
|
* ```
|
|
67
84
|
*/
|
|
68
|
-
|
|
69
|
-
return NUM_TO_HASH_TYPE[bytesFrom(bytes)[0]];
|
|
85
|
+
function hashTypeFromBytes(bytes) {
|
|
86
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[(0, index_js_1.bytesFrom)(bytes)[0]];
|
|
70
87
|
}
|
|
71
88
|
/**
|
|
72
89
|
* @public
|
|
73
90
|
*/
|
|
74
|
-
|
|
91
|
+
let Script = Script_1 = class Script extends index_js_3.mol.Entity.Base() {
|
|
75
92
|
/**
|
|
76
93
|
* Creates an instance of Script.
|
|
77
94
|
*
|
|
@@ -80,12 +97,13 @@ export class Script {
|
|
|
80
97
|
* @param args - The arguments for the script.
|
|
81
98
|
*/
|
|
82
99
|
constructor(codeHash, hashType, args) {
|
|
100
|
+
super();
|
|
83
101
|
this.codeHash = codeHash;
|
|
84
102
|
this.hashType = hashType;
|
|
85
103
|
this.args = args;
|
|
86
104
|
}
|
|
87
105
|
get occupiedSize() {
|
|
88
|
-
return 33 + bytesFrom(this.args).length;
|
|
106
|
+
return 33 + (0, index_js_1.bytesFrom)(this.args).length;
|
|
89
107
|
}
|
|
90
108
|
/**
|
|
91
109
|
* Clone a script.
|
|
@@ -98,7 +116,7 @@ export class Script {
|
|
|
98
116
|
* ```
|
|
99
117
|
*/
|
|
100
118
|
clone() {
|
|
101
|
-
return new
|
|
119
|
+
return new Script_1(this.codeHash, this.hashType, this.args);
|
|
102
120
|
}
|
|
103
121
|
/**
|
|
104
122
|
* Creates a Script instance from a ScriptLike object.
|
|
@@ -116,10 +134,10 @@ export class Script {
|
|
|
116
134
|
* ```
|
|
117
135
|
*/
|
|
118
136
|
static from(script) {
|
|
119
|
-
if (script instanceof
|
|
137
|
+
if (script instanceof Script_1) {
|
|
120
138
|
return script;
|
|
121
139
|
}
|
|
122
|
-
return new
|
|
140
|
+
return new Script_1((0, index_js_2.hexFrom)(script.codeHash), hashTypeFrom(script.hashType), (0, index_js_2.hexFrom)(script.args));
|
|
123
141
|
}
|
|
124
142
|
/**
|
|
125
143
|
* Creates a Script instance from client and known script.
|
|
@@ -140,76 +158,17 @@ export class Script {
|
|
|
140
158
|
*/
|
|
141
159
|
static async fromKnownScript(client, knownScript, args) {
|
|
142
160
|
const script = await client.getKnownScript(knownScript);
|
|
143
|
-
return new
|
|
161
|
+
return new Script_1(script.codeHash, script.hashType, (0, index_js_2.hexFrom)(args));
|
|
144
162
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Converts the Script instance to bytes.
|
|
159
|
-
*
|
|
160
|
-
* @returns A Uint8Array containing the script bytes.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* const scriptBytes = script.toBytes();
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
toBytes() {
|
|
168
|
-
return bytesFrom(mol.SerializeScript(this._toMolData()));
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Get hash of a script
|
|
172
|
-
*
|
|
173
|
-
* @returns Hash of this script
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* const hash = script.hash();
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
hash() {
|
|
181
|
-
return hashCkb(this.toBytes());
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Creates a Script instance from a byte-like value or molecule Script.
|
|
185
|
-
*
|
|
186
|
-
* @param bytes - The byte-like value or molecule Script to convert.
|
|
187
|
-
* @returns A Script instance.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```typescript
|
|
191
|
-
* const script = Script.fromBytes(new Uint8Array([/* script bytes *\/]));
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
static fromBytes(bytes) {
|
|
195
|
-
const view = bytes instanceof mol.Script ? bytes : new mol.Script(bytesFrom(bytes));
|
|
196
|
-
return new Script(hexFrom(view.getCodeHash().raw()), hashTypeFromBytes([view.getHashType()]), hexFrom(view.getArgs().raw()));
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Compares the current Script instance with another ScriptLike object for equality.
|
|
200
|
-
*
|
|
201
|
-
* @param val - The ScriptLike object to compare with.
|
|
202
|
-
* @returns True if the scripts are equal, otherwise false.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```typescript
|
|
206
|
-
* const isEqual = script.eq(anotherScript);
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
eq(val) {
|
|
210
|
-
const script = Script.from(val);
|
|
211
|
-
return (this.codeHash === script.codeHash &&
|
|
212
|
-
this.args === script.args &&
|
|
213
|
-
this.hashType === script.hashType);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
163
|
+
};
|
|
164
|
+
exports.Script = Script;
|
|
165
|
+
exports.Script = Script = Script_1 = __decorate([
|
|
166
|
+
index_js_3.mol.codec(index_js_3.mol
|
|
167
|
+
.table({
|
|
168
|
+
codeHash: index_js_3.mol.Byte32,
|
|
169
|
+
hashType: exports.HashTypeCodec,
|
|
170
|
+
args: index_js_3.mol.Bytes,
|
|
171
|
+
})
|
|
172
|
+
.map({ outMap: (decoded) => Script.from(decoded) }))
|
|
173
|
+
], Script);
|
|
174
|
+
exports.ScriptOpt = index_js_3.mol.option(Script);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEP_TYPES = exports.NUM_TO_DEP_TYPE = exports.DEP_TYPE_TO_NUM = void 0;
|
|
4
|
+
exports.DEP_TYPE_TO_NUM = {
|
|
2
5
|
code: 0x00,
|
|
3
6
|
depGroup: 0x01,
|
|
4
7
|
};
|
|
5
|
-
|
|
8
|
+
exports.NUM_TO_DEP_TYPE = {
|
|
6
9
|
0x00: "code",
|
|
7
10
|
0x01: "depGroup",
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
exports.DEP_TYPES = Object.keys(exports.DEP_TYPE_TO_NUM);
|