@offckb/cli 0.3.0-canary-e0c0069.0 → 0.3.0-canary-4864353.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/dist/cfg/setting.d.ts +11 -2
- package/dist/cmd/deposit.js +3 -4
- package/dist/deploy/index.js +7 -2
- package/dist/deploy/migration.d.ts +1 -1
- package/dist/deploy/migration.js +4 -1
- package/dist/node/install.js +3 -4
- package/dist/tools/moleculec-es.js +3 -4
- package/dist/util/request.d.ts +6 -6
- package/dist/util/request.js +15 -11
- package/package.json +4 -2
package/dist/cfg/setting.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { AxiosProxyConfig } from 'axios';
|
|
2
1
|
export declare const configPath: string;
|
|
3
2
|
export declare const dataPath: string;
|
|
4
3
|
export declare const cachePath: string;
|
|
5
4
|
export declare const packageSrcPath: string;
|
|
6
5
|
export declare const packageRootPath: string;
|
|
6
|
+
export interface ProxyBasicCredentials {
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ProxyConfig {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
auth?: ProxyBasicCredentials;
|
|
14
|
+
protocol?: string;
|
|
15
|
+
}
|
|
7
16
|
export interface Settings {
|
|
8
|
-
proxy?:
|
|
17
|
+
proxy?: ProxyConfig;
|
|
9
18
|
rpc: {
|
|
10
19
|
proxyPort: number;
|
|
11
20
|
};
|
package/dist/cmd/deposit.js
CHANGED
|
@@ -62,7 +62,7 @@ function sendClaimRequest(toAddress) {
|
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
63
|
const url = 'https://faucet-api.nervos.org/claim_events'; // Replace 'YOUR_API_ENDPOINT' with the actual API endpoint
|
|
64
64
|
const headers = {
|
|
65
|
-
'User-Agent': '
|
|
65
|
+
'User-Agent': 'node-fetch-requests/v2',
|
|
66
66
|
'Accept-Encoding': 'gzip, deflate',
|
|
67
67
|
Accept: '*/*',
|
|
68
68
|
Connection: 'keep-alive',
|
|
@@ -76,12 +76,11 @@ function sendClaimRequest(toAddress) {
|
|
|
76
76
|
});
|
|
77
77
|
const config = {
|
|
78
78
|
method: 'post',
|
|
79
|
-
url: url,
|
|
80
79
|
headers: headers,
|
|
81
|
-
|
|
80
|
+
body,
|
|
82
81
|
};
|
|
83
82
|
try {
|
|
84
|
-
const response = yield request_1.Request.send(config);
|
|
83
|
+
const response = yield request_1.Request.send(url, config);
|
|
85
84
|
console.log('send claim request, status: ', response.status); // Handle the response data here
|
|
86
85
|
}
|
|
87
86
|
catch (error) {
|
package/dist/deploy/index.js
CHANGED
|
@@ -79,7 +79,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
80
|
const bin = yield (0, fs_1.readFileToUint8Array)(binPath);
|
|
81
81
|
const contractName = path_1.default.basename(binPath);
|
|
82
|
-
const result = enableTypeId
|
|
82
|
+
const result = !enableTypeId
|
|
83
83
|
? yield ckb.deployScript(bin, privateKey)
|
|
84
84
|
: migration_1.Migration.isDeployedWithTypeId(contractName, ckb.network)
|
|
85
85
|
? yield ckb.upgradeTypeIdScript(contractName, bin, privateKey)
|
|
@@ -89,11 +89,16 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
89
89
|
yield ckb.waitForTxConfirm(result.txHash);
|
|
90
90
|
console.log('tx committed.');
|
|
91
91
|
const txHash = result.txHash;
|
|
92
|
+
const typeIdScript = result.typeId;
|
|
92
93
|
const index = result.scriptOutputCellIndex;
|
|
93
94
|
const tx = result.tx;
|
|
94
95
|
const dataByteLen = BigInt(tx.outputsData[+index].slice(2).length / 2);
|
|
95
96
|
const dataShannonLen = dataByteLen * BigInt('100000000');
|
|
96
97
|
const occupiedCapacity = '0x' + dataShannonLen.toString(16);
|
|
98
|
+
if (enableTypeId && typeIdScript == null) {
|
|
99
|
+
throw new Error('type id script is null while enableTypeId is true.');
|
|
100
|
+
}
|
|
101
|
+
const typeIdScriptHash = enableTypeId ? (0, utils_1.computeScriptHash)(typeIdScript) : undefined;
|
|
97
102
|
// todo: handle multiple cell recipes?
|
|
98
103
|
return {
|
|
99
104
|
deploymentOptions: {
|
|
@@ -110,7 +115,7 @@ function deployBinary(binPath, privateKey, enableTypeId, ckb) {
|
|
|
110
115
|
index: '0x' + index.toString(16),
|
|
111
116
|
occupiedCapacity,
|
|
112
117
|
dataHash: (0, utils_1.ckbHash)(tx.outputsData[+index]),
|
|
113
|
-
typeId:
|
|
118
|
+
typeId: typeIdScriptHash,
|
|
114
119
|
},
|
|
115
120
|
],
|
|
116
121
|
depGroupRecipes: [],
|
|
@@ -45,6 +45,6 @@ export declare function generateDeploymentMigrationFile(name: string, deployment
|
|
|
45
45
|
export declare function readDeploymentMigrationFile(filePath: string): DeploymentRecipe;
|
|
46
46
|
export declare function getFormattedMigrationDate(): string;
|
|
47
47
|
export declare function getMigrationFolderPath(scriptName: string, network: Network): string;
|
|
48
|
-
export declare function getNewestMigrationFile(folderPath: string): string |
|
|
48
|
+
export declare function getNewestMigrationFile(folderPath: string): string | null;
|
|
49
49
|
export declare function deploymentRecipeToJson(recipe: DeploymentRecipe): MigrationJson;
|
|
50
50
|
export declare function deploymentRecipeFromJson(json: MigrationJson): DeploymentRecipe;
|
package/dist/deploy/migration.js
CHANGED
|
@@ -94,6 +94,9 @@ function getMigrationFolderPath(scriptName, network) {
|
|
|
94
94
|
}
|
|
95
95
|
exports.getMigrationFolderPath = getMigrationFolderPath;
|
|
96
96
|
function getNewestMigrationFile(folderPath) {
|
|
97
|
+
if (!fs_1.default.existsSync(folderPath) || !fs_1.default.lstatSync(folderPath).isDirectory()) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
97
100
|
const files = fs_1.default
|
|
98
101
|
.readdirSync(folderPath)
|
|
99
102
|
.filter((file) => file.endsWith('.json')) // Ensure only JSON files are considered
|
|
@@ -104,7 +107,7 @@ function getNewestMigrationFile(folderPath) {
|
|
|
104
107
|
return timestampA.localeCompare(timestampB);
|
|
105
108
|
});
|
|
106
109
|
// Return the full path of the newest file (last in sorted array) or undefined if no files
|
|
107
|
-
return files.length > 0 ? path_1.default.join(folderPath, files[files.length - 1]) :
|
|
110
|
+
return files.length > 0 ? path_1.default.join(folderPath, files[files.length - 1]) : null;
|
|
108
111
|
}
|
|
109
112
|
exports.getNewestMigrationFile = getNewestMigrationFile;
|
|
110
113
|
function deploymentRecipeToJson(recipe) {
|
package/dist/node/install.js
CHANGED
|
@@ -97,10 +97,9 @@ exports.downloadCKBBinaryAndUnzip = downloadCKBBinaryAndUnzip;
|
|
|
97
97
|
function downloadAndSaveCKBBinary(version, tempFilePath) {
|
|
98
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
99
|
const downloadURL = buildDownloadUrl(version);
|
|
100
|
-
const response = yield request_1.Request.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
fs.writeFileSync(tempFilePath, response.data);
|
|
100
|
+
const response = yield request_1.Request.send(downloadURL);
|
|
101
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
102
|
+
fs.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
exports.downloadAndSaveCKBBinary = downloadAndSaveCKBBinary;
|
|
@@ -57,10 +57,9 @@ class MoleculecES {
|
|
|
57
57
|
static downloadAndSaveMoleculeES(version, tempFilePath) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
59
|
const downloadURL = MoleculecES.buildDownloadUrl(version);
|
|
60
|
-
const response = yield request_1.Request.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fs_1.default.writeFileSync(tempFilePath, response.data);
|
|
60
|
+
const response = yield request_1.Request.send(downloadURL);
|
|
61
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
62
|
+
fs_1.default.writeFileSync(tempFilePath, Buffer.from(arrayBuffer));
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
static buildDownloadUrl(version) {
|
package/dist/util/request.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProxyConfig } from '../cfg/setting';
|
|
2
|
+
import fetch, { RequestInit } from 'node-fetch';
|
|
2
3
|
export declare class Request {
|
|
3
|
-
static proxy:
|
|
4
|
-
static send(
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static proxyConfigToUrl(proxy: AxiosProxyConfig): string;
|
|
4
|
+
static proxy: ProxyConfig | undefined;
|
|
5
|
+
static send(url: string, options?: RequestInit): Promise<fetch.Response>;
|
|
6
|
+
static parseProxyUrl(url: string): ProxyConfig;
|
|
7
|
+
static proxyConfigToUrl(proxy: ProxyConfig): string;
|
|
8
8
|
}
|
package/dist/util/request.js
CHANGED
|
@@ -13,20 +13,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Request = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
16
|
const setting_1 = require("../cfg/setting");
|
|
17
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
18
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
19
|
class Request {
|
|
19
|
-
static send(
|
|
20
|
+
static send(url, options = {}) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const agent = this.proxy ? new https_proxy_agent_1.HttpsProxyAgent(this.proxyConfigToUrl(this.proxy)) : undefined;
|
|
23
|
+
const opt = Object.assign({ agent }, options);
|
|
24
|
+
try {
|
|
25
|
+
const response = yield (0, node_fetch_1.default)(url, opt);
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`HTTP error! Status: ${response.status}, URL: ${response.url}`);
|
|
28
|
+
}
|
|
29
|
+
return yield response;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new Error(`fetch error! ${error.message}`);
|
|
33
|
+
}
|
|
30
34
|
});
|
|
31
35
|
}
|
|
32
36
|
static parseProxyUrl(url) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offckb/cli",
|
|
3
|
-
"version": "0.3.0-canary-
|
|
3
|
+
"version": "0.3.0-canary-4864353.0",
|
|
4
4
|
"description": "ckb development network for your first try",
|
|
5
5
|
"author": "CKB EcoFund",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/adm-zip": "^0.5.5",
|
|
49
49
|
"@types/node": "^20.11.19",
|
|
50
|
+
"@types/node-fetch": "^2.6.11",
|
|
50
51
|
"@types/semver": "^7.5.7",
|
|
51
52
|
"@types/tar": "^6.1.11",
|
|
52
53
|
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
@@ -65,11 +66,12 @@
|
|
|
65
66
|
"@inquirer/prompts": "^4.1.0",
|
|
66
67
|
"@types/http-proxy": "^1.17.15",
|
|
67
68
|
"adm-zip": "^0.5.10",
|
|
68
|
-
"axios": "^1.6.7",
|
|
69
69
|
"child_process": "^1.0.2",
|
|
70
70
|
"ckb-transaction-dumper": "^0.4.0",
|
|
71
71
|
"commander": "^12.0.0",
|
|
72
72
|
"http-proxy": "^1.18.1",
|
|
73
|
+
"https-proxy-agent": "^7.0.5",
|
|
74
|
+
"node-fetch": "2",
|
|
73
75
|
"semver": "^7.6.0",
|
|
74
76
|
"tar": "^6.2.1"
|
|
75
77
|
}
|