@offckb/cli 0.2.7 → 0.3.0-canary-a9175e7.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/README.md +46 -19
- package/ckb/devnet/specs/dev.toml +7 -7
- package/dist/cfg/setting.d.ts +38 -0
- package/dist/cfg/setting.js +67 -7
- package/dist/cli.js +51 -32
- package/dist/cmd/clean.js +7 -5
- package/dist/cmd/config.d.ts +5 -3
- package/dist/cmd/config.js +39 -12
- package/dist/cmd/create.d.ts +1 -1
- package/dist/cmd/create.js +19 -8
- package/dist/cmd/debug.d.ts +13 -0
- package/dist/cmd/debug.js +100 -0
- package/dist/cmd/deploy.js +45 -25
- package/dist/cmd/deposit.js +9 -2
- package/dist/cmd/inject-config.d.ts +0 -3
- package/dist/cmd/inject-config.js +20 -80
- package/dist/cmd/list-hashes.d.ts +25 -1
- package/dist/cmd/list-hashes.js +24 -16
- package/dist/cmd/{deployed-scripts.d.ts → my-scripts.d.ts} +1 -1
- package/dist/cmd/my-scripts.js +25 -0
- package/dist/cmd/node.d.ts +5 -1
- package/dist/cmd/node.js +22 -8
- package/dist/cmd/proxy-rpc.d.ts +7 -0
- package/dist/cmd/proxy-rpc.js +23 -0
- package/dist/cmd/sync-config.js +16 -11
- package/dist/cmd/system-scripts.d.ts +42 -0
- package/dist/cmd/system-scripts.js +265 -0
- package/dist/deploy/migration.d.ts +45 -0
- package/dist/deploy/migration.js +131 -0
- package/dist/deploy/toml.d.ts +38 -0
- package/dist/deploy/toml.js +60 -0
- package/dist/deploy/util.d.ts +2 -0
- package/dist/deploy/util.js +19 -0
- package/dist/node/init-chain.js +41 -0
- package/dist/{cmd/develop → node}/install.d.ts +4 -5
- package/dist/{cmd/develop → node}/install.js +31 -31
- package/dist/scripts/gen.d.ts +5 -0
- package/dist/scripts/gen.js +69 -0
- package/dist/scripts/public.d.ts +8 -0
- package/dist/scripts/public.js +396 -0
- package/dist/scripts/type.d.ts +46 -0
- package/dist/scripts/type.js +19 -0
- package/dist/scripts/util.d.ts +3 -0
- package/dist/scripts/util.js +84 -0
- package/dist/template/config.d.ts +4 -0
- package/dist/template/config.js +60 -0
- package/dist/template/offckb.config.d.ts +69 -0
- package/dist/template/offckb.config.js +79 -0
- package/dist/{util/template.js → template/option.js} +2 -2
- package/dist/template/option.json +16 -0
- package/dist/tools/ckb-debugger.d.ts +12 -0
- package/dist/tools/ckb-debugger.js +31 -0
- package/dist/tools/ckb-tx-dumper.d.ts +6 -0
- package/dist/tools/ckb-tx-dumper.js +21 -0
- package/dist/tools/rpc-proxy.d.ts +9 -0
- package/dist/tools/rpc-proxy.js +84 -0
- package/dist/util/ckb.d.ts +3 -2
- package/dist/util/ckb.js +16 -3
- package/dist/util/encoding.d.ts +1 -0
- package/dist/util/encoding.js +7 -1
- package/dist/util/fs.d.ts +1 -2
- package/dist/util/fs.js +8 -32
- package/dist/util/git.js +19 -7
- package/dist/util/request.js +0 -1
- package/dist/util/type.d.ts +1 -0
- package/dist/util/validator.d.ts +1 -0
- package/dist/util/validator.js +13 -4
- package/package.json +6 -2
- package/dist/cfg/const.d.ts +0 -20
- package/dist/cfg/const.js +0 -51
- package/dist/cmd/deployed-scripts.js +0 -14
- package/dist/cmd/develop/build-account.d.ts +0 -1
- package/dist/cmd/develop/build-account.js +0 -9
- package/dist/cmd/develop/genkey.d.ts +0 -14
- package/dist/cmd/develop/genkey.js +0 -143
- package/dist/cmd/develop/init-chain.js +0 -76
- package/dist/cmd/develop/lumos-config.d.ts +0 -4
- package/dist/cmd/develop/lumos-config.js +0 -153
- package/dist/util/config.d.ts +0 -9
- package/dist/util/config.js +0 -136
- package/templates/config.json +0 -98
- /package/ckb/devnet/specs/{omni_lock → omnilock} +0 -0
- /package/ckb/devnet/specs/{spore-scripts → spore}/spore +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster → spore/spore_cluster} +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster_agent → spore/spore_cluster_agent} +0 -0
- /package/ckb/devnet/specs/{spore-scripts/cluster_proxy → spore/spore_cluster_proxy} +0 -0
- /package/ckb/devnet/specs/{spore-scripts → spore}/spore_extension_lua +0 -0
- /package/ckb/devnet/specs/{xudt_rce → xudt} +0 -0
- /package/dist/{cmd/develop → node}/init-chain.d.ts +0 -0
- /package/dist/{util/template.d.ts → template/option.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
- built-in scripts like [Omnilock](https://github.com/cryptape/omnilock) and [Spore-contract](https://github.com/sporeprotocol/spore-contract)
|
|
15
15
|
- multiple minimal dApp templates to learn and get your hands dirty
|
|
16
16
|
|
|
17
|
-
Start building on
|
|
17
|
+
Start building on CKB blockchain, right now, right away!
|
|
18
18
|
|
|
19
19
|
## Table of Contents
|
|
20
20
|
|
|
@@ -25,10 +25,14 @@ Start building on Nervos blockchain, right now, right away!
|
|
|
25
25
|
- [Get started](#get-started)
|
|
26
26
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
27
27
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
28
|
-
|
|
28
|
+
- [Config Setting](#config-setting)
|
|
29
|
+
- [List All Settings](#list-all-settings)
|
|
30
|
+
- [Set CKB version](#set-ckb-version)
|
|
31
|
+
- [Set Network Proxy](#set-network-proxy)
|
|
29
32
|
- [Built-in scripts](#built-in-scripts)
|
|
30
33
|
- [Accounts](#accounts)
|
|
31
|
-
- [About
|
|
34
|
+
- [About CCC](#about-ccc)
|
|
35
|
+
- [FAQ](#faq)
|
|
32
36
|
- [Contributing](#contributing)
|
|
33
37
|
|
|
34
38
|
## Install
|
|
@@ -51,31 +55,27 @@ Options:
|
|
|
51
55
|
-h, --help display help for command
|
|
52
56
|
|
|
53
57
|
Commands:
|
|
54
|
-
create [your-project-name]
|
|
55
|
-
node
|
|
58
|
+
create [options] [your-project-name] Create a new dApp from bare templates
|
|
59
|
+
node [options] [CKB-Version] Use the CKB to start devnet
|
|
60
|
+
proxy-rpc [options] Start the rpc proxy server
|
|
56
61
|
clean Clean the devnet data, need to stop running the chain first
|
|
57
62
|
accounts Print account list info
|
|
58
|
-
list-hashes
|
|
63
|
+
list-hashes [CKB-Version] Use the CKB to list blockchain scripts hashes
|
|
59
64
|
inject-config Add offckb.config.ts to your workspace
|
|
60
|
-
sync-config
|
|
65
|
+
sync-config Sync offckb.config.ts in your workspace
|
|
61
66
|
deposit [options] [toAddress] [amountInShannon] Deposit CKB tokens to address, only devnet and testnet
|
|
62
67
|
transfer [options] [toAddress] [amountInShannon] Transfer CKB tokens to address, only devnet and testnet
|
|
63
68
|
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
64
69
|
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
65
|
-
|
|
66
|
-
config <action>
|
|
70
|
+
my-scripts [options] Show deployed contracts info on different networks, only supports devnet and testnet
|
|
71
|
+
config <action> [item] [value] do a configuration action
|
|
72
|
+
debug [options] CKB Debugger for development
|
|
73
|
+
system-scripts [options] Output system scripts of the local devnet
|
|
67
74
|
help [command] display help for command
|
|
68
75
|
```
|
|
69
76
|
|
|
70
77
|
*Use `offckb [command] -h` to learn more about a specific command.*
|
|
71
78
|
|
|
72
|
-
Sometimes you might encounter sudo permission problems. Granting the current user write access to the node_modules directory can resolve the problem.
|
|
73
|
-
|
|
74
|
-
```sh
|
|
75
|
-
sudo chown -R $(whoami) /usr/local/lib/node_modules
|
|
76
|
-
npm install -g @offckb/cli
|
|
77
|
-
```
|
|
78
|
-
|
|
79
79
|
## Get started
|
|
80
80
|
|
|
81
81
|
### Create a full-stack Project
|
|
@@ -98,7 +98,25 @@ offckb create <your-project-name> --script
|
|
|
98
98
|
|
|
99
99
|
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-tempaltes) to do all the magic.
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
## Config Setting
|
|
102
|
+
|
|
103
|
+
### List All Settings
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
offckb config list
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Set CKB version
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
offckb config get ckb-version
|
|
113
|
+
> 0.113.0
|
|
114
|
+
offckb config set ckb-version 0.117.0
|
|
115
|
+
offckb config get ckb-version
|
|
116
|
+
> 0.117.0
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Set Network Proxy
|
|
102
120
|
|
|
103
121
|
```sh
|
|
104
122
|
offckb config set proxy http://127.0.0.1:1086
|
|
@@ -133,9 +151,18 @@ detail informations about each account are recorded in the `account/account.json
|
|
|
133
151
|
|
|
134
152
|
:warning: **DO NOT SEND REAL ASSETS INTO ALL THESE ACCOUNTS, YOU CAN LOOSE YOUR MONEY** :warning:
|
|
135
153
|
|
|
136
|
-
## About
|
|
154
|
+
## About CCC
|
|
155
|
+
|
|
156
|
+
`offckb` uses [CCC](https://github.com/ckb-ecofund/ccc) as the development framework to build the CKB dApp template projects.
|
|
157
|
+
|
|
158
|
+
## FAQ
|
|
137
159
|
|
|
138
|
-
|
|
160
|
+
Sometimes you might encounter sudo permission problems. Granting the current user write access to the node_modules directory can resolve the problem.
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
sudo chown -R $(whoami) /usr/local/lib/node_modules
|
|
164
|
+
npm install -g @offckb/cli
|
|
165
|
+
```
|
|
139
166
|
|
|
140
167
|
## Contributing
|
|
141
168
|
|
|
@@ -38,10 +38,10 @@ capacity = 100_000_0000_0000
|
|
|
38
38
|
file = { file = "sudt" }
|
|
39
39
|
create_type_id = true
|
|
40
40
|
[[genesis.system_cells]]
|
|
41
|
-
file = { file = "
|
|
41
|
+
file = { file = "xudt" }
|
|
42
42
|
create_type_id = true
|
|
43
43
|
[[genesis.system_cells]]
|
|
44
|
-
file = { file = "
|
|
44
|
+
file = { file = "omnilock" }
|
|
45
45
|
create_type_id = true
|
|
46
46
|
[[genesis.system_cells]]
|
|
47
47
|
file = { file = "anyone_can_pay" }
|
|
@@ -50,19 +50,19 @@ create_type_id = true
|
|
|
50
50
|
file = { file = "always_success" }
|
|
51
51
|
create_type_id = true
|
|
52
52
|
[[genesis.system_cells]]
|
|
53
|
-
file = { file = "spore
|
|
53
|
+
file = { file = "spore/spore" }
|
|
54
54
|
create_type_id = false
|
|
55
55
|
[[genesis.system_cells]]
|
|
56
|
-
file = { file = "spore
|
|
56
|
+
file = { file = "spore/spore_cluster" }
|
|
57
57
|
create_type_id = false
|
|
58
58
|
[[genesis.system_cells]]
|
|
59
|
-
file = { file = "spore
|
|
59
|
+
file = { file = "spore/spore_cluster_agent" }
|
|
60
60
|
create_type_id = false
|
|
61
61
|
[[genesis.system_cells]]
|
|
62
|
-
file = { file = "spore
|
|
62
|
+
file = { file = "spore/spore_cluster_proxy" }
|
|
63
63
|
create_type_id = false
|
|
64
64
|
[[genesis.system_cells]]
|
|
65
|
-
file = { file = "spore
|
|
65
|
+
file = { file = "spore/spore_extension_lua" }
|
|
66
66
|
create_type_id = false
|
|
67
67
|
|
|
68
68
|
[genesis.system_cells_lock]
|
package/dist/cfg/setting.d.ts
CHANGED
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
import { AxiosProxyConfig } from 'axios';
|
|
2
|
+
export declare const configPath: string;
|
|
3
|
+
export declare const dataPath: string;
|
|
4
|
+
export declare const cachePath: string;
|
|
5
|
+
export declare const packageSrcPath: string;
|
|
6
|
+
export declare const packageRootPath: string;
|
|
2
7
|
export interface Settings {
|
|
3
8
|
proxy?: AxiosProxyConfig;
|
|
9
|
+
rpc: {
|
|
10
|
+
proxyPort: number;
|
|
11
|
+
};
|
|
12
|
+
bins: {
|
|
13
|
+
rootFolder: string;
|
|
14
|
+
defaultCKBVersion: string;
|
|
15
|
+
downloadPath: string;
|
|
16
|
+
};
|
|
17
|
+
devnet: {
|
|
18
|
+
rpcUrl: string;
|
|
19
|
+
configPath: string;
|
|
20
|
+
dataPath: string;
|
|
21
|
+
debugFullTransactionsPath: string;
|
|
22
|
+
transactionsPath: string;
|
|
23
|
+
failedTransactionsPath: string;
|
|
24
|
+
contractsPath: string;
|
|
25
|
+
};
|
|
26
|
+
testnet: {
|
|
27
|
+
rpcUrl: string;
|
|
28
|
+
contractsPath: string;
|
|
29
|
+
};
|
|
30
|
+
mainnet: {
|
|
31
|
+
rpcUrl: string;
|
|
32
|
+
contractsPath: string;
|
|
33
|
+
};
|
|
34
|
+
dappTemplate: {
|
|
35
|
+
gitRepoUrl: string;
|
|
36
|
+
gitBranch: string;
|
|
37
|
+
gitFolder: string;
|
|
38
|
+
downloadPath: string;
|
|
39
|
+
};
|
|
4
40
|
}
|
|
5
41
|
export declare const defaultSettings: Settings;
|
|
6
42
|
export declare function readSettings(): Settings;
|
|
7
43
|
export declare function writeSettings(settings: Settings): void;
|
|
44
|
+
export declare function getCKBBinaryInstallPath(version: string): string;
|
|
45
|
+
export declare function getCKBBinaryPath(version: string): string;
|
package/dist/cfg/setting.js
CHANGED
|
@@ -26,20 +26,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.writeSettings = exports.readSettings = exports.defaultSettings = void 0;
|
|
29
|
+
exports.getCKBBinaryPath = exports.getCKBBinaryInstallPath = exports.writeSettings = exports.readSettings = exports.defaultSettings = exports.packageRootPath = exports.packageSrcPath = exports.cachePath = exports.dataPath = exports.configPath = void 0;
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const path = __importStar(require("path"));
|
|
32
32
|
const env_path_1 = __importDefault(require("./env-path"));
|
|
33
33
|
const paths = (0, env_path_1.default)('offckb');
|
|
34
|
-
|
|
34
|
+
exports.configPath = path.join(paths.config, 'settings.json');
|
|
35
|
+
exports.dataPath = paths.data;
|
|
36
|
+
exports.cachePath = paths.cache;
|
|
37
|
+
exports.packageSrcPath = path.dirname(require.main.filename);
|
|
38
|
+
exports.packageRootPath = path.resolve(exports.packageSrcPath, '../');
|
|
35
39
|
exports.defaultSettings = {
|
|
36
40
|
proxy: undefined,
|
|
41
|
+
rpc: {
|
|
42
|
+
proxyPort: 9000,
|
|
43
|
+
},
|
|
44
|
+
bins: {
|
|
45
|
+
rootFolder: path.resolve(exports.dataPath, 'bins'),
|
|
46
|
+
defaultCKBVersion: '0.113.1',
|
|
47
|
+
downloadPath: path.resolve(exports.cachePath, 'download'),
|
|
48
|
+
},
|
|
49
|
+
devnet: {
|
|
50
|
+
rpcUrl: 'http://localhost:8114',
|
|
51
|
+
// todo: maybe add a root folder for all devnet data
|
|
52
|
+
// so we can clean it easily
|
|
53
|
+
configPath: path.resolve(exports.dataPath, 'devnet'),
|
|
54
|
+
dataPath: path.resolve(exports.dataPath, 'devnet/data'),
|
|
55
|
+
debugFullTransactionsPath: path.resolve(exports.dataPath, 'devnet/full-transactions'),
|
|
56
|
+
transactionsPath: path.resolve(exports.dataPath, 'devnet/transactions'),
|
|
57
|
+
failedTransactionsPath: path.resolve(exports.dataPath, 'devnet/failed-transactions'),
|
|
58
|
+
contractsPath: path.resolve(exports.dataPath, 'devnet/contracts'),
|
|
59
|
+
},
|
|
60
|
+
testnet: {
|
|
61
|
+
rpcUrl: 'https://testnet.ckb.dev',
|
|
62
|
+
contractsPath: path.resolve(exports.dataPath, 'testnet/contracts'),
|
|
63
|
+
},
|
|
64
|
+
mainnet: {
|
|
65
|
+
rpcUrl: 'https://mainnet.ckb.dev',
|
|
66
|
+
contractsPath: path.resolve(exports.dataPath, 'mainnet/contracts'),
|
|
67
|
+
},
|
|
68
|
+
dappTemplate: {
|
|
69
|
+
gitRepoUrl: `https://github.com/ckb-ecofund/offckb`,
|
|
70
|
+
gitBranch: 'v0.3.x',
|
|
71
|
+
gitFolder: 'templates/v3',
|
|
72
|
+
downloadPath: path.resolve(exports.cachePath, 'download', 'dapp-template'),
|
|
73
|
+
},
|
|
37
74
|
};
|
|
38
75
|
function readSettings() {
|
|
39
76
|
try {
|
|
40
|
-
if (fs.existsSync(configPath)) {
|
|
41
|
-
const data = fs.readFileSync(configPath, 'utf8');
|
|
42
|
-
return JSON.parse(data);
|
|
77
|
+
if (fs.existsSync(exports.configPath)) {
|
|
78
|
+
const data = fs.readFileSync(exports.configPath, 'utf8');
|
|
79
|
+
return deepMerge(exports.defaultSettings, JSON.parse(data));
|
|
43
80
|
}
|
|
44
81
|
else {
|
|
45
82
|
return exports.defaultSettings;
|
|
@@ -53,8 +90,8 @@ function readSettings() {
|
|
|
53
90
|
exports.readSettings = readSettings;
|
|
54
91
|
function writeSettings(settings) {
|
|
55
92
|
try {
|
|
56
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
57
|
-
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2));
|
|
93
|
+
fs.mkdirSync(path.dirname(exports.configPath), { recursive: true });
|
|
94
|
+
fs.writeFileSync(exports.configPath, JSON.stringify(settings, null, 2));
|
|
58
95
|
console.log('save new settings');
|
|
59
96
|
}
|
|
60
97
|
catch (error) {
|
|
@@ -62,3 +99,26 @@ function writeSettings(settings) {
|
|
|
62
99
|
}
|
|
63
100
|
}
|
|
64
101
|
exports.writeSettings = writeSettings;
|
|
102
|
+
function getCKBBinaryInstallPath(version) {
|
|
103
|
+
const setting = readSettings();
|
|
104
|
+
return `${setting.bins.rootFolder}/${version}`;
|
|
105
|
+
}
|
|
106
|
+
exports.getCKBBinaryInstallPath = getCKBBinaryInstallPath;
|
|
107
|
+
function getCKBBinaryPath(version) {
|
|
108
|
+
return `${getCKBBinaryInstallPath(version)}/ckb`;
|
|
109
|
+
}
|
|
110
|
+
exports.getCKBBinaryPath = getCKBBinaryPath;
|
|
111
|
+
function deepMerge(target, source) {
|
|
112
|
+
for (const key in source) {
|
|
113
|
+
if (source[key] && typeof source[key] === 'object') {
|
|
114
|
+
if (!target[key]) {
|
|
115
|
+
target[key] = {};
|
|
116
|
+
}
|
|
117
|
+
deepMerge(target[key], source[key]);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
target[key] = source[key];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return target;
|
|
124
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -11,12 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
const commander_1 = require("commander");
|
|
14
|
-
const install_1 = require("./cmd/develop/install");
|
|
15
|
-
const genkey_1 = require("./cmd/develop/genkey");
|
|
16
14
|
const list_hashes_1 = require("./cmd/list-hashes");
|
|
17
15
|
const node_1 = require("./cmd/node");
|
|
18
|
-
const init_chain_1 = require("./cmd/develop/init-chain");
|
|
19
|
-
const lumos_config_1 = require("./cmd/develop/lumos-config");
|
|
20
16
|
const accounts_1 = require("./cmd/accounts");
|
|
21
17
|
const clean_1 = require("./cmd/clean");
|
|
22
18
|
const encoding_1 = require("./util/encoding");
|
|
@@ -26,10 +22,12 @@ const deploy_1 = require("./cmd/deploy");
|
|
|
26
22
|
const sync_config_1 = require("./cmd/sync-config");
|
|
27
23
|
const transfer_1 = require("./cmd/transfer");
|
|
28
24
|
const balance_1 = require("./cmd/balance");
|
|
29
|
-
const build_account_1 = require("./cmd/develop/build-account");
|
|
30
25
|
const create_1 = require("./cmd/create");
|
|
31
|
-
const
|
|
26
|
+
const my_scripts_1 = require("./cmd/my-scripts");
|
|
32
27
|
const config_1 = require("./cmd/config");
|
|
28
|
+
const debug_1 = require("./cmd/debug");
|
|
29
|
+
const system_scripts_1 = require("./cmd/system-scripts");
|
|
30
|
+
const proxy_rpc_1 = require("./cmd/proxy-rpc");
|
|
33
31
|
const version = require('../package.json').version;
|
|
34
32
|
const description = require('../package.json').description;
|
|
35
33
|
// fix windows terminal encoding of simplified chinese text
|
|
@@ -48,10 +46,29 @@ program
|
|
|
48
46
|
const template = yield (0, create_1.selectBareTemplate)();
|
|
49
47
|
return (0, create_1.create)(name, template);
|
|
50
48
|
}));
|
|
51
|
-
program
|
|
49
|
+
program
|
|
50
|
+
.command('node [CKB-Version]')
|
|
51
|
+
.description('Use the CKB to start devnet')
|
|
52
|
+
.option('--no-proxy', 'Do not start the rpc proxy server', true)
|
|
53
|
+
.action((version, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
// commander.js change our noProxy option to proxy
|
|
55
|
+
return (0, node_1.node)({ version, noProxyServer: !options.proxy });
|
|
56
|
+
}));
|
|
57
|
+
program
|
|
58
|
+
.command('proxy-rpc')
|
|
59
|
+
.description('Start the rpc proxy server')
|
|
60
|
+
.option('--ckb-rpc <ckbRpc>', 'Specify the ckb rpc address')
|
|
61
|
+
.option('--port <port>', 'Specify the port to start the proxy server')
|
|
62
|
+
.option('--network <network>', 'Specify the network to proxy')
|
|
63
|
+
.action((options) => {
|
|
64
|
+
return (0, proxy_rpc_1.proxyRpc)(options);
|
|
65
|
+
});
|
|
52
66
|
program.command('clean').description('Clean the devnet data, need to stop running the chain first').action(clean_1.clean);
|
|
53
67
|
program.command('accounts').description('Print account list info').action(accounts_1.accounts);
|
|
54
|
-
program
|
|
68
|
+
program
|
|
69
|
+
.command('list-hashes [CKB-Version]')
|
|
70
|
+
.description('Use the CKB to list blockchain scripts hashes')
|
|
71
|
+
.action(list_hashes_1.listHashes);
|
|
55
72
|
program.command('inject-config').description('Add offckb.config.ts to your workspace').action(inject_config_1.injectConfig);
|
|
56
73
|
program.command('sync-config').description('Sync offckb.config.ts in your workspace').action(sync_config_1.syncConfig);
|
|
57
74
|
program
|
|
@@ -84,34 +101,36 @@ program
|
|
|
84
101
|
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
85
102
|
.action((options) => (0, deploy_1.deploy)(options));
|
|
86
103
|
program
|
|
87
|
-
.command('
|
|
104
|
+
.command('my-scripts')
|
|
88
105
|
.description('Show deployed contracts info on different networks, only supports devnet and testnet')
|
|
89
106
|
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
90
|
-
.action((options) => (0,
|
|
107
|
+
.action((options) => (0, my_scripts_1.printMyScripts)(options));
|
|
91
108
|
program
|
|
92
|
-
.command('config <action>
|
|
109
|
+
.command('config <action> [item] [value]')
|
|
93
110
|
.description('do a configuration action')
|
|
94
|
-
.action((action,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
.action((action, item, value) => (0, config_1.Config)(action, item, value));
|
|
112
|
+
program
|
|
113
|
+
.command('debug')
|
|
114
|
+
.requiredOption('--tx-hash <txHash>', 'Specify the transaction hash to debug with')
|
|
115
|
+
.option('--single-script <singleScript>', 'Specify the cell script to debug with')
|
|
116
|
+
.option('--bin <bin>', 'Specify a binary to replace the script to debug with')
|
|
117
|
+
.description('CKB Debugger for development')
|
|
118
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
const txHash = option.txHash;
|
|
120
|
+
if (option.singleScript) {
|
|
121
|
+
const { cellType, cellIndex, scriptType } = (0, debug_1.parseSingleScriptOption)(option.singleScript);
|
|
122
|
+
return (0, debug_1.debugSingleScript)(txHash, cellIndex, cellType, scriptType, option.bin);
|
|
123
|
+
}
|
|
124
|
+
return (0, debug_1.debugTransaction)(txHash);
|
|
125
|
+
}));
|
|
126
|
+
program
|
|
127
|
+
.command('system-scripts')
|
|
128
|
+
.option('--export-style <exportStyle>', 'Specify the export format, possible values are lumos and ccc.')
|
|
129
|
+
.description('Output system scripts of the local devnet')
|
|
130
|
+
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
+
const exportStyle = option.exportStyle;
|
|
132
|
+
return (0, system_scripts_1.printSystemScripts)(exportStyle);
|
|
133
|
+
}));
|
|
115
134
|
program.parse(process.argv);
|
|
116
135
|
// If no command is specified, display help
|
|
117
136
|
if (!process.argv.slice(2).length) {
|
package/dist/cmd/clean.js
CHANGED
|
@@ -4,15 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.clean = void 0;
|
|
7
|
-
const const_1 = require("../cfg/const");
|
|
8
7
|
const fs_1 = __importDefault(require("fs"));
|
|
9
8
|
const fs_2 = require("../util/fs");
|
|
9
|
+
const setting_1 = require("../cfg/setting");
|
|
10
10
|
function clean() {
|
|
11
|
-
|
|
11
|
+
const settings = (0, setting_1.readSettings)();
|
|
12
|
+
const allDevnetDataPath = settings.devnet.configPath;
|
|
13
|
+
// this is the root folder of devnet, it contains config, data, debugFullTransactions, transactions, failed-transactions, contracts
|
|
14
|
+
if ((0, fs_2.isFolderExists)(allDevnetDataPath)) {
|
|
12
15
|
try {
|
|
13
|
-
fs_1.default.rmSync(
|
|
16
|
+
fs_1.default.rmSync(allDevnetDataPath, { recursive: true });
|
|
14
17
|
console.log(`Chain data cleaned.`);
|
|
15
|
-
// todo: rm deploy info too
|
|
16
18
|
}
|
|
17
19
|
catch (error) {
|
|
18
20
|
console.log(`Did you stop running the chain first?`);
|
|
@@ -20,7 +22,7 @@ function clean() {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
else {
|
|
23
|
-
console.log(`${
|
|
25
|
+
console.log(`${allDevnetDataPath} not found, unable to clean it.`);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
exports.clean = clean;
|
package/dist/cmd/config.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare enum ConfigAction {
|
|
2
|
+
list = "list",
|
|
2
3
|
get = "get",
|
|
3
4
|
set = "set",
|
|
4
5
|
rm = "rm"
|
|
5
6
|
}
|
|
6
|
-
export declare enum
|
|
7
|
-
proxy = "proxy"
|
|
7
|
+
export declare enum ConfigItem {
|
|
8
|
+
proxy = "proxy",
|
|
9
|
+
ckbVersion = "ckb-version"
|
|
8
10
|
}
|
|
9
|
-
export declare function Config(action: ConfigAction,
|
|
11
|
+
export declare function Config(action: ConfigAction, item: ConfigItem, value?: string): Promise<void>;
|
package/dist/cmd/config.js
CHANGED
|
@@ -9,24 +9,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Config = exports.
|
|
12
|
+
exports.Config = exports.ConfigItem = exports.ConfigAction = void 0;
|
|
13
13
|
const setting_1 = require("../cfg/setting");
|
|
14
14
|
const request_1 = require("../util/request");
|
|
15
|
+
const validator_1 = require("../util/validator");
|
|
15
16
|
var ConfigAction;
|
|
16
17
|
(function (ConfigAction) {
|
|
18
|
+
ConfigAction["list"] = "list";
|
|
17
19
|
ConfigAction["get"] = "get";
|
|
18
20
|
ConfigAction["set"] = "set";
|
|
19
21
|
ConfigAction["rm"] = "rm";
|
|
20
22
|
})(ConfigAction || (exports.ConfigAction = ConfigAction = {}));
|
|
21
|
-
var
|
|
22
|
-
(function (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
var ConfigItem;
|
|
24
|
+
(function (ConfigItem) {
|
|
25
|
+
ConfigItem["proxy"] = "proxy";
|
|
26
|
+
ConfigItem["ckbVersion"] = "ckb-version";
|
|
27
|
+
})(ConfigItem || (exports.ConfigItem = ConfigItem = {}));
|
|
28
|
+
function Config(action, item, value) {
|
|
26
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (action === ConfigAction.list) {
|
|
31
|
+
console.log('config file: ', setting_1.configPath);
|
|
32
|
+
return console.log((0, setting_1.readSettings)());
|
|
33
|
+
}
|
|
27
34
|
if (action === ConfigAction.get) {
|
|
28
|
-
switch (
|
|
29
|
-
case
|
|
35
|
+
switch (item) {
|
|
36
|
+
case ConfigItem.proxy: {
|
|
30
37
|
const settings = (0, setting_1.readSettings)();
|
|
31
38
|
const proxy = settings.proxy;
|
|
32
39
|
if (proxy == null) {
|
|
@@ -35,13 +42,18 @@ function Config(action, section, value) {
|
|
|
35
42
|
}
|
|
36
43
|
return console.log(`${request_1.Request.proxyConfigToUrl(proxy)}`);
|
|
37
44
|
}
|
|
45
|
+
case ConfigItem.ckbVersion: {
|
|
46
|
+
const settings = (0, setting_1.readSettings)();
|
|
47
|
+
const version = settings.bins.defaultCKBVersion;
|
|
48
|
+
return console.log(`${version}`);
|
|
49
|
+
}
|
|
38
50
|
default:
|
|
39
51
|
break;
|
|
40
52
|
}
|
|
41
53
|
}
|
|
42
54
|
if (action === ConfigAction.set) {
|
|
43
|
-
switch (
|
|
44
|
-
case
|
|
55
|
+
switch (item) {
|
|
56
|
+
case ConfigItem.proxy: {
|
|
45
57
|
if (value == null)
|
|
46
58
|
throw new Error('No proxyUrl!');
|
|
47
59
|
try {
|
|
@@ -54,13 +66,28 @@ function Config(action, section, value) {
|
|
|
54
66
|
return console.error(`invalid proxyURL, `, error.message);
|
|
55
67
|
}
|
|
56
68
|
}
|
|
69
|
+
case ConfigItem.ckbVersion: {
|
|
70
|
+
const settings = (0, setting_1.readSettings)();
|
|
71
|
+
try {
|
|
72
|
+
if ((0, validator_1.isValidVersion)(value)) {
|
|
73
|
+
settings.bins.defaultCKBVersion = value;
|
|
74
|
+
return (0, setting_1.writeSettings)(settings);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return console.error(`invalid version value, `, value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return console.error(`invalid version value, `, error.message);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
57
84
|
default:
|
|
58
85
|
break;
|
|
59
86
|
}
|
|
60
87
|
}
|
|
61
88
|
if (action === ConfigAction.rm) {
|
|
62
|
-
switch (
|
|
63
|
-
case
|
|
89
|
+
switch (item) {
|
|
90
|
+
case ConfigItem.proxy: {
|
|
64
91
|
const settings = (0, setting_1.readSettings)();
|
|
65
92
|
settings.proxy = undefined;
|
|
66
93
|
return (0, setting_1.writeSettings)(settings);
|
package/dist/cmd/create.d.ts
CHANGED
package/dist/cmd/create.js
CHANGED
|
@@ -14,12 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.selectBareTemplate = exports.create = exports.createScriptProject = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const const_1 = require("../cfg/const");
|
|
18
17
|
const fs_1 = require("../util/fs");
|
|
19
|
-
const template_1 = require("../util/template");
|
|
20
18
|
const git_1 = require("../util/git");
|
|
21
19
|
const prompts_1 = require("@inquirer/prompts");
|
|
22
20
|
const child_process_1 = require("child_process");
|
|
21
|
+
const gen_1 = require("../scripts/gen");
|
|
22
|
+
const setting_1 = require("../cfg/setting");
|
|
23
|
+
const option_1 = require("../template/option");
|
|
24
|
+
const config_1 = require("../template/config");
|
|
23
25
|
const version = require('../../package.json').version;
|
|
24
26
|
function createScriptProject(name) {
|
|
25
27
|
const cmd = `cargo generate gh:cryptape/ckb-script-templates workspace --name ${name}`;
|
|
@@ -33,14 +35,23 @@ function createScriptProject(name) {
|
|
|
33
35
|
exports.createScriptProject = createScriptProject;
|
|
34
36
|
function create(name, template) {
|
|
35
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const targetPath = path_1.default.resolve(
|
|
37
|
-
const
|
|
38
|
-
|
|
38
|
+
const targetPath = path_1.default.resolve(process.cwd(), name);
|
|
39
|
+
const settings = (0, setting_1.readSettings)();
|
|
40
|
+
const dappTemplateFolderPath = `${settings.dappTemplate.gitFolder}/${template.value}`;
|
|
41
|
+
(0, git_1.gitCloneAndDownloadFolderSync)(settings.dappTemplate.gitRepoUrl, settings.dappTemplate.gitBranch, dappTemplateFolderPath, targetPath);
|
|
39
42
|
// update the version
|
|
40
|
-
const projectFolder = path_1.default.resolve(
|
|
43
|
+
const projectFolder = path_1.default.resolve(process.cwd(), name);
|
|
41
44
|
const targetConfigPath = (0, fs_1.findFileInFolder)(projectFolder, 'offckb.config.ts');
|
|
42
45
|
if (targetConfigPath) {
|
|
43
|
-
|
|
46
|
+
config_1.OffCKBConfigFile.updateVersion(version, targetConfigPath);
|
|
47
|
+
const contractInfoFolder = config_1.OffCKBConfigFile.readContractInfoFolder(targetConfigPath);
|
|
48
|
+
if (!contractInfoFolder) {
|
|
49
|
+
throw new Error('No contract info folder found in offckb.config.ts!');
|
|
50
|
+
}
|
|
51
|
+
const systemJsonFilePath = path_1.default.resolve(contractInfoFolder, 'system-scripts.json');
|
|
52
|
+
(0, gen_1.genSystemScriptsJsonFile)(systemJsonFilePath);
|
|
53
|
+
const myScriptsJsonFilePath = path_1.default.resolve(contractInfoFolder, 'my-scripts.json');
|
|
54
|
+
(0, gen_1.genMyScriptsJsonFile)(myScriptsJsonFilePath);
|
|
44
55
|
}
|
|
45
56
|
else {
|
|
46
57
|
console.log("Couldn't find the offckb config file in project. abort.");
|
|
@@ -50,7 +61,7 @@ function create(name, template) {
|
|
|
50
61
|
exports.create = create;
|
|
51
62
|
function selectBareTemplate() {
|
|
52
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const opts = yield (0,
|
|
64
|
+
const opts = yield (0, option_1.loadBareTemplateOpts)();
|
|
54
65
|
const answer = yield (0, prompts_1.select)({
|
|
55
66
|
message: 'Select a bare template',
|
|
56
67
|
choices: opts.map((opt) => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function debugTransaction(txHash: string): void;
|
|
2
|
+
export declare function buildTransactionDebugOptions(txHash: string): {
|
|
3
|
+
name: string;
|
|
4
|
+
cmdOption: string;
|
|
5
|
+
}[];
|
|
6
|
+
export declare function debugSingleScript(txHash: string, cellIndex: number, cellType: 'input' | 'output', scriptType: 'type' | 'lock', bin?: string): void;
|
|
7
|
+
export declare function parseSingleScriptOption(value: string): {
|
|
8
|
+
cellType: "output" | "input";
|
|
9
|
+
cellIndex: number;
|
|
10
|
+
scriptType: "type" | "lock";
|
|
11
|
+
};
|
|
12
|
+
export declare function buildTxFileOptionBy(txHash: string): string;
|
|
13
|
+
export declare function debugRaw(options: string): void;
|