@ckb-ccc/core 0.1.0 → 0.1.2
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.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.js +41 -12
- package/dist.commonjs/bytes/advanced.js +2 -1
- package/dist.commonjs/bytes/index.js +12 -7
- package/dist.commonjs/ckb/advanced.js +32 -3
- package/dist.commonjs/ckb/index.js +19 -3
- package/dist.commonjs/ckb/molecule.advanced/generated.js +131 -64
- package/dist.commonjs/ckb/molecule.advanced/index.js +19 -2
- package/dist.commonjs/ckb/script.advanced.js +6 -3
- package/dist.commonjs/ckb/script.js +53 -23
- package/dist.commonjs/ckb/transaction.advanced.js +6 -3
- package/dist.commonjs/ckb/transaction.js +163 -122
- 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/codec.js +63 -48
- package/dist.commonjs/molecule/index.js +18 -2
- package/dist.commonjs/molecule/predefined.js +103 -77
- 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.js +12 -6
- package/package.json +6 -2
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.Script = void 0;
|
|
27
|
+
exports.hashTypeFrom = hashTypeFrom;
|
|
28
|
+
exports.hashTypeToBytes = hashTypeToBytes;
|
|
29
|
+
exports.hashTypeFromBytes = hashTypeFromBytes;
|
|
30
|
+
const index_js_1 = require("../bytes/index.js");
|
|
31
|
+
const index_js_2 = require("../hasher/index.js");
|
|
32
|
+
const index_js_3 = require("../hex/index.js");
|
|
33
|
+
const mol = __importStar(require("./molecule.advanced/index.js"));
|
|
34
|
+
const script_advanced_js_1 = require("./script.advanced.js");
|
|
6
35
|
/**
|
|
7
36
|
* Converts a HashTypeLike value to a HashType.
|
|
8
37
|
* @public
|
|
@@ -18,15 +47,15 @@ import { HASH_TYPES, HASH_TYPE_TO_NUM, NUM_TO_HASH_TYPE, } from "./script.advanc
|
|
|
18
47
|
* const hashType = hashTypeFrom("type"); // Outputs "type"
|
|
19
48
|
* ```
|
|
20
49
|
*/
|
|
21
|
-
|
|
50
|
+
function hashTypeFrom(val) {
|
|
22
51
|
const hashType = (() => {
|
|
23
52
|
if (typeof val === "number") {
|
|
24
|
-
return NUM_TO_HASH_TYPE[val];
|
|
53
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[val];
|
|
25
54
|
}
|
|
26
55
|
if (typeof val === "bigint") {
|
|
27
|
-
return NUM_TO_HASH_TYPE[Number(val)];
|
|
56
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[Number(val)];
|
|
28
57
|
}
|
|
29
|
-
if (!HASH_TYPES.includes(val)) {
|
|
58
|
+
if (!script_advanced_js_1.HASH_TYPES.includes(val)) {
|
|
30
59
|
return;
|
|
31
60
|
}
|
|
32
61
|
return val;
|
|
@@ -48,8 +77,8 @@ export function hashTypeFrom(val) {
|
|
|
48
77
|
* const hashTypeBytes = hashTypeToBytes("type"); // Outputs Uint8Array [0]
|
|
49
78
|
* ```
|
|
50
79
|
*/
|
|
51
|
-
|
|
52
|
-
return bytesFrom([HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
|
|
80
|
+
function hashTypeToBytes(hashType) {
|
|
81
|
+
return (0, index_js_1.bytesFrom)([script_advanced_js_1.HASH_TYPE_TO_NUM[hashTypeFrom(hashType)]]);
|
|
53
82
|
}
|
|
54
83
|
/**
|
|
55
84
|
* Converts a byte-like value to a HashType.
|
|
@@ -65,13 +94,13 @@ export function hashTypeToBytes(hashType) {
|
|
|
65
94
|
* const hashType = hashTypeFromBytes(new Uint8Array([0])); // Outputs "type"
|
|
66
95
|
* ```
|
|
67
96
|
*/
|
|
68
|
-
|
|
69
|
-
return NUM_TO_HASH_TYPE[bytesFrom(bytes)[0]];
|
|
97
|
+
function hashTypeFromBytes(bytes) {
|
|
98
|
+
return script_advanced_js_1.NUM_TO_HASH_TYPE[(0, index_js_1.bytesFrom)(bytes)[0]];
|
|
70
99
|
}
|
|
71
100
|
/**
|
|
72
101
|
* @public
|
|
73
102
|
*/
|
|
74
|
-
|
|
103
|
+
class Script {
|
|
75
104
|
/**
|
|
76
105
|
* Creates an instance of Script.
|
|
77
106
|
*
|
|
@@ -85,7 +114,7 @@ export class Script {
|
|
|
85
114
|
this.args = args;
|
|
86
115
|
}
|
|
87
116
|
get occupiedSize() {
|
|
88
|
-
return 33 + bytesFrom(this.args).length;
|
|
117
|
+
return 33 + (0, index_js_1.bytesFrom)(this.args).length;
|
|
89
118
|
}
|
|
90
119
|
/**
|
|
91
120
|
* Clone a script.
|
|
@@ -119,7 +148,7 @@ export class Script {
|
|
|
119
148
|
if (script instanceof Script) {
|
|
120
149
|
return script;
|
|
121
150
|
}
|
|
122
|
-
return new Script(hexFrom(script.codeHash), hashTypeFrom(script.hashType), hexFrom(script.args));
|
|
151
|
+
return new Script((0, index_js_3.hexFrom)(script.codeHash), hashTypeFrom(script.hashType), (0, index_js_3.hexFrom)(script.args));
|
|
123
152
|
}
|
|
124
153
|
/**
|
|
125
154
|
* Creates a Script instance from client and known script.
|
|
@@ -140,7 +169,7 @@ export class Script {
|
|
|
140
169
|
*/
|
|
141
170
|
static async fromKnownScript(client, knownScript, args) {
|
|
142
171
|
const script = await client.getKnownScript(knownScript);
|
|
143
|
-
return new Script(script.codeHash, script.hashType, hexFrom(args));
|
|
172
|
+
return new Script(script.codeHash, script.hashType, (0, index_js_3.hexFrom)(args));
|
|
144
173
|
}
|
|
145
174
|
/**
|
|
146
175
|
* Converts the Script instance to molecule data format.
|
|
@@ -149,9 +178,9 @@ export class Script {
|
|
|
149
178
|
*/
|
|
150
179
|
_toMolData() {
|
|
151
180
|
return {
|
|
152
|
-
codeHash: bytesFrom(this.codeHash),
|
|
181
|
+
codeHash: (0, index_js_1.bytesFrom)(this.codeHash),
|
|
153
182
|
hashType: hashTypeToBytes(this.hashType),
|
|
154
|
-
args: bytesFrom(this.args),
|
|
183
|
+
args: (0, index_js_1.bytesFrom)(this.args),
|
|
155
184
|
};
|
|
156
185
|
}
|
|
157
186
|
/**
|
|
@@ -165,7 +194,7 @@ export class Script {
|
|
|
165
194
|
* ```
|
|
166
195
|
*/
|
|
167
196
|
toBytes() {
|
|
168
|
-
return bytesFrom(mol.SerializeScript(this._toMolData()));
|
|
197
|
+
return (0, index_js_1.bytesFrom)(mol.SerializeScript(this._toMolData()));
|
|
169
198
|
}
|
|
170
199
|
/**
|
|
171
200
|
* Get hash of a script
|
|
@@ -178,7 +207,7 @@ export class Script {
|
|
|
178
207
|
* ```
|
|
179
208
|
*/
|
|
180
209
|
hash() {
|
|
181
|
-
return hashCkb(this.toBytes());
|
|
210
|
+
return (0, index_js_2.hashCkb)(this.toBytes());
|
|
182
211
|
}
|
|
183
212
|
/**
|
|
184
213
|
* Creates a Script instance from a byte-like value or molecule Script.
|
|
@@ -192,8 +221,8 @@ export class Script {
|
|
|
192
221
|
* ```
|
|
193
222
|
*/
|
|
194
223
|
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()));
|
|
224
|
+
const view = bytes instanceof mol.Script ? bytes : new mol.Script((0, index_js_1.bytesFrom)(bytes));
|
|
225
|
+
return new Script((0, index_js_3.hexFrom)(view.getCodeHash().raw()), hashTypeFromBytes([view.getHashType()]), (0, index_js_3.hexFrom)(view.getArgs().raw()));
|
|
197
226
|
}
|
|
198
227
|
/**
|
|
199
228
|
* Compares the current Script instance with another ScriptLike object for equality.
|
|
@@ -213,3 +242,4 @@ export class Script {
|
|
|
213
242
|
this.hashType === script.hashType);
|
|
214
243
|
}
|
|
215
244
|
}
|
|
245
|
+
exports.Script = 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);
|