@offckb/cli 0.3.4 → 0.4.0-canary-113bf31.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 +17 -138
- package/build/build/Release/cpufeatures.node +0 -0
- package/build/build/Release/secp256k1.node +0 -0
- package/build/index.js +114977 -0
- package/package.json +12 -6
- package/dist/cfg/account.d.ts +0 -55
- package/dist/cfg/account.js +0 -66
- package/dist/cfg/env-path.d.ts +0 -9
- package/dist/cfg/env-path.js +0 -63
- package/dist/cfg/setting.d.ts +0 -67
- package/dist/cfg/setting.js +0 -147
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -224
- package/dist/cmd/accounts.d.ts +0 -1
- package/dist/cmd/accounts.js +0 -40
- package/dist/cmd/balance.d.ts +0 -4
- package/dist/cmd/balance.js +0 -25
- package/dist/cmd/clean.d.ts +0 -1
- package/dist/cmd/clean.js +0 -27
- package/dist/cmd/config.d.ts +0 -11
- package/dist/cmd/config.js +0 -107
- package/dist/cmd/create.d.ts +0 -7
- package/dist/cmd/create.js +0 -77
- package/dist/cmd/debug.d.ts +0 -16
- package/dist/cmd/debug.js +0 -120
- package/dist/cmd/deploy.d.ts +0 -9
- package/dist/cmd/deploy.js +0 -76
- package/dist/cmd/deposit.d.ts +0 -5
- package/dist/cmd/deposit.js +0 -97
- package/dist/cmd/inject-config.d.ts +0 -4
- package/dist/cmd/inject-config.js +0 -72
- package/dist/cmd/list-hashes.d.ts +0 -25
- package/dist/cmd/list-hashes.js +0 -39
- package/dist/cmd/mol.d.ts +0 -2
- package/dist/cmd/mol.js +0 -38
- package/dist/cmd/my-scripts.d.ts +0 -4
- package/dist/cmd/my-scripts.js +0 -24
- package/dist/cmd/node.d.ts +0 -5
- package/dist/cmd/node.js +0 -70
- package/dist/cmd/proxy-rpc.d.ts +0 -7
- package/dist/cmd/proxy-rpc.js +0 -22
- package/dist/cmd/repl.d.ts +0 -17
- package/dist/cmd/repl.js +0 -111
- package/dist/cmd/sync-scripts.d.ts +0 -4
- package/dist/cmd/sync-scripts.js +0 -30
- package/dist/cmd/system-scripts.d.ts +0 -99
- package/dist/cmd/system-scripts.js +0 -301
- package/dist/cmd/transfer-all.d.ts +0 -6
- package/dist/cmd/transfer-all.js +0 -37
- package/dist/cmd/transfer.d.ts +0 -6
- package/dist/cmd/transfer.js +0 -38
- package/dist/deploy/index.d.ts +0 -18
- package/dist/deploy/index.js +0 -127
- package/dist/deploy/migration.d.ts +0 -50
- package/dist/deploy/migration.js +0 -178
- package/dist/deploy/toml.d.ts +0 -42
- package/dist/deploy/toml.js +0 -59
- package/dist/deploy/util.d.ts +0 -2
- package/dist/deploy/util.js +0 -18
- package/dist/molecule/mol.d.ts +0 -9
- package/dist/molecule/mol.js +0 -149
- package/dist/node/init-chain.d.ts +0 -1
- package/dist/node/init-chain.js +0 -40
- package/dist/node/install.d.ts +0 -11
- package/dist/node/install.js +0 -235
- package/dist/scripts/gen.d.ts +0 -5
- package/dist/scripts/gen.js +0 -78
- package/dist/scripts/private.d.ts +0 -4
- package/dist/scripts/private.js +0 -13
- package/dist/scripts/public.d.ts +0 -8
- package/dist/scripts/public.js +0 -229
- package/dist/scripts/type.d.ts +0 -51
- package/dist/scripts/type.js +0 -19
- package/dist/scripts/util.d.ts +0 -3
- package/dist/scripts/util.js +0 -93
- package/dist/sdk/ckb.d.ts +0 -37
- package/dist/sdk/ckb.js +0 -254
- package/dist/sdk/network.d.ts +0 -17
- package/dist/sdk/network.js +0 -22
- package/dist/template/offckb-config.d.ts +0 -4
- package/dist/template/offckb-config.js +0 -70
- package/dist/template/option.d.ts +0 -8
- package/dist/template/option.js +0 -22
- package/dist/tools/ckb-debugger.d.ts +0 -12
- package/dist/tools/ckb-debugger.js +0 -31
- package/dist/tools/ckb-tx-dumper.d.ts +0 -6
- package/dist/tools/ckb-tx-dumper.js +0 -20
- package/dist/tools/moleculec-es.d.ts +0 -8
- package/dist/tools/moleculec-es.js +0 -100
- package/dist/tools/moleculec-go.d.ts +0 -5
- package/dist/tools/moleculec-go.js +0 -35
- package/dist/tools/moleculec-rust.d.ts +0 -5
- package/dist/tools/moleculec-rust.js +0 -35
- package/dist/tools/rpc-proxy.d.ts +0 -7
- package/dist/tools/rpc-proxy.js +0 -90
- package/dist/type/base.d.ts +0 -11
- package/dist/type/base.js +0 -10
- package/dist/util/encoding.d.ts +0 -2
- package/dist/util/encoding.js +0 -24
- package/dist/util/fs.d.ts +0 -13
- package/dist/util/fs.js +0 -218
- package/dist/util/git.d.ts +0 -2
- package/dist/util/git.js +0 -106
- package/dist/util/link.d.ts +0 -1
- package/dist/util/link.js +0 -6
- package/dist/util/request.d.ts +0 -8
- package/dist/util/request.js +0 -61
- package/dist/util/validator.d.ts +0 -5
- package/dist/util/validator.js +0 -67
- package/npm-shrinkwrap.json +0 -4514
package/dist/cli.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
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
|
-
})();
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
const commander_1 = require("commander");
|
|
47
|
-
const list_hashes_1 = require("./cmd/list-hashes");
|
|
48
|
-
const node_1 = require("./cmd/node");
|
|
49
|
-
const accounts_1 = require("./cmd/accounts");
|
|
50
|
-
const clean_1 = require("./cmd/clean");
|
|
51
|
-
const encoding_1 = require("./util/encoding");
|
|
52
|
-
const inject_config_1 = require("./cmd/inject-config");
|
|
53
|
-
const deposit_1 = require("./cmd/deposit");
|
|
54
|
-
const deploy_1 = require("./cmd/deploy");
|
|
55
|
-
const sync_scripts_1 = require("./cmd/sync-scripts");
|
|
56
|
-
const transfer_1 = require("./cmd/transfer");
|
|
57
|
-
const balance_1 = require("./cmd/balance");
|
|
58
|
-
const create_1 = require("./cmd/create");
|
|
59
|
-
const my_scripts_1 = require("./cmd/my-scripts");
|
|
60
|
-
const config_1 = require("./cmd/config");
|
|
61
|
-
const debug_1 = require("./cmd/debug");
|
|
62
|
-
const system_scripts_1 = require("./cmd/system-scripts");
|
|
63
|
-
const proxy_rpc_1 = require("./cmd/proxy-rpc");
|
|
64
|
-
const mol_1 = require("./cmd/mol");
|
|
65
|
-
const fs = __importStar(require("fs"));
|
|
66
|
-
const transfer_all_1 = require("./cmd/transfer-all");
|
|
67
|
-
const repl_1 = require("./cmd/repl");
|
|
68
|
-
const version = require('../package.json').version;
|
|
69
|
-
const description = require('../package.json').description;
|
|
70
|
-
// fix windows terminal encoding of simplified chinese text
|
|
71
|
-
(0, encoding_1.setUTF8EncodingForWindows)();
|
|
72
|
-
const program = new commander_1.Command();
|
|
73
|
-
program.name('offckb').description(description).version(version);
|
|
74
|
-
program
|
|
75
|
-
.command('create [your-project-name]')
|
|
76
|
-
.description('Create a new dApp from bare templates')
|
|
77
|
-
.option('-s, --script', 'Only create the script project')
|
|
78
|
-
.action((projectName, option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
const name = projectName !== null && projectName !== void 0 ? projectName : 'my-first-ckb-project';
|
|
80
|
-
if (option.script) {
|
|
81
|
-
return yield (0, create_1.createScriptProject)(name);
|
|
82
|
-
}
|
|
83
|
-
const template = yield (0, create_1.selectBareTemplate)();
|
|
84
|
-
return (0, create_1.create)(name, template);
|
|
85
|
-
}));
|
|
86
|
-
program
|
|
87
|
-
.command('node [CKB-Version]')
|
|
88
|
-
.description('Use the CKB to start devnet')
|
|
89
|
-
.option('--no-proxy', 'Do not start the rpc proxy server', true)
|
|
90
|
-
.action((version, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
// commander.js change our noProxy option to proxy
|
|
92
|
-
return (0, node_1.node)({ version, noProxyServer: !options.proxy });
|
|
93
|
-
}));
|
|
94
|
-
program
|
|
95
|
-
.command('proxy-rpc')
|
|
96
|
-
.description('Start the rpc proxy server')
|
|
97
|
-
.option('--ckb-rpc <ckbRpc>', 'Specify the ckb rpc address')
|
|
98
|
-
.option('--port <port>', 'Specify the port to start the proxy server')
|
|
99
|
-
.option('--network <network>', 'Specify the network to proxy')
|
|
100
|
-
.action((options) => {
|
|
101
|
-
return (0, proxy_rpc_1.proxyRpc)(options);
|
|
102
|
-
});
|
|
103
|
-
program.command('clean').description('Clean the devnet data, need to stop running the chain first').action(clean_1.clean);
|
|
104
|
-
program.command('accounts').description('Print account list info').action(accounts_1.accounts);
|
|
105
|
-
program
|
|
106
|
-
.command('list-hashes [CKB-Version]')
|
|
107
|
-
.description('Use the CKB to list blockchain scripts hashes')
|
|
108
|
-
.action(list_hashes_1.printDevnetListHashes);
|
|
109
|
-
program
|
|
110
|
-
.command('inject-config')
|
|
111
|
-
.description('Add offckb.config.ts to your frontend workspace')
|
|
112
|
-
.option('--target <target>', 'Specify the custom file path of the new injected config')
|
|
113
|
-
.action(inject_config_1.injectConfig);
|
|
114
|
-
program
|
|
115
|
-
.command('sync-scripts')
|
|
116
|
-
.description('Sync scripts json files in your frontend workspace')
|
|
117
|
-
.option('--config <config>', 'Specify the offckb.config.ts file path', undefined)
|
|
118
|
-
.action((opt) => {
|
|
119
|
-
const configPath = opt.config;
|
|
120
|
-
return (0, sync_scripts_1.syncScripts)({ configPath });
|
|
121
|
-
});
|
|
122
|
-
program
|
|
123
|
-
.command('deposit [toAddress] [amountInCKB]')
|
|
124
|
-
.description('Deposit CKB tokens to address, only devnet and testnet')
|
|
125
|
-
.option('--network <network>', 'Specify the network to deposit to', 'devnet')
|
|
126
|
-
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
127
|
-
.action((toAddress, amountInCKB, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
-
return (0, deposit_1.deposit)(toAddress, amountInCKB, options);
|
|
129
|
-
}));
|
|
130
|
-
program
|
|
131
|
-
.command('transfer [toAddress] [amountInCKB]')
|
|
132
|
-
.description('Transfer CKB tokens to address, only devnet and testnet')
|
|
133
|
-
.option('--network <network>', 'Specify the network to transfer to', 'devnet')
|
|
134
|
-
.option('--privkey <privkey>', 'Specify the private key to transfer CKB')
|
|
135
|
-
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
136
|
-
.action((toAddress, amountInCKB, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
-
return (0, transfer_1.transfer)(toAddress, amountInCKB, options);
|
|
138
|
-
}));
|
|
139
|
-
program
|
|
140
|
-
.command('transfer-all [toAddress]')
|
|
141
|
-
.description('Transfer All CKB tokens to address, only devnet and testnet')
|
|
142
|
-
.option('--network <network>', 'Specify the network to transfer to', 'devnet')
|
|
143
|
-
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
144
|
-
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
145
|
-
.action((toAddress, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
146
|
-
return (0, transfer_all_1.transferAll)(toAddress, options);
|
|
147
|
-
}));
|
|
148
|
-
program
|
|
149
|
-
.command('balance [toAddress]')
|
|
150
|
-
.description('Check account balance, only devnet and testnet')
|
|
151
|
-
.option('--network <network>', 'Specify the network to check', 'devnet')
|
|
152
|
-
.action((toAddress, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
return (0, balance_1.balanceOf)(toAddress, options);
|
|
154
|
-
}));
|
|
155
|
-
program
|
|
156
|
-
.command('deploy')
|
|
157
|
-
.description('Deploy contracts to different networks, only supports devnet and testnet')
|
|
158
|
-
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
159
|
-
.option('--target <target>', 'Specify the script binaries file/folder path to deploy')
|
|
160
|
-
.option('--config <config>', 'Specify the offckb.config.ts file path for deployment', undefined)
|
|
161
|
-
.option('-t, --type-id', 'Specify if use upgradable type id to deploy the script')
|
|
162
|
-
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
163
|
-
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
164
|
-
.action((options) => (0, deploy_1.deploy)(options));
|
|
165
|
-
program
|
|
166
|
-
.command('my-scripts')
|
|
167
|
-
.description('Show deployed contracts info on different networks, only supports devnet and testnet')
|
|
168
|
-
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
169
|
-
.action((options) => (0, my_scripts_1.printMyScripts)(options));
|
|
170
|
-
program
|
|
171
|
-
.command('config <action> [item] [value]')
|
|
172
|
-
.description('do a configuration action')
|
|
173
|
-
.action((action, item, value) => (0, config_1.Config)(action, item, value));
|
|
174
|
-
program
|
|
175
|
-
.command('debug')
|
|
176
|
-
.requiredOption('--tx-hash <txHash>', 'Specify the transaction hash to debug with')
|
|
177
|
-
.option('--single-script <singleScript>', 'Specify the cell script to debug with')
|
|
178
|
-
.option('--bin <bin>', 'Specify a binary to replace the script to debug with')
|
|
179
|
-
.option('--network <network>', 'Specify the network to debug', 'devnet')
|
|
180
|
-
.description('CKB Debugger for development')
|
|
181
|
-
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
182
|
-
const txHash = option.txHash;
|
|
183
|
-
if (option.singleScript) {
|
|
184
|
-
const { cellType, cellIndex, scriptType } = (0, debug_1.parseSingleScriptOption)(option.singleScript);
|
|
185
|
-
return (0, debug_1.debugSingleScript)(txHash, cellIndex, cellType, scriptType, option.network, option.bin);
|
|
186
|
-
}
|
|
187
|
-
return (0, debug_1.debugTransaction)(txHash, option.network);
|
|
188
|
-
}));
|
|
189
|
-
program
|
|
190
|
-
.command('system-scripts')
|
|
191
|
-
.option('--export-style <exportStyle>', 'Specify the export format, possible values are system, lumos and ccc.')
|
|
192
|
-
.option('--network <network>', 'Specify the CKB blockchain network', 'devnet')
|
|
193
|
-
.description('Output system scripts of the CKB blockchain')
|
|
194
|
-
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
195
|
-
const network = option.network;
|
|
196
|
-
const exportStyle = option.exportStyle;
|
|
197
|
-
return (0, system_scripts_1.printSystemScripts)({ style: exportStyle, network });
|
|
198
|
-
}));
|
|
199
|
-
program
|
|
200
|
-
.command('mol')
|
|
201
|
-
.requiredOption('--schema <schema>', 'Specify the scheme .mol file/folders to generate bindings')
|
|
202
|
-
.option('--output <output>', 'Specify the output file/folder path')
|
|
203
|
-
.option('--output-folder <output-folder>', 'Specify the output folder path, only valid when schema is a folder')
|
|
204
|
-
.option('--lang <lang>', 'Specify the binding language, [ts, js, c, rs, go]', 'ts')
|
|
205
|
-
.description('Generate CKB Moleculec binding code for development')
|
|
206
|
-
.action((option) => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
-
var _a;
|
|
208
|
-
if (fs.statSync(option.schema).isDirectory()) {
|
|
209
|
-
const outputFolderPath = (_a = option.outputFolder) !== null && _a !== void 0 ? _a : './';
|
|
210
|
-
return (0, mol_1.molFiles)(option.schema, outputFolderPath, option.lang);
|
|
211
|
-
}
|
|
212
|
-
return (0, mol_1.molSingleFile)(option.schema, option.output, option.lang);
|
|
213
|
-
}));
|
|
214
|
-
program
|
|
215
|
-
.command('repl')
|
|
216
|
-
.description('A custom Nodejs REPL environment bundle for CKB.')
|
|
217
|
-
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
218
|
-
.option('-r, --proxy-rpc', 'Use Proxy RPC to connect to blockchain')
|
|
219
|
-
.action(repl_1.repl);
|
|
220
|
-
program.parse(process.argv);
|
|
221
|
-
// If no command is specified, display help
|
|
222
|
-
if (!process.argv.slice(2).length) {
|
|
223
|
-
program.outputHelp();
|
|
224
|
-
}
|
package/dist/cmd/accounts.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function accounts(): void;
|
package/dist/cmd/accounts.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.accounts = accounts;
|
|
7
|
-
const account_json_1 = __importDefault(require("../../account/account.json"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const highlightText = (text) => {
|
|
10
|
-
return chalk_1.default.green(text);
|
|
11
|
-
};
|
|
12
|
-
const alertText = (text) => {
|
|
13
|
-
return chalk_1.default.bgRed(text);
|
|
14
|
-
};
|
|
15
|
-
const infoText = (text) => {
|
|
16
|
-
return chalk_1.default.blue(text);
|
|
17
|
-
};
|
|
18
|
-
function accounts() {
|
|
19
|
-
console.log(alertText(`#### All Accounts are for test and develop only ####`.toUpperCase()));
|
|
20
|
-
console.log(alertText(`#### DON'T use these accounts on Mainnet ####`.toUpperCase()));
|
|
21
|
-
console.log(alertText(`#### Otherwise You will loose your money ####`.toUpperCase()));
|
|
22
|
-
console.log('');
|
|
23
|
-
console.log(infoText(`Print account list, each account is funded with 42_000_000_00000000 capacity in the devnet genesis block.`));
|
|
24
|
-
const item = (index, account) => {
|
|
25
|
-
return `
|
|
26
|
-
- "${highlightText('#')}": ${highlightText(index)}
|
|
27
|
-
address: ${highlightText(account.address)}
|
|
28
|
-
privkey: ${highlightText(account.privkey)}
|
|
29
|
-
pubkey: ${highlightText(account.pubkey)}
|
|
30
|
-
lock_arg: ${highlightText(account.lockScript.args)}
|
|
31
|
-
lockScript:
|
|
32
|
-
codeHash: ${highlightText(account.lockScript.codeHash)}
|
|
33
|
-
hashType: ${highlightText(account.lockScript.hashType)}
|
|
34
|
-
args: ${highlightText(account.lockScript.args)}`;
|
|
35
|
-
};
|
|
36
|
-
for (let i = 0; i < account_json_1.default.length; i++) {
|
|
37
|
-
const account = account_json_1.default[i];
|
|
38
|
-
console.log(item(i, account));
|
|
39
|
-
}
|
|
40
|
-
}
|
package/dist/cmd/balance.d.ts
DELETED
package/dist/cmd/balance.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.balanceOf = balanceOf;
|
|
13
|
-
const ckb_1 = require("../sdk/ckb");
|
|
14
|
-
const validator_1 = require("../util/validator");
|
|
15
|
-
const base_1 = require("../type/base");
|
|
16
|
-
function balanceOf(address_1) {
|
|
17
|
-
return __awaiter(this, arguments, void 0, function* (address, opt = { network: base_1.Network.devnet }) {
|
|
18
|
-
const network = opt.network;
|
|
19
|
-
(0, validator_1.validateNetworkOpt)(network);
|
|
20
|
-
const ckb = new ckb_1.CKB({ network });
|
|
21
|
-
const balanceInCKB = yield ckb.balance(address);
|
|
22
|
-
console.log(`Balance: ${balanceInCKB} CKB`);
|
|
23
|
-
process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
}
|
package/dist/cmd/clean.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function clean(): void;
|
package/dist/cmd/clean.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.clean = clean;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const fs_2 = require("../util/fs");
|
|
9
|
-
const setting_1 = require("../cfg/setting");
|
|
10
|
-
function clean() {
|
|
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)) {
|
|
15
|
-
try {
|
|
16
|
-
fs_1.default.rmSync(allDevnetDataPath, { recursive: true });
|
|
17
|
-
console.log(`Chain data cleaned.`);
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
console.log(`Did you stop running the chain first?`);
|
|
21
|
-
console.log(error.message);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
console.log(`${allDevnetDataPath} not found, unable to clean it.`);
|
|
26
|
-
}
|
|
27
|
-
}
|
package/dist/cmd/config.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
package/dist/cmd/config.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ConfigItem = exports.ConfigAction = void 0;
|
|
13
|
-
exports.Config = Config;
|
|
14
|
-
const setting_1 = require("../cfg/setting");
|
|
15
|
-
const request_1 = require("../util/request");
|
|
16
|
-
const validator_1 = require("../util/validator");
|
|
17
|
-
var ConfigAction;
|
|
18
|
-
(function (ConfigAction) {
|
|
19
|
-
ConfigAction["list"] = "list";
|
|
20
|
-
ConfigAction["get"] = "get";
|
|
21
|
-
ConfigAction["set"] = "set";
|
|
22
|
-
ConfigAction["rm"] = "rm";
|
|
23
|
-
})(ConfigAction || (exports.ConfigAction = ConfigAction = {}));
|
|
24
|
-
var ConfigItem;
|
|
25
|
-
(function (ConfigItem) {
|
|
26
|
-
ConfigItem["proxy"] = "proxy";
|
|
27
|
-
ConfigItem["ckbVersion"] = "ckb-version";
|
|
28
|
-
})(ConfigItem || (exports.ConfigItem = ConfigItem = {}));
|
|
29
|
-
function Config(action, item, value) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (action === ConfigAction.list) {
|
|
32
|
-
console.log('config file: ', setting_1.configPath);
|
|
33
|
-
return console.log((0, setting_1.readSettings)());
|
|
34
|
-
}
|
|
35
|
-
if (action === ConfigAction.get) {
|
|
36
|
-
switch (item) {
|
|
37
|
-
case ConfigItem.proxy: {
|
|
38
|
-
const settings = (0, setting_1.readSettings)();
|
|
39
|
-
const proxy = settings.proxy;
|
|
40
|
-
if (proxy == null) {
|
|
41
|
-
console.log(`No Proxy.`);
|
|
42
|
-
process.exit(0);
|
|
43
|
-
}
|
|
44
|
-
return console.log(`${request_1.Request.proxyConfigToUrl(proxy)}`);
|
|
45
|
-
}
|
|
46
|
-
case ConfigItem.ckbVersion: {
|
|
47
|
-
const settings = (0, setting_1.readSettings)();
|
|
48
|
-
const version = settings.bins.defaultCKBVersion;
|
|
49
|
-
return console.log(`${version}`);
|
|
50
|
-
}
|
|
51
|
-
default:
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (action === ConfigAction.set) {
|
|
56
|
-
switch (item) {
|
|
57
|
-
case ConfigItem.proxy: {
|
|
58
|
-
if (value == null)
|
|
59
|
-
throw new Error('No proxyUrl!');
|
|
60
|
-
try {
|
|
61
|
-
const proxy = request_1.Request.parseProxyUrl(value);
|
|
62
|
-
const settings = (0, setting_1.readSettings)();
|
|
63
|
-
settings.proxy = proxy;
|
|
64
|
-
return (0, setting_1.writeSettings)(settings);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
return console.error(`invalid proxyURL, `, error.message);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
case ConfigItem.ckbVersion: {
|
|
71
|
-
const settings = (0, setting_1.readSettings)();
|
|
72
|
-
try {
|
|
73
|
-
if ((0, validator_1.isValidVersion)(value)) {
|
|
74
|
-
const version = extractVersion(value);
|
|
75
|
-
settings.bins.defaultCKBVersion = version;
|
|
76
|
-
return (0, setting_1.writeSettings)(settings);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return console.error(`invalid version value, ${value}. Check available versions on https://github.com/nervosnetwork/ckb/tags`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
return console.error(`invalid version value, `, error.message);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
default:
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (action === ConfigAction.rm) {
|
|
91
|
-
switch (item) {
|
|
92
|
-
case ConfigItem.proxy: {
|
|
93
|
-
const settings = (0, setting_1.readSettings)();
|
|
94
|
-
settings.proxy = undefined;
|
|
95
|
-
return (0, setting_1.writeSettings)(settings);
|
|
96
|
-
}
|
|
97
|
-
default:
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
throw new Error('invalid config action.');
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function extractVersion(version) {
|
|
105
|
-
// If the version starts with 'v', remove it
|
|
106
|
-
return version.startsWith('v') ? version.slice(1) : version;
|
|
107
|
-
}
|
package/dist/cmd/create.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BareTemplateOption } from '../template/option';
|
|
2
|
-
export interface CreateOption {
|
|
3
|
-
script: boolean;
|
|
4
|
-
}
|
|
5
|
-
export declare function createScriptProject(name: string): void;
|
|
6
|
-
export declare function create(name: string, template: BareTemplateOption): Promise<void>;
|
|
7
|
-
export declare function selectBareTemplate(): Promise<BareTemplateOption>;
|
package/dist/cmd/create.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createScriptProject = createScriptProject;
|
|
16
|
-
exports.create = create;
|
|
17
|
-
exports.selectBareTemplate = selectBareTemplate;
|
|
18
|
-
const path_1 = __importDefault(require("path"));
|
|
19
|
-
const fs_1 = require("../util/fs");
|
|
20
|
-
const git_1 = require("../util/git");
|
|
21
|
-
const prompts_1 = require("@inquirer/prompts");
|
|
22
|
-
const child_process_1 = require("child_process");
|
|
23
|
-
const gen_1 = require("../scripts/gen");
|
|
24
|
-
const setting_1 = require("../cfg/setting");
|
|
25
|
-
const option_1 = require("../template/option");
|
|
26
|
-
const offckb_config_1 = require("../template/offckb-config");
|
|
27
|
-
const version = require('../../package.json').version;
|
|
28
|
-
function createScriptProject(name) {
|
|
29
|
-
const cmd = `cargo generate gh:cryptape/ckb-script-templates workspace --name ${name}`;
|
|
30
|
-
try {
|
|
31
|
-
(0, child_process_1.execSync)(cmd, { encoding: 'utf-8', stdio: 'inherit' });
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error('create script project failed, ', error.message);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function create(name, template) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const targetPath = path_1.default.resolve(process.cwd(), name);
|
|
40
|
-
const settings = (0, setting_1.readSettings)();
|
|
41
|
-
const dappTemplateFolderPath = `${settings.dappTemplate.gitFolder}/${template.value}`;
|
|
42
|
-
(0, git_1.gitCloneAndDownloadFolderSync)(settings.dappTemplate.gitRepoUrl, settings.dappTemplate.gitBranch, dappTemplateFolderPath, targetPath);
|
|
43
|
-
// update the version
|
|
44
|
-
const projectFolder = path_1.default.resolve(process.cwd(), name);
|
|
45
|
-
const targetConfigPath = (0, fs_1.findFileInFolder)(projectFolder, 'offckb.config.ts');
|
|
46
|
-
if (targetConfigPath) {
|
|
47
|
-
offckb_config_1.OffCKBConfigFile.updateVersion(version, targetConfigPath);
|
|
48
|
-
const contractInfoFolder = offckb_config_1.OffCKBConfigFile.readContractInfoFolder(targetConfigPath);
|
|
49
|
-
if (!contractInfoFolder) {
|
|
50
|
-
throw new Error('No contract info folder found in offckb.config.ts!');
|
|
51
|
-
}
|
|
52
|
-
const systemJsonFilePath = path_1.default.resolve(contractInfoFolder, 'system-scripts.json');
|
|
53
|
-
(0, gen_1.genSystemScriptsJsonFile)(systemJsonFilePath);
|
|
54
|
-
const myScriptsJsonFilePath = path_1.default.resolve(contractInfoFolder, 'my-scripts.json');
|
|
55
|
-
(0, gen_1.genMyScriptsJsonFile)(myScriptsJsonFilePath);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
console.log("Couldn't find the offckb config file in project. abort.");
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function selectBareTemplate() {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const opts = yield (0, option_1.loadBareTemplateOpts)();
|
|
65
|
-
const answer = yield (0, prompts_1.select)({
|
|
66
|
-
message: 'Select a bare template',
|
|
67
|
-
choices: opts.map((opt) => {
|
|
68
|
-
return {
|
|
69
|
-
name: opt.name,
|
|
70
|
-
value: opt.value,
|
|
71
|
-
description: `${opt.description}, \n[${opt.tag.toString()}]`,
|
|
72
|
-
};
|
|
73
|
-
}),
|
|
74
|
-
});
|
|
75
|
-
return opts.find((opt) => opt.value === answer);
|
|
76
|
-
});
|
|
77
|
-
}
|
package/dist/cmd/debug.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Network } from '../type/base';
|
|
2
|
-
export declare function debugTransaction(txHash: string, network: Network): void;
|
|
3
|
-
export declare function buildTransactionDebugOptions(txHash: string, network: Network): {
|
|
4
|
-
name: string;
|
|
5
|
-
cmdOption: string;
|
|
6
|
-
}[];
|
|
7
|
-
export declare function debugSingleScript(txHash: string, cellIndex: number, cellType: 'input' | 'output', scriptType: 'type' | 'lock', network: Network, bin?: string): void;
|
|
8
|
-
export declare function parseSingleScriptOption(value: string): {
|
|
9
|
-
cellType: "input" | "output";
|
|
10
|
-
cellIndex: number;
|
|
11
|
-
scriptType: "type" | "lock";
|
|
12
|
-
};
|
|
13
|
-
export declare function buildTxFileOptionBy(txHash: string, network: Network): string;
|
|
14
|
-
export declare function buildTransactionJsonFilePath(network: Network, txHash: string): string;
|
|
15
|
-
export declare function buildDebugFullTransactionFilePath(network: Network, txHash: string): string;
|
|
16
|
-
export declare function debugRaw(options: string): void;
|