@offckb/cli 0.3.0-canary-1bb6394.0 → 0.3.0-canary-ee0ab6a.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 +21 -20
- package/dist/cli.js +9 -0
- package/dist/cmd/balance.d.ts +1 -1
- package/dist/cmd/balance.js +2 -2
- package/dist/cmd/debug.d.ts +1 -1
- package/dist/cmd/debug.js +5 -5
- package/dist/cmd/deploy.d.ts +1 -1
- package/dist/cmd/deploy.js +2 -2
- package/dist/cmd/deposit.d.ts +1 -1
- package/dist/cmd/deposit.js +2 -2
- package/dist/cmd/list-hashes.d.ts +1 -1
- package/dist/cmd/my-scripts.d.ts +1 -1
- package/dist/cmd/my-scripts.js +2 -2
- package/dist/cmd/node.js +2 -2
- package/dist/cmd/proxy-rpc.d.ts +1 -1
- package/dist/cmd/proxy-rpc.js +4 -4
- package/dist/cmd/system-scripts.d.ts +70 -2
- package/dist/cmd/system-scripts.js +4 -0
- package/dist/cmd/transfer-all.d.ts +5 -0
- package/dist/cmd/transfer-all.js +37 -0
- package/dist/cmd/transfer.d.ts +1 -1
- package/dist/cmd/transfer.js +2 -2
- package/dist/deploy/index.d.ts +2 -2
- package/dist/deploy/index.js +3 -3
- package/dist/deploy/migration.d.ts +2 -2
- package/dist/deploy/migration.js +5 -5
- package/dist/deploy/toml.d.ts +7 -3
- package/dist/deploy/util.d.ts +1 -1
- package/dist/deploy/util.js +4 -4
- package/dist/scripts/gen.js +4 -4
- package/dist/scripts/util.d.ts +1 -1
- package/dist/sdk/ckb.d.ts +1 -2
- package/dist/sdk/ckb.js +2 -2
- package/dist/tools/rpc-proxy.d.ts +1 -1
- package/dist/tools/rpc-proxy.js +2 -2
- package/dist/{util/type.d.ts → type/base.d.ts} +2 -0
- package/dist/util/validator.js +2 -2
- package/package.json +1 -2
- /package/dist/{util/type.js → type/base.js} +0 -0
package/README.md
CHANGED
|
@@ -58,28 +58,29 @@ Usage: offckb [options] [command]
|
|
|
58
58
|
ckb development network for your first try
|
|
59
59
|
|
|
60
60
|
Options:
|
|
61
|
-
-V, --version
|
|
62
|
-
-h, --help
|
|
61
|
+
-V, --version output the version number
|
|
62
|
+
-h, --help display help for command
|
|
63
63
|
|
|
64
64
|
Commands:
|
|
65
|
-
create [options] [your-project-name]
|
|
66
|
-
node [options] [CKB-Version]
|
|
67
|
-
proxy-rpc [options]
|
|
68
|
-
clean
|
|
69
|
-
accounts
|
|
70
|
-
list-hashes [CKB-Version]
|
|
71
|
-
inject-config
|
|
72
|
-
sync-scripts
|
|
73
|
-
deposit [options] [toAddress] [
|
|
74
|
-
transfer [options] [toAddress] [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
65
|
+
create [options] [your-project-name] Create a new dApp from bare templates
|
|
66
|
+
node [options] [CKB-Version] Use the CKB to start devnet
|
|
67
|
+
proxy-rpc [options] Start the rpc proxy server
|
|
68
|
+
clean Clean the devnet data, need to stop running the chain first
|
|
69
|
+
accounts Print account list info
|
|
70
|
+
list-hashes [CKB-Version] Use the CKB to list blockchain scripts hashes
|
|
71
|
+
inject-config Add offckb.config.ts to your frontend workspace
|
|
72
|
+
sync-scripts Sync scripts json files in your frontend workspace
|
|
73
|
+
deposit [options] [toAddress] [amountInCKB] Deposit CKB tokens to address, only devnet and testnet
|
|
74
|
+
transfer [options] [toAddress] [amountInCKB] Transfer CKB tokens to address, only devnet and testnet
|
|
75
|
+
transfer-all [options] [toAddress] Transfer All CKB tokens to address, only devnet and testnet
|
|
76
|
+
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
77
|
+
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
78
|
+
my-scripts [options] Show deployed contracts info on different networks, only supports devnet and testnet
|
|
79
|
+
config <action> [item] [value] do a configuration action
|
|
80
|
+
debug [options] CKB Debugger for development
|
|
81
|
+
system-scripts [options] Output system scripts of the local devnet
|
|
82
|
+
mol [options] Generate CKB Moleculec binding code for development
|
|
83
|
+
help [command] display help for command
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
_Use `offckb [command] -h` to learn more about a specific command._
|
package/dist/cli.js
CHANGED
|
@@ -53,6 +53,7 @@ const system_scripts_1 = require("./cmd/system-scripts");
|
|
|
53
53
|
const proxy_rpc_1 = require("./cmd/proxy-rpc");
|
|
54
54
|
const mol_1 = require("./cmd/mol");
|
|
55
55
|
const fs = __importStar(require("fs"));
|
|
56
|
+
const transfer_all_1 = require("./cmd/transfer-all");
|
|
56
57
|
const version = require('../package.json').version;
|
|
57
58
|
const description = require('../package.json').description;
|
|
58
59
|
// fix windows terminal encoding of simplified chinese text
|
|
@@ -111,6 +112,14 @@ program
|
|
|
111
112
|
.action((toAddress, amountInCKB, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
113
|
return (0, transfer_1.transfer)(toAddress, amountInCKB, options);
|
|
113
114
|
}));
|
|
115
|
+
program
|
|
116
|
+
.command('transfer-all [toAddress]')
|
|
117
|
+
.description('Transfer All CKB tokens to address, only devnet and testnet')
|
|
118
|
+
.option('--network <network>', 'Specify the network to transfer to', 'devnet')
|
|
119
|
+
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
120
|
+
.action((toAddress, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
+
return (0, transfer_all_1.transferAll)(toAddress, options);
|
|
122
|
+
}));
|
|
114
123
|
program
|
|
115
124
|
.command('balance [toAddress]')
|
|
116
125
|
.description('Check account balance, only devnet and testnet')
|
package/dist/cmd/balance.d.ts
CHANGED
package/dist/cmd/balance.js
CHANGED
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.balanceOf = void 0;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const validator_1 = require("../util/validator");
|
|
15
|
-
const
|
|
16
|
-
function balanceOf(address, opt = { network:
|
|
15
|
+
const base_1 = require("../type/base");
|
|
16
|
+
function balanceOf(address, opt = { network: base_1.Network.devnet }) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const network = opt.network;
|
|
19
19
|
(0, validator_1.validateNetworkOpt)(network);
|
package/dist/cmd/debug.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network } from '../
|
|
1
|
+
import { Network } from '../type/base';
|
|
2
2
|
export declare function debugTransaction(txHash: string, network: Network): void;
|
|
3
3
|
export declare function buildTransactionDebugOptions(txHash: string, network: Network): {
|
|
4
4
|
name: string;
|
package/dist/cmd/debug.js
CHANGED
|
@@ -10,7 +10,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
10
10
|
const ckb_tx_dumper_1 = require("../tools/ckb-tx-dumper");
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const advanced_1 = require("@ckb-ccc/core/advanced");
|
|
13
|
-
const
|
|
13
|
+
const base_1 = require("../type/base");
|
|
14
14
|
function debugTransaction(txHash, network) {
|
|
15
15
|
const txFile = buildTxFileOptionBy(txHash, network);
|
|
16
16
|
const opts = buildTransactionDebugOptions(txHash, network);
|
|
@@ -91,10 +91,10 @@ function buildTxFileOptionBy(txHash, network) {
|
|
|
91
91
|
exports.buildTxFileOptionBy = buildTxFileOptionBy;
|
|
92
92
|
function buildTransactionJsonFilePath(network, txHash) {
|
|
93
93
|
const settings = (0, setting_1.readSettings)();
|
|
94
|
-
if (network ===
|
|
94
|
+
if (network === base_1.Network.devnet) {
|
|
95
95
|
return `${settings.devnet.transactionsPath}/${txHash}.json`;
|
|
96
96
|
}
|
|
97
|
-
if (network ===
|
|
97
|
+
if (network === base_1.Network.testnet) {
|
|
98
98
|
return `${settings.testnet.transactionsPath}/${txHash}.json`;
|
|
99
99
|
}
|
|
100
100
|
return `${settings.mainnet.transactionsPath}/${txHash}.json`;
|
|
@@ -102,10 +102,10 @@ function buildTransactionJsonFilePath(network, txHash) {
|
|
|
102
102
|
exports.buildTransactionJsonFilePath = buildTransactionJsonFilePath;
|
|
103
103
|
function buildDebugFullTransactionFilePath(network, txHash) {
|
|
104
104
|
const settings = (0, setting_1.readSettings)();
|
|
105
|
-
if (network ===
|
|
105
|
+
if (network === base_1.Network.devnet) {
|
|
106
106
|
return `${settings.devnet.debugFullTransactionsPath}/${txHash}.json`;
|
|
107
107
|
}
|
|
108
|
-
if (network ===
|
|
108
|
+
if (network === base_1.Network.testnet) {
|
|
109
109
|
return `${settings.testnet.debugFullTransactionsPath}/${txHash}.json`;
|
|
110
110
|
}
|
|
111
111
|
return `${settings.mainnet.debugFullTransactionsPath}/${txHash}.json`;
|
package/dist/cmd/deploy.d.ts
CHANGED
package/dist/cmd/deploy.js
CHANGED
|
@@ -13,14 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.deploy = void 0;
|
|
16
|
-
const
|
|
16
|
+
const base_1 = require("../type/base");
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const account_1 = require("../cfg/account");
|
|
19
19
|
const fs_1 = require("../util/fs");
|
|
20
20
|
const validator_1 = require("../util/validator");
|
|
21
21
|
const deploy_1 = require("../deploy");
|
|
22
22
|
const ckb_1 = require("../sdk/ckb");
|
|
23
|
-
function deploy(opt = { network:
|
|
23
|
+
function deploy(opt = { network: base_1.Network.devnet, typeId: false, target: null }) {
|
|
24
24
|
var _a;
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
const network = opt.network;
|
package/dist/cmd/deposit.d.ts
CHANGED
package/dist/cmd/deposit.js
CHANGED
|
@@ -12,11 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.deposit = void 0;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
14
|
const account_1 = require("../cfg/account");
|
|
15
|
-
const
|
|
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(toAddress, amountInCKB, opt = { network:
|
|
19
|
+
function deposit(toAddress, amountInCKB, opt = { network: base_1.Network.devnet }) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
const network = opt.network;
|
|
22
22
|
(0, validator_1.validateNetworkOpt)(network);
|
package/dist/cmd/my-scripts.d.ts
CHANGED
package/dist/cmd/my-scripts.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.printMyScripts = void 0;
|
|
|
4
4
|
const toml_1 = require("../deploy/toml");
|
|
5
5
|
const util_1 = require("../deploy/util");
|
|
6
6
|
const util_2 = require("../scripts/util");
|
|
7
|
-
const
|
|
7
|
+
const base_1 = require("../type/base");
|
|
8
8
|
const validator_1 = require("../util/validator");
|
|
9
|
-
function printMyScripts(option = { network:
|
|
9
|
+
function printMyScripts(option = { network: base_1.Network.devnet }) {
|
|
10
10
|
const network = option.network;
|
|
11
11
|
(0, validator_1.validateNetworkOpt)(network);
|
|
12
12
|
const scriptsInfo = (0, util_2.readUserDeployedScriptsInfo)(network);
|
package/dist/cmd/node.js
CHANGED
|
@@ -16,7 +16,7 @@ const install_1 = require("../node/install");
|
|
|
16
16
|
const setting_1 = require("../cfg/setting");
|
|
17
17
|
const encoding_1 = require("../util/encoding");
|
|
18
18
|
const rpc_proxy_1 = require("../tools/rpc-proxy");
|
|
19
|
-
const
|
|
19
|
+
const base_1 = require("../type/base");
|
|
20
20
|
function node({ version, noProxyServer }) {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,7 +54,7 @@ function node({ version, noProxyServer }) {
|
|
|
54
54
|
if (!noProxyServer) {
|
|
55
55
|
const ckbRpc = settings.devnet.rpcUrl;
|
|
56
56
|
const port = settings.rpc.proxyPort;
|
|
57
|
-
const proxy = (0, rpc_proxy_1.createRPCProxy)(
|
|
57
|
+
const proxy = (0, rpc_proxy_1.createRPCProxy)(base_1.Network.devnet, ckbRpc, port);
|
|
58
58
|
proxy.start();
|
|
59
59
|
}
|
|
60
60
|
}
|
package/dist/cmd/proxy-rpc.d.ts
CHANGED
package/dist/cmd/proxy-rpc.js
CHANGED
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.proxyRpc = void 0;
|
|
4
4
|
const setting_1 = require("../cfg/setting");
|
|
5
5
|
const rpc_proxy_1 = require("../tools/rpc-proxy");
|
|
6
|
-
const
|
|
6
|
+
const base_1 = require("../type/base");
|
|
7
7
|
function proxyRpc(options) {
|
|
8
8
|
const settings = (0, setting_1.readSettings)();
|
|
9
|
-
const network = options.network ||
|
|
9
|
+
const network = options.network || base_1.Network.devnet;
|
|
10
10
|
let ckbRpc = options.ckbRpc;
|
|
11
11
|
if (!ckbRpc) {
|
|
12
12
|
ckbRpc =
|
|
13
|
-
network ===
|
|
13
|
+
network === base_1.Network.devnet
|
|
14
14
|
? settings.devnet.rpcUrl
|
|
15
|
-
: network ===
|
|
15
|
+
: network === base_1.Network.testnet
|
|
16
16
|
? settings.testnet.rpcUrl
|
|
17
17
|
: settings.mainnet.rpcUrl;
|
|
18
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { config } from '@ckb-lumos/lumos';
|
|
2
1
|
import { SystemCell } from './list-hashes';
|
|
3
2
|
import { CellDepInfoLike, Script } from '@ckb-ccc/core';
|
|
4
3
|
import { SystemScriptsRecord } from '../scripts/type';
|
|
@@ -36,7 +35,76 @@ export declare function systemCellToScriptInfo(cell: SystemCell, depType: 'code'
|
|
|
36
35
|
};
|
|
37
36
|
}[];
|
|
38
37
|
};
|
|
39
|
-
export declare function toLumosConfig(scripts: SystemScriptsRecord, addressPrefix?: 'ckb' | 'ckt'):
|
|
38
|
+
export declare function toLumosConfig(scripts: SystemScriptsRecord, addressPrefix?: 'ckb' | 'ckt'): {
|
|
39
|
+
PREFIX: "ckb" | "ckt";
|
|
40
|
+
SCRIPTS: {
|
|
41
|
+
SECP256K1_BLAKE160: {
|
|
42
|
+
CODE_HASH: `0x${string}`;
|
|
43
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
44
|
+
TX_HASH: `0x${string}`;
|
|
45
|
+
INDEX: string;
|
|
46
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
47
|
+
SHORT_ID: number;
|
|
48
|
+
};
|
|
49
|
+
SECP256K1_BLAKE160_MULTISIG: {
|
|
50
|
+
CODE_HASH: `0x${string}`;
|
|
51
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
52
|
+
TX_HASH: `0x${string}`;
|
|
53
|
+
INDEX: string;
|
|
54
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
55
|
+
};
|
|
56
|
+
DAO: {
|
|
57
|
+
CODE_HASH: `0x${string}`;
|
|
58
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
59
|
+
TX_HASH: `0x${string}`;
|
|
60
|
+
INDEX: string;
|
|
61
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
62
|
+
SHORT_ID: number;
|
|
63
|
+
};
|
|
64
|
+
SUDT: {
|
|
65
|
+
CODE_HASH: `0x${string}`;
|
|
66
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
67
|
+
TX_HASH: `0x${string}`;
|
|
68
|
+
INDEX: string;
|
|
69
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
70
|
+
};
|
|
71
|
+
XUDT: {
|
|
72
|
+
CODE_HASH: `0x${string}`;
|
|
73
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
74
|
+
TX_HASH: `0x${string}`;
|
|
75
|
+
INDEX: string;
|
|
76
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
77
|
+
};
|
|
78
|
+
OMNILOCK: {
|
|
79
|
+
CODE_HASH: `0x${string}`;
|
|
80
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
81
|
+
TX_HASH: `0x${string}`;
|
|
82
|
+
INDEX: string;
|
|
83
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
84
|
+
};
|
|
85
|
+
ANYONE_CAN_PAY: {
|
|
86
|
+
CODE_HASH: `0x${string}`;
|
|
87
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
88
|
+
TX_HASH: `0x${string}`;
|
|
89
|
+
INDEX: string;
|
|
90
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
91
|
+
};
|
|
92
|
+
SPORE: {
|
|
93
|
+
CODE_HASH: `0x${string}`;
|
|
94
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
95
|
+
TX_HASH: `0x${string}`;
|
|
96
|
+
INDEX: string;
|
|
97
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
98
|
+
};
|
|
99
|
+
SPORE_CLUSTER: {
|
|
100
|
+
CODE_HASH: `0x${string}`;
|
|
101
|
+
HASH_TYPE: import("@ckb-ccc/core").HashType;
|
|
102
|
+
TX_HASH: `0x${string}`;
|
|
103
|
+
INDEX: string;
|
|
104
|
+
DEP_TYPE: import("@ckb-ccc/core").DepType;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
40
108
|
export declare function toCCCKnownScripts(scripts: SystemScriptsRecord): Record<string, Pick<Script, "codeHash" | "hashType"> & {
|
|
41
109
|
cellDeps: CellDepInfoLike[];
|
|
42
110
|
}>;
|
|
@@ -213,6 +213,7 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
|
213
213
|
},
|
|
214
214
|
};
|
|
215
215
|
if (scripts.always_success) {
|
|
216
|
+
// @ts-expect-error we remove the lumos config type deps
|
|
216
217
|
config.SCRIPTS['ALWAYS_SUCCESS'] = {
|
|
217
218
|
CODE_HASH: scripts.always_success.script.codeHash,
|
|
218
219
|
HASH_TYPE: scripts.always_success.script.hashType,
|
|
@@ -222,6 +223,7 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
|
222
223
|
};
|
|
223
224
|
}
|
|
224
225
|
if (scripts.spore_cluster_agent) {
|
|
226
|
+
// @ts-expect-error we remove the lumos config type deps
|
|
225
227
|
config.SCRIPTS['SPORE_CLUSTER_AGENT'] = {
|
|
226
228
|
CODE_HASH: scripts.spore_cluster_agent.script.codeHash,
|
|
227
229
|
HASH_TYPE: scripts.spore_cluster_agent.script.hashType,
|
|
@@ -231,6 +233,7 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
|
231
233
|
};
|
|
232
234
|
}
|
|
233
235
|
if (scripts.spore_cluster_proxy) {
|
|
236
|
+
// @ts-expect-error we remove the lumos config type deps
|
|
234
237
|
config.SCRIPTS['SPORE_CLUSTER_PROXY'] = {
|
|
235
238
|
CODE_HASH: scripts.spore_cluster_proxy.script.codeHash,
|
|
236
239
|
HASH_TYPE: scripts.spore_cluster_proxy.script.hashType,
|
|
@@ -240,6 +243,7 @@ function toLumosConfig(scripts, addressPrefix = 'ckt') {
|
|
|
240
243
|
};
|
|
241
244
|
}
|
|
242
245
|
if (scripts.spore_extension_lua) {
|
|
246
|
+
// @ts-expect-error we remove the lumos config type deps
|
|
243
247
|
config.SCRIPTS['SPORE_LUA'] = {
|
|
244
248
|
CODE_HASH: scripts.spore_extension_lua.script.codeHash,
|
|
245
249
|
HASH_TYPE: scripts.spore_extension_lua.script.hashType,
|
|
@@ -0,0 +1,37 @@
|
|
|
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.transferAll = void 0;
|
|
13
|
+
const ckb_1 = require("../sdk/ckb");
|
|
14
|
+
const base_1 = require("../type/base");
|
|
15
|
+
const link_1 = require("../util/link");
|
|
16
|
+
const validator_1 = require("../util/validator");
|
|
17
|
+
function transferAll(toAddress, opt = { network: base_1.Network.devnet }) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const network = opt.network;
|
|
20
|
+
(0, validator_1.validateNetworkOpt)(network);
|
|
21
|
+
if (opt.privkey == null) {
|
|
22
|
+
throw new Error('--privkey is required!');
|
|
23
|
+
}
|
|
24
|
+
const privateKey = opt.privkey;
|
|
25
|
+
const ckb = new ckb_1.CKB({ network });
|
|
26
|
+
const txHash = yield ckb.transferAll({
|
|
27
|
+
toAddress,
|
|
28
|
+
privateKey,
|
|
29
|
+
});
|
|
30
|
+
if (network === 'testnet') {
|
|
31
|
+
console.log(`Successfully transfer, check ${(0, link_1.buildTestnetTxLink)(txHash)} for details.`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
console.log('Successfully transfer, txHash:', txHash);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.transferAll = transferAll;
|
package/dist/cmd/transfer.d.ts
CHANGED
package/dist/cmd/transfer.js
CHANGED
|
@@ -11,10 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.transfer = void 0;
|
|
13
13
|
const ckb_1 = require("../sdk/ckb");
|
|
14
|
-
const
|
|
14
|
+
const base_1 = require("../type/base");
|
|
15
15
|
const link_1 = require("../util/link");
|
|
16
16
|
const validator_1 = require("../util/validator");
|
|
17
|
-
function transfer(toAddress, amountInCKB, opt = { network:
|
|
17
|
+
function transfer(toAddress, amountInCKB, opt = { network: base_1.Network.devnet }) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
const network = opt.network;
|
|
20
20
|
(0, validator_1.validateNetworkOpt)(network);
|
package/dist/deploy/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DeploymentOptions } from '../deploy/toml';
|
|
2
2
|
import { DeploymentRecipe } from '../deploy/migration';
|
|
3
|
-
import {
|
|
4
|
-
import { Network } from '../util/type';
|
|
3
|
+
import { Network } from '../type/base';
|
|
5
4
|
import { CKB } from '../sdk/ckb';
|
|
5
|
+
import { HexString } from '../type/base';
|
|
6
6
|
export type DeployBinaryReturnType = ReturnType<typeof deployBinary>;
|
|
7
7
|
export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
8
8
|
export type DeployedInterfaceType = UnwrapPromise<DeployBinaryReturnType>;
|
package/dist/deploy/index.js
CHANGED
|
@@ -15,12 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.deployBinary = exports.deployBinaries = exports.recordDeployResult = exports.getToDeployBinsPath = void 0;
|
|
16
16
|
const toml_1 = require("../deploy/toml");
|
|
17
17
|
const migration_1 = require("../deploy/migration");
|
|
18
|
-
const utils_1 = require("@ckb-lumos/lumos/utils");
|
|
19
18
|
const gen_1 = require("../scripts/gen");
|
|
20
19
|
const offckb_config_1 = require("../template/offckb-config");
|
|
21
20
|
const fs_1 = require("../util/fs");
|
|
22
21
|
const path_1 = __importDefault(require("path"));
|
|
23
22
|
const fs_2 = __importDefault(require("fs"));
|
|
23
|
+
const core_1 = require("@ckb-ccc/core");
|
|
24
24
|
function getToDeployBinsPath() {
|
|
25
25
|
const userOffCKBConfigPath = path_1.default.resolve(process.cwd(), 'offckb.config.ts');
|
|
26
26
|
const fileContent = fs_2.default.readFileSync(userOffCKBConfigPath, 'utf-8');
|
|
@@ -98,7 +98,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
98
98
|
if (enableTypeId && typeIdScript == null) {
|
|
99
99
|
throw new Error('type id script is null while enableTypeId is true.');
|
|
100
100
|
}
|
|
101
|
-
const typeIdScriptHash = enableTypeId ?
|
|
101
|
+
const typeIdScriptHash = enableTypeId ? core_1.ccc.Script.from(typeIdScript).hash() : undefined;
|
|
102
102
|
// todo: handle multiple cell recipes?
|
|
103
103
|
return {
|
|
104
104
|
deploymentOptions: {
|
|
@@ -114,7 +114,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
114
114
|
txHash,
|
|
115
115
|
index: '0x' + index.toString(16),
|
|
116
116
|
occupiedCapacity,
|
|
117
|
-
dataHash:
|
|
117
|
+
dataHash: core_1.ccc.hashCkb(tx.outputsData[+index]),
|
|
118
118
|
typeId: typeIdScriptHash,
|
|
119
119
|
},
|
|
120
120
|
],
|
package/dist/deploy/migration.js
CHANGED
|
@@ -27,25 +27,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.deploymentRecipeFromJson = exports.deploymentRecipeToJson = exports.getNewestMigrationFile = exports.getMigrationFolderPath = exports.getFormattedMigrationDate = exports.readDeploymentMigrationFile = exports.generateDeploymentMigrationFile = exports.Migration = void 0;
|
|
30
|
-
const
|
|
30
|
+
const base_1 = require("../type/base");
|
|
31
31
|
const path_1 = __importStar(require("path"));
|
|
32
32
|
const fs_1 = __importDefault(require("fs"));
|
|
33
33
|
const util_1 = require("./util");
|
|
34
34
|
class Migration {
|
|
35
|
-
static find(scriptName, network =
|
|
35
|
+
static find(scriptName, network = base_1.Network.devnet) {
|
|
36
36
|
const filePath = getMigrationFolderPath(scriptName, network);
|
|
37
37
|
const migrationFile = getNewestMigrationFile(filePath);
|
|
38
38
|
if (migrationFile == null)
|
|
39
39
|
return null;
|
|
40
40
|
return readDeploymentMigrationFile(migrationFile);
|
|
41
41
|
}
|
|
42
|
-
static isDeployed(scriptName, network =
|
|
42
|
+
static isDeployed(scriptName, network = base_1.Network.devnet) {
|
|
43
43
|
const deploymentReceipt = Migration.find(scriptName, network);
|
|
44
44
|
if (deploymentReceipt == null)
|
|
45
45
|
return false;
|
|
46
46
|
return true;
|
|
47
47
|
}
|
|
48
|
-
static isDeployedWithTypeId(scriptName, network =
|
|
48
|
+
static isDeployedWithTypeId(scriptName, network = base_1.Network.devnet) {
|
|
49
49
|
const isDeployed = this.isDeployed(scriptName, network);
|
|
50
50
|
if (isDeployed === false)
|
|
51
51
|
return false;
|
|
@@ -57,7 +57,7 @@ class Migration {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
exports.Migration = Migration;
|
|
60
|
-
function generateDeploymentMigrationFile(name, deploymentRecipe, network =
|
|
60
|
+
function generateDeploymentMigrationFile(name, deploymentRecipe, network = base_1.Network.devnet) {
|
|
61
61
|
const cellRecipes = deploymentRecipe.cellRecipes;
|
|
62
62
|
const depGroupRecipes = deploymentRecipe.depGroupRecipes;
|
|
63
63
|
const jsonString = JSON.stringify(deploymentRecipeToJson({ cellRecipes, depGroupRecipes }), null, 2);
|
package/dist/deploy/toml.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Network } from '../util/type';
|
|
1
|
+
import { Network } from '../type/base';
|
|
3
2
|
import { HashType } from '@ckb-ccc/core';
|
|
3
|
+
import { HexString } from '../type/base';
|
|
4
4
|
export interface DeploymentOptions {
|
|
5
5
|
name: string;
|
|
6
6
|
binFilePath: string;
|
|
7
7
|
enableTypeId: boolean;
|
|
8
|
-
lockScript:
|
|
8
|
+
lockScript: {
|
|
9
|
+
codeHash: HexString;
|
|
10
|
+
hashType: HashType;
|
|
11
|
+
args: HexString;
|
|
12
|
+
};
|
|
9
13
|
}
|
|
10
14
|
export interface DeploymentToml {
|
|
11
15
|
cells: {
|
package/dist/deploy/util.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Network } from '../
|
|
1
|
+
import { Network } from '../type/base';
|
|
2
2
|
export declare function getContractsPath(network: Network): string;
|
package/dist/deploy/util.js
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getContractsPath = void 0;
|
|
4
4
|
const setting_1 = require("../cfg/setting");
|
|
5
|
-
const
|
|
5
|
+
const base_1 = require("../type/base");
|
|
6
6
|
function getContractsPath(network) {
|
|
7
7
|
const settings = (0, setting_1.readSettings)();
|
|
8
|
-
if (network ===
|
|
8
|
+
if (network === base_1.Network.devnet) {
|
|
9
9
|
return settings.devnet.contractsPath;
|
|
10
10
|
}
|
|
11
|
-
if (network ===
|
|
11
|
+
if (network === base_1.Network.testnet) {
|
|
12
12
|
return settings.testnet.contractsPath;
|
|
13
13
|
}
|
|
14
|
-
if (network ===
|
|
14
|
+
if (network === base_1.Network.mainnet) {
|
|
15
15
|
return settings.mainnet.contractsPath;
|
|
16
16
|
}
|
|
17
17
|
throw new Error(`invalid network ${network}`);
|
package/dist/scripts/gen.js
CHANGED
|
@@ -31,7 +31,7 @@ const fs = __importStar(require("fs"));
|
|
|
31
31
|
const public_1 = __importDefault(require("./public"));
|
|
32
32
|
const system_scripts_1 = require("../cmd/system-scripts");
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
34
|
-
const
|
|
34
|
+
const base_1 = require("../type/base");
|
|
35
35
|
const util_1 = require("./util");
|
|
36
36
|
function genSystemScripts() {
|
|
37
37
|
const devnetScripts = (0, system_scripts_1.getSystemScriptsFromListHashes)();
|
|
@@ -54,9 +54,9 @@ function genSystemScriptsJsonFile(filePath) {
|
|
|
54
54
|
exports.genSystemScriptsJsonFile = genSystemScriptsJsonFile;
|
|
55
55
|
function genMyScripts() {
|
|
56
56
|
const networkMyScripts = {
|
|
57
|
-
devnet: (0, util_1.readUserDeployedScriptsInfo)(
|
|
58
|
-
testnet: (0, util_1.readUserDeployedScriptsInfo)(
|
|
59
|
-
mainnet: (0, util_1.readUserDeployedScriptsInfo)(
|
|
57
|
+
devnet: (0, util_1.readUserDeployedScriptsInfo)(base_1.Network.devnet),
|
|
58
|
+
testnet: (0, util_1.readUserDeployedScriptsInfo)(base_1.Network.testnet),
|
|
59
|
+
mainnet: (0, util_1.readUserDeployedScriptsInfo)(base_1.Network.mainnet),
|
|
60
60
|
};
|
|
61
61
|
return networkMyScripts;
|
|
62
62
|
}
|
package/dist/scripts/util.d.ts
CHANGED
package/dist/sdk/ckb.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ccc, Script } from '@ckb-ccc/core';
|
|
2
|
-
import { Network } from '../
|
|
3
|
-
import { HexNumber, HexString } from '@ckb-lumos/lumos';
|
|
2
|
+
import { Network, HexNumber, HexString } from '../type/base';
|
|
4
3
|
export declare class CKBProps {
|
|
5
4
|
network?: Network;
|
|
6
5
|
feeRate?: number;
|
package/dist/sdk/ckb.js
CHANGED
|
@@ -13,16 +13,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.CKB = exports.CKBProps = void 0;
|
|
15
15
|
const core_1 = require("@ckb-ccc/core");
|
|
16
|
-
const type_1 = require("../util/type");
|
|
17
16
|
const validator_1 = require("../util/validator");
|
|
18
17
|
const network_1 = require("./network");
|
|
19
18
|
const private_1 = require("../scripts/private");
|
|
20
19
|
const migration_1 = require("../deploy/migration");
|
|
20
|
+
const base_1 = require("../type/base");
|
|
21
21
|
class CKBProps {
|
|
22
22
|
}
|
|
23
23
|
exports.CKBProps = CKBProps;
|
|
24
24
|
class CKB {
|
|
25
|
-
constructor({ network =
|
|
25
|
+
constructor({ network = base_1.Network.devnet, feeRate = 1000, isEnableProxyRpc = false }) {
|
|
26
26
|
if (!(0, validator_1.isValidNetworkString)(network)) {
|
|
27
27
|
throw new Error('invalid network option');
|
|
28
28
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import http from 'http';
|
|
3
|
-
import { Network } from '../
|
|
3
|
+
import { Network } from '../type/base';
|
|
4
4
|
export declare function createRPCProxy(network: Network, targetRpcUrl: string, port: number): {
|
|
5
5
|
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
6
6
|
network: Network;
|
package/dist/tools/rpc-proxy.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createRPCProxy = void 0;
|
|
7
7
|
const http_proxy_1 = __importDefault(require("http-proxy"));
|
|
8
8
|
const http_1 = __importDefault(require("http"));
|
|
9
|
-
const
|
|
9
|
+
const base_1 = require("../type/base");
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const setting_1 = require("../cfg/setting");
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
@@ -38,7 +38,7 @@ function createRPCProxy(network, targetRpcUrl, port) {
|
|
|
38
38
|
if (method === 'send_transaction') {
|
|
39
39
|
const tx = params[0];
|
|
40
40
|
// todo: record tx
|
|
41
|
-
if (network ===
|
|
41
|
+
if (network === base_1.Network.devnet) {
|
|
42
42
|
const cccTx = cccA.JsonRpcTransformers.transactionTo(tx);
|
|
43
43
|
const txHash = cccTx.hash();
|
|
44
44
|
const settings = (0, setting_1.readSettings)();
|
package/dist/util/validator.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.isValidVersion = exports.validateNetworkOpt = exports.isValidNetworkString = exports.validateExecDappEnvironment = exports.validateTypescriptWorkspace = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
9
|
+
const base_1 = require("../type/base");
|
|
10
10
|
function validateTypescriptWorkspace() {
|
|
11
11
|
const cwd = process.cwd();
|
|
12
12
|
// Check if package.json exists
|
|
@@ -50,7 +50,7 @@ function validateNetworkOpt(network) {
|
|
|
50
50
|
if (!isValidNetworkString(network)) {
|
|
51
51
|
throw new Error('invalid network option, ' + network);
|
|
52
52
|
}
|
|
53
|
-
if (network ===
|
|
53
|
+
if (network === base_1.Network.mainnet) {
|
|
54
54
|
console.log('Mainnet not support yet. Please use CKB-CLI to operate on mainnet for better security. Check https://github.com/nervosnetwork/ckb-cli');
|
|
55
55
|
process.exit(1);
|
|
56
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.3.0-canary-
|
|
3
|
+
"version": "0.3.0-canary-ee0ab6a.0",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@ckb-ccc/core": "^0.0.16-alpha.3",
|
|
64
|
-
"@ckb-lumos/lumos": "0.23.0",
|
|
65
64
|
"@iarna/toml": "^2.2.5",
|
|
66
65
|
"@inquirer/prompts": "^4.1.0",
|
|
67
66
|
"@types/http-proxy": "^1.17.15",
|
|
File without changes
|