@offckb/cli 0.3.3 → 0.3.5
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 +15 -0
- package/dist/cfg/env-path.js +1 -1
- package/dist/cfg/setting.d.ts +3 -0
- package/dist/cfg/setting.js +26 -13
- package/dist/cli.js +21 -7
- package/dist/cmd/accounts.js +1 -2
- package/dist/cmd/balance.js +3 -4
- package/dist/cmd/clean.js +1 -2
- package/dist/cmd/config.js +2 -2
- package/dist/cmd/create.d.ts +11 -3
- package/dist/cmd/create.js +30 -4
- package/dist/cmd/debug.d.ts +1 -1
- package/dist/cmd/debug.js +9 -10
- package/dist/cmd/deploy.js +24 -7
- package/dist/cmd/deposit.js +3 -4
- package/dist/cmd/inject-config.js +20 -10
- package/dist/cmd/list-hashes.js +2 -3
- package/dist/cmd/mol.js +2 -3
- package/dist/cmd/my-scripts.js +1 -2
- package/dist/cmd/node.js +9 -10
- package/dist/cmd/proxy-rpc.js +1 -2
- package/dist/cmd/repl.js +5 -6
- package/dist/cmd/sync-scripts.js +1 -2
- package/dist/cmd/system-scripts.js +11 -11
- package/dist/cmd/transfer-all.js +3 -4
- package/dist/cmd/transfer.js +3 -4
- package/dist/deploy/index.js +6 -6
- package/dist/deploy/migration.js +25 -15
- package/dist/deploy/toml.js +2 -3
- package/dist/deploy/util.js +1 -2
- package/dist/molecule/mol.js +20 -10
- package/dist/node/init-chain.js +1 -2
- package/dist/node/install.js +26 -17
- package/dist/scripts/gen.js +21 -12
- package/dist/scripts/private.js +1 -2
- package/dist/scripts/util.js +18 -9
- package/dist/sdk/ckb.js +7 -7
- package/dist/template/offckb-config.js +17 -7
- package/dist/template/option.js +10 -4
- package/dist/tools/ckb-debugger.d.ts +1 -0
- package/dist/tools/ckb-debugger.js +15 -0
- package/dist/tools/ckb-tx-dumper.js +1 -2
- package/dist/tools/rpc-proxy.d.ts +0 -1
- package/dist/tools/rpc-proxy.js +1 -2
- package/dist/util/encoding.js +2 -3
- package/dist/util/fs.d.ts +1 -0
- package/dist/util/fs.js +34 -20
- package/dist/util/git.js +19 -10
- package/dist/util/link.js +1 -2
- package/dist/util/request.js +2 -2
- package/dist/util/validator.js +5 -6
- package/npm-shrinkwrap.json +4514 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
30
30
|
- [Tweak Devnet Config](#tweak-devnet-config)
|
|
31
31
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
32
32
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
33
|
+
- [Create a dApp-only Project](#create-a-dapp-only-project)
|
|
33
34
|
- [Build and Deploy a script](#build-and-deploy-a-script)
|
|
34
35
|
- [Start the frontend project](#start-the-frontend-project)
|
|
35
36
|
- [Debug a transaction](#debug-a-transaction)
|
|
@@ -54,6 +55,12 @@ There are BREAKING CHANGES between v0.2.x and v0.3.x, make sure to read the [mig
|
|
|
54
55
|
npm install -g @offckb/cli
|
|
55
56
|
```
|
|
56
57
|
|
|
58
|
+
or use `pnpm` to install:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
pnpm install -g @offckb/cli
|
|
62
|
+
```
|
|
63
|
+
|
|
57
64
|
_We recommend using [LTS](https://nodejs.org/en/download/package-manager) version of Node to run `offckb`_
|
|
58
65
|
|
|
59
66
|
## Usage
|
|
@@ -202,6 +209,14 @@ offckb create <your-project-name> --script
|
|
|
202
209
|
|
|
203
210
|
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-templates) to do all the magic.
|
|
204
211
|
|
|
212
|
+
### Create a dApp-only Project
|
|
213
|
+
|
|
214
|
+
You can create a new dApp project without the script(CKB Smart Contract). This is useful when you don't need to create your own on-chain script logic.
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
offckb create <your-project-name> --dapp # or -d
|
|
218
|
+
```
|
|
219
|
+
|
|
205
220
|
### Build and Deploy a script
|
|
206
221
|
|
|
207
222
|
The fullstack boilerplate project is a monorepo, which contains a script project and a frontend project.
|
package/dist/cfg/env-path.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = envPaths;
|
|
6
7
|
// take and adapt from https://github.com/sindresorhus/env-paths/blob/main/index.js
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const os_1 = __importDefault(require("os"));
|
|
@@ -60,4 +61,3 @@ function envPaths(appName, { suffix = 'nodejs' } = {}) {
|
|
|
60
61
|
}
|
|
61
62
|
return linux(appName);
|
|
62
63
|
}
|
|
63
|
-
exports.default = envPaths;
|
package/dist/cfg/setting.d.ts
CHANGED
package/dist/cfg/setting.js
CHANGED
|
@@ -15,18 +15,32 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.defaultSettings = exports.packageRootPath = exports.packageSrcPath = exports.cachePath = exports.dataPath = exports.configPath = void 0;
|
|
40
|
+
exports.readSettings = readSettings;
|
|
41
|
+
exports.writeSettings = writeSettings;
|
|
42
|
+
exports.getCKBBinaryInstallPath = getCKBBinaryInstallPath;
|
|
43
|
+
exports.getCKBBinaryPath = getCKBBinaryPath;
|
|
30
44
|
const fs = __importStar(require("fs"));
|
|
31
45
|
const path = __importStar(require("path"));
|
|
32
46
|
const env_path_1 = __importDefault(require("./env-path"));
|
|
@@ -43,7 +57,7 @@ exports.defaultSettings = {
|
|
|
43
57
|
},
|
|
44
58
|
bins: {
|
|
45
59
|
rootFolder: path.resolve(exports.dataPath, 'bins'),
|
|
46
|
-
defaultCKBVersion: '0.
|
|
60
|
+
defaultCKBVersion: '0.201.0',
|
|
47
61
|
downloadPath: path.resolve(exports.cachePath, 'download'),
|
|
48
62
|
},
|
|
49
63
|
devnet: {
|
|
@@ -83,6 +97,9 @@ exports.defaultSettings = {
|
|
|
83
97
|
cachePath: path.resolve(exports.cachePath, 'tools', 'moleculec-es'),
|
|
84
98
|
binFolder: path.resolve(exports.dataPath, 'tools', 'moleculec-es'),
|
|
85
99
|
},
|
|
100
|
+
ckbDebugger: {
|
|
101
|
+
minVersion: '0.200.0',
|
|
102
|
+
},
|
|
86
103
|
},
|
|
87
104
|
};
|
|
88
105
|
function readSettings() {
|
|
@@ -100,7 +117,6 @@ function readSettings() {
|
|
|
100
117
|
return exports.defaultSettings;
|
|
101
118
|
}
|
|
102
119
|
}
|
|
103
|
-
exports.readSettings = readSettings;
|
|
104
120
|
function writeSettings(settings) {
|
|
105
121
|
try {
|
|
106
122
|
fs.mkdirSync(path.dirname(exports.configPath), { recursive: true });
|
|
@@ -111,16 +127,13 @@ function writeSettings(settings) {
|
|
|
111
127
|
console.error('Error writing settings:', error);
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
|
-
exports.writeSettings = writeSettings;
|
|
115
130
|
function getCKBBinaryInstallPath(version) {
|
|
116
131
|
const setting = readSettings();
|
|
117
132
|
return `${setting.bins.rootFolder}/${version}`;
|
|
118
133
|
}
|
|
119
|
-
exports.getCKBBinaryInstallPath = getCKBBinaryInstallPath;
|
|
120
134
|
function getCKBBinaryPath(version) {
|
|
121
135
|
return `${getCKBBinaryInstallPath(version)}/ckb`;
|
|
122
136
|
}
|
|
123
|
-
exports.getCKBBinaryPath = getCKBBinaryPath;
|
|
124
137
|
function deepMerge(target, source) {
|
|
125
138
|
for (const key in source) {
|
|
126
139
|
if (source[key] && typeof source[key] === 'object') {
|
package/dist/cli.js
CHANGED
|
@@ -16,13 +16,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
16
16
|
}) : function(o, v) {
|
|
17
17
|
o["default"] = v;
|
|
18
18
|
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
26
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -65,11 +75,15 @@ program
|
|
|
65
75
|
.command('create [your-project-name]')
|
|
66
76
|
.description('Create a new dApp from bare templates')
|
|
67
77
|
.option('-s, --script', 'Only create the script project')
|
|
78
|
+
.option('-d, --dapp', 'Only create the ccc dapp project')
|
|
68
79
|
.action((projectName, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
80
|
const name = projectName !== null && projectName !== void 0 ? projectName : 'my-first-ckb-project';
|
|
70
81
|
if (option.script) {
|
|
71
82
|
return yield (0, create_1.createScriptProject)(name);
|
|
72
83
|
}
|
|
84
|
+
if (option.dapp) {
|
|
85
|
+
return yield (0, create_1.createDappProject)(name);
|
|
86
|
+
}
|
|
73
87
|
const template = yield (0, create_1.selectBareTemplate)();
|
|
74
88
|
return (0, create_1.create)(name, template);
|
|
75
89
|
}));
|
package/dist/cmd/accounts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.accounts =
|
|
6
|
+
exports.accounts = accounts;
|
|
7
7
|
const account_json_1 = __importDefault(require("../../account/account.json"));
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const highlightText = (text) => {
|
|
@@ -38,4 +38,3 @@ lockScript:
|
|
|
38
38
|
console.log(item(i, account));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
exports.accounts = accounts;
|
package/dist/cmd/balance.js
CHANGED
|
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.balanceOf =
|
|
12
|
+
exports.balanceOf = balanceOf;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const validator_1 = require("../util/validator");
|
|
15
15
|
const base_1 = require("../type/base");
|
|
16
|
-
function balanceOf(
|
|
17
|
-
return __awaiter(this,
|
|
16
|
+
function balanceOf(address_1) {
|
|
17
|
+
return __awaiter(this, arguments, void 0, function* (address, opt = { network: base_1.Network.devnet }) {
|
|
18
18
|
const network = opt.network;
|
|
19
19
|
(0, validator_1.validateNetworkOpt)(network);
|
|
20
20
|
const ckb = new ckb_1.CKB({ network });
|
|
@@ -23,4 +23,3 @@ function balanceOf(address, opt = { network: base_1.Network.devnet }) {
|
|
|
23
23
|
process.exit(0);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
exports.balanceOf = balanceOf;
|
package/dist/cmd/clean.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.clean =
|
|
6
|
+
exports.clean = clean;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const fs_2 = require("../util/fs");
|
|
9
9
|
const setting_1 = require("../cfg/setting");
|
|
@@ -25,4 +25,3 @@ function clean() {
|
|
|
25
25
|
console.log(`${allDevnetDataPath} not found, unable to clean it.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
exports.clean = clean;
|
package/dist/cmd/config.js
CHANGED
|
@@ -9,7 +9,8 @@ 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.ConfigItem = exports.ConfigAction = void 0;
|
|
13
|
+
exports.Config = Config;
|
|
13
14
|
const setting_1 = require("../cfg/setting");
|
|
14
15
|
const request_1 = require("../util/request");
|
|
15
16
|
const validator_1 = require("../util/validator");
|
|
@@ -100,7 +101,6 @@ function Config(action, item, value) {
|
|
|
100
101
|
throw new Error('invalid config action.');
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
exports.Config = Config;
|
|
104
104
|
function extractVersion(version) {
|
|
105
105
|
// If the version starts with 'v', remove it
|
|
106
106
|
return version.startsWith('v') ? version.slice(1) : version;
|
package/dist/cmd/create.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { BareTemplateOption } from '../template/option';
|
|
2
|
-
export
|
|
3
|
-
script:
|
|
4
|
-
|
|
2
|
+
export type ScriptOnly = {
|
|
3
|
+
script: true;
|
|
4
|
+
dapp?: false;
|
|
5
|
+
};
|
|
6
|
+
export type DappOnly = {
|
|
7
|
+
dapp: true;
|
|
8
|
+
script?: false;
|
|
9
|
+
};
|
|
10
|
+
export type CreateOption = ScriptOnly | DappOnly;
|
|
5
11
|
export declare function createScriptProject(name: string): void;
|
|
12
|
+
export declare function createDappProject(name: string): Promise<void>;
|
|
6
13
|
export declare function create(name: string, template: BareTemplateOption): Promise<void>;
|
|
7
14
|
export declare function selectBareTemplate(): Promise<BareTemplateOption>;
|
|
15
|
+
export declare function askForInjectOffckbConfig(dappFolderPath: string): Promise<void>;
|
package/dist/cmd/create.js
CHANGED
|
@@ -12,10 +12,15 @@ 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.
|
|
15
|
+
exports.createScriptProject = createScriptProject;
|
|
16
|
+
exports.createDappProject = createDappProject;
|
|
17
|
+
exports.create = create;
|
|
18
|
+
exports.selectBareTemplate = selectBareTemplate;
|
|
19
|
+
exports.askForInjectOffckbConfig = askForInjectOffckbConfig;
|
|
16
20
|
const path_1 = __importDefault(require("path"));
|
|
17
21
|
const fs_1 = require("../util/fs");
|
|
18
22
|
const git_1 = require("../util/git");
|
|
23
|
+
const inject_config_1 = require("./inject-config");
|
|
19
24
|
const prompts_1 = require("@inquirer/prompts");
|
|
20
25
|
const child_process_1 = require("child_process");
|
|
21
26
|
const gen_1 = require("../scripts/gen");
|
|
@@ -32,7 +37,19 @@ function createScriptProject(name) {
|
|
|
32
37
|
console.error('create script project failed, ', error.message);
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
|
|
40
|
+
function createDappProject(name) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const cmd = `npx create-ccc-app@latest ${name} --ts --}`;
|
|
43
|
+
try {
|
|
44
|
+
(0, child_process_1.execSync)(cmd, { encoding: 'utf-8', stdio: 'inherit' });
|
|
45
|
+
const dappFolderPath = path_1.default.resolve(process.cwd(), name);
|
|
46
|
+
yield askForInjectOffckbConfig(dappFolderPath);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('create ccc-appp project failed, ', error.message);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
36
53
|
function create(name, template) {
|
|
37
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
55
|
const targetPath = path_1.default.resolve(process.cwd(), name);
|
|
@@ -58,7 +75,6 @@ function create(name, template) {
|
|
|
58
75
|
}
|
|
59
76
|
});
|
|
60
77
|
}
|
|
61
|
-
exports.create = create;
|
|
62
78
|
function selectBareTemplate() {
|
|
63
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
80
|
const opts = yield (0, option_1.loadBareTemplateOpts)();
|
|
@@ -75,4 +91,14 @@ function selectBareTemplate() {
|
|
|
75
91
|
return opts.find((opt) => opt.value === answer);
|
|
76
92
|
});
|
|
77
93
|
}
|
|
78
|
-
|
|
94
|
+
function askForInjectOffckbConfig(dappFolderPath) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const answer = yield (0, prompts_1.confirm)({
|
|
97
|
+
message: 'Do you want to inject offckb configs in your project so that it can work with local blockchain info?',
|
|
98
|
+
});
|
|
99
|
+
if (answer) {
|
|
100
|
+
const target = path_1.default.resolve(dappFolderPath, 'offckb.config.ts');
|
|
101
|
+
(0, inject_config_1.injectConfig)({ target });
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
package/dist/cmd/debug.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function buildTransactionDebugOptions(txHash: string, network: Ne
|
|
|
6
6
|
}[];
|
|
7
7
|
export declare function debugSingleScript(txHash: string, cellIndex: number, cellType: 'input' | 'output', scriptType: 'type' | 'lock', network: Network, bin?: string): void;
|
|
8
8
|
export declare function parseSingleScriptOption(value: string): {
|
|
9
|
-
cellType: "
|
|
9
|
+
cellType: "input" | "output";
|
|
10
10
|
cellIndex: number;
|
|
11
11
|
scriptType: "type" | "lock";
|
|
12
12
|
};
|
package/dist/cmd/debug.js
CHANGED
|
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.debugTransaction = debugTransaction;
|
|
7
|
+
exports.buildTransactionDebugOptions = buildTransactionDebugOptions;
|
|
8
|
+
exports.debugSingleScript = debugSingleScript;
|
|
9
|
+
exports.parseSingleScriptOption = parseSingleScriptOption;
|
|
10
|
+
exports.buildTxFileOptionBy = buildTxFileOptionBy;
|
|
11
|
+
exports.buildTransactionJsonFilePath = buildTransactionJsonFilePath;
|
|
12
|
+
exports.buildDebugFullTransactionFilePath = buildDebugFullTransactionFilePath;
|
|
13
|
+
exports.debugRaw = debugRaw;
|
|
7
14
|
const setting_1 = require("../cfg/setting");
|
|
8
15
|
const ckb_debugger_1 = require("../tools/ckb-debugger");
|
|
9
16
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -21,7 +28,6 @@ function debugTransaction(txHash, network) {
|
|
|
21
28
|
debugRaw(`${txFile} ${opt.cmdOption}`);
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
|
-
exports.debugTransaction = debugTransaction;
|
|
25
31
|
function buildTransactionDebugOptions(txHash, network) {
|
|
26
32
|
var _a;
|
|
27
33
|
const txJsonFilePath = buildTransactionJsonFilePath(network, txHash);
|
|
@@ -50,7 +56,6 @@ function buildTransactionDebugOptions(txHash, network) {
|
|
|
50
56
|
}
|
|
51
57
|
return result;
|
|
52
58
|
}
|
|
53
|
-
exports.buildTransactionDebugOptions = buildTransactionDebugOptions;
|
|
54
59
|
function debugSingleScript(txHash, cellIndex, cellType, scriptType, network, bin) {
|
|
55
60
|
const txFile = buildTxFileOptionBy(txHash, network);
|
|
56
61
|
let opt = `--cell-index ${cellIndex} --cell-type ${cellType} --script-group-type ${scriptType}`;
|
|
@@ -59,7 +64,6 @@ function debugSingleScript(txHash, cellIndex, cellType, scriptType, network, bin
|
|
|
59
64
|
}
|
|
60
65
|
debugRaw(`${txFile} ${opt}`);
|
|
61
66
|
}
|
|
62
|
-
exports.debugSingleScript = debugSingleScript;
|
|
63
67
|
// Helper function to validate and parse the --script value
|
|
64
68
|
function parseSingleScriptOption(value) {
|
|
65
69
|
const regex = /^(input|output)\[(\d+)\]\.(lock|type)$/i;
|
|
@@ -74,7 +78,6 @@ function parseSingleScriptOption(value) {
|
|
|
74
78
|
scriptType: scriptType.toLowerCase(), // lock or type
|
|
75
79
|
};
|
|
76
80
|
}
|
|
77
|
-
exports.parseSingleScriptOption = parseSingleScriptOption;
|
|
78
81
|
function buildTxFileOptionBy(txHash, network) {
|
|
79
82
|
const settings = (0, setting_1.readSettings)();
|
|
80
83
|
const outputFilePath = buildDebugFullTransactionFilePath(network, txHash);
|
|
@@ -89,7 +92,6 @@ function buildTxFileOptionBy(txHash, network) {
|
|
|
89
92
|
const opt = `--tx-file ${(0, encoding_1.encodeBinPathForTerminal)(outputFilePath)}`;
|
|
90
93
|
return opt;
|
|
91
94
|
}
|
|
92
|
-
exports.buildTxFileOptionBy = buildTxFileOptionBy;
|
|
93
95
|
function buildTransactionJsonFilePath(network, txHash) {
|
|
94
96
|
const settings = (0, setting_1.readSettings)();
|
|
95
97
|
if (network === base_1.Network.devnet) {
|
|
@@ -100,7 +102,6 @@ function buildTransactionJsonFilePath(network, txHash) {
|
|
|
100
102
|
}
|
|
101
103
|
return `${settings.mainnet.transactionsPath}/${txHash}.json`;
|
|
102
104
|
}
|
|
103
|
-
exports.buildTransactionJsonFilePath = buildTransactionJsonFilePath;
|
|
104
105
|
function buildDebugFullTransactionFilePath(network, txHash) {
|
|
105
106
|
const settings = (0, setting_1.readSettings)();
|
|
106
107
|
if (network === base_1.Network.devnet) {
|
|
@@ -111,11 +112,9 @@ function buildDebugFullTransactionFilePath(network, txHash) {
|
|
|
111
112
|
}
|
|
112
113
|
return `${settings.mainnet.debugFullTransactionsPath}/${txHash}.json`;
|
|
113
114
|
}
|
|
114
|
-
exports.buildDebugFullTransactionFilePath = buildDebugFullTransactionFilePath;
|
|
115
115
|
function debugRaw(options) {
|
|
116
|
-
if (!ckb_debugger_1.CKBDebugger.isBinaryInstalled()) {
|
|
116
|
+
if (!ckb_debugger_1.CKBDebugger.isBinaryInstalled() || !ckb_debugger_1.CKBDebugger.isBinaryVersionValid()) {
|
|
117
117
|
ckb_debugger_1.CKBDebugger.installCKBDebugger();
|
|
118
118
|
}
|
|
119
119
|
return ckb_debugger_1.CKBDebugger.runRaw(options);
|
|
120
120
|
}
|
|
121
|
-
exports.debugRaw = debugRaw;
|
package/dist/cmd/deploy.js
CHANGED
|
@@ -12,7 +12,7 @@ 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.deploy =
|
|
15
|
+
exports.deploy = deploy;
|
|
16
16
|
const base_1 = require("../type/base");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const account_1 = require("../cfg/account");
|
|
@@ -21,9 +21,9 @@ const validator_1 = require("../util/validator");
|
|
|
21
21
|
const deploy_1 = require("../deploy");
|
|
22
22
|
const ckb_1 = require("../sdk/ckb");
|
|
23
23
|
const fs_2 = __importDefault(require("fs"));
|
|
24
|
-
function deploy(
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function deploy() {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* (opt = { network: base_1.Network.devnet, typeId: false, target: undefined, proxyRpc: false }) {
|
|
26
|
+
var _a;
|
|
27
27
|
const network = opt.network;
|
|
28
28
|
(0, validator_1.validateNetworkOpt)(network);
|
|
29
29
|
const isEnableProxyRpc = opt.proxyRpc;
|
|
@@ -35,7 +35,16 @@ function deploy(opt = { network: base_1.Network.devnet, typeId: false, target: u
|
|
|
35
35
|
const targetFolder = opt.target;
|
|
36
36
|
if (targetFolder) {
|
|
37
37
|
const binFilesOrFolder = (0, fs_1.isAbsolutePath)(targetFolder) ? targetFolder : path_1.default.resolve(process.cwd(), targetFolder);
|
|
38
|
-
|
|
38
|
+
let binPaths = (0, fs_1.getBinaryFilesFromPath)(binFilesOrFolder);
|
|
39
|
+
// ignore the binary file which is too large(> 500kb) to upload on chain
|
|
40
|
+
binPaths = binPaths.filter((binPath) => {
|
|
41
|
+
const size = (0, fs_1.getBinaryFileSizeInBytes)(binPath);
|
|
42
|
+
if (size > 500 * 1024) {
|
|
43
|
+
console.warn(`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
});
|
|
39
48
|
const results = yield (0, deploy_1.deployBinaries)(binPaths, privateKey, enableTypeId, ckb);
|
|
40
49
|
// record the deployed contract infos
|
|
41
50
|
(0, deploy_1.recordDeployResult)(results, network); // we don't update my-scripts.json since we don't know where the file is
|
|
@@ -50,10 +59,18 @@ function deploy(opt = { network: base_1.Network.devnet, typeId: false, target: u
|
|
|
50
59
|
if (!fs_2.default.existsSync(userOffCKBConfigPath)) {
|
|
51
60
|
throw new Error(`config file not exits: ${userOffCKBConfigPath}, tips: use --config to specific the offckb.config.ts file`);
|
|
52
61
|
}
|
|
53
|
-
|
|
62
|
+
let bins = (0, deploy_1.getToDeployBinsPath)(userOffCKBConfigPath);
|
|
63
|
+
// ignore the binary file which is too large(> 500kb) to upload on chain
|
|
64
|
+
bins = bins.filter((binPath) => {
|
|
65
|
+
const size = (0, fs_1.getBinaryFileSizeInBytes)(binPath);
|
|
66
|
+
if (size > 500 * 1024) {
|
|
67
|
+
console.warn(`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
54
72
|
const results = yield (0, deploy_1.deployBinaries)(bins, privateKey, enableTypeId, ckb);
|
|
55
73
|
// record the deployed contract infos
|
|
56
74
|
(0, deploy_1.recordDeployResult)(results, network, userOffCKBConfigPath);
|
|
57
75
|
});
|
|
58
76
|
}
|
|
59
|
-
exports.deploy = deploy;
|
package/dist/cmd/deposit.js
CHANGED
|
@@ -9,15 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.deposit =
|
|
12
|
+
exports.deposit = deposit;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const account_1 = require("../cfg/account");
|
|
15
15
|
const base_1 = require("../type/base");
|
|
16
16
|
const link_1 = require("../util/link");
|
|
17
17
|
const validator_1 = require("../util/validator");
|
|
18
18
|
const request_1 = require("../util/request");
|
|
19
|
-
function deposit(
|
|
20
|
-
return __awaiter(this,
|
|
19
|
+
function deposit(toAddress_1, amountInCKB_1) {
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* (toAddress, amountInCKB, opt = { network: base_1.Network.devnet, proxyRpc: false }) {
|
|
21
21
|
const network = opt.network;
|
|
22
22
|
(0, validator_1.validateNetworkOpt)(network);
|
|
23
23
|
const isEnableProxyRpc = opt.proxyRpc;
|
|
@@ -35,7 +35,6 @@ function deposit(toAddress, amountInCKB, opt = { network: base_1.Network.devnet,
|
|
|
35
35
|
console.log('tx hash: ', txHash);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
exports.deposit = deposit;
|
|
39
38
|
function depositFromTestnetFaucet(ckbAddress, ckb) {
|
|
40
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
40
|
console.log('testnet faucet only supports fixed-amount claim: 10,000 CKB');
|
|
@@ -15,15 +15,25 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.injectConfig =
|
|
36
|
+
exports.injectConfig = injectConfig;
|
|
27
37
|
const fs_1 = require("fs");
|
|
28
38
|
const path_1 = __importStar(require("path"));
|
|
29
39
|
const gen_1 = require("../scripts/gen");
|
|
@@ -57,7 +67,7 @@ function injectConfig({ target }) {
|
|
|
57
67
|
const myScriptCodeHash = offCKB.myScripts['script-name'].codeHash;
|
|
58
68
|
const omnilockScriptCodeHash = offCKB.systemScripts['omnilock'].codeHash;
|
|
59
69
|
|
|
60
|
-
Check
|
|
70
|
+
Check more on how to integrate offckb config to develop your app at https://docs.nervos.org/docs/getting-started/quick-start#different-frontend-framework
|
|
71
|
+
A Full example can also be found at https://github.com/nervosnetwork/docs.nervos.org/tree/develop/examples/simple-transfer
|
|
61
72
|
`);
|
|
62
73
|
}
|
|
63
|
-
exports.injectConfig = injectConfig;
|
package/dist/cmd/list-hashes.js
CHANGED
|
@@ -9,7 +9,8 @@ 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.printDevnetListHashes = printDevnetListHashes;
|
|
13
|
+
exports.getDevnetListHashes = getDevnetListHashes;
|
|
13
14
|
const child_process_1 = require("child_process");
|
|
14
15
|
const setting_1 = require("../cfg/setting");
|
|
15
16
|
const encoding_1 = require("../util/encoding");
|
|
@@ -19,7 +20,6 @@ function printDevnetListHashes(version) {
|
|
|
19
20
|
console.log(output);
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
exports.printDevnetListHashes = printDevnetListHashes;
|
|
23
23
|
function getDevnetListHashes(version) {
|
|
24
24
|
const settings = (0, setting_1.readSettings)();
|
|
25
25
|
const ckbVersion = version || settings.bins.defaultCKBVersion;
|
|
@@ -37,4 +37,3 @@ function getDevnetListHashes(version) {
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
exports.getDevnetListHashes = getDevnetListHashes;
|
package/dist/cmd/mol.js
CHANGED
|
@@ -12,7 +12,8 @@ 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.
|
|
15
|
+
exports.molSingleFile = molSingleFile;
|
|
16
|
+
exports.molFiles = molFiles;
|
|
16
17
|
const mol_1 = require("../molecule/mol");
|
|
17
18
|
const fs_1 = __importDefault(require("fs"));
|
|
18
19
|
const path_1 = __importDefault(require("path"));
|
|
@@ -21,7 +22,6 @@ function molSingleFile(schemeFilePath, outputFilePath, bindingLang) {
|
|
|
21
22
|
yield (0, mol_1.generateMolBindings)(schemeFilePath, outputFilePath, bindingLang);
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
exports.molSingleFile = molSingleFile;
|
|
25
25
|
function molFiles(schemaFolderPath, outputFolderPath, bindingLang) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const files = fs_1.default.readdirSync(schemaFolderPath).filter((file) => file.endsWith('.mol'));
|
|
@@ -36,4 +36,3 @@ function molFiles(schemaFolderPath, outputFolderPath, bindingLang) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
exports.molFiles = molFiles;
|
package/dist/cmd/my-scripts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printMyScripts =
|
|
3
|
+
exports.printMyScripts = printMyScripts;
|
|
4
4
|
const toml_1 = require("../deploy/toml");
|
|
5
5
|
const util_1 = require("../deploy/util");
|
|
6
6
|
const util_2 = require("../scripts/util");
|
|
@@ -22,4 +22,3 @@ function printMyScripts(option = { network: base_1.Network.devnet }) {
|
|
|
22
22
|
console.log(`\n`);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
exports.printMyScripts = printMyScripts;
|