@offckb/cli 0.2.6 → 0.3.0-canary-cfe9b48.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 +59 -17
- package/ckb/devnet/specs/dev.toml +7 -7
- package/dist/cfg/env-path.d.ts +9 -0
- package/dist/cfg/env-path.js +63 -0
- package/dist/cfg/setting.d.ts +45 -0
- package/dist/cfg/setting.js +124 -0
- package/dist/cli.js +54 -30
- package/dist/cmd/clean.js +7 -5
- package/dist/cmd/config.d.ts +11 -0
- package/dist/cmd/config.js +102 -0
- 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 +11 -7
- 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 +32 -32
- 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 +81 -0
- package/dist/{util/template.d.ts → template/option.d.ts} +1 -1
- package/dist/template/option.js +11 -0
- 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 +64 -0
- 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.d.ts +8 -0
- package/dist/util/request.js +57 -0
- 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 +9 -4
- package/templates/offckb.config.ts +3 -3
- package/templates/template.json +16 -0
- package/dist/cfg/const.d.ts +0 -21
- 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/dist/util/template.js +0 -30
- 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/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,9 +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
|
+
- [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)
|
|
28
32
|
- [Built-in scripts](#built-in-scripts)
|
|
29
33
|
- [Accounts](#accounts)
|
|
30
|
-
- [About
|
|
34
|
+
- [About CCC](#about-ccc)
|
|
35
|
+
- [FAQ](#faq)
|
|
31
36
|
- [Contributing](#contributing)
|
|
32
37
|
|
|
33
38
|
## Install
|
|
@@ -50,30 +55,27 @@ Options:
|
|
|
50
55
|
-h, --help display help for command
|
|
51
56
|
|
|
52
57
|
Commands:
|
|
53
|
-
create [your-project-name]
|
|
54
|
-
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
|
|
55
61
|
clean Clean the devnet data, need to stop running the chain first
|
|
56
62
|
accounts Print account list info
|
|
57
|
-
list-hashes
|
|
63
|
+
list-hashes [CKB-Version] Use the CKB to list blockchain scripts hashes
|
|
58
64
|
inject-config Add offckb.config.ts to your workspace
|
|
59
|
-
sync-config
|
|
65
|
+
sync-config Sync offckb.config.ts in your workspace
|
|
60
66
|
deposit [options] [toAddress] [amountInShannon] Deposit CKB tokens to address, only devnet and testnet
|
|
61
67
|
transfer [options] [toAddress] [amountInShannon] Transfer CKB tokens to address, only devnet and testnet
|
|
62
68
|
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
63
69
|
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
64
|
-
|
|
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
|
|
65
74
|
help [command] display help for command
|
|
66
75
|
```
|
|
67
76
|
|
|
68
77
|
*Use `offckb [command] -h` to learn more about a specific command.*
|
|
69
78
|
|
|
70
|
-
Sometimes you might encounter sudo permission problems. Granting the current user write access to the node_modules directory can resolve the problem.
|
|
71
|
-
|
|
72
|
-
```sh
|
|
73
|
-
sudo chown -R $(whoami) /usr/local/lib/node_modules
|
|
74
|
-
npm install -g @offckb/cli
|
|
75
|
-
```
|
|
76
|
-
|
|
77
79
|
## Get started
|
|
78
80
|
|
|
79
81
|
### Create a full-stack Project
|
|
@@ -94,7 +96,38 @@ You can create a new script project without a frontend. This is useful when you
|
|
|
94
96
|
offckb create <your-project-name> --script
|
|
95
97
|
```
|
|
96
98
|
|
|
97
|
-
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.
|
|
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
|
+
|
|
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
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
offckb config set proxy http://127.0.0.1:1086
|
|
123
|
+
> save new settings
|
|
124
|
+
offckb config get proxy
|
|
125
|
+
> http://127.0.0.1:1086
|
|
126
|
+
offckb config rm proxy
|
|
127
|
+
> save new settings
|
|
128
|
+
offckb config get proxy
|
|
129
|
+
> No Proxy.
|
|
130
|
+
```
|
|
98
131
|
|
|
99
132
|
## Built-in scripts
|
|
100
133
|
|
|
@@ -118,9 +151,18 @@ detail informations about each account are recorded in the `account/account.json
|
|
|
118
151
|
|
|
119
152
|
:warning: **DO NOT SEND REAL ASSETS INTO ALL THESE ACCOUNTS, YOU CAN LOOSE YOUR MONEY** :warning:
|
|
120
153
|
|
|
121
|
-
## 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.
|
|
122
157
|
|
|
123
|
-
|
|
158
|
+
## FAQ
|
|
159
|
+
|
|
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
|
+
```
|
|
124
166
|
|
|
125
167
|
## Contributing
|
|
126
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]
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
// take and adapt from https://github.com/sindresorhus/env-paths/blob/main/index.js
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const process_1 = __importDefault(require("process"));
|
|
10
|
+
const homedir = os_1.default.homedir();
|
|
11
|
+
const tmpdir = os_1.default.tmpdir();
|
|
12
|
+
const { env } = process_1.default;
|
|
13
|
+
const macos = (appName) => {
|
|
14
|
+
const library = path_1.default.join(homedir, 'Library');
|
|
15
|
+
return {
|
|
16
|
+
data: path_1.default.join(library, 'Application Support', appName),
|
|
17
|
+
config: path_1.default.join(library, 'Preferences', appName),
|
|
18
|
+
cache: path_1.default.join(library, 'Caches', appName),
|
|
19
|
+
log: path_1.default.join(library, 'Logs', appName),
|
|
20
|
+
temp: path_1.default.join(tmpdir, appName),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const windows = (appName) => {
|
|
24
|
+
const appData = env.APPDATA || path_1.default.join(homedir, 'AppData', 'Roaming');
|
|
25
|
+
const localAppData = env.LOCALAPPDATA || path_1.default.join(homedir, 'AppData', 'Local');
|
|
26
|
+
return {
|
|
27
|
+
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
28
|
+
data: path_1.default.join(localAppData, appName, 'Data'),
|
|
29
|
+
config: path_1.default.join(appData, appName, 'Config'),
|
|
30
|
+
cache: path_1.default.join(localAppData, appName, 'Cache'),
|
|
31
|
+
log: path_1.default.join(localAppData, appName, 'Log'),
|
|
32
|
+
temp: path_1.default.join(tmpdir, appName),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
36
|
+
const linux = (appName) => {
|
|
37
|
+
const username = path_1.default.basename(homedir);
|
|
38
|
+
return {
|
|
39
|
+
data: path_1.default.join(env.XDG_DATA_HOME || path_1.default.join(homedir, '.local', 'share'), appName),
|
|
40
|
+
config: path_1.default.join(env.XDG_CONFIG_HOME || path_1.default.join(homedir, '.config'), appName),
|
|
41
|
+
cache: path_1.default.join(env.XDG_CACHE_HOME || path_1.default.join(homedir, '.cache'), appName),
|
|
42
|
+
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
43
|
+
log: path_1.default.join(env.XDG_STATE_HOME || path_1.default.join(homedir, '.local', 'state'), appName),
|
|
44
|
+
temp: path_1.default.join(tmpdir, username, appName),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
function envPaths(appName, { suffix = 'nodejs' } = {}) {
|
|
48
|
+
if (typeof appName !== 'string') {
|
|
49
|
+
throw new TypeError(`Expected a string, got ${typeof appName}`);
|
|
50
|
+
}
|
|
51
|
+
if (suffix) {
|
|
52
|
+
// Add suffix to prevent possible conflict with native apps
|
|
53
|
+
appName += `-${suffix}`;
|
|
54
|
+
}
|
|
55
|
+
if (process_1.default.platform === 'darwin') {
|
|
56
|
+
return macos(appName);
|
|
57
|
+
}
|
|
58
|
+
if (process_1.default.platform === 'win32') {
|
|
59
|
+
return windows(appName);
|
|
60
|
+
}
|
|
61
|
+
return linux(appName);
|
|
62
|
+
}
|
|
63
|
+
exports.default = envPaths;
|
|
@@ -0,0 +1,45 @@
|
|
|
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;
|
|
7
|
+
export interface Settings {
|
|
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
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const defaultSettings: Settings;
|
|
42
|
+
export declare function readSettings(): Settings;
|
|
43
|
+
export declare function writeSettings(settings: Settings): void;
|
|
44
|
+
export declare function getCKBBinaryInstallPath(version: string): string;
|
|
45
|
+
export declare function getCKBBinaryPath(version: string): string;
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getCKBBinaryPath = exports.getCKBBinaryInstallPath = exports.writeSettings = exports.readSettings = exports.defaultSettings = exports.packageRootPath = exports.packageSrcPath = exports.cachePath = exports.dataPath = exports.configPath = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const env_path_1 = __importDefault(require("./env-path"));
|
|
33
|
+
const paths = (0, env_path_1.default)('offckb');
|
|
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, '../');
|
|
39
|
+
exports.defaultSettings = {
|
|
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
|
+
},
|
|
74
|
+
};
|
|
75
|
+
function readSettings() {
|
|
76
|
+
try {
|
|
77
|
+
if (fs.existsSync(exports.configPath)) {
|
|
78
|
+
const data = fs.readFileSync(exports.configPath, 'utf8');
|
|
79
|
+
return deepMerge(exports.defaultSettings, JSON.parse(data));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return exports.defaultSettings;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error('Error reading settings:', error);
|
|
87
|
+
return exports.defaultSettings;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.readSettings = readSettings;
|
|
91
|
+
function writeSettings(settings) {
|
|
92
|
+
try {
|
|
93
|
+
fs.mkdirSync(path.dirname(exports.configPath), { recursive: true });
|
|
94
|
+
fs.writeFileSync(exports.configPath, JSON.stringify(settings, null, 2));
|
|
95
|
+
console.log('save new settings');
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error('Error writing settings:', error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
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,9 +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");
|
|
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");
|
|
32
31
|
const version = require('../package.json').version;
|
|
33
32
|
const description = require('../package.json').description;
|
|
34
33
|
// fix windows terminal encoding of simplified chinese text
|
|
@@ -47,10 +46,29 @@ program
|
|
|
47
46
|
const template = yield (0, create_1.selectBareTemplate)();
|
|
48
47
|
return (0, create_1.create)(name, template);
|
|
49
48
|
}));
|
|
50
|
-
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
|
+
});
|
|
51
66
|
program.command('clean').description('Clean the devnet data, need to stop running the chain first').action(clean_1.clean);
|
|
52
67
|
program.command('accounts').description('Print account list info').action(accounts_1.accounts);
|
|
53
|
-
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);
|
|
54
72
|
program.command('inject-config').description('Add offckb.config.ts to your workspace').action(inject_config_1.injectConfig);
|
|
55
73
|
program.command('sync-config').description('Sync offckb.config.ts in your workspace').action(sync_config_1.syncConfig);
|
|
56
74
|
program
|
|
@@ -83,30 +101,36 @@ program
|
|
|
83
101
|
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
84
102
|
.action((options) => (0, deploy_1.deploy)(options));
|
|
85
103
|
program
|
|
86
|
-
.command('
|
|
104
|
+
.command('my-scripts')
|
|
87
105
|
.description('Show deployed contracts info on different networks, only supports devnet and testnet')
|
|
88
106
|
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
89
|
-
.action((options) => (0,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
.action((options) => (0, my_scripts_1.printMyScripts)(options));
|
|
108
|
+
program
|
|
109
|
+
.command('config <action> [item] [value]')
|
|
110
|
+
.description('do a configuration action')
|
|
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
|
+
}));
|
|
110
134
|
program.parse(process.argv);
|
|
111
135
|
// If no command is specified, display help
|
|
112
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum ConfigAction {
|
|
2
|
+
list = "list",
|
|
3
|
+
get = "get",
|
|
4
|
+
set = "set",
|
|
5
|
+
rm = "rm"
|
|
6
|
+
}
|
|
7
|
+
export declare enum ConfigItem {
|
|
8
|
+
proxy = "proxy",
|
|
9
|
+
ckbVersion = "ckb-version"
|
|
10
|
+
}
|
|
11
|
+
export declare function Config(action: ConfigAction, item: ConfigItem, value?: string): Promise<void>;
|