@offckb/cli 0.2.5 → 0.2.7
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 +16 -1
- package/dist/cfg/const.d.ts +0 -1
- package/dist/cfg/const.js +2 -2
- package/dist/cfg/env-path.d.ts +9 -0
- package/dist/cfg/env-path.js +63 -0
- package/dist/cfg/setting.d.ts +7 -0
- package/dist/cfg/setting.js +64 -0
- package/dist/cli.js +5 -0
- package/dist/cmd/config.d.ts +9 -0
- package/dist/cmd/config.js +75 -0
- package/dist/cmd/deposit.js +2 -5
- package/dist/cmd/develop/install.js +2 -2
- package/dist/util/ckb.d.ts +63 -0
- package/dist/util/request.d.ts +8 -0
- package/dist/util/request.js +58 -0
- package/dist/util/template.d.ts +1 -1
- package/dist/util/template.js +2 -21
- package/package.json +4 -3
- package/templates/offckb.config.ts +3 -3
- package/templates/template.json +16 -0
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Start building on Nervos blockchain, right now, right away!
|
|
|
25
25
|
- [Get started](#get-started)
|
|
26
26
|
- [Create a full-stack Project](#create-a-full-stack-project)
|
|
27
27
|
- [Create a script-only Project](#create-a-script-only-project)
|
|
28
|
+
- [Add Network Proxy](#add-network-proxy)
|
|
28
29
|
- [Built-in scripts](#built-in-scripts)
|
|
29
30
|
- [Accounts](#accounts)
|
|
30
31
|
- [About Lumos](#about-lumos)
|
|
@@ -62,6 +63,7 @@ Commands:
|
|
|
62
63
|
balance [options] [toAddress] Check account balance, only devnet and testnet
|
|
63
64
|
deploy [options] Deploy contracts to different networks, only supports devnet and testnet
|
|
64
65
|
deployed-scripts [options] Show deployed contracts info on networks, only supports devnet and testnet
|
|
66
|
+
config <action> <section> [value] do a configuration action
|
|
65
67
|
help [command] display help for command
|
|
66
68
|
```
|
|
67
69
|
|
|
@@ -94,7 +96,20 @@ You can create a new script project without a frontend. This is useful when you
|
|
|
94
96
|
offckb create <your-project-name> --script
|
|
95
97
|
```
|
|
96
98
|
|
|
97
|
-
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-tempaltes) to do all the magic.
|
|
99
|
+
Note: you need to have rust/cargo/cargo-generate/clang 16+ installed in your environment to use this command. offckb doesn't do anything really, it just call [ckb-script-template](https://github.com/cryptape/ckb-script-tempaltes) to do all the magic.
|
|
100
|
+
|
|
101
|
+
### Add Network Proxy
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
offckb config set proxy http://127.0.0.1:1086
|
|
105
|
+
> save new settings
|
|
106
|
+
offckb config get proxy
|
|
107
|
+
> http://127.0.0.1:1086
|
|
108
|
+
offckb config rm proxy
|
|
109
|
+
> save new settings
|
|
110
|
+
offckb config get proxy
|
|
111
|
+
> No Proxy.
|
|
112
|
+
```
|
|
98
113
|
|
|
99
114
|
## Built-in scripts
|
|
100
115
|
|
package/dist/cfg/const.d.ts
CHANGED
|
@@ -18,4 +18,3 @@ export declare const dappTemplateGitRepoUserAndName = "RetricSu/offckb";
|
|
|
18
18
|
export declare const dappTemplateGitUrl = "https://github.com/RetricSu/offckb";
|
|
19
19
|
export declare const dappTemplateGitBranch = "develop";
|
|
20
20
|
export declare const dappTemplateGitFolder = "templates";
|
|
21
|
-
export declare const bareTemplateGitSelectOptionFile = "template.json";
|
package/dist/cfg/const.js
CHANGED
|
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
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
27
|
const path = __importStar(require("path"));
|
|
28
|
+
// todo: move some to user settings
|
|
28
29
|
// path
|
|
29
30
|
exports.currentExecPath = process.cwd();
|
|
30
31
|
exports.packageSrcPath = path.dirname(require.main.filename);
|
|
@@ -48,4 +49,3 @@ exports.dappTemplateGitRepoUserAndName = 'RetricSu/offckb';
|
|
|
48
49
|
exports.dappTemplateGitUrl = `https://github.com/${exports.dappTemplateGitRepoUserAndName}`;
|
|
49
50
|
exports.dappTemplateGitBranch = 'develop';
|
|
50
51
|
exports.dappTemplateGitFolder = 'templates';
|
|
51
|
-
exports.bareTemplateGitSelectOptionFile = 'template.json';
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
// take and adapt from https://github.com/sindresorhus/env-paths/blob/main/index.js
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const process_1 = __importDefault(require("process"));
|
|
10
|
+
const homedir = os_1.default.homedir();
|
|
11
|
+
const tmpdir = os_1.default.tmpdir();
|
|
12
|
+
const { env } = process_1.default;
|
|
13
|
+
const macos = (appName) => {
|
|
14
|
+
const library = path_1.default.join(homedir, 'Library');
|
|
15
|
+
return {
|
|
16
|
+
data: path_1.default.join(library, 'Application Support', appName),
|
|
17
|
+
config: path_1.default.join(library, 'Preferences', appName),
|
|
18
|
+
cache: path_1.default.join(library, 'Caches', appName),
|
|
19
|
+
log: path_1.default.join(library, 'Logs', appName),
|
|
20
|
+
temp: path_1.default.join(tmpdir, appName),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const windows = (appName) => {
|
|
24
|
+
const appData = env.APPDATA || path_1.default.join(homedir, 'AppData', 'Roaming');
|
|
25
|
+
const localAppData = env.LOCALAPPDATA || path_1.default.join(homedir, 'AppData', 'Local');
|
|
26
|
+
return {
|
|
27
|
+
// Data/config/cache/log are invented by me as Windows isn't opinionated about this
|
|
28
|
+
data: path_1.default.join(localAppData, appName, 'Data'),
|
|
29
|
+
config: path_1.default.join(appData, appName, 'Config'),
|
|
30
|
+
cache: path_1.default.join(localAppData, appName, 'Cache'),
|
|
31
|
+
log: path_1.default.join(localAppData, appName, 'Log'),
|
|
32
|
+
temp: path_1.default.join(tmpdir, appName),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
36
|
+
const linux = (appName) => {
|
|
37
|
+
const username = path_1.default.basename(homedir);
|
|
38
|
+
return {
|
|
39
|
+
data: path_1.default.join(env.XDG_DATA_HOME || path_1.default.join(homedir, '.local', 'share'), appName),
|
|
40
|
+
config: path_1.default.join(env.XDG_CONFIG_HOME || path_1.default.join(homedir, '.config'), appName),
|
|
41
|
+
cache: path_1.default.join(env.XDG_CACHE_HOME || path_1.default.join(homedir, '.cache'), appName),
|
|
42
|
+
// https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
|
43
|
+
log: path_1.default.join(env.XDG_STATE_HOME || path_1.default.join(homedir, '.local', 'state'), appName),
|
|
44
|
+
temp: path_1.default.join(tmpdir, username, appName),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
function envPaths(appName, { suffix = 'nodejs' } = {}) {
|
|
48
|
+
if (typeof appName !== 'string') {
|
|
49
|
+
throw new TypeError(`Expected a string, got ${typeof appName}`);
|
|
50
|
+
}
|
|
51
|
+
if (suffix) {
|
|
52
|
+
// Add suffix to prevent possible conflict with native apps
|
|
53
|
+
appName += `-${suffix}`;
|
|
54
|
+
}
|
|
55
|
+
if (process_1.default.platform === 'darwin') {
|
|
56
|
+
return macos(appName);
|
|
57
|
+
}
|
|
58
|
+
if (process_1.default.platform === 'win32') {
|
|
59
|
+
return windows(appName);
|
|
60
|
+
}
|
|
61
|
+
return linux(appName);
|
|
62
|
+
}
|
|
63
|
+
exports.default = envPaths;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosProxyConfig } from 'axios';
|
|
2
|
+
export interface Settings {
|
|
3
|
+
proxy?: AxiosProxyConfig;
|
|
4
|
+
}
|
|
5
|
+
export declare const defaultSettings: Settings;
|
|
6
|
+
export declare function readSettings(): Settings;
|
|
7
|
+
export declare function writeSettings(settings: Settings): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.writeSettings = exports.readSettings = exports.defaultSettings = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const env_path_1 = __importDefault(require("./env-path"));
|
|
33
|
+
const paths = (0, env_path_1.default)('offckb');
|
|
34
|
+
const configPath = path.join(paths.config, 'settings.json');
|
|
35
|
+
exports.defaultSettings = {
|
|
36
|
+
proxy: undefined,
|
|
37
|
+
};
|
|
38
|
+
function readSettings() {
|
|
39
|
+
try {
|
|
40
|
+
if (fs.existsSync(configPath)) {
|
|
41
|
+
const data = fs.readFileSync(configPath, 'utf8');
|
|
42
|
+
return JSON.parse(data);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return exports.defaultSettings;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('Error reading settings:', error);
|
|
50
|
+
return exports.defaultSettings;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.readSettings = readSettings;
|
|
54
|
+
function writeSettings(settings) {
|
|
55
|
+
try {
|
|
56
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
57
|
+
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2));
|
|
58
|
+
console.log('save new settings');
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('Error writing settings:', error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.writeSettings = writeSettings;
|
package/dist/cli.js
CHANGED
|
@@ -29,6 +29,7 @@ const balance_1 = require("./cmd/balance");
|
|
|
29
29
|
const build_account_1 = require("./cmd/develop/build-account");
|
|
30
30
|
const create_1 = require("./cmd/create");
|
|
31
31
|
const deployed_scripts_1 = require("./cmd/deployed-scripts");
|
|
32
|
+
const config_1 = require("./cmd/config");
|
|
32
33
|
const version = require('../package.json').version;
|
|
33
34
|
const description = require('../package.json').description;
|
|
34
35
|
// fix windows terminal encoding of simplified chinese text
|
|
@@ -87,6 +88,10 @@ program
|
|
|
87
88
|
.description('Show deployed contracts info on different networks, only supports devnet and testnet')
|
|
88
89
|
.option('--network <network>', 'Specify the network to deploy to', 'devnet')
|
|
89
90
|
.action((options) => (0, deployed_scripts_1.deployedScripts)(options));
|
|
91
|
+
program
|
|
92
|
+
.command('config <action> <section> [value]')
|
|
93
|
+
.description('do a configuration action')
|
|
94
|
+
.action((action, section, value) => (0, config_1.Config)(action, section, value));
|
|
90
95
|
// Add commands meant for developers
|
|
91
96
|
if (process.env.NODE_ENV === 'development') {
|
|
92
97
|
// Define the CLI commands and options
|
|
@@ -0,0 +1,75 @@
|
|
|
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.Config = exports.ConfigSection = exports.ConfigAction = void 0;
|
|
13
|
+
const setting_1 = require("../cfg/setting");
|
|
14
|
+
const request_1 = require("../util/request");
|
|
15
|
+
var ConfigAction;
|
|
16
|
+
(function (ConfigAction) {
|
|
17
|
+
ConfigAction["get"] = "get";
|
|
18
|
+
ConfigAction["set"] = "set";
|
|
19
|
+
ConfigAction["rm"] = "rm";
|
|
20
|
+
})(ConfigAction || (exports.ConfigAction = ConfigAction = {}));
|
|
21
|
+
var ConfigSection;
|
|
22
|
+
(function (ConfigSection) {
|
|
23
|
+
ConfigSection["proxy"] = "proxy";
|
|
24
|
+
})(ConfigSection || (exports.ConfigSection = ConfigSection = {}));
|
|
25
|
+
function Config(action, section, value) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (action === ConfigAction.get) {
|
|
28
|
+
switch (section) {
|
|
29
|
+
case ConfigSection.proxy: {
|
|
30
|
+
const settings = (0, setting_1.readSettings)();
|
|
31
|
+
const proxy = settings.proxy;
|
|
32
|
+
if (proxy == null) {
|
|
33
|
+
console.log(`No Proxy.`);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
return console.log(`${request_1.Request.proxyConfigToUrl(proxy)}`);
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (action === ConfigAction.set) {
|
|
43
|
+
switch (section) {
|
|
44
|
+
case ConfigSection.proxy: {
|
|
45
|
+
if (value == null)
|
|
46
|
+
throw new Error('No proxyUrl!');
|
|
47
|
+
try {
|
|
48
|
+
const proxy = request_1.Request.parseProxyUrl(value);
|
|
49
|
+
const settings = (0, setting_1.readSettings)();
|
|
50
|
+
settings.proxy = proxy;
|
|
51
|
+
return (0, setting_1.writeSettings)(settings);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
return console.error(`invalid proxyURL, `, error.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (action === ConfigAction.rm) {
|
|
62
|
+
switch (section) {
|
|
63
|
+
case ConfigSection.proxy: {
|
|
64
|
+
const settings = (0, setting_1.readSettings)();
|
|
65
|
+
settings.proxy = undefined;
|
|
66
|
+
return (0, setting_1.writeSettings)(settings);
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
throw new Error('invalid config action.');
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.Config = Config;
|
package/dist/cmd/deposit.js
CHANGED
|
@@ -8,18 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.deposit = void 0;
|
|
16
13
|
const ckb_1 = require("../util/ckb");
|
|
17
|
-
const axios_1 = __importDefault(require("axios"));
|
|
18
14
|
const genkey_1 = require("./develop/genkey");
|
|
19
15
|
const account_1 = require("../cfg/account");
|
|
20
16
|
const type_1 = require("../util/type");
|
|
21
17
|
const link_1 = require("../util/link");
|
|
22
18
|
const validator_1 = require("../util/validator");
|
|
19
|
+
const request_1 = require("../util/request");
|
|
23
20
|
function deposit(toAddress, amount, opt = { network: type_1.Network.devnet }) {
|
|
24
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
22
|
const network = opt.network;
|
|
@@ -85,7 +82,7 @@ function sendClaimRequest(toAddress) {
|
|
|
85
82
|
data: body,
|
|
86
83
|
};
|
|
87
84
|
try {
|
|
88
|
-
const response = yield
|
|
85
|
+
const response = yield request_1.Request.send(config);
|
|
89
86
|
console.log('send claim request, status: ', response.status); // Handle the response data here
|
|
90
87
|
}
|
|
91
88
|
catch (error) {
|
|
@@ -36,7 +36,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.buildDownloadUrl = exports.getExtension = exports.getArch = exports.getOS = exports.isVersionOutdated = exports.getInstalledVersion = exports.decompressTarGzAsync = exports.unZipFile = exports.downloadAndSaveCKBBinary = exports.downloadBinaryAndUnzip = exports.installDependency = void 0;
|
|
39
|
-
const axios_1 = __importDefault(require("axios"));
|
|
40
39
|
const child_process_1 = require("child_process");
|
|
41
40
|
const fs = __importStar(require("fs"));
|
|
42
41
|
const path = __importStar(require("path"));
|
|
@@ -45,6 +44,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
45
44
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
46
45
|
const tar = __importStar(require("tar"));
|
|
47
46
|
const const_1 = require("../../cfg/const");
|
|
47
|
+
const request_1 = require("../../util/request");
|
|
48
48
|
const BINARY = const_1.ckbBinPath;
|
|
49
49
|
const MINIMAL_VERSION = const_1.minimalRequiredCKBVersion;
|
|
50
50
|
// Function to download and install the dependency binary
|
|
@@ -93,7 +93,7 @@ exports.downloadBinaryAndUnzip = downloadBinaryAndUnzip;
|
|
|
93
93
|
function downloadAndSaveCKBBinary(tempFilePath) {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
const downloadURL = buildDownloadUrl(MINIMAL_VERSION);
|
|
96
|
-
const response = yield
|
|
96
|
+
const response = yield request_1.Request.get(downloadURL, {
|
|
97
97
|
responseType: 'arraybuffer',
|
|
98
98
|
});
|
|
99
99
|
fs.writeFileSync(tempFilePath, response.data);
|
package/dist/util/ckb.d.ts
CHANGED
|
@@ -67,6 +67,69 @@ export declare class CKB {
|
|
|
67
67
|
INDEX: string;
|
|
68
68
|
DEP_TYPE: "code";
|
|
69
69
|
};
|
|
70
|
+
XUDT: {
|
|
71
|
+
CODE_HASH: string;
|
|
72
|
+
HASH_TYPE: "data1";
|
|
73
|
+
TX_HASH: string;
|
|
74
|
+
INDEX: string;
|
|
75
|
+
DEP_TYPE: "code";
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
} | {
|
|
79
|
+
PREFIX: string;
|
|
80
|
+
SCRIPTS: {
|
|
81
|
+
SECP256K1_BLAKE160: {
|
|
82
|
+
CODE_HASH: string;
|
|
83
|
+
HASH_TYPE: "type";
|
|
84
|
+
TX_HASH: string;
|
|
85
|
+
INDEX: string;
|
|
86
|
+
DEP_TYPE: "depGroup";
|
|
87
|
+
SHORT_ID: number;
|
|
88
|
+
};
|
|
89
|
+
SECP256K1_BLAKE160_MULTISIG: {
|
|
90
|
+
CODE_HASH: string;
|
|
91
|
+
HASH_TYPE: "type";
|
|
92
|
+
TX_HASH: string;
|
|
93
|
+
INDEX: string;
|
|
94
|
+
DEP_TYPE: "depGroup";
|
|
95
|
+
SHORT_ID: number;
|
|
96
|
+
};
|
|
97
|
+
DAO: {
|
|
98
|
+
CODE_HASH: string;
|
|
99
|
+
HASH_TYPE: "type";
|
|
100
|
+
TX_HASH: string;
|
|
101
|
+
INDEX: string;
|
|
102
|
+
DEP_TYPE: "code";
|
|
103
|
+
};
|
|
104
|
+
SUDT: {
|
|
105
|
+
CODE_HASH: string;
|
|
106
|
+
HASH_TYPE: "type";
|
|
107
|
+
TX_HASH: string;
|
|
108
|
+
INDEX: string;
|
|
109
|
+
DEP_TYPE: "code";
|
|
110
|
+
};
|
|
111
|
+
ANYONE_CAN_PAY: {
|
|
112
|
+
CODE_HASH: string;
|
|
113
|
+
HASH_TYPE: "type";
|
|
114
|
+
TX_HASH: string;
|
|
115
|
+
INDEX: string;
|
|
116
|
+
DEP_TYPE: "depGroup";
|
|
117
|
+
SHORT_ID: number;
|
|
118
|
+
};
|
|
119
|
+
OMNILOCK: {
|
|
120
|
+
CODE_HASH: string;
|
|
121
|
+
HASH_TYPE: "type";
|
|
122
|
+
TX_HASH: string;
|
|
123
|
+
INDEX: string;
|
|
124
|
+
DEP_TYPE: "code";
|
|
125
|
+
};
|
|
126
|
+
XUDT: {
|
|
127
|
+
CODE_HASH: string;
|
|
128
|
+
HASH_TYPE: "type";
|
|
129
|
+
TX_HASH: string;
|
|
130
|
+
INDEX: string;
|
|
131
|
+
DEP_TYPE: "code";
|
|
132
|
+
};
|
|
70
133
|
};
|
|
71
134
|
};
|
|
72
135
|
initializedLumosConfig(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosProxyConfig, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export declare class Request {
|
|
3
|
+
static proxy: AxiosProxyConfig | undefined;
|
|
4
|
+
static send(_config: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>;
|
|
5
|
+
static get(url: string, _config?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
+
static parseProxyUrl(url: string): AxiosProxyConfig;
|
|
7
|
+
static proxyConfigToUrl(proxy: AxiosProxyConfig): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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.Request = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const setting_1 = require("../cfg/setting");
|
|
18
|
+
class Request {
|
|
19
|
+
static send(_config) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const config = this.proxy ? Object.assign({ proxy: this.proxy }, _config) : _config;
|
|
22
|
+
console.log(config);
|
|
23
|
+
return yield (0, axios_1.default)(config);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static get(url, _config) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const config = this.proxy ? Object.assign({ proxy: this.proxy }, _config) : _config;
|
|
29
|
+
console.log(config);
|
|
30
|
+
return yield axios_1.default.get(url, config);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static parseProxyUrl(url) {
|
|
34
|
+
const parsedUrl = new URL(url);
|
|
35
|
+
const proxyConfig = {
|
|
36
|
+
host: parsedUrl.hostname,
|
|
37
|
+
port: parseInt(parsedUrl.port, 10),
|
|
38
|
+
};
|
|
39
|
+
if (parsedUrl.username || parsedUrl.password) {
|
|
40
|
+
proxyConfig.auth = {
|
|
41
|
+
username: parsedUrl.username,
|
|
42
|
+
password: parsedUrl.password,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (parsedUrl.protocol) {
|
|
46
|
+
proxyConfig.protocol = parsedUrl.protocol.slice(0, -1); // Remove the trailing ':'
|
|
47
|
+
}
|
|
48
|
+
return proxyConfig;
|
|
49
|
+
}
|
|
50
|
+
static proxyConfigToUrl(proxy) {
|
|
51
|
+
const protocol = proxy.protocol ? `${proxy.protocol}://` : '';
|
|
52
|
+
const auth = proxy.auth ? `${proxy.auth.username}:${proxy.auth.password}@` : '';
|
|
53
|
+
const port = proxy.port ? `:${proxy.port}` : '';
|
|
54
|
+
return `${protocol}${auth}${proxy.host}${port}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.Request = Request;
|
|
58
|
+
Request.proxy = (0, setting_1.readSettings)().proxy;
|
package/dist/util/template.d.ts
CHANGED
package/dist/util/template.js
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.loadBareTemplateOpts = void 0;
|
|
16
|
-
const
|
|
17
|
-
const const_1 = require("../cfg/const");
|
|
7
|
+
const template_json_1 = __importDefault(require("../../templates/template.json"));
|
|
18
8
|
function loadBareTemplateOpts() {
|
|
19
|
-
return
|
|
20
|
-
const githubUrl = `https://raw.githubusercontent.com/${const_1.dappTemplateGitRepoUserAndName}/${const_1.dappTemplateGitBranch}/${const_1.dappTemplateGitFolder}/${const_1.bareTemplateGitSelectOptionFile}`;
|
|
21
|
-
try {
|
|
22
|
-
const response = yield axios_1.default.get(githubUrl);
|
|
23
|
-
return response.data;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
throw new Error(`Error fetching JSON: ${error.message}`);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
9
|
+
return template_json_1.default;
|
|
29
10
|
}
|
|
30
11
|
exports.loadBareTemplateOpts = loadBareTemplateOpts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "Retric Su <retric@cryptape.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"account",
|
|
18
18
|
"ckb",
|
|
19
19
|
"templates/config.json",
|
|
20
|
-
"templates/offckb.config.ts"
|
|
20
|
+
"templates/offckb.config.ts",
|
|
21
|
+
"templates/template.json"
|
|
21
22
|
],
|
|
22
23
|
"private": false,
|
|
23
24
|
"publishConfig": {
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"typescript": "^5.3.3"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
|
-
"@ckb-lumos/lumos": "0.
|
|
64
|
+
"@ckb-lumos/lumos": "0.23.0",
|
|
64
65
|
"@inquirer/prompts": "^4.1.0",
|
|
65
66
|
"adm-zip": "^0.5.10",
|
|
66
67
|
"axios": "^1.6.7",
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
+
]
|