@offckb/cli 0.3.0-rc6 → 0.3.0-rc8
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/README.md +70 -1
- package/dist/cli.js +13 -4
- package/dist/cmd/list-hashes.d.ts +2 -2
- package/dist/cmd/list-hashes.js +6 -6
- package/dist/cmd/repl.d.ts +11 -0
- package/dist/cmd/repl.js +75 -0
- package/dist/cmd/system-scripts.d.ts +24 -35
- package/dist/cmd/system-scripts.js +108 -80
- package/dist/node/install.js +36 -8
- package/dist/scripts/gen.js +1 -1
- package/dist/scripts/private.js +1 -1
- package/dist/scripts/public.js +14 -181
- package/dist/scripts/type.d.ts +5 -0
- package/package.json +3 -1
- package/templates/v3/offckb.config.example.ts +6 -1
package/README.md
CHANGED
|
@@ -34,6 +34,10 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
34
34
|
- [Start the frontend project](#start-the-frontend-project)
|
|
35
35
|
- [Debug a transaction](#debug-a-transaction)
|
|
36
36
|
- [Generate Moleculec bindings](#generate-moleculec-bindings)
|
|
37
|
+
- [REPL Mode](#repl-mode)
|
|
38
|
+
- [Start the OffCKB REPL](#start-the-offckb-repl)
|
|
39
|
+
- [Build CKB transaction in REPL](#build-ckb-transaction-in-repl)
|
|
40
|
+
- [Get balance in REPL](#get-balance-in-repl)
|
|
37
41
|
- [Config Setting](#config-setting)
|
|
38
42
|
- [List All Settings](#list-all-settings)
|
|
39
43
|
- [Set CKB version](#set-ckb-version)
|
|
@@ -50,7 +54,7 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
50
54
|
npm install -g @offckb/cli
|
|
51
55
|
```
|
|
52
56
|
|
|
53
|
-
_We
|
|
57
|
+
_We recommend using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
|
|
54
58
|
|
|
55
59
|
## Usage
|
|
56
60
|
|
|
@@ -82,6 +86,7 @@ Commands:
|
|
|
82
86
|
debug [options] CKB Debugger for development
|
|
83
87
|
system-scripts [options] Output system scripts of the local devnet
|
|
84
88
|
mol [options] Generate CKB Moleculec binding code for development
|
|
89
|
+
repl [options] A custom Nodejs REPL environment bundle for CKB.
|
|
85
90
|
help [command] display help for command
|
|
86
91
|
```
|
|
87
92
|
|
|
@@ -310,6 +315,70 @@ If you have multiple `.mol` files, you can use a folder as the input and specify
|
|
|
310
315
|
offckb mol --schema <path/to/mol/folder> --output-folder <path/to/output/folder> --lang <lang>
|
|
311
316
|
```
|
|
312
317
|
|
|
318
|
+
## REPL Mode
|
|
319
|
+
|
|
320
|
+
OffCKB pack a custom Nodejs REPL with built-in variables and functions to help you develop CKB right in the terminal with minimal effort. This is suitable for simple script testing task when you don't want to write long and serious codes.
|
|
321
|
+
|
|
322
|
+
### Start the OffCKB REPL
|
|
323
|
+
|
|
324
|
+
```sh
|
|
325
|
+
offckb repl --network <devnet/testnet/mainnet, default: devnet>
|
|
326
|
+
|
|
327
|
+
Welcome to OffCKB REPL!
|
|
328
|
+
[[ Default Network: devnet, enableProxyRPC: false ]]
|
|
329
|
+
Type 'help()' to learn how to use.
|
|
330
|
+
OffCKB >
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Type `help()` to learn about the built-in variables and functions:
|
|
334
|
+
|
|
335
|
+
```sh
|
|
336
|
+
OffCKB > help()
|
|
337
|
+
|
|
338
|
+
OffCKB Repl, a Nodejs REPL with CKB bundles.
|
|
339
|
+
|
|
340
|
+
Global Variables to use:
|
|
341
|
+
- ccc, cccA, imported from CKB Javascript SDK CCC
|
|
342
|
+
- client, a CCC client instance bundle with current network
|
|
343
|
+
- Client, a Wrap of CCC client class, you can build new client with
|
|
344
|
+
const myClient = Client.new('devnet' | 'testnet' | 'mainnet');
|
|
345
|
+
// or
|
|
346
|
+
const myClient = Client.fromUrl('<your rpc url>', 'devnet' | 'testnet' | 'mainnet');
|
|
347
|
+
- accounts, test accounts array from OffCKB
|
|
348
|
+
- networks, network information configs
|
|
349
|
+
- help, print this help message
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Build CKB transaction in REPL
|
|
353
|
+
|
|
354
|
+
```sh
|
|
355
|
+
OffCKB > let amountInCKB = ccc.fixedPointFrom(63);
|
|
356
|
+
OffCKB > let tx = ccc.Transaction.from({
|
|
357
|
+
... outputs: [
|
|
358
|
+
... {
|
|
359
|
+
... capacity: ccc.fixedPointFrom(amountInCKB),
|
|
360
|
+
... lock: accounts[0].lockScript,
|
|
361
|
+
... },
|
|
362
|
+
... ],
|
|
363
|
+
... });
|
|
364
|
+
OffCKB > let signer = new ccc.SignerCkbPrivateKey(client, accounts[0].privkey);
|
|
365
|
+
OffCKB > await tx.completeInputsByCapacity(signer);
|
|
366
|
+
2
|
|
367
|
+
OffCKB > await tx.completeFeeBy(signer, 1000);
|
|
368
|
+
[ 0, true ]
|
|
369
|
+
OffCKB > await mySigner.sendTransaction(tx)
|
|
370
|
+
'0x50fbfa8c47907d6842a325e85e48d5da6917e16ca7e2253ec3bd5bcdf8da99ce'
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Get balance in REPL
|
|
374
|
+
|
|
375
|
+
```sh
|
|
376
|
+
OffCKB > let myClient = Client.fromUrl(networks.testnet.rpc_url, 'testnet');
|
|
377
|
+
OffCKB > await myClient.getBalanceSingle(accounts[0].lockScript);
|
|
378
|
+
60838485293944n
|
|
379
|
+
OffCKB >
|
|
380
|
+
```
|
|
381
|
+
|
|
313
382
|
## Config Setting
|
|
314
383
|
|
|
315
384
|
### List All Settings
|
package/dist/cli.js
CHANGED
|
@@ -54,6 +54,7 @@ const proxy_rpc_1 = require("./cmd/proxy-rpc");
|
|
|
54
54
|
const mol_1 = require("./cmd/mol");
|
|
55
55
|
const fs = __importStar(require("fs"));
|
|
56
56
|
const transfer_all_1 = require("./cmd/transfer-all");
|
|
57
|
+
const repl_1 = require("./cmd/repl");
|
|
57
58
|
const version = require('../package.json').version;
|
|
58
59
|
const description = require('../package.json').description;
|
|
59
60
|
// fix windows terminal encoding of simplified chinese text
|
|
@@ -94,7 +95,7 @@ program.command('accounts').description('Print account list info').action(accoun
|
|
|
94
95
|
program
|
|
95
96
|
.command('list-hashes [CKB-Version]')
|
|
96
97
|
.description('Use the CKB to list blockchain scripts hashes')
|
|
97
|
-
.action(list_hashes_1.
|
|
98
|
+
.action(list_hashes_1.printDevnetListHashes);
|
|
98
99
|
program.command('inject-config').description('Add offckb.config.ts to your frontend workspace').action(inject_config_1.injectConfig);
|
|
99
100
|
program.command('sync-scripts').description('Sync scripts json files in your frontend workspace').action(sync_scripts_1.syncScripts);
|
|
100
101
|
program
|
|
@@ -165,11 +166,13 @@ program
|
|
|
165
166
|
}));
|
|
166
167
|
program
|
|
167
168
|
.command('system-scripts')
|
|
168
|
-
.option('--export-style <exportStyle>', 'Specify the export format, possible values are lumos and ccc.')
|
|
169
|
-
.
|
|
169
|
+
.option('--export-style <exportStyle>', 'Specify the export format, possible values are system, lumos and ccc.')
|
|
170
|
+
.option('--network <network>', 'Specify the CKB blockchain network', 'devnet')
|
|
171
|
+
.description('Output system scripts of the CKB blockchain')
|
|
170
172
|
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
const network = option.network;
|
|
171
174
|
const exportStyle = option.exportStyle;
|
|
172
|
-
return (0, system_scripts_1.printSystemScripts)(exportStyle);
|
|
175
|
+
return (0, system_scripts_1.printSystemScripts)({ style: exportStyle, network });
|
|
173
176
|
}));
|
|
174
177
|
program
|
|
175
178
|
.command('mol')
|
|
@@ -186,6 +189,12 @@ program
|
|
|
186
189
|
}
|
|
187
190
|
return (0, mol_1.molSingleFile)(option.schema, option.output, option.lang);
|
|
188
191
|
}));
|
|
192
|
+
program
|
|
193
|
+
.command('repl')
|
|
194
|
+
.description('A custom Nodejs REPL environment bundle for CKB.')
|
|
195
|
+
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
196
|
+
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
197
|
+
.action(repl_1.repl);
|
|
189
198
|
program.parse(process.argv);
|
|
190
199
|
// If no command is specified, display help
|
|
191
200
|
if (!process.argv.slice(2).length) {
|
|
@@ -21,5 +21,5 @@ export interface SpecHashes {
|
|
|
21
21
|
export interface ListHashes {
|
|
22
22
|
offckb: SpecHashes;
|
|
23
23
|
}
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
24
|
+
export declare function printDevnetListHashes(version?: string): Promise<void>;
|
|
25
|
+
export declare function getDevnetListHashes(version?: string): string | null;
|
package/dist/cmd/list-hashes.js
CHANGED
|
@@ -9,18 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getDevnetListHashes = exports.printDevnetListHashes = void 0;
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const setting_1 = require("../cfg/setting");
|
|
15
15
|
const encoding_1 = require("../util/encoding");
|
|
16
|
-
function
|
|
16
|
+
function printDevnetListHashes(version) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const output =
|
|
18
|
+
const output = getDevnetListHashes(version);
|
|
19
19
|
console.log(output);
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
exports.
|
|
23
|
-
function
|
|
22
|
+
exports.printDevnetListHashes = printDevnetListHashes;
|
|
23
|
+
function getDevnetListHashes(version) {
|
|
24
24
|
const settings = (0, setting_1.readSettings)();
|
|
25
25
|
const ckbVersion = version || settings.bins.defaultCKBVersion;
|
|
26
26
|
const ckbBinPath = (0, encoding_1.encodeBinPathForTerminal)((0, setting_1.getCKBBinaryPath)(ckbVersion));
|
|
@@ -37,4 +37,4 @@ function getListHashes(version) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.getDevnetListHashes = getDevnetListHashes;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ccc } from '@ckb-ccc/core';
|
|
2
|
+
import { Network, NetworkOption } from '../type/base';
|
|
3
|
+
export interface ReplProp extends NetworkOption {
|
|
4
|
+
proxyRpc?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function repl({ network, proxyRpc }: ReplProp): void;
|
|
7
|
+
export declare function initGlobalClientBuilder(): {
|
|
8
|
+
new: (network: Network) => ccc.ClientPublicTestnet | ccc.ClientPublicMainnet;
|
|
9
|
+
fromUrl: (rpcUrl: string, network: Network) => ccc.ClientPublicTestnet | ccc.ClientPublicMainnet;
|
|
10
|
+
};
|
|
11
|
+
export declare function printHelpText(): void;
|
package/dist/cmd/repl.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printHelpText = exports.initGlobalClientBuilder = exports.repl = void 0;
|
|
7
|
+
const repl_1 = require("repl");
|
|
8
|
+
const core_1 = require("@ckb-ccc/core");
|
|
9
|
+
const advanced_1 = require("@ckb-ccc/core/advanced");
|
|
10
|
+
const network_1 = require("../sdk/network");
|
|
11
|
+
const base_1 = require("../type/base");
|
|
12
|
+
const private_1 = require("../scripts/private");
|
|
13
|
+
const account_json_1 = __importDefault(require("../../account/account.json"));
|
|
14
|
+
const validator_1 = require("../util/validator");
|
|
15
|
+
function repl({ network = base_1.Network.devnet, proxyRpc = false }) {
|
|
16
|
+
(0, validator_1.validateNetworkOpt)(network);
|
|
17
|
+
console.log(
|
|
18
|
+
// Note remember update the CCC version since require CCC's package.json not work
|
|
19
|
+
`Welcome to OffCKB REPL!\n[[ Default Network: ${network}, enableProxyRPC: ${proxyRpc}, CCC SDK: 0.0.16-alpha.3 ]]\nType 'help()' to learn how to use.`);
|
|
20
|
+
const context = (0, repl_1.start)({
|
|
21
|
+
prompt: 'OffCKB > ',
|
|
22
|
+
ignoreUndefined: true,
|
|
23
|
+
useColors: true,
|
|
24
|
+
}).context;
|
|
25
|
+
context.ccc = core_1.ccc;
|
|
26
|
+
context.cccA = advanced_1.cccA;
|
|
27
|
+
context.networks = network_1.networks;
|
|
28
|
+
context.Client = initGlobalClientBuilder();
|
|
29
|
+
context.client = initGlobalClientBuilder().new(network);
|
|
30
|
+
context.accounts = account_json_1.default;
|
|
31
|
+
context.help = printHelpText;
|
|
32
|
+
}
|
|
33
|
+
exports.repl = repl;
|
|
34
|
+
function initGlobalClientBuilder() {
|
|
35
|
+
return {
|
|
36
|
+
new: (network) => {
|
|
37
|
+
return network === 'mainnet'
|
|
38
|
+
? new core_1.ccc.ClientPublicMainnet()
|
|
39
|
+
: network === 'testnet'
|
|
40
|
+
? new core_1.ccc.ClientPublicTestnet()
|
|
41
|
+
: new core_1.ccc.ClientPublicTestnet({
|
|
42
|
+
url: network_1.networks.devnet.rpc_url,
|
|
43
|
+
scripts: (0, private_1.buildCCCDevnetKnownScripts)(),
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
fromUrl: (rpcUrl, network) => {
|
|
47
|
+
return network === 'mainnet'
|
|
48
|
+
? new core_1.ccc.ClientPublicMainnet({ url: rpcUrl })
|
|
49
|
+
: network === 'testnet'
|
|
50
|
+
? new core_1.ccc.ClientPublicTestnet({ url: rpcUrl })
|
|
51
|
+
: new core_1.ccc.ClientPublicTestnet({
|
|
52
|
+
url: rpcUrl,
|
|
53
|
+
scripts: (0, private_1.buildCCCDevnetKnownScripts)(),
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.initGlobalClientBuilder = initGlobalClientBuilder;
|
|
59
|
+
function printHelpText() {
|
|
60
|
+
return console.log(`
|
|
61
|
+
OffCKB Repl, a Nodejs REPL with CKB bundles.
|
|
62
|
+
|
|
63
|
+
Global Variables to use:
|
|
64
|
+
- ccc, cccA, imported from CKB Javascript SDK CCC
|
|
65
|
+
- client, a CCC client instance bundle with current network
|
|
66
|
+
- Client, a Wrap of CCC client class, you can build new client with
|
|
67
|
+
const myClient = Client.new('devnet' | 'testnet' | 'mainnet');
|
|
68
|
+
// or
|
|
69
|
+
const myClient = Client.fromUrl('<your rpc url>', 'devnet' | 'testnet' | 'mainnet');
|
|
70
|
+
- accounts, test accounts array from OffCKB
|
|
71
|
+
- networks, network information configs
|
|
72
|
+
- help, print this help message
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
exports.printHelpText = printHelpText;
|
|
@@ -1,40 +1,29 @@
|
|
|
1
1
|
import { SystemCell } from './list-hashes';
|
|
2
2
|
import { CellDepInfoLike, Script } from '@ckb-ccc/core';
|
|
3
|
-
import { SystemScriptsRecord } from '../scripts/type';
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}):
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
hashType: string;
|
|
28
|
-
cellDeps: {
|
|
29
|
-
cellDep: {
|
|
30
|
-
outPoint: {
|
|
31
|
-
txHash: string;
|
|
32
|
-
index: number;
|
|
33
|
-
};
|
|
34
|
-
depType: "depGroup";
|
|
35
|
-
};
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
3
|
+
import { ScriptInfo, SystemScriptsRecord } from '../scripts/type';
|
|
4
|
+
import { Network, NetworkOption } from '../type/base';
|
|
5
|
+
export declare enum PrintStyle {
|
|
6
|
+
system = "system",
|
|
7
|
+
lumos = "lumos",
|
|
8
|
+
ccc = "ccc"
|
|
9
|
+
}
|
|
10
|
+
export interface PrintProps extends NetworkOption {
|
|
11
|
+
style?: PrintStyle;
|
|
12
|
+
}
|
|
13
|
+
export declare function printSystemScripts({ style, network }: PrintProps): Promise<void>;
|
|
14
|
+
export declare function printInSystemStyle(systemScripts: SystemScriptsRecord, network: Network): void;
|
|
15
|
+
export declare function printInLumosConfigStyle(scripts: SystemScriptsRecord, network: Network): void;
|
|
16
|
+
export declare function printInCCCStyle(scripts: SystemScriptsRecord, network: Network): void;
|
|
17
|
+
export declare function getDevnetSystemScriptsFromListHashes(): SystemScriptsRecord | null;
|
|
18
|
+
export declare function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }: {
|
|
19
|
+
cell: SystemCell;
|
|
20
|
+
depType: 'code' | 'depGroup';
|
|
21
|
+
depGroup?: {
|
|
22
|
+
txHash: string;
|
|
23
|
+
index: number;
|
|
24
|
+
};
|
|
25
|
+
extraCellDeps?: ScriptInfo['cellDeps'];
|
|
26
|
+
}): ScriptInfo;
|
|
38
27
|
export declare function toLumosConfig(scripts: SystemScriptsRecord, addressPrefix?: 'ckb' | 'ckt'): {
|
|
39
28
|
PREFIX: "ckb" | "ckt";
|
|
40
29
|
SCRIPTS: {
|
|
@@ -12,30 +12,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.
|
|
15
|
+
exports.toCCCKnownScripts = exports.toLumosConfig = exports.systemCellToScriptInfo = exports.getDevnetSystemScriptsFromListHashes = exports.printInCCCStyle = exports.printInLumosConfigStyle = exports.printInSystemStyle = exports.printSystemScripts = exports.PrintStyle = void 0;
|
|
16
16
|
const setting_1 = require("../cfg/setting");
|
|
17
17
|
const list_hashes_1 = require("./list-hashes");
|
|
18
18
|
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
19
19
|
const core_1 = require("@ckb-ccc/core");
|
|
20
|
-
|
|
20
|
+
const base_1 = require("../type/base");
|
|
21
|
+
const public_1 = require("../scripts/public");
|
|
22
|
+
var PrintStyle;
|
|
23
|
+
(function (PrintStyle) {
|
|
24
|
+
PrintStyle["system"] = "system";
|
|
25
|
+
PrintStyle["lumos"] = "lumos";
|
|
26
|
+
PrintStyle["ccc"] = "ccc";
|
|
27
|
+
})(PrintStyle || (exports.PrintStyle = PrintStyle = {}));
|
|
28
|
+
function printSystemScripts({ style = PrintStyle.system, network = base_1.Network.devnet }) {
|
|
21
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const systemScripts =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const systemScripts = network === base_1.Network.mainnet
|
|
31
|
+
? public_1.MAINNET_SYSTEM_SCRIPTS
|
|
32
|
+
: network === base_1.Network.testnet
|
|
33
|
+
? public_1.TESTNET_SYSTEM_SCRIPTS
|
|
34
|
+
: getDevnetSystemScriptsFromListHashes();
|
|
35
|
+
if (!systemScripts)
|
|
36
|
+
return console.log(`SystemScripts is null, ${network}`);
|
|
37
|
+
if (style === PrintStyle.system) {
|
|
38
|
+
return printInSystemStyle(systemScripts, network);
|
|
39
|
+
}
|
|
40
|
+
if (style === PrintStyle.lumos) {
|
|
41
|
+
return printInLumosConfigStyle(systemScripts, network);
|
|
42
|
+
}
|
|
43
|
+
if (style === PrintStyle.ccc) {
|
|
44
|
+
return printInCCCStyle(systemScripts, network);
|
|
33
45
|
}
|
|
34
46
|
});
|
|
35
47
|
}
|
|
36
48
|
exports.printSystemScripts = printSystemScripts;
|
|
37
|
-
function printInSystemStyle(systemScripts) {
|
|
38
|
-
console.log(
|
|
49
|
+
function printInSystemStyle(systemScripts, network) {
|
|
50
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts ***\n`);
|
|
39
51
|
for (const [name, script] of Object.entries(systemScripts)) {
|
|
40
52
|
console.log(`- name: ${name}`);
|
|
41
53
|
if (script == null) {
|
|
@@ -48,86 +60,93 @@ function printInSystemStyle(systemScripts) {
|
|
|
48
60
|
}
|
|
49
61
|
}
|
|
50
62
|
exports.printInSystemStyle = printInSystemStyle;
|
|
51
|
-
function printInLumosConfigStyle(scripts) {
|
|
52
|
-
const config = toLumosConfig(scripts);
|
|
53
|
-
console.log(
|
|
63
|
+
function printInLumosConfigStyle(scripts, network) {
|
|
64
|
+
const config = toLumosConfig(scripts, network === base_1.Network.mainnet ? 'ckb' : 'ckt');
|
|
65
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts As LumosConfig ***\n`);
|
|
54
66
|
console.log(JSON.stringify(config, null, 2));
|
|
55
67
|
}
|
|
56
68
|
exports.printInLumosConfigStyle = printInLumosConfigStyle;
|
|
57
|
-
function printInCCCStyle(scripts) {
|
|
69
|
+
function printInCCCStyle(scripts, network) {
|
|
58
70
|
const knownsScripts = toCCCKnownScripts(scripts);
|
|
59
|
-
console.log(
|
|
71
|
+
console.log(`*** CKB ${network.toUpperCase()} System Scripts As CCC KnownScripts ***\n`);
|
|
60
72
|
console.log(JSON.stringify(knownsScripts, null, 2));
|
|
61
73
|
}
|
|
62
74
|
exports.printInCCCStyle = printInCCCStyle;
|
|
63
|
-
function
|
|
75
|
+
function getDevnetSystemScriptsFromListHashes() {
|
|
76
|
+
var _a;
|
|
64
77
|
const settings = (0, setting_1.readSettings)();
|
|
65
|
-
const listHashesString = (0, list_hashes_1.
|
|
66
|
-
if (listHashesString) {
|
|
67
|
-
const listHashes = toml_1.default.parse(listHashesString);
|
|
68
|
-
const chainSpecHashes = Object.values(listHashes)[0];
|
|
69
|
-
if (chainSpecHashes == null) {
|
|
70
|
-
throw new Error(`invalid chain spec hashes file ${listHashesString}`);
|
|
71
|
-
}
|
|
72
|
-
const systemScriptArray = chainSpecHashes.system_cells
|
|
73
|
-
.map((cell) => {
|
|
74
|
-
var _a;
|
|
75
|
-
// Extract the file name
|
|
76
|
-
const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
|
|
77
|
-
const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
|
|
78
|
-
const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
|
|
79
|
-
const depGroup = depGroupIndex === -1
|
|
80
|
-
? undefined
|
|
81
|
-
: {
|
|
82
|
-
txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
|
|
83
|
-
index: chainSpecHashes.dep_groups[depGroupIndex].index,
|
|
84
|
-
};
|
|
85
|
-
const scriptInfo = systemCellToScriptInfo(cell, depType, depGroup);
|
|
86
|
-
return {
|
|
87
|
-
name,
|
|
88
|
-
file: cell.path,
|
|
89
|
-
script: scriptInfo,
|
|
90
|
-
};
|
|
91
|
-
})
|
|
92
|
-
.filter((s) => s.name != 'secp256k1_data');
|
|
93
|
-
const systemScripts = systemScriptArray.reduce((acc, item) => {
|
|
94
|
-
const key = item.name;
|
|
95
|
-
acc[key] = item;
|
|
96
|
-
return acc;
|
|
97
|
-
}, {});
|
|
98
|
-
return systemScripts;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
78
|
+
const listHashesString = (0, list_hashes_1.getDevnetListHashes)(settings.bins.defaultCKBVersion);
|
|
79
|
+
if (!listHashesString) {
|
|
101
80
|
console.log(`list-hashes not found!`);
|
|
102
81
|
return null;
|
|
103
82
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new Error('require depGroup info since the dep type is depGroup');
|
|
83
|
+
const listHashes = toml_1.default.parse(listHashesString);
|
|
84
|
+
const chainSpecHashes = Object.values(listHashes)[0];
|
|
85
|
+
if (chainSpecHashes == null) {
|
|
86
|
+
throw new Error(`invalid chain spec hashes file ${listHashesString}`);
|
|
109
87
|
}
|
|
110
|
-
|
|
88
|
+
const systemScriptArray = chainSpecHashes.system_cells
|
|
89
|
+
.map((cell) => {
|
|
90
|
+
var _a;
|
|
91
|
+
// Extract the file name
|
|
92
|
+
const name = ((_a = cell.path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.replace(')', '')) || 'unknown script';
|
|
93
|
+
const depGroupIndex = chainSpecHashes.dep_groups.findIndex((depGroup) => depGroup.included_cells.includes(`Bundled(specs/cells/${name})`));
|
|
94
|
+
const depType = depGroupIndex === -1 ? 'code' : 'depGroup';
|
|
95
|
+
const depGroup = depGroupIndex === -1
|
|
96
|
+
? undefined
|
|
97
|
+
: {
|
|
98
|
+
txHash: chainSpecHashes.dep_groups[depGroupIndex].tx_hash,
|
|
99
|
+
index: chainSpecHashes.dep_groups[depGroupIndex].index,
|
|
100
|
+
};
|
|
101
|
+
const scriptInfo = systemCellToScriptInfo({ cell, depType, depGroup });
|
|
111
102
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
name,
|
|
104
|
+
file: cell.path,
|
|
105
|
+
script: scriptInfo,
|
|
106
|
+
};
|
|
107
|
+
})
|
|
108
|
+
.filter((s) => s.name != 'secp256k1_data');
|
|
109
|
+
const systemScripts = systemScriptArray.reduce((acc, item) => {
|
|
110
|
+
const key = item.name;
|
|
111
|
+
acc[key] = item;
|
|
112
|
+
return acc;
|
|
113
|
+
}, {});
|
|
114
|
+
// some special case fixes
|
|
115
|
+
// eg: omnilock also requires the deps of secp256k1-sigHashAll
|
|
116
|
+
(_a = systemScripts.omnilock) === null || _a === void 0 ? void 0 : _a.script.cellDeps.push(systemScripts.secp256k1_blake160_sighash_all.script.cellDeps[0]);
|
|
117
|
+
return systemScripts;
|
|
118
|
+
}
|
|
119
|
+
exports.getDevnetSystemScriptsFromListHashes = getDevnetSystemScriptsFromListHashes;
|
|
120
|
+
function systemCellToScriptInfo({ cell, depType, depGroup, extraCellDeps, }) {
|
|
121
|
+
// todo: we left the type in cellDepsInfo since it requires async fetching and
|
|
122
|
+
// chain running to get the full type script of the type-id deps.
|
|
123
|
+
// Also, in devnet there is no real need to auto upgrade the system scripts with type-id
|
|
124
|
+
if (depType === 'code') {
|
|
125
|
+
let cellDeps = [
|
|
126
|
+
{
|
|
127
|
+
cellDep: {
|
|
128
|
+
outPoint: {
|
|
129
|
+
txHash: cell.tx_hash,
|
|
130
|
+
index: cell.index,
|
|
122
131
|
},
|
|
132
|
+
depType,
|
|
123
133
|
},
|
|
124
|
-
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
if (extraCellDeps && extraCellDeps.length > 0) {
|
|
137
|
+
cellDeps = [...extraCellDeps, ...cellDeps];
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
codeHash: (cell.type_hash || cell.data_hash),
|
|
141
|
+
hashType: cell.type_hash ? 'type' : 'data1',
|
|
142
|
+
cellDeps,
|
|
125
143
|
};
|
|
126
144
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
145
|
+
if (depType === 'depGroup') {
|
|
146
|
+
if (!depGroup) {
|
|
147
|
+
throw new Error('require depGroup info since the dep type is depGroup');
|
|
148
|
+
}
|
|
149
|
+
let cellDeps = [
|
|
131
150
|
{
|
|
132
151
|
cellDep: {
|
|
133
152
|
outPoint: {
|
|
@@ -137,8 +156,17 @@ function systemCellToScriptInfo(cell, depType, depGroup) {
|
|
|
137
156
|
depType,
|
|
138
157
|
},
|
|
139
158
|
},
|
|
140
|
-
]
|
|
141
|
-
|
|
159
|
+
];
|
|
160
|
+
if (extraCellDeps && extraCellDeps.length > 0) {
|
|
161
|
+
cellDeps = [...extraCellDeps, ...cellDeps];
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
codeHash: (cell.type_hash || cell.data_hash),
|
|
165
|
+
hashType: cell.type_hash ? 'type' : 'data1',
|
|
166
|
+
cellDeps,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
throw new Error(`unknown DepType ${depType}`);
|
|
142
170
|
}
|
|
143
171
|
exports.systemCellToScriptInfo = systemCellToScriptInfo;
|
|
144
172
|
function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
package/dist/node/install.js
CHANGED
|
@@ -46,6 +46,7 @@ const tar = __importStar(require("tar"));
|
|
|
46
46
|
const request_1 = require("../util/request");
|
|
47
47
|
const setting_1 = require("../cfg/setting");
|
|
48
48
|
const encoding_1 = require("../util/encoding");
|
|
49
|
+
const cpu_features_1 = __importDefault(require("cpu-features"));
|
|
49
50
|
function installCKBBinary(version) {
|
|
50
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
52
|
const ckbBinPath = (0, setting_1.getCKBBinaryPath)(version);
|
|
@@ -67,18 +68,16 @@ function installCKBBinary(version) {
|
|
|
67
68
|
exports.installCKBBinary = installCKBBinary;
|
|
68
69
|
function downloadCKBBinaryAndUnzip(version) {
|
|
69
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const
|
|
71
|
-
const osname = getOS();
|
|
72
|
-
const ext = getExtension();
|
|
73
|
-
const ckbVersionOSName = `ckb_v${version}_${arch}-${osname}`;
|
|
71
|
+
const ckbPackageName = buildCKBGithubReleasePackageName(version);
|
|
74
72
|
try {
|
|
75
|
-
const
|
|
73
|
+
const ext = getExtension();
|
|
74
|
+
const tempFilePath = path.join(os_1.default.tmpdir(), `${ckbPackageName}.${ext}`);
|
|
76
75
|
yield downloadAndSaveCKBBinary(version, tempFilePath);
|
|
77
76
|
// Unzip the file
|
|
78
77
|
const extractDir = path.join((0, setting_1.readSettings)().bins.downloadPath, `ckb_v${version}`);
|
|
79
78
|
yield unZipFile(tempFilePath, extractDir, ext === 'tar.gz');
|
|
80
79
|
// Install the extracted files
|
|
81
|
-
const sourcePath = path.join(extractDir,
|
|
80
|
+
const sourcePath = path.join(extractDir, ckbPackageName);
|
|
82
81
|
const targetPath = (0, setting_1.getCKBBinaryInstallPath)(version);
|
|
83
82
|
if (fs.existsSync(targetPath)) {
|
|
84
83
|
fs.rmdirSync(targetPath, { recursive: true });
|
|
@@ -97,6 +96,7 @@ exports.downloadCKBBinaryAndUnzip = downloadCKBBinaryAndUnzip;
|
|
|
97
96
|
function downloadAndSaveCKBBinary(version, tempFilePath) {
|
|
98
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
98
|
const downloadURL = buildDownloadUrl(version);
|
|
99
|
+
console.log(`downloading ${downloadURL} ..`);
|
|
100
100
|
const response = yield request_1.Request.send(downloadURL);
|
|
101
101
|
const arrayBuffer = yield response.arrayBuffer();
|
|
102
102
|
fs.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
|
|
@@ -189,10 +189,38 @@ function getExtension() {
|
|
|
189
189
|
}
|
|
190
190
|
return 'zip';
|
|
191
191
|
}
|
|
192
|
-
function
|
|
192
|
+
function isPortable() {
|
|
193
|
+
const features = (0, cpu_features_1.default)();
|
|
194
|
+
if (features.arch === 'x86') {
|
|
195
|
+
const flags = features.flags;
|
|
196
|
+
// if lacks any of the following instruction, use portable binary
|
|
197
|
+
return !(flags.avx2 && flags.sse4_2 && flags.bmi2 && flags.pclmulqdq);
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
function buildCKBGithubReleasePackageName(version, opt = {}) {
|
|
202
|
+
const os = opt.os || getOS();
|
|
203
|
+
const arch = opt.arch || getArch();
|
|
204
|
+
if (isPortable()) {
|
|
205
|
+
return `ckb_v${version}_${arch}-${os}-portable`;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return `ckb_v${version}_${arch}-${os}`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function buildCKBGithubReleasePackageNameWithExtension(version, opt = {}) {
|
|
193
212
|
const os = opt.os || getOS();
|
|
194
213
|
const arch = opt.arch || getArch();
|
|
195
214
|
const extension = opt.ext || getExtension();
|
|
196
|
-
|
|
215
|
+
if (isPortable()) {
|
|
216
|
+
return `ckb_v${version}_${arch}-${os}-portable.${extension}`;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return `ckb_v${version}_${arch}-${os}.${extension}`;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function buildDownloadUrl(version, opt = {}) {
|
|
223
|
+
const fullPackageName = buildCKBGithubReleasePackageNameWithExtension(version, opt);
|
|
224
|
+
return `https://github.com/nervosnetwork/ckb/releases/download/v${version}/${fullPackageName}`;
|
|
197
225
|
}
|
|
198
226
|
exports.buildDownloadUrl = buildDownloadUrl;
|
package/dist/scripts/gen.js
CHANGED
|
@@ -34,7 +34,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
34
34
|
const base_1 = require("../type/base");
|
|
35
35
|
const util_1 = require("./util");
|
|
36
36
|
function genSystemScripts() {
|
|
37
|
-
const devnetScripts = (0, system_scripts_1.
|
|
37
|
+
const devnetScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
|
|
38
38
|
if (devnetScripts != null) {
|
|
39
39
|
const networkScripts = {
|
|
40
40
|
devnet: devnetScripts,
|
package/dist/scripts/private.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.buildCCCDevnetKnownScripts = void 0;
|
|
|
4
4
|
//todo: extract getSystemScriptsFromListHashes/toCCCKnownScripts from cmd folder
|
|
5
5
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
6
6
|
function buildCCCDevnetKnownScripts() {
|
|
7
|
-
const devnetSystemScripts = (0, system_scripts_1.
|
|
7
|
+
const devnetSystemScripts = (0, system_scripts_1.getDevnetSystemScriptsFromListHashes)();
|
|
8
8
|
if (devnetSystemScripts == null) {
|
|
9
9
|
throw new Error('can not getSystemScriptsFromListHashes in devnet');
|
|
10
10
|
}
|
package/dist/scripts/public.js
CHANGED
|
@@ -1,62 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MAINNET_SYSTEM_SCRIPTS = exports.TESTNET_SYSTEM_SCRIPTS = void 0;
|
|
4
|
+
const advanced_1 = require("@ckb-ccc/core/advanced");
|
|
5
|
+
const advanced_2 = require("@ckb-ccc/core/advanced");
|
|
4
6
|
// spore: https://github.com/sporeprotocol/spore-contract/blob/master/docs/VERSIONS.md
|
|
5
7
|
exports.TESTNET_SYSTEM_SCRIPTS = {
|
|
6
8
|
secp256k1_blake160_sighash_all: {
|
|
7
9
|
name: 'secp256k1_blake160_sighash_all',
|
|
8
|
-
script:
|
|
9
|
-
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
|
|
10
|
-
hashType: 'type',
|
|
11
|
-
cellDeps: [
|
|
12
|
-
{
|
|
13
|
-
cellDep: {
|
|
14
|
-
outPoint: {
|
|
15
|
-
txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37',
|
|
16
|
-
index: 0,
|
|
17
|
-
},
|
|
18
|
-
depType: 'depGroup',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
},
|
|
10
|
+
script: advanced_1.TESTNET_SCRIPTS.Secp256k1Blake160,
|
|
23
11
|
},
|
|
24
12
|
dao: {
|
|
25
13
|
name: 'dao',
|
|
26
|
-
script:
|
|
27
|
-
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
|
|
28
|
-
hashType: 'type',
|
|
29
|
-
cellDeps: [
|
|
30
|
-
{
|
|
31
|
-
cellDep: {
|
|
32
|
-
outPoint: {
|
|
33
|
-
txHash: '0x8f8c79eb6671709633fe6a46de93c0fedc9c1b8a6527a18d3983879542635c9f',
|
|
34
|
-
index: 2,
|
|
35
|
-
},
|
|
36
|
-
depType: 'code',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
},
|
|
14
|
+
script: advanced_1.TESTNET_SCRIPTS.NervosDao,
|
|
41
15
|
},
|
|
42
16
|
secp256k1_blake160_multisig_all: {
|
|
43
17
|
name: 'secp256k1_blake160_multisig_all',
|
|
44
|
-
|
|
45
|
-
script: {
|
|
46
|
-
codeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
|
|
47
|
-
hashType: 'type',
|
|
48
|
-
cellDeps: [
|
|
49
|
-
{
|
|
50
|
-
cellDep: {
|
|
51
|
-
outPoint: {
|
|
52
|
-
txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37',
|
|
53
|
-
index: 1,
|
|
54
|
-
},
|
|
55
|
-
depType: 'depGroup',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
18
|
+
script: advanced_1.TESTNET_SCRIPTS.Secp256k1Multisig,
|
|
60
19
|
},
|
|
61
20
|
sudt: {
|
|
62
21
|
name: 'sudt',
|
|
@@ -78,57 +37,15 @@ exports.TESTNET_SYSTEM_SCRIPTS = {
|
|
|
78
37
|
},
|
|
79
38
|
xudt: {
|
|
80
39
|
name: 'xudt',
|
|
81
|
-
script:
|
|
82
|
-
codeHash: '0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb',
|
|
83
|
-
hashType: 'type',
|
|
84
|
-
cellDeps: [
|
|
85
|
-
{
|
|
86
|
-
cellDep: {
|
|
87
|
-
outPoint: {
|
|
88
|
-
txHash: '0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f',
|
|
89
|
-
index: 0,
|
|
90
|
-
},
|
|
91
|
-
depType: 'code',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
},
|
|
40
|
+
script: advanced_1.TESTNET_SCRIPTS.XUdt,
|
|
96
41
|
},
|
|
97
42
|
omnilock: {
|
|
98
43
|
name: 'omnilock',
|
|
99
|
-
script:
|
|
100
|
-
codeHash: '0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb',
|
|
101
|
-
hashType: 'type',
|
|
102
|
-
cellDeps: [
|
|
103
|
-
{
|
|
104
|
-
cellDep: {
|
|
105
|
-
outPoint: {
|
|
106
|
-
txHash: '0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602',
|
|
107
|
-
index: 0,
|
|
108
|
-
},
|
|
109
|
-
depType: 'code',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
44
|
+
script: advanced_1.TESTNET_SCRIPTS.OmniLock,
|
|
114
45
|
},
|
|
115
46
|
anyone_can_pay: {
|
|
116
47
|
name: 'anyone_can_pay',
|
|
117
|
-
script:
|
|
118
|
-
codeHash: '0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356',
|
|
119
|
-
hashType: 'type',
|
|
120
|
-
cellDeps: [
|
|
121
|
-
{
|
|
122
|
-
cellDep: {
|
|
123
|
-
outPoint: {
|
|
124
|
-
txHash: '0xec26b0f85ed839ece5f11c4c4e837ec359f5adc4420410f6453b1f6b60fb96a6',
|
|
125
|
-
index: 0,
|
|
126
|
-
},
|
|
127
|
-
depType: 'depGroup',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
},
|
|
48
|
+
script: advanced_1.TESTNET_SCRIPTS.AnyoneCanPay,
|
|
132
49
|
},
|
|
133
50
|
always_success: undefined,
|
|
134
51
|
spore: {
|
|
@@ -225,57 +142,15 @@ exports.TESTNET_SYSTEM_SCRIPTS = {
|
|
|
225
142
|
exports.MAINNET_SYSTEM_SCRIPTS = {
|
|
226
143
|
secp256k1_blake160_sighash_all: {
|
|
227
144
|
name: 'secp256k1_blake160_sighash_all',
|
|
228
|
-
script:
|
|
229
|
-
codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
|
|
230
|
-
hashType: 'type',
|
|
231
|
-
cellDeps: [
|
|
232
|
-
{
|
|
233
|
-
cellDep: {
|
|
234
|
-
outPoint: {
|
|
235
|
-
txHash: '0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c',
|
|
236
|
-
index: 0,
|
|
237
|
-
},
|
|
238
|
-
depType: 'depGroup',
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
},
|
|
145
|
+
script: advanced_2.MAINNET_SCRIPTS.Secp256k1Blake160,
|
|
243
146
|
},
|
|
244
147
|
dao: {
|
|
245
148
|
name: 'dao',
|
|
246
|
-
script:
|
|
247
|
-
codeHash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
|
|
248
|
-
hashType: 'type',
|
|
249
|
-
cellDeps: [
|
|
250
|
-
{
|
|
251
|
-
cellDep: {
|
|
252
|
-
outPoint: {
|
|
253
|
-
txHash: '0xe2fb199810d49a4d8beec56718ba2593b665db9d52299a0f9e6e75416d73ff5c',
|
|
254
|
-
index: 2,
|
|
255
|
-
},
|
|
256
|
-
depType: 'code',
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
},
|
|
149
|
+
script: advanced_2.MAINNET_SCRIPTS.NervosDao,
|
|
261
150
|
},
|
|
262
151
|
secp256k1_blake160_multisig_all: {
|
|
263
152
|
name: 'secp256k1_blake160_multisig_all',
|
|
264
|
-
script:
|
|
265
|
-
codeHash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
|
|
266
|
-
hashType: 'type',
|
|
267
|
-
cellDeps: [
|
|
268
|
-
{
|
|
269
|
-
cellDep: {
|
|
270
|
-
outPoint: {
|
|
271
|
-
txHash: '0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c',
|
|
272
|
-
index: 1,
|
|
273
|
-
},
|
|
274
|
-
depType: 'depGroup',
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
},
|
|
153
|
+
script: advanced_2.MAINNET_SCRIPTS.Secp256k1Multisig,
|
|
279
154
|
},
|
|
280
155
|
sudt: {
|
|
281
156
|
name: 'sudt',
|
|
@@ -297,57 +172,15 @@ exports.MAINNET_SYSTEM_SCRIPTS = {
|
|
|
297
172
|
},
|
|
298
173
|
xudt: {
|
|
299
174
|
name: 'xudt',
|
|
300
|
-
script:
|
|
301
|
-
codeHash: '0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95',
|
|
302
|
-
hashType: 'data1',
|
|
303
|
-
cellDeps: [
|
|
304
|
-
{
|
|
305
|
-
cellDep: {
|
|
306
|
-
outPoint: {
|
|
307
|
-
txHash: '0xc07844ce21b38e4b071dd0e1ee3b0e27afd8d7532491327f39b786343f558ab7',
|
|
308
|
-
index: 0,
|
|
309
|
-
},
|
|
310
|
-
depType: 'code',
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
|
-
},
|
|
175
|
+
script: advanced_2.MAINNET_SCRIPTS.XUdt,
|
|
315
176
|
},
|
|
316
177
|
omnilock: {
|
|
317
178
|
name: 'omnilock',
|
|
318
|
-
script:
|
|
319
|
-
codeHash: '0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26',
|
|
320
|
-
hashType: 'type',
|
|
321
|
-
cellDeps: [
|
|
322
|
-
{
|
|
323
|
-
cellDep: {
|
|
324
|
-
outPoint: {
|
|
325
|
-
txHash: '0xc76edf469816aa22f416503c38d0b533d2a018e253e379f134c3985b3472c842',
|
|
326
|
-
index: 0,
|
|
327
|
-
},
|
|
328
|
-
depType: 'code',
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
],
|
|
332
|
-
},
|
|
179
|
+
script: advanced_2.MAINNET_SCRIPTS.OmniLock,
|
|
333
180
|
},
|
|
334
181
|
anyone_can_pay: {
|
|
335
182
|
name: 'anyone_can_pay',
|
|
336
|
-
script:
|
|
337
|
-
codeHash: '0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354',
|
|
338
|
-
hashType: 'type',
|
|
339
|
-
cellDeps: [
|
|
340
|
-
{
|
|
341
|
-
cellDep: {
|
|
342
|
-
outPoint: {
|
|
343
|
-
txHash: '0x4153a2014952d7cac45f285ce9a7c5c0c0e1b21f2d378b82ac1433cb11c25c4d',
|
|
344
|
-
index: 0,
|
|
345
|
-
},
|
|
346
|
-
depType: 'depGroup',
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
],
|
|
350
|
-
},
|
|
183
|
+
script: advanced_2.MAINNET_SCRIPTS.AnyoneCanPay,
|
|
351
184
|
},
|
|
352
185
|
always_success: undefined,
|
|
353
186
|
spore: {
|
package/dist/scripts/type.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.3.0-
|
|
3
|
+
"version": "0.3.0-rc8",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/adm-zip": "^0.5.5",
|
|
49
|
+
"@types/cpu-features": "^0.0.3",
|
|
49
50
|
"@types/node": "^20.11.19",
|
|
50
51
|
"@types/node-fetch": "^2.6.11",
|
|
51
52
|
"@types/semver": "^7.5.7",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"child_process": "^1.0.2",
|
|
69
70
|
"ckb-transaction-dumper": "^0.4.0",
|
|
70
71
|
"commander": "^12.0.0",
|
|
72
|
+
"cpu-features": "^0.0.10",
|
|
71
73
|
"http-proxy": "^1.18.1",
|
|
72
74
|
"https-proxy-agent": "^7.0.5",
|
|
73
75
|
"node-fetch": "2",
|
|
@@ -21,7 +21,7 @@ export enum SystemScriptName {
|
|
|
21
21
|
|
|
22
22
|
export interface ScriptInfo {
|
|
23
23
|
codeHash: `0x${string}`;
|
|
24
|
-
hashType: 'type' | 'data';
|
|
24
|
+
hashType: 'type' | 'data' | 'data1';
|
|
25
25
|
cellDeps: {
|
|
26
26
|
cellDep: {
|
|
27
27
|
outPoint: {
|
|
@@ -30,6 +30,11 @@ export interface ScriptInfo {
|
|
|
30
30
|
};
|
|
31
31
|
depType: 'code' | 'dep_group';
|
|
32
32
|
};
|
|
33
|
+
type?: {
|
|
34
|
+
codeHash: `0x${string}`;
|
|
35
|
+
hashType: 'type' | 'data' | 'data1';
|
|
36
|
+
args: `0x${string}`;
|
|
37
|
+
};
|
|
33
38
|
}[];
|
|
34
39
|
}
|
|
35
40
|
|