Skip to content

Commit bdb4817

Browse files
authored
update default CKB version and debugger minimal version (#234)
1 parent 51771f9 commit bdb4817

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/cfg/setting.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export interface Settings {
6868
cachePath: string;
6969
binFolder: string;
7070
};
71+
ckbDebugger: {
72+
minVersion: string;
73+
};
7174
};
7275
}
7376

@@ -78,7 +81,7 @@ export const defaultSettings: Settings = {
7881
},
7982
bins: {
8083
rootFolder: path.resolve(dataPath, 'bins'),
81-
defaultCKBVersion: '0.113.1',
84+
defaultCKBVersion: '0.201.0',
8285
downloadPath: path.resolve(cachePath, 'download'),
8386
},
8487
devnet: {
@@ -118,6 +121,9 @@ export const defaultSettings: Settings = {
118121
cachePath: path.resolve(cachePath, 'tools', 'moleculec-es'),
119122
binFolder: path.resolve(dataPath, 'tools', 'moleculec-es'),
120123
},
124+
ckbDebugger: {
125+
minVersion: '0.200.0',
126+
},
121127
},
122128
};
123129

src/cmd/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export function buildDebugFullTransactionFilePath(network: Network, txHash: stri
119119
}
120120

121121
export function debugRaw(options: string) {
122-
if (!CKBDebugger.isBinaryInstalled()) {
122+
if (!CKBDebugger.isBinaryInstalled() || !CKBDebugger.isBinaryVersionValid()) {
123123
CKBDebugger.installCKBDebugger();
124124
}
125125
return CKBDebugger.runRaw(options);

src/tools/ckb-debugger.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawnSync, execSync } from 'child_process';
2+
import { readSettings } from '../cfg/setting';
23

34
export interface DebugOption {
45
fullTxJsonFilePath: string;
@@ -23,6 +24,21 @@ export class CKBDebugger {
2324
return result.status === 0;
2425
}
2526

27+
static isBinaryVersionValid() {
28+
const result = spawnSync('ckb-debugger', ['--version']);
29+
if (result.status !== 0) {
30+
console.error('ckb-debugger is not installed');
31+
return false;
32+
}
33+
const version = result.stdout.toString().split(' ')[1];
34+
const settings = readSettings();
35+
if (version < settings.tools.ckbDebugger.minVersion) {
36+
console.error(`ckb-debugger version ${version} is less than ${settings.tools.ckbDebugger.minVersion}`);
37+
return false;
38+
}
39+
return true;
40+
}
41+
2642
static installCKBDebugger() {
2743
const command = `cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger`;
2844
try {

0 commit comments

Comments
 (0)