@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/scripts/type.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SystemScriptName = void 0;
|
|
4
|
-
var SystemScriptName;
|
|
5
|
-
(function (SystemScriptName) {
|
|
6
|
-
SystemScriptName["secp256k1_blake160_sighash_all"] = "secp256k1_blake160_sighash_all";
|
|
7
|
-
SystemScriptName["secp256k1_blake160_multisig_all"] = "secp256k1_blake160_multisig_all";
|
|
8
|
-
SystemScriptName["dao"] = "dao";
|
|
9
|
-
SystemScriptName["sudt"] = "sudt";
|
|
10
|
-
SystemScriptName["xudt"] = "xudt";
|
|
11
|
-
SystemScriptName["omnilock"] = "omnilock";
|
|
12
|
-
SystemScriptName["anyone_can_pay"] = "anyone_can_pay";
|
|
13
|
-
SystemScriptName["always_success"] = "always_success";
|
|
14
|
-
SystemScriptName["spore"] = "spore";
|
|
15
|
-
SystemScriptName["spore_cluster"] = "spore_cluster";
|
|
16
|
-
SystemScriptName["spore_cluster_agent"] = "spore_cluster_agent";
|
|
17
|
-
SystemScriptName["spore_cluster_proxy"] = "spore_cluster_proxy";
|
|
18
|
-
SystemScriptName["spore_extension_lua"] = "spore_extension_lua";
|
|
19
|
-
})(SystemScriptName || (exports.SystemScriptName = SystemScriptName = {}));
|
package/dist/scripts/util.d.ts
DELETED
package/dist/scripts/util.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.readUserDeployedScriptsInfo = readUserDeployedScriptsInfo;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const util_1 = require("../deploy/util");
|
|
39
|
-
const migration_1 = require("../deploy/migration");
|
|
40
|
-
const fs_1 = require("../util/fs");
|
|
41
|
-
function readUserDeployedScriptsInfo(network) {
|
|
42
|
-
const deployedScriptsInfo = {};
|
|
43
|
-
// Read all files in the folder
|
|
44
|
-
const folder = (0, util_1.getContractsPath)(network);
|
|
45
|
-
if (!fs.existsSync(folder)) {
|
|
46
|
-
return deployedScriptsInfo;
|
|
47
|
-
}
|
|
48
|
-
const contractNames = (0, fs_1.getSubfolders)(folder);
|
|
49
|
-
for (const contractName of contractNames) {
|
|
50
|
-
const folderPath = (0, migration_1.getMigrationFolderPath)(contractName, network); // Replace with your function to get the folder path
|
|
51
|
-
const newestFilePath = (0, migration_1.getNewestMigrationFile)(folderPath);
|
|
52
|
-
if (newestFilePath) {
|
|
53
|
-
try {
|
|
54
|
-
// Read the file content
|
|
55
|
-
const recipe = (0, migration_1.readDeploymentMigrationFile)(newestFilePath);
|
|
56
|
-
// todo: handle multiple cell recipes?
|
|
57
|
-
const firstCell = recipe.cellRecipes[0];
|
|
58
|
-
const isDepCode = recipe.depGroupRecipes.length > 0;
|
|
59
|
-
deployedScriptsInfo[firstCell.name] = {
|
|
60
|
-
codeHash: (firstCell.typeId ? firstCell.typeId : firstCell.dataHash),
|
|
61
|
-
hashType: firstCell.typeId ? 'type' : 'data1',
|
|
62
|
-
cellDeps: !isDepCode
|
|
63
|
-
? [
|
|
64
|
-
{
|
|
65
|
-
cellDep: {
|
|
66
|
-
outPoint: {
|
|
67
|
-
txHash: firstCell.txHash,
|
|
68
|
-
index: +firstCell.index,
|
|
69
|
-
},
|
|
70
|
-
depType: 'code',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
]
|
|
74
|
-
: recipe.depGroupRecipes.map((depGroupRecipe) => {
|
|
75
|
-
return {
|
|
76
|
-
cellDep: {
|
|
77
|
-
outPoint: {
|
|
78
|
-
txHash: depGroupRecipe.txHash,
|
|
79
|
-
index: +depGroupRecipe.index,
|
|
80
|
-
},
|
|
81
|
-
depType: 'depGroup',
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
}),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
console.error(`Error reading or parsing file '${newestFilePath}':`, error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return deployedScriptsInfo;
|
|
93
|
-
}
|
package/dist/sdk/ckb.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ccc, Script } from '@ckb-ccc/core';
|
|
2
|
-
import { Network, HexNumber, HexString } from '../type/base';
|
|
3
|
-
export declare class CKBProps {
|
|
4
|
-
network?: Network;
|
|
5
|
-
feeRate?: number;
|
|
6
|
-
isEnableProxyRpc?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface DeploymentResult {
|
|
9
|
-
txHash: HexString;
|
|
10
|
-
tx: ccc.Transaction;
|
|
11
|
-
scriptOutputCellIndex: number;
|
|
12
|
-
isTypeId: boolean;
|
|
13
|
-
typeId?: Script;
|
|
14
|
-
}
|
|
15
|
-
export interface TransferOption {
|
|
16
|
-
privateKey: HexString;
|
|
17
|
-
toAddress: string;
|
|
18
|
-
amountInCKB: HexNumber;
|
|
19
|
-
}
|
|
20
|
-
export type TransferAllOption = Pick<TransferOption, 'privateKey' | 'toAddress'>;
|
|
21
|
-
export declare class CKB {
|
|
22
|
-
network: Network;
|
|
23
|
-
feeRate: number;
|
|
24
|
-
isEnableProxyRpc: boolean;
|
|
25
|
-
private client;
|
|
26
|
-
constructor({ network, feeRate, isEnableProxyRpc }: CKBProps);
|
|
27
|
-
buildSigner(privateKey: HexString): ccc.SignerCkbPrivateKey;
|
|
28
|
-
buildSecp256k1Address(privateKey: HexString): Promise<string>;
|
|
29
|
-
waitForTxConfirm(txHash: HexString, timeout?: number): Promise<void>;
|
|
30
|
-
waitForBlocksBy(interval: number): Promise<void>;
|
|
31
|
-
balance(address: string): Promise<string>;
|
|
32
|
-
transfer({ privateKey, toAddress, amountInCKB }: TransferOption): Promise<HexString>;
|
|
33
|
-
transferAll({ privateKey, toAddress }: TransferAllOption): Promise<HexString>;
|
|
34
|
-
deployScript(scriptBinBytes: Uint8Array, privateKey: string): Promise<DeploymentResult>;
|
|
35
|
-
deployNewTypeIDScript(scriptBinBytes: Uint8Array, privateKey: string): Promise<DeploymentResult>;
|
|
36
|
-
upgradeTypeIdScript(scriptName: string, newScriptBinBytes: Uint8Array, privateKey: HexString): Promise<DeploymentResult>;
|
|
37
|
-
}
|
package/dist/sdk/ckb.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// this is a rewrite for util/ckb.ts
|
|
3
|
-
// to replace lumos with ccc
|
|
4
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.CKB = exports.CKBProps = void 0;
|
|
15
|
-
const core_1 = require("@ckb-ccc/core");
|
|
16
|
-
const validator_1 = require("../util/validator");
|
|
17
|
-
const network_1 = require("./network");
|
|
18
|
-
const private_1 = require("../scripts/private");
|
|
19
|
-
const migration_1 = require("../deploy/migration");
|
|
20
|
-
const base_1 = require("../type/base");
|
|
21
|
-
class CKBProps {
|
|
22
|
-
}
|
|
23
|
-
exports.CKBProps = CKBProps;
|
|
24
|
-
class CKB {
|
|
25
|
-
constructor({ network = base_1.Network.devnet, feeRate = 1000, isEnableProxyRpc = false }) {
|
|
26
|
-
if (!(0, validator_1.isValidNetworkString)(network)) {
|
|
27
|
-
throw new Error('invalid network option');
|
|
28
|
-
}
|
|
29
|
-
this.network = network;
|
|
30
|
-
this.feeRate = feeRate;
|
|
31
|
-
this.isEnableProxyRpc = isEnableProxyRpc;
|
|
32
|
-
if (isEnableProxyRpc === true) {
|
|
33
|
-
this.client =
|
|
34
|
-
network === 'mainnet'
|
|
35
|
-
? new core_1.ccc.ClientPublicMainnet({ url: network_1.networks.mainnet.proxy_rpc_url })
|
|
36
|
-
: network === 'testnet'
|
|
37
|
-
? new core_1.ccc.ClientPublicTestnet({ url: network_1.networks.testnet.proxy_rpc_url })
|
|
38
|
-
: new core_1.ccc.ClientPublicTestnet({
|
|
39
|
-
url: network_1.networks.devnet.proxy_rpc_url,
|
|
40
|
-
scripts: (0, private_1.buildCCCDevnetKnownScripts)(),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.client =
|
|
45
|
-
network === 'mainnet'
|
|
46
|
-
? new core_1.ccc.ClientPublicMainnet()
|
|
47
|
-
: network === 'testnet'
|
|
48
|
-
? new core_1.ccc.ClientPublicTestnet()
|
|
49
|
-
: new core_1.ccc.ClientPublicTestnet({
|
|
50
|
-
url: network_1.networks.devnet.rpc_url,
|
|
51
|
-
scripts: (0, private_1.buildCCCDevnetKnownScripts)(),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
buildSigner(privateKey) {
|
|
56
|
-
const signer = new core_1.ccc.SignerCkbPrivateKey(this.client, privateKey);
|
|
57
|
-
return signer;
|
|
58
|
-
}
|
|
59
|
-
buildSecp256k1Address(privateKey) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const signer = this.buildSigner(privateKey);
|
|
62
|
-
const address = yield signer.getAddressObjSecp256k1();
|
|
63
|
-
return address.toString();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
waitForTxConfirm(txHash_1) {
|
|
67
|
-
return __awaiter(this, arguments, void 0, function* (txHash, timeout = 60000) {
|
|
68
|
-
const query = () => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const res = yield this.client.getTransactionNoCache(txHash);
|
|
70
|
-
if (res && res.status === 'committed') {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return waitFor(query, timeout, 5000);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
waitForBlocksBy(interval) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
if (interval < 0)
|
|
83
|
-
throw new Error('interval must be number >= 0');
|
|
84
|
-
const timeout = interval * 50000; // block interval is 18 secs, we set limit to 30s
|
|
85
|
-
const tip = yield this.client.getTip();
|
|
86
|
-
const blockNum = tip + BigInt(interval);
|
|
87
|
-
const query = () => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const res = yield this.client.getBlockByNumber(blockNum);
|
|
89
|
-
if (res) {
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return waitFor(query, timeout, 5000);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
balance(address) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const lock = (yield core_1.ccc.Address.fromString(address, this.client)).script;
|
|
102
|
-
const balanceInShannon = yield this.client.getBalanceSingle(lock);
|
|
103
|
-
const balanceInCKB = core_1.ccc.fixedPointToString(balanceInShannon);
|
|
104
|
-
return balanceInCKB;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
transfer(_a) {
|
|
108
|
-
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress, amountInCKB }) {
|
|
109
|
-
const signer = this.buildSigner(privateKey);
|
|
110
|
-
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
111
|
-
const tx = core_1.ccc.Transaction.from({
|
|
112
|
-
outputs: [
|
|
113
|
-
{
|
|
114
|
-
capacity: core_1.ccc.fixedPointFrom(amountInCKB),
|
|
115
|
-
lock: to.script,
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
});
|
|
119
|
-
yield tx.completeInputsByCapacity(signer);
|
|
120
|
-
yield tx.completeFeeBy(signer, this.feeRate);
|
|
121
|
-
const txHash = yield signer.sendTransaction(tx);
|
|
122
|
-
return txHash;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
transferAll(_a) {
|
|
126
|
-
return __awaiter(this, arguments, void 0, function* ({ privateKey, toAddress }) {
|
|
127
|
-
const signer = this.buildSigner(privateKey);
|
|
128
|
-
const to = yield core_1.ccc.Address.fromString(toAddress, this.client);
|
|
129
|
-
const balanceInCKB = yield this.balance((yield signer.getRecommendedAddressObj()).toString());
|
|
130
|
-
// leave 0.001 ckb for tx fee
|
|
131
|
-
const amountInCKB = core_1.ccc.fixedPointFrom(balanceInCKB) - core_1.ccc.fixedPointFrom(0.001);
|
|
132
|
-
const tx = core_1.ccc.Transaction.from({
|
|
133
|
-
outputs: [
|
|
134
|
-
{
|
|
135
|
-
capacity: core_1.ccc.fixedPointFrom(amountInCKB),
|
|
136
|
-
lock: to.script,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
});
|
|
140
|
-
yield tx.completeInputsByCapacity(signer);
|
|
141
|
-
const txHash = yield signer.sendTransaction(tx);
|
|
142
|
-
return txHash;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
deployScript(scriptBinBytes, privateKey) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const signer = this.buildSigner(privateKey);
|
|
148
|
-
const signerSecp256k1Address = yield signer.getAddressObjSecp256k1();
|
|
149
|
-
const tx = core_1.ccc.Transaction.from({
|
|
150
|
-
outputs: [
|
|
151
|
-
{
|
|
152
|
-
lock: signerSecp256k1Address.script,
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
outputsData: [scriptBinBytes],
|
|
156
|
-
});
|
|
157
|
-
yield tx.completeInputsByCapacity(signer);
|
|
158
|
-
yield tx.completeFeeBy(signer, this.feeRate);
|
|
159
|
-
const txHash = yield signer.sendTransaction(tx);
|
|
160
|
-
return { txHash, tx, scriptOutputCellIndex: 0, isTypeId: false };
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
deployNewTypeIDScript(scriptBinBytes, privateKey) {
|
|
164
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
165
|
-
const signer = this.buildSigner(privateKey);
|
|
166
|
-
const signerSecp256k1Address = yield signer.getAddressObjSecp256k1();
|
|
167
|
-
const typeIdTx = core_1.ccc.Transaction.from({
|
|
168
|
-
outputs: [
|
|
169
|
-
{
|
|
170
|
-
lock: signerSecp256k1Address.script,
|
|
171
|
-
type: yield core_1.ccc.Script.fromKnownScript(this.client, core_1.ccc.KnownScript.TypeId, '00'.repeat(32)),
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
outputsData: [scriptBinBytes],
|
|
175
|
-
});
|
|
176
|
-
yield typeIdTx.completeInputsByCapacity(signer);
|
|
177
|
-
if (!typeIdTx.outputs[0].type) {
|
|
178
|
-
throw new Error('Unexpected disappeared output');
|
|
179
|
-
}
|
|
180
|
-
typeIdTx.outputs[0].type.args = core_1.ccc.hashTypeId(typeIdTx.inputs[0], 0);
|
|
181
|
-
yield typeIdTx.completeFeeBy(signer, this.feeRate);
|
|
182
|
-
const txHash = yield signer.sendTransaction(typeIdTx);
|
|
183
|
-
return { txHash, tx: typeIdTx, scriptOutputCellIndex: 0, isTypeId: true, typeId: typeIdTx.outputs[0].type };
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
upgradeTypeIdScript(scriptName, newScriptBinBytes, privateKey) {
|
|
187
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
var _a;
|
|
189
|
-
const deploymentReceipt = migration_1.Migration.find(scriptName, this.network);
|
|
190
|
-
if (deploymentReceipt == null)
|
|
191
|
-
throw new Error("no migration file, can't be updated.");
|
|
192
|
-
const outpoint = {
|
|
193
|
-
txHash: deploymentReceipt.cellRecipes[0].txHash,
|
|
194
|
-
index: deploymentReceipt.cellRecipes[0].index,
|
|
195
|
-
};
|
|
196
|
-
const typeId = deploymentReceipt.cellRecipes[0].typeId;
|
|
197
|
-
if (typeId == null)
|
|
198
|
-
throw new Error("type id in migration file is null, can't be updated.");
|
|
199
|
-
const cell = yield this.client.getCell(outpoint);
|
|
200
|
-
if (cell == null) {
|
|
201
|
-
throw new Error('type id cell not found!');
|
|
202
|
-
}
|
|
203
|
-
const typeIdArgs = (_a = cell.cellOutput.type) === null || _a === void 0 ? void 0 : _a.args;
|
|
204
|
-
if (typeIdArgs == null) {
|
|
205
|
-
throw new Error("type id args is null, can't be updated");
|
|
206
|
-
}
|
|
207
|
-
const typeIdFromLiveCell = core_1.ccc.Script.from(cell.cellOutput.type).hash();
|
|
208
|
-
if (typeId !== typeIdFromLiveCell) {
|
|
209
|
-
throw new Error(`type id not matched! migration file type id: ${typeId}, live cell type id: ${typeIdFromLiveCell}`);
|
|
210
|
-
}
|
|
211
|
-
const cellInput = core_1.ccc.CellInput.from({ previousOutput: cell.outPoint, since: 0 });
|
|
212
|
-
const signer = this.buildSigner(privateKey);
|
|
213
|
-
const signerSecp256k1Address = yield signer.getAddressObjSecp256k1();
|
|
214
|
-
const typeIdTx = core_1.ccc.Transaction.from({
|
|
215
|
-
inputs: [cellInput],
|
|
216
|
-
outputs: [
|
|
217
|
-
{
|
|
218
|
-
lock: signerSecp256k1Address.script,
|
|
219
|
-
type: yield core_1.ccc.Script.fromKnownScript(this.client, core_1.ccc.KnownScript.TypeId, '00'.repeat(32)),
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
outputsData: [newScriptBinBytes],
|
|
223
|
-
});
|
|
224
|
-
yield typeIdTx.completeInputsByCapacity(signer);
|
|
225
|
-
if (!typeIdTx.outputs[0].type) {
|
|
226
|
-
throw new Error('Unexpected disappeared output');
|
|
227
|
-
}
|
|
228
|
-
typeIdTx.outputs[0].type.args = typeIdArgs;
|
|
229
|
-
yield typeIdTx.completeFeeBy(signer, this.feeRate);
|
|
230
|
-
const txHash = yield signer.sendTransaction(typeIdTx);
|
|
231
|
-
return { txHash, tx: typeIdTx, scriptOutputCellIndex: 0, isTypeId: true, typeId: typeIdTx.outputs[0].type };
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
exports.CKB = CKB;
|
|
236
|
-
function waitFor(query, timeout, interval) {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
-
const startTime = Date.now();
|
|
239
|
-
while (true) {
|
|
240
|
-
if (Date.now() - startTime > timeout) {
|
|
241
|
-
throw new Error('Operation timed out');
|
|
242
|
-
}
|
|
243
|
-
try {
|
|
244
|
-
const result = yield query();
|
|
245
|
-
if (result)
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
console.debug(error.message);
|
|
250
|
-
}
|
|
251
|
-
yield new Promise((resolve) => setTimeout(resolve, interval));
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
package/dist/sdk/network.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const networks: {
|
|
2
|
-
devnet: {
|
|
3
|
-
addr_prefix: string;
|
|
4
|
-
rpc_url: string;
|
|
5
|
-
proxy_rpc_url: string;
|
|
6
|
-
};
|
|
7
|
-
testnet: {
|
|
8
|
-
addr_prefix: string;
|
|
9
|
-
rpc_url: string;
|
|
10
|
-
proxy_rpc_url: string;
|
|
11
|
-
};
|
|
12
|
-
mainnet: {
|
|
13
|
-
addr_prefix: string;
|
|
14
|
-
rpc_url: string;
|
|
15
|
-
proxy_rpc_url: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
package/dist/sdk/network.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.networks = void 0;
|
|
4
|
-
const setting_1 = require("../cfg/setting");
|
|
5
|
-
const config = (0, setting_1.readSettings)();
|
|
6
|
-
exports.networks = {
|
|
7
|
-
devnet: {
|
|
8
|
-
addr_prefix: 'ckt',
|
|
9
|
-
rpc_url: config.devnet.rpcUrl,
|
|
10
|
-
proxy_rpc_url: `http://127.0.0.1:${config.rpc.proxyPort}`,
|
|
11
|
-
},
|
|
12
|
-
testnet: {
|
|
13
|
-
addr_prefix: 'ckt',
|
|
14
|
-
rpc_url: config.testnet.rpcUrl,
|
|
15
|
-
proxy_rpc_url: `http://127.0.0.1:${config.rpc.proxyPort}`,
|
|
16
|
-
},
|
|
17
|
-
mainnet: {
|
|
18
|
-
addr_prefix: 'ckb',
|
|
19
|
-
rpc_url: config.mainnet.rpcUrl,
|
|
20
|
-
proxy_rpc_url: `http://127.0.0.1:${config.rpc.proxyPort}`,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.OffCKBConfigFile = void 0;
|
|
40
|
-
const fs = __importStar(require("fs"));
|
|
41
|
-
const path_1 = __importDefault(require("path"));
|
|
42
|
-
const fs_1 = require("../util/fs");
|
|
43
|
-
class OffCKBConfigFile {
|
|
44
|
-
static updateVersion(version, filePath) {
|
|
45
|
-
const versionTarget = '@offckb-update-version';
|
|
46
|
-
let fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
47
|
-
fileContent = fileContent.replace(versionTarget, version);
|
|
48
|
-
// Write the updated content back to the file
|
|
49
|
-
fs.writeFileSync(filePath, fileContent, 'utf-8');
|
|
50
|
-
}
|
|
51
|
-
static readContractInfoFolder(filePath) {
|
|
52
|
-
// Read the contents of the TS file
|
|
53
|
-
const fileContents = fs.readFileSync(filePath, 'utf8');
|
|
54
|
-
// Use a regular expression to find the version value
|
|
55
|
-
const match = fileContents.match(/contractInfoFolder:\s*['"]([^'"]+)['"]/);
|
|
56
|
-
if (match && match[1]) {
|
|
57
|
-
const contractInfoFolderValue = match[1];
|
|
58
|
-
const folderPath = path_1.default.dirname(filePath);
|
|
59
|
-
const contractInfoFolder = (0, fs_1.isAbsolutePath)(contractInfoFolderValue)
|
|
60
|
-
? contractInfoFolderValue
|
|
61
|
-
: path_1.default.resolve(folderPath, contractInfoFolderValue);
|
|
62
|
-
return contractInfoFolder;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
console.log('contractBinFolder value not found in offckb.config.ts');
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.OffCKBConfigFile = OffCKBConfigFile;
|
package/dist/template/option.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadBareTemplateOpts = loadBareTemplateOpts;
|
|
4
|
-
const templates = [
|
|
5
|
-
{
|
|
6
|
-
name: 'Remix-Vite Bare Templates',
|
|
7
|
-
value: 'remix-vite-template',
|
|
8
|
-
description: 'A full-stack template with Remix-vite and ckb-script-templates',
|
|
9
|
-
tag: ['remix', 'vite', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
|
|
10
|
-
author: 'retric@cryptape.com',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
name: 'Next.js Bare Templates',
|
|
14
|
-
value: 'next-js-template',
|
|
15
|
-
description: 'A full-stack template with Next.js framework and ckb-script-templates',
|
|
16
|
-
tag: ['next.js', 'tailwindcss', 'ckb-script-templates', 'typescript', 'rust'],
|
|
17
|
-
author: 'retric@cryptape.com',
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
function loadBareTemplateOpts() {
|
|
21
|
-
return templates;
|
|
22
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface DebugOption {
|
|
2
|
-
fullTxJsonFilePath: string;
|
|
3
|
-
cellIndex: number;
|
|
4
|
-
cellType: 'output' | 'input';
|
|
5
|
-
scriptGroupType: 'lock' | 'type';
|
|
6
|
-
}
|
|
7
|
-
export declare class CKBDebugger {
|
|
8
|
-
static runRaw(options: string): void;
|
|
9
|
-
static runTxCellScript({ fullTxJsonFilePath, cellIndex, cellType, scriptGroupType }: DebugOption): void;
|
|
10
|
-
static isBinaryInstalled(): boolean;
|
|
11
|
-
static installCKBDebugger(): void;
|
|
12
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CKBDebugger = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
class CKBDebugger {
|
|
6
|
-
static runRaw(options) {
|
|
7
|
-
const command = `ckb-debugger ${options}`;
|
|
8
|
-
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
9
|
-
}
|
|
10
|
-
static runTxCellScript({ fullTxJsonFilePath, cellIndex, cellType, scriptGroupType }) {
|
|
11
|
-
const command = `ckb-debugger --tx-file ${fullTxJsonFilePath} --cell-index ${cellIndex} --cell-type ${cellType} --script-group-type ${scriptGroupType}`;
|
|
12
|
-
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
13
|
-
}
|
|
14
|
-
static isBinaryInstalled() {
|
|
15
|
-
const result = (0, child_process_1.spawnSync)('ckb-debugger', ['--version'], { stdio: 'ignore' });
|
|
16
|
-
return result.status === 0;
|
|
17
|
-
}
|
|
18
|
-
static installCKBDebugger() {
|
|
19
|
-
const command = `cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger`;
|
|
20
|
-
try {
|
|
21
|
-
console.log('Installing ckb-debugger...');
|
|
22
|
-
(0, child_process_1.execSync)(command);
|
|
23
|
-
console.log('ckb-debugger installed successfully.');
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error('Failed to install ckb-debugger:', error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.CKBDebugger = CKBDebugger;
|
|
@@ -1,20 +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.dumpTransaction = dumpTransaction;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const child_process_1 = require("child_process");
|
|
9
|
-
const setting_1 = require("../cfg/setting");
|
|
10
|
-
function dumpTransaction({ rpc, txJsonFilePath, outputFilePath }) {
|
|
11
|
-
const ckbTransactionDumperPath = path_1.default.resolve(setting_1.packageRootPath, 'node_modules/.bin/ckb-transaction-dumper');
|
|
12
|
-
const command = `${ckbTransactionDumperPath} --rpc ${rpc} --tx "${txJsonFilePath}" --output "${outputFilePath}"`;
|
|
13
|
-
try {
|
|
14
|
-
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
|
15
|
-
console.debug('Dump transaction successfully');
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
console.error('Command failed:', error.message);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare class MoleculecES {
|
|
2
|
-
static isBinaryInstalled(): boolean;
|
|
3
|
-
static installMoleculeES(version: string): Promise<void>;
|
|
4
|
-
static get binPath(): string;
|
|
5
|
-
static get bin(): string;
|
|
6
|
-
static downloadAndSaveMoleculeES(version: string, tempFilePath: string): Promise<void>;
|
|
7
|
-
static buildDownloadUrl(version: string): string;
|
|
8
|
-
}
|