@offckb/cli 0.3.0-rc4 → 0.3.0-rc5
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/cfg/setting.d.ts +11 -2
- package/dist/cli.js +15 -6
- package/dist/cmd/balance.d.ts +1 -1
- package/dist/cmd/balance.js +6 -8
- 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 +2 -2
- package/dist/cmd/deposit.js +29 -31
- 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 +2 -2
- package/dist/cmd/transfer.js +8 -11
- 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/node/install.js +3 -4
- package/dist/scripts/gen.js +4 -4
- package/dist/scripts/util.d.ts +1 -1
- package/dist/sdk/ckb.d.ts +17 -4
- package/dist/sdk/ckb.js +79 -5
- package/dist/tools/moleculec-es.js +3 -4
- 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/request.d.ts +6 -6
- package/dist/util/request.js +15 -11
- package/dist/util/validator.js +2 -2
- package/package.json +4 -3
- package/dist/util/ckb.d.ts +0 -141
- package/dist/util/ckb.js +0 -312
- /package/dist/{util/type.js → type/base.js} +0 -0
package/README.md
CHANGED
|
@@ -60,28 +60,29 @@ Usage: offckb [options] [command]
|
|
|
60
60
|
ckb development network for your first try
|
|
61
61
|
|
|
62
62
|
Options:
|
|
63
|
-
-V, --version
|
|
64
|
-
-h, --help
|
|
63
|
+
-V, --version output the version number
|
|
64
|
+
-h, --help display help for command
|
|
65
65
|
|
|
66
66
|
Commands:
|
|
67
|
-
create [options] [your-project-name]
|
|
68
|
-
node [options] [CKB-Version]
|
|
69
|
-
proxy-rpc [options]
|
|
70
|
-
clean
|
|
71
|
-
accounts
|
|
72
|
-
list-hashes [CKB-Version]
|
|
73
|
-
inject-config
|
|
74
|
-
sync-scripts
|
|
75
|
-
deposit [options] [toAddress] [
|
|
76
|
-
transfer [options] [toAddress] [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
create [options] [your-project-name] Create a new dApp from bare templates
|
|
68
|
+
node [options] [CKB-Version] Use the CKB to start devnet
|
|
69
|
+
proxy-rpc [options] Start the rpc proxy server
|
|
70
|
+
clean Clean the devnet data, need to stop running the chain first
|
|
71
|
+
accounts Print account list info
|
|
72
|
+
list-hashes [CKB-Version] Use the CKB to list blockchain scripts hashes
|
|
73
|
+
inject-config Add offckb.config.ts to your frontend workspace
|
|
74
|
+
sync-scripts Sync scripts json files in your frontend workspace
|
|
75
|
+
deposit [options] [toAddress] [amountInCKB] Deposit CKB tokens to address, only devnet and testnet
|
|
76
|
+
transfer [options] [toAddress] [amountInCKB] Transfer CKB tokens to address, only devnet and testnet
|
|
77
|
+
transfer-all [options] [toAddress] Transfer All CKB tokens to address, only devnet and testnet
|
|
78
|
+
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
79
|
+
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
80
|
+
my-scripts [options] Show deployed contracts info on different networks, only supports devnet and testnet
|
|
81
|
+
config <action> [item] [value] do a configuration action
|
|
82
|
+
debug [options] CKB Debugger for development
|
|
83
|
+
system-scripts [options] Output system scripts of the local devnet
|
|
84
|
+
mol [options] Generate CKB Moleculec binding code for development
|
|
85
|
+
help [command] display help for command
|
|
85
86
|
```
|
|
86
87
|
|
|
87
88
|
_Use `offckb [command] -h` to learn more about a specific command._
|
package/dist/cfg/setting.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { AxiosProxyConfig } from 'axios';
|
|
2
1
|
export declare const configPath: string;
|
|
3
2
|
export declare const dataPath: string;
|
|
4
3
|
export declare const cachePath: string;
|
|
5
4
|
export declare const packageSrcPath: string;
|
|
6
5
|
export declare const packageRootPath: string;
|
|
6
|
+
export interface ProxyBasicCredentials {
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ProxyConfig {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
auth?: ProxyBasicCredentials;
|
|
14
|
+
protocol?: string;
|
|
15
|
+
}
|
|
7
16
|
export interface Settings {
|
|
8
|
-
proxy?:
|
|
17
|
+
proxy?: ProxyConfig;
|
|
9
18
|
rpc: {
|
|
10
19
|
proxyPort: number;
|
|
11
20
|
};
|
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
|
|
@@ -97,19 +98,27 @@ program
|
|
|
97
98
|
program.command('inject-config').description('Add offckb.config.ts to your frontend workspace').action(inject_config_1.injectConfig);
|
|
98
99
|
program.command('sync-scripts').description('Sync scripts json files in your frontend workspace').action(sync_scripts_1.syncScripts);
|
|
99
100
|
program
|
|
100
|
-
.command('deposit [toAddress] [
|
|
101
|
+
.command('deposit [toAddress] [amountInCKB]')
|
|
101
102
|
.description('Deposit CKB tokens to address, only devnet and testnet')
|
|
102
103
|
.option('--network <network>', 'Specify the network to deposit to', 'devnet')
|
|
103
|
-
.action((toAddress,
|
|
104
|
-
return (0, deposit_1.deposit)(toAddress,
|
|
104
|
+
.action((toAddress, amountInCKB, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
return (0, deposit_1.deposit)(toAddress, amountInCKB, options);
|
|
105
106
|
}));
|
|
106
107
|
program
|
|
107
|
-
.command('transfer [toAddress] [
|
|
108
|
+
.command('transfer [toAddress] [amountInCKB]')
|
|
108
109
|
.description('Transfer CKB tokens to address, only devnet and testnet')
|
|
109
110
|
.option('--network <network>', 'Specify the network to transfer to', 'devnet')
|
|
110
111
|
.option('--privkey <privkey>', 'Specify the private key to deploy scripts')
|
|
111
|
-
.action((toAddress,
|
|
112
|
-
return (0, transfer_1.transfer)(toAddress,
|
|
112
|
+
.action((toAddress, amountInCKB, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
+
return (0, transfer_1.transfer)(toAddress, amountInCKB, options);
|
|
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);
|
|
113
122
|
}));
|
|
114
123
|
program
|
|
115
124
|
.command('balance [toAddress]')
|
package/dist/cmd/balance.d.ts
CHANGED
package/dist/cmd/balance.js
CHANGED
|
@@ -10,19 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.balanceOf = void 0;
|
|
13
|
-
const
|
|
14
|
-
const ckb_1 = require("../util/ckb");
|
|
13
|
+
const ckb_1 = require("../sdk/ckb");
|
|
15
14
|
const validator_1 = require("../util/validator");
|
|
16
|
-
const
|
|
17
|
-
function balanceOf(address, opt = { network:
|
|
15
|
+
const base_1 = require("../type/base");
|
|
16
|
+
function balanceOf(address, opt = { network: base_1.Network.devnet }) {
|
|
18
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
const network = opt.network;
|
|
20
19
|
(0, validator_1.validateNetworkOpt)(network);
|
|
21
|
-
const ckb = new ckb_1.CKB(network);
|
|
22
|
-
const
|
|
23
|
-
const balance = yield ckb.capacityOf(address, lumosConfig);
|
|
24
|
-
const balanceInCKB = balance.div(lumos_1.BI.from('100000000'));
|
|
20
|
+
const ckb = new ckb_1.CKB({ network });
|
|
21
|
+
const balanceInCKB = yield ckb.balance(address);
|
|
25
22
|
console.log(`Balance: ${balanceInCKB} CKB`);
|
|
23
|
+
process.exit(0);
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
exports.balanceOf = balanceOf;
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NetworkOption } from '../
|
|
1
|
+
import { NetworkOption } from '../type/base';
|
|
2
2
|
export interface DepositOptions extends NetworkOption {
|
|
3
3
|
}
|
|
4
|
-
export declare function deposit(toAddress: string,
|
|
4
|
+
export declare function deposit(toAddress: string, amountInCKB: string, opt?: DepositOptions): Promise<void>;
|
package/dist/cmd/deposit.js
CHANGED
|
@@ -10,29 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.deposit = void 0;
|
|
13
|
-
const ckb_1 = require("../
|
|
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,
|
|
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);
|
|
23
|
-
const ckb = new ckb_1.CKB(network);
|
|
24
|
-
const lumosConfig = ckb.getLumosConfig();
|
|
23
|
+
const ckb = new ckb_1.CKB({ network });
|
|
25
24
|
if (network === 'testnet') {
|
|
26
25
|
return yield depositFromTestnetFaucet(toAddress, ckb);
|
|
27
26
|
}
|
|
28
27
|
// deposit from devnet miner
|
|
29
|
-
const
|
|
28
|
+
const privateKey = account_1.ckbDevnetMinerAccount.privkey;
|
|
30
29
|
const txHash = yield ckb.transfer({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, lumosConfig);
|
|
30
|
+
toAddress,
|
|
31
|
+
privateKey,
|
|
32
|
+
amountInCKB,
|
|
33
|
+
});
|
|
36
34
|
console.log('tx hash: ', txHash);
|
|
37
35
|
});
|
|
38
36
|
}
|
|
@@ -40,29 +38,33 @@ exports.deposit = deposit;
|
|
|
40
38
|
function depositFromTestnetFaucet(ckbAddress, ckb) {
|
|
41
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
40
|
console.log('testnet faucet only supports fixed-amount claim: 10,000 CKB');
|
|
43
|
-
const lumosConfig = ckb.getLumosConfig();
|
|
44
41
|
const randomAccountPrivateKey = '0x' + generateHex(64);
|
|
45
|
-
const
|
|
46
|
-
console.log(`use random account to claim from faucet: \n\nprivate key: ${randomAccountPrivateKey}\n\n address: ${
|
|
42
|
+
const randomAccountAddress = yield ckb.buildSecp256k1Address(randomAccountPrivateKey);
|
|
43
|
+
console.log(`use random account to claim from faucet: \n\nprivate key: ${randomAccountPrivateKey}\n\n address: ${randomAccountAddress}`);
|
|
47
44
|
try {
|
|
48
|
-
yield sendClaimRequest(
|
|
49
|
-
console.log('Wait for
|
|
45
|
+
const claimResponse = yield sendClaimRequest(randomAccountAddress);
|
|
46
|
+
console.log('Wait for claim transaction confirmed to transfer all from random account to your account..');
|
|
50
47
|
console.log('You can transfer by yourself if it ends up fails..');
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
if (claimResponse.txHash != null) {
|
|
49
|
+
yield ckb.waitForTxConfirm(claimResponse.txHash);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
yield ckb.waitForBlocksBy(4); // wait 4 blocks
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
56
|
console.log(error);
|
|
57
|
-
throw new Error('request failed.');
|
|
57
|
+
throw new Error('claim request failed.');
|
|
58
58
|
}
|
|
59
|
+
const txHash = yield ckb.transferAll({ privateKey: randomAccountPrivateKey, toAddress: ckbAddress });
|
|
60
|
+
console.log(`Done, check ${(0, link_1.buildTestnetTxLink)(txHash)} for details.`);
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
function sendClaimRequest(toAddress) {
|
|
62
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
65
|
const url = 'https://faucet-api.nervos.org/claim_events'; // Replace 'YOUR_API_ENDPOINT' with the actual API endpoint
|
|
64
66
|
const headers = {
|
|
65
|
-
'User-Agent': '
|
|
67
|
+
'User-Agent': 'node-fetch-requests/v2',
|
|
66
68
|
'Accept-Encoding': 'gzip, deflate',
|
|
67
69
|
Accept: '*/*',
|
|
68
70
|
Connection: 'keep-alive',
|
|
@@ -71,22 +73,18 @@ function sendClaimRequest(toAddress) {
|
|
|
71
73
|
const body = JSON.stringify({
|
|
72
74
|
claim_event: {
|
|
73
75
|
address_hash: toAddress,
|
|
74
|
-
amount: '10000',
|
|
76
|
+
amount: '10000', // unit: CKB
|
|
75
77
|
},
|
|
76
78
|
});
|
|
77
79
|
const config = {
|
|
78
80
|
method: 'post',
|
|
79
|
-
url: url,
|
|
80
81
|
headers: headers,
|
|
81
|
-
|
|
82
|
+
body,
|
|
82
83
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
catch (error) {
|
|
88
|
-
console.error('Error:', error);
|
|
89
|
-
}
|
|
84
|
+
const response = yield request_1.Request.send(url, config);
|
|
85
|
+
console.log('send claim request, status: ', response.status); // Handle the response data here
|
|
86
|
+
const jsonResponse = yield response.json();
|
|
87
|
+
return jsonResponse.data.attributes;
|
|
90
88
|
});
|
|
91
89
|
}
|
|
92
90
|
function generateHex(length) {
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NetworkOption } from '../
|
|
1
|
+
import { NetworkOption } from '../type/base';
|
|
2
2
|
export interface TransferOptions extends NetworkOption {
|
|
3
3
|
privkey?: string | null;
|
|
4
4
|
}
|
|
5
|
-
export declare function transfer(toAddress: string,
|
|
5
|
+
export declare function transfer(toAddress: string, amountInCKB: string, opt?: TransferOptions): Promise<void>;
|
package/dist/cmd/transfer.js
CHANGED
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.transfer = void 0;
|
|
13
|
-
const ckb_1 = require("../
|
|
14
|
-
const
|
|
13
|
+
const ckb_1 = require("../sdk/ckb");
|
|
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,
|
|
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);
|
|
@@ -22,15 +22,12 @@ function transfer(toAddress, amount, opt = { network: type_1.Network.devnet }) {
|
|
|
22
22
|
throw new Error('--privkey is required!');
|
|
23
23
|
}
|
|
24
24
|
const privateKey = opt.privkey;
|
|
25
|
-
const ckb = new ckb_1.CKB(network);
|
|
26
|
-
const lumosConfig = ckb.getLumosConfig();
|
|
27
|
-
const from = ckb_1.CKB.generateAccountFromPrivateKey(privateKey, lumosConfig);
|
|
25
|
+
const ckb = new ckb_1.CKB({ network });
|
|
28
26
|
const txHash = yield ckb.transfer({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, lumosConfig);
|
|
27
|
+
toAddress,
|
|
28
|
+
amountInCKB,
|
|
29
|
+
privateKey,
|
|
30
|
+
});
|
|
34
31
|
if (network === 'testnet') {
|
|
35
32
|
console.log(`Successfully transfer, check ${(0, link_1.buildTestnetTxLink)(txHash)} for details.`);
|
|
36
33
|
return;
|
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>;
|