@offckb/cli 0.2.6 → 0.3.0-canary-cfe9b48.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.
Files changed (96) hide show
  1. package/README.md +59 -17
  2. package/ckb/devnet/specs/dev.toml +7 -7
  3. package/dist/cfg/env-path.d.ts +9 -0
  4. package/dist/cfg/env-path.js +63 -0
  5. package/dist/cfg/setting.d.ts +45 -0
  6. package/dist/cfg/setting.js +124 -0
  7. package/dist/cli.js +54 -30
  8. package/dist/cmd/clean.js +7 -5
  9. package/dist/cmd/config.d.ts +11 -0
  10. package/dist/cmd/config.js +102 -0
  11. package/dist/cmd/create.d.ts +1 -1
  12. package/dist/cmd/create.js +19 -8
  13. package/dist/cmd/debug.d.ts +13 -0
  14. package/dist/cmd/debug.js +100 -0
  15. package/dist/cmd/deploy.js +45 -25
  16. package/dist/cmd/deposit.js +11 -7
  17. package/dist/cmd/inject-config.d.ts +0 -3
  18. package/dist/cmd/inject-config.js +20 -80
  19. package/dist/cmd/list-hashes.d.ts +25 -1
  20. package/dist/cmd/list-hashes.js +24 -16
  21. package/dist/cmd/{deployed-scripts.d.ts → my-scripts.d.ts} +1 -1
  22. package/dist/cmd/my-scripts.js +25 -0
  23. package/dist/cmd/node.d.ts +5 -1
  24. package/dist/cmd/node.js +22 -8
  25. package/dist/cmd/proxy-rpc.d.ts +7 -0
  26. package/dist/cmd/proxy-rpc.js +23 -0
  27. package/dist/cmd/sync-config.js +16 -11
  28. package/dist/cmd/system-scripts.d.ts +42 -0
  29. package/dist/cmd/system-scripts.js +265 -0
  30. package/dist/deploy/migration.d.ts +45 -0
  31. package/dist/deploy/migration.js +131 -0
  32. package/dist/deploy/toml.d.ts +38 -0
  33. package/dist/deploy/toml.js +60 -0
  34. package/dist/deploy/util.d.ts +2 -0
  35. package/dist/deploy/util.js +19 -0
  36. package/dist/node/init-chain.js +41 -0
  37. package/dist/{cmd/develop → node}/install.d.ts +4 -5
  38. package/dist/{cmd/develop → node}/install.js +32 -32
  39. package/dist/scripts/gen.d.ts +5 -0
  40. package/dist/scripts/gen.js +69 -0
  41. package/dist/scripts/public.d.ts +8 -0
  42. package/dist/scripts/public.js +396 -0
  43. package/dist/scripts/type.d.ts +46 -0
  44. package/dist/scripts/type.js +19 -0
  45. package/dist/scripts/util.d.ts +3 -0
  46. package/dist/scripts/util.js +84 -0
  47. package/dist/template/config.d.ts +4 -0
  48. package/dist/template/config.js +60 -0
  49. package/dist/template/offckb.config.d.ts +69 -0
  50. package/dist/template/offckb.config.js +81 -0
  51. package/dist/{util/template.d.ts → template/option.d.ts} +1 -1
  52. package/dist/template/option.js +11 -0
  53. package/dist/template/option.json +16 -0
  54. package/dist/tools/ckb-debugger.d.ts +12 -0
  55. package/dist/tools/ckb-debugger.js +31 -0
  56. package/dist/tools/ckb-tx-dumper.d.ts +6 -0
  57. package/dist/tools/ckb-tx-dumper.js +21 -0
  58. package/dist/tools/rpc-proxy.d.ts +9 -0
  59. package/dist/tools/rpc-proxy.js +84 -0
  60. package/dist/util/ckb.d.ts +64 -0
  61. package/dist/util/ckb.js +16 -3
  62. package/dist/util/encoding.d.ts +1 -0
  63. package/dist/util/encoding.js +7 -1
  64. package/dist/util/fs.d.ts +1 -2
  65. package/dist/util/fs.js +8 -32
  66. package/dist/util/git.js +19 -7
  67. package/dist/util/request.d.ts +8 -0
  68. package/dist/util/request.js +57 -0
  69. package/dist/util/type.d.ts +1 -0
  70. package/dist/util/validator.d.ts +1 -0
  71. package/dist/util/validator.js +13 -4
  72. package/package.json +9 -4
  73. package/templates/offckb.config.ts +3 -3
  74. package/templates/template.json +16 -0
  75. package/dist/cfg/const.d.ts +0 -21
  76. package/dist/cfg/const.js +0 -51
  77. package/dist/cmd/deployed-scripts.js +0 -14
  78. package/dist/cmd/develop/build-account.d.ts +0 -1
  79. package/dist/cmd/develop/build-account.js +0 -9
  80. package/dist/cmd/develop/genkey.d.ts +0 -14
  81. package/dist/cmd/develop/genkey.js +0 -143
  82. package/dist/cmd/develop/init-chain.js +0 -76
  83. package/dist/cmd/develop/lumos-config.d.ts +0 -4
  84. package/dist/cmd/develop/lumos-config.js +0 -153
  85. package/dist/util/config.d.ts +0 -9
  86. package/dist/util/config.js +0 -136
  87. package/dist/util/template.js +0 -30
  88. package/templates/config.json +0 -98
  89. /package/ckb/devnet/specs/{omni_lock → omnilock} +0 -0
  90. /package/ckb/devnet/specs/{spore-scripts → spore}/spore +0 -0
  91. /package/ckb/devnet/specs/{spore-scripts/cluster → spore/spore_cluster} +0 -0
  92. /package/ckb/devnet/specs/{spore-scripts/cluster_agent → spore/spore_cluster_agent} +0 -0
  93. /package/ckb/devnet/specs/{spore-scripts/cluster_proxy → spore/spore_cluster_proxy} +0 -0
  94. /package/ckb/devnet/specs/{spore-scripts → spore}/spore_extension_lua +0 -0
  95. /package/ckb/devnet/specs/{xudt_rce → xudt} +0 -0
  96. /package/dist/{cmd/develop → node}/init-chain.d.ts +0 -0
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateNetworkOpt = exports.isValidNetworkString = exports.validateExecDappEnvironment = exports.validateTypescriptWorkspace = void 0;
6
+ exports.isValidVersion = exports.validateNetworkOpt = exports.isValidNetworkString = exports.validateExecDappEnvironment = exports.validateTypescriptWorkspace = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const const_1 = require("../cfg/const");
9
8
  const fs_1 = __importDefault(require("fs"));
10
9
  const type_1 = require("./type");
11
10
  function validateTypescriptWorkspace() {
12
- const cwd = const_1.currentExecPath;
11
+ const cwd = process.cwd();
13
12
  // Check if package.json exists
14
13
  const packageJsonPath = path_1.default.join(cwd, 'package.json');
15
14
  if (!fs_1.default.existsSync(packageJsonPath)) {
@@ -23,7 +22,7 @@ function validateTypescriptWorkspace() {
23
22
  }
24
23
  exports.validateTypescriptWorkspace = validateTypescriptWorkspace;
25
24
  function validateExecDappEnvironment() {
26
- const cwd = const_1.currentExecPath;
25
+ const cwd = process.cwd();
27
26
  // Check if package.json and tsconfig.json exists
28
27
  validateTypescriptWorkspace();
29
28
  // Check if offckb.config.ts exists
@@ -57,3 +56,13 @@ function validateNetworkOpt(network) {
57
56
  }
58
57
  }
59
58
  exports.validateNetworkOpt = validateNetworkOpt;
59
+ function isValidVersion(version) {
60
+ if (typeof version !== 'string') {
61
+ return false;
62
+ }
63
+ // Regular expression to match version strings like X.Y.Z
64
+ const versionRegex = /^\d+\.\d+\.\d+$/;
65
+ // Test the version against the regex
66
+ return versionRegex.test(version);
67
+ }
68
+ exports.isValidVersion = isValidVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@offckb/cli",
3
- "version": "0.2.6",
3
+ "version": "0.3.0-canary-cfe9b48.0",
4
4
  "description": "ckb development network for your first try",
5
5
  "author": "Retric Su <retric@cryptape.com>",
6
6
  "license": "MIT",
@@ -16,8 +16,8 @@
16
16
  "dist",
17
17
  "account",
18
18
  "ckb",
19
- "templates/config.json",
20
- "templates/offckb.config.ts"
19
+ "templates/offckb.config.ts",
20
+ "templates/template.json"
21
21
  ],
22
22
  "private": false,
23
23
  "publishConfig": {
@@ -60,12 +60,17 @@
60
60
  "typescript": "^5.3.3"
61
61
  },
62
62
  "dependencies": {
63
- "@ckb-lumos/lumos": "0.22.2",
63
+ "@ckb-ccc/core": "^0.0.11-alpha.3",
64
+ "@ckb-lumos/lumos": "0.23.0",
65
+ "@iarna/toml": "^2.2.5",
64
66
  "@inquirer/prompts": "^4.1.0",
67
+ "@types/http-proxy": "^1.17.15",
65
68
  "adm-zip": "^0.5.10",
66
69
  "axios": "^1.6.7",
67
70
  "child_process": "^1.0.2",
71
+ "ckb-transaction-dumper": "^0.4.0",
68
72
  "commander": "^12.0.0",
73
+ "http-proxy": "^1.18.1",
69
74
  "semver": "^7.6.0",
70
75
  "tar": "^6.2.1"
71
76
  }
@@ -146,15 +146,15 @@ const lumosConfig: config.Config = {
146
146
  } as config.Config;
147
147
  // ---end of devnet lumos config---
148
148
  // ---testnet lumos config---
149
- const testnetLumosConfig: config.Config = { ...config.predefined.AGGRON4, ...{} } as config.Config;
149
+ const testnetLumosConfig: config.Config = { ...config.TESTNET, ...{} } as config.Config;
150
150
  // ---end of testnet lumos config---
151
151
  // ---mainnet lumos config---
152
- const mainnetLumosConfig: config.Config = { ...config.predefined.LINA, ...{} } as config.Config;
152
+ const mainnetLumosConfig: config.Config = { ...config.MAINNET, ...{} } as config.Config;
153
153
  // ---end of mainnet lumos config---
154
154
 
155
155
  const offCKBConfig: OffCKBConfig = {
156
156
  version: 'update-me-offckb-config-version',
157
- lumosVersion: '0.22.2',
157
+ lumosVersion: '0.23.0',
158
158
  contractBinFolder: '../build/release',
159
159
  networks: {
160
160
  devnet: {
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "name": "Remix-Vite Bare Templates",
4
+ "value": "remix-vite-template",
5
+ "description": "A full-stack template with Remix-vite and ckb-script-templates",
6
+ "tag": ["remix", "vite", "tailwindcss", "ckb-script-templates", "typescript", "rust"],
7
+ "author": "retric@cryptape.com"
8
+ },
9
+ {
10
+ "name": "Next.js Bare Templates",
11
+ "value": "next-js-template",
12
+ "description": "A full-stack template with Next.js framework and ckb-script-templates",
13
+ "tag": ["next.js", "tailwindcss", "ckb-script-templates", "typescript", "rust"],
14
+ "author": "retric@cryptape.com"
15
+ }
16
+ ]
@@ -1,21 +0,0 @@
1
- export declare const currentExecPath: string;
2
- export declare const packageSrcPath: string;
3
- export declare const packageRootPath: string;
4
- export declare const dappTemplatePath: string;
5
- export declare const targetEnvironmentPath: string;
6
- export declare const predefinedOffCKBConfigTsPath: string;
7
- export declare const userOffCKBConfigPath: string;
8
- export declare const devnetSourcePath: string;
9
- export declare const devnetPath: string;
10
- export declare const devnetDataPath: string;
11
- export declare const ckbFolderPath: string;
12
- export declare const ckbBinPath: string;
13
- export declare const deployedContractInfoFolderPath: string;
14
- export declare const accountTargetDir: string;
15
- export declare const minimalRequiredCKBVersion = "0.113.1";
16
- export declare const defaultLumosVersion = "0.21.0";
17
- export declare const dappTemplateGitRepoUserAndName = "RetricSu/offckb";
18
- export declare const dappTemplateGitUrl = "https://github.com/RetricSu/offckb";
19
- export declare const dappTemplateGitBranch = "develop";
20
- export declare const dappTemplateGitFolder = "templates";
21
- export declare const bareTemplateGitSelectOptionFile = "template.json";
package/dist/cfg/const.js DELETED
@@ -1,51 +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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.bareTemplateGitSelectOptionFile = exports.dappTemplateGitFolder = exports.dappTemplateGitBranch = exports.dappTemplateGitUrl = exports.dappTemplateGitRepoUserAndName = exports.defaultLumosVersion = exports.minimalRequiredCKBVersion = exports.accountTargetDir = exports.deployedContractInfoFolderPath = exports.ckbBinPath = exports.ckbFolderPath = exports.devnetDataPath = exports.devnetPath = exports.devnetSourcePath = exports.userOffCKBConfigPath = exports.predefinedOffCKBConfigTsPath = exports.targetEnvironmentPath = exports.dappTemplatePath = exports.packageRootPath = exports.packageSrcPath = exports.currentExecPath = void 0;
27
- const path = __importStar(require("path"));
28
- // path
29
- exports.currentExecPath = process.cwd();
30
- exports.packageSrcPath = path.dirname(require.main.filename);
31
- exports.packageRootPath = path.resolve(exports.packageSrcPath, '../');
32
- exports.dappTemplatePath = path.resolve(exports.packageRootPath, './templates');
33
- exports.targetEnvironmentPath = path.resolve(exports.packageRootPath, './target');
34
- exports.predefinedOffCKBConfigTsPath = path.resolve(exports.dappTemplatePath, 'offckb.config.ts');
35
- exports.userOffCKBConfigPath = path.resolve(exports.currentExecPath, 'offckb.config.ts');
36
- exports.devnetSourcePath = path.resolve(exports.packageRootPath, './ckb/devnet');
37
- exports.devnetPath = path.resolve(exports.targetEnvironmentPath, `devnet`);
38
- exports.devnetDataPath = path.resolve(exports.devnetPath, `data`);
39
- exports.ckbFolderPath = path.resolve(exports.targetEnvironmentPath, 'ckb');
40
- exports.ckbBinPath = path.resolve(exports.ckbFolderPath, 'ckb');
41
- exports.deployedContractInfoFolderPath = path.resolve(exports.targetEnvironmentPath, 'contracts');
42
- exports.accountTargetDir = path.join(exports.packageRootPath, `account`);
43
- // Version
44
- exports.minimalRequiredCKBVersion = '0.113.1';
45
- exports.defaultLumosVersion = '0.21.0';
46
- // url
47
- exports.dappTemplateGitRepoUserAndName = 'RetricSu/offckb';
48
- exports.dappTemplateGitUrl = `https://github.com/${exports.dappTemplateGitRepoUserAndName}`;
49
- exports.dappTemplateGitBranch = 'develop';
50
- exports.dappTemplateGitFolder = 'templates';
51
- exports.bareTemplateGitSelectOptionFile = 'template.json';
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deployedScripts = void 0;
4
- const config_1 = require("../util/config");
5
- const type_1 = require("../util/type");
6
- const validator_1 = require("../util/validator");
7
- function deployedScripts(option = { network: type_1.Network.devnet }) {
8
- const network = option.network;
9
- (0, validator_1.validateNetworkOpt)(network);
10
- const scritpsInfo = (0, config_1.readUserDeployedScriptsInfo)(network);
11
- console.log(`User deployed scripts on ${network}`);
12
- console.log(JSON.stringify(scritpsInfo, null, 2));
13
- }
14
- exports.deployedScripts = deployedScripts;
@@ -1 +0,0 @@
1
- export declare function buildAccount(privKey: string): void;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildAccount = void 0;
4
- const genkey_1 = require("./genkey");
5
- function buildAccount(privKey) {
6
- const account = (0, genkey_1.genAccount)(privKey);
7
- console.log(account);
8
- }
9
- exports.buildAccount = buildAccount;
@@ -1,14 +0,0 @@
1
- import { Address, HexString, Script } from '@ckb-lumos/lumos';
2
- interface Account {
3
- privkey: HexString;
4
- pubkey: HexString;
5
- args: HexString;
6
- lockScript: Script;
7
- address: Address;
8
- }
9
- export declare function genkey(): void;
10
- export declare function generateHex(length: number): string;
11
- export declare function buildAccounts(): Promise<void>;
12
- export declare function genAccount(privkey: HexString): Account;
13
- export declare function printIssueSectionForToml(): void;
14
- export {};
@@ -1,143 +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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __asyncValues = (this && this.__asyncValues) || function (o) {
35
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
36
- var m = o[Symbol.asyncIterator], i;
37
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
38
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
39
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.printIssueSectionForToml = exports.genAccount = exports.buildAccounts = exports.generateHex = exports.genkey = void 0;
43
- const fs = __importStar(require("fs"));
44
- const path = __importStar(require("path"));
45
- const const_1 = require("../../cfg/const");
46
- const lumos_1 = require("@ckb-lumos/lumos");
47
- const readline = __importStar(require("readline"));
48
- function genkey() {
49
- const numKeys = 20; // Number of keys to generate
50
- const keyLength = 64; // Length of each key
51
- generateKeysFile(numKeys, keyLength);
52
- console.log(`Generated ${numKeys} keys in keys file.`);
53
- }
54
- exports.genkey = genkey;
55
- function generateHex(length) {
56
- const characters = 'abcdef0123456789';
57
- let result = '';
58
- for (let i = 0; i < length; i++) {
59
- result += characters[Math.floor(Math.random() * characters.length)];
60
- }
61
- return result;
62
- }
63
- exports.generateHex = generateHex;
64
- function generateKeysFile(numKeys, keyLength) {
65
- const targetDir = path.join(const_1.accountTargetDir, `keys`);
66
- const stream = fs.createWriteStream(targetDir);
67
- for (let i = 0; i < numKeys; i++) {
68
- const key = generateHex(keyLength);
69
- stream.write(key + '\n');
70
- }
71
- stream.end();
72
- }
73
- function buildAccounts() {
74
- var _a, e_1, _b, _c;
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const keysDir = path.join(const_1.accountTargetDir, `keys`);
77
- // Create a Readable stream from the file
78
- const fileStream = fs.createReadStream(keysDir);
79
- // Create an interface for reading data from the stream line by line
80
- const rl = readline.createInterface({
81
- input: fileStream,
82
- crlfDelay: Infinity, // Specify Infinity to read all lines without removing newlines
83
- });
84
- const accounts = [];
85
- try {
86
- // Read each line from the file
87
- for (var _d = true, rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), _a = rl_1_1.done, !_a; _d = true) {
88
- _c = rl_1_1.value;
89
- _d = false;
90
- const line = _c;
91
- const privkey = `0x${line}`;
92
- const account = genAccount(privkey);
93
- accounts.push(account);
94
- }
95
- }
96
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
97
- finally {
98
- try {
99
- if (!_d && !_a && (_b = rl_1.return)) yield _b.call(rl_1);
100
- }
101
- finally { if (e_1) throw e_1.error; }
102
- }
103
- const accountDir = path.join(const_1.accountTargetDir, `account.json`);
104
- fs.writeFile(accountDir, JSON.stringify(accounts, null, 2), 'utf8', (err) => {
105
- if (err) {
106
- return console.error('Error writing file:', err);
107
- }
108
- });
109
- });
110
- }
111
- exports.buildAccounts = buildAccounts;
112
- function genAccount(privkey) {
113
- const pubkey = lumos_1.hd.key.privateToPublic(privkey);
114
- const args = lumos_1.hd.key.publicKeyToBlake160(pubkey);
115
- const lockScript = {
116
- codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
117
- hashType: 'type',
118
- args: args,
119
- };
120
- const address = lumos_1.helpers.encodeToAddress(lockScript);
121
- return {
122
- privkey,
123
- pubkey,
124
- lockScript,
125
- address,
126
- args,
127
- };
128
- }
129
- exports.genAccount = genAccount;
130
- function printIssueSectionForToml() {
131
- const config = require('../../account/account.json');
132
- for (const account of config) {
133
- const section = `# issue for account private key: ${account.privkey}
134
- [[genesis.issued_cells]]
135
- capacity = 42_000_000_00000000
136
- lock.code_hash = "${account.lockScript.codeHash}"
137
- lock.args = "${account.lockScript.args}"
138
- lock.hash_type = "${account.lockScript.hashType}"
139
- `;
140
- console.log(section);
141
- }
142
- }
143
- exports.printIssueSectionForToml = printIssueSectionForToml;
@@ -1,76 +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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.initChainIfNeeded = void 0;
39
- const fs = __importStar(require("fs"));
40
- const const_1 = require("../../cfg/const");
41
- const path_1 = __importDefault(require("path"));
42
- const fs_1 = require("../../util/fs");
43
- function initChainIfNeeded() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (!(0, fs_1.isFolderExists)(const_1.devnetPath)) {
46
- yield doInitChain();
47
- }
48
- });
49
- }
50
- exports.initChainIfNeeded = initChainIfNeeded;
51
- function doInitChain() {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- yield (0, fs_1.copyFilesWithExclusion)(const_1.devnetSourcePath, const_1.devnetPath, ['data']);
54
- console.debug(`init devnet config folder: ${const_1.devnetPath}`);
55
- copyAndEditMinerToml();
56
- });
57
- }
58
- function copyAndEditMinerToml() {
59
- const minerToml = path_1.default.join(const_1.devnetSourcePath, 'ckb-miner.toml');
60
- const newMinerToml = path_1.default.join(const_1.devnetPath, 'ckb-miner.toml');
61
- // Read the content of the ckb-miner.toml file
62
- fs.readFile(minerToml, 'utf8', (err, data) => {
63
- if (err) {
64
- return console.error('Error reading file:', err);
65
- }
66
- // Replace the URL
67
- const modifiedData = data.replace('http://ckb:8114/', 'http://localhost:8114');
68
- // Write the modified content back to the file
69
- fs.writeFile(newMinerToml, modifiedData, 'utf8', (err) => {
70
- if (err) {
71
- return console.error('Error writing file:', err);
72
- }
73
- console.debug('modified ', newMinerToml);
74
- });
75
- });
76
- }
@@ -1,4 +0,0 @@
1
- import { config } from '@ckb-lumos/lumos';
2
- export declare function devnetLumosConfigTemplate(cellBaseTxHashInGenesisBlock: string, secondTxHashInGenesisBlock: string): config.Config;
3
- export declare function fetchDevnetLumosConfig(): Promise<config.Config>;
4
- export declare function writePredefinedDevnetLumosConfig(): Promise<void>;
@@ -1,153 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.writePredefinedDevnetLumosConfig = exports.fetchDevnetLumosConfig = exports.devnetLumosConfigTemplate = void 0;
16
- const fs_1 = __importDefault(require("fs"));
17
- const path_1 = __importDefault(require("path"));
18
- const const_1 = require("../../cfg/const");
19
- const config_1 = require("../../util/config");
20
- const ckb_1 = require("../../util/ckb");
21
- const type_1 = require("../../util/type");
22
- function devnetLumosConfigTemplate(cellBaseTxHashInGenesisBlock, secondTxHashInGenesisBlock) {
23
- const devnetConfig = {
24
- PREFIX: 'ckt',
25
- SCRIPTS: {
26
- SECP256K1_BLAKE160: {
27
- CODE_HASH: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8',
28
- HASH_TYPE: 'type',
29
- TX_HASH: secondTxHashInGenesisBlock,
30
- INDEX: '0x0',
31
- DEP_TYPE: 'depGroup',
32
- SHORT_ID: 1,
33
- },
34
- SECP256K1_BLAKE160_MULTISIG: {
35
- CODE_HASH: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8',
36
- HASH_TYPE: 'type',
37
- TX_HASH: secondTxHashInGenesisBlock,
38
- INDEX: '0x1',
39
- DEP_TYPE: 'depGroup',
40
- },
41
- DAO: {
42
- CODE_HASH: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e',
43
- HASH_TYPE: 'type',
44
- TX_HASH: cellBaseTxHashInGenesisBlock,
45
- INDEX: '0x2',
46
- DEP_TYPE: 'code',
47
- SHORT_ID: 2,
48
- },
49
- SUDT: {
50
- CODE_HASH: '0x6283a479a3cf5d4276cd93594de9f1827ab9b55c7b05b3d28e4c2e0a696cfefd',
51
- HASH_TYPE: 'type',
52
- TX_HASH: cellBaseTxHashInGenesisBlock,
53
- INDEX: '0x5',
54
- DEP_TYPE: 'code',
55
- },
56
- XUDT: {
57
- CODE_HASH: '0x1a1e4fef34f5982906f745b048fe7b1089647e82346074e0f32c2ece26cf6b1e',
58
- HASH_TYPE: 'type',
59
- TX_HASH: cellBaseTxHashInGenesisBlock,
60
- INDEX: '0x6',
61
- DEP_TYPE: 'code',
62
- },
63
- OMNILOCK: {
64
- CODE_HASH: '0x9c6933d977360f115a3e9cd5a2e0e475853681b80d775d93ad0f8969da343e56',
65
- HASH_TYPE: 'type',
66
- TX_HASH: cellBaseTxHashInGenesisBlock,
67
- INDEX: '0x7',
68
- DEP_TYPE: 'code',
69
- },
70
- ANYONE_CAN_PAY: {
71
- CODE_HASH: '0xe09352af0066f3162287763ce4ddba9af6bfaeab198dc7ab37f8c71c9e68bb5b',
72
- HASH_TYPE: 'type',
73
- TX_HASH: cellBaseTxHashInGenesisBlock,
74
- INDEX: '0x8',
75
- DEP_TYPE: 'code',
76
- },
77
- ALWAYS_SUCCESS: {
78
- CODE_HASH: '0xbb4469004225b39e983929db71fe2253cba1d49a76223e9e1d212cdca1f79f28',
79
- HASH_TYPE: 'type',
80
- TX_HASH: cellBaseTxHashInGenesisBlock,
81
- INDEX: '0x9',
82
- DEP_TYPE: 'code',
83
- },
84
- SPORE: {
85
- CODE_HASH: '0x7e8bf78a62232caa2f5d47e691e8db1a90d05e93dc6828ad3cb935c01ec6d208',
86
- HASH_TYPE: 'data1',
87
- TX_HASH: cellBaseTxHashInGenesisBlock,
88
- INDEX: '0xa',
89
- DEP_TYPE: 'code',
90
- },
91
- SPORE_CLUSTER: {
92
- CODE_HASH: '0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075',
93
- HASH_TYPE: 'data1',
94
- TX_HASH: cellBaseTxHashInGenesisBlock,
95
- INDEX: '0xb',
96
- DEP_TYPE: 'code',
97
- },
98
- SPORE_CLUSTER_AGENT: {
99
- CODE_HASH: '0xc986099b41d79ca1b2a56ce5874bcda8175440a17298ea5e2bbc3897736b8c21',
100
- HASH_TYPE: 'data1',
101
- TX_HASH: cellBaseTxHashInGenesisBlock,
102
- INDEX: '0xc',
103
- DEP_TYPE: 'code',
104
- },
105
- SPORE_CLUSTER_PROXY: {
106
- CODE_HASH: '0xbe8b9ce3d05a32c4bb26fe71cd5fc1407ce91e3a8b9e8719be2ab072cef1454b',
107
- HASH_TYPE: 'data1',
108
- TX_HASH: cellBaseTxHashInGenesisBlock,
109
- INDEX: '0xd',
110
- DEP_TYPE: 'code',
111
- },
112
- SPORE_LUA: {
113
- CODE_HASH: '0x94a9b875911ace20f1f0d063a26495d14e4b04e32fd218261bb747f34e71ae47',
114
- HASH_TYPE: 'data1',
115
- TX_HASH: cellBaseTxHashInGenesisBlock,
116
- INDEX: '0xe',
117
- DEP_TYPE: 'code',
118
- },
119
- },
120
- };
121
- return devnetConfig;
122
- }
123
- exports.devnetLumosConfigTemplate = devnetLumosConfigTemplate;
124
- function fetchDevnetLumosConfig() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- const ckb = new ckb_1.CKB(type_1.Network.devnet);
127
- const rpc = ckb.rpc;
128
- const chainInfo = yield rpc.getBlockchainInfo();
129
- const genesisBlock = yield rpc.getBlockByNumber('0x0');
130
- const cellBaseTxHashInGenesisBlock = genesisBlock.transactions[0].hash;
131
- const secondTxHashInGenesisBlock = genesisBlock.transactions[1].hash;
132
- if (chainInfo.chain === 'offckb') {
133
- const config = devnetLumosConfigTemplate(cellBaseTxHashInGenesisBlock, secondTxHashInGenesisBlock);
134
- return config;
135
- }
136
- throw new Error('not a devnet!');
137
- });
138
- }
139
- exports.fetchDevnetLumosConfig = fetchDevnetLumosConfig;
140
- function writePredefinedDevnetLumosConfig() {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const config = yield fetchDevnetLumosConfig();
143
- const filePath = path_1.default.resolve(const_1.dappTemplatePath, 'config.json');
144
- fs_1.default.writeFile(filePath, JSON.stringify(config, null, 2), 'utf8', (err) => {
145
- if (err) {
146
- return console.error('Error writing file:', err);
147
- }
148
- });
149
- // update the offckb.config.ts too
150
- (0, config_1.updateScriptInfoInOffCKBConfigTs)(config, const_1.predefinedOffCKBConfigTsPath, type_1.Network.devnet);
151
- });
152
- }
153
- exports.writePredefinedDevnetLumosConfig = writePredefinedDevnetLumosConfig;
@@ -1,9 +0,0 @@
1
- import { config } from '@ckb-lumos/lumos';
2
- import { Network } from './type';
3
- export declare function updateOffCKBConfigVersion(filePath: string): void;
4
- export declare function updateScriptInfoInOffCKBConfigTs(newConfig: config.Config, filePath: string, network: Network): void;
5
- export declare function readUserDeployedScriptsInfo(network: Network): Record<string, config.ScriptConfig>;
6
- export declare function readPredefinedDevnetLumosConfig(): config.Config;
7
- export declare function readPredefinedMainnetLumosConfig(): config.Config;
8
- export declare function readPredefinedTestnetLumosConfig(): config.Config;
9
- export declare function buildFullLumosConfig(network: Network): any;