Skip to content

Commit eea3da1

Browse files
authored
fix: lock deps and deploy ignore the debug version (#224)
1 parent 3768d40 commit eea3da1

5 files changed

Lines changed: 39 additions & 10 deletions

File tree

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@
6262
"typescript": "^5.3.3"
6363
},
6464
"dependencies": {
65-
"@ckb-ccc/core": "^1.5.3",
65+
"@ckb-ccc/core": "1.5.3",
6666
"@iarna/toml": "^2.2.5",
6767
"@inquirer/prompts": "^4.1.0",
6868
"@types/http-proxy": "^1.17.15",
6969
"adm-zip": "^0.5.10",
70-
"chalk": "^5.4.1",
70+
"chalk": "4.1.2",
7171
"child_process": "^1.0.2",
7272
"ckb-transaction-dumper": "^0.4.2",
7373
"commander": "^12.0.0",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/deploy.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NetworkOption, Network } from '../type/base';
22
import path from 'path';
33
import { deployerAccount } from '../cfg/account';
4-
import { isAbsolutePath, getBinaryFilesFromPath } from '../util/fs';
4+
import { isAbsolutePath, getBinaryFilesFromPath, getBinaryFileSizeInBytes } from '../util/fs';
55
import { validateNetworkOpt } from '../util/validator';
66
import { deployBinaries, getToDeployBinsPath, recordDeployResult } from '../deploy';
77
import { CKB } from '../sdk/ckb';
@@ -31,7 +31,20 @@ export async function deploy(
3131
const targetFolder = opt.target;
3232
if (targetFolder) {
3333
const binFilesOrFolder = isAbsolutePath(targetFolder) ? targetFolder : path.resolve(process.cwd(), targetFolder);
34-
const binPaths = getBinaryFilesFromPath(binFilesOrFolder);
34+
let binPaths = getBinaryFilesFromPath(binFilesOrFolder);
35+
36+
// ignore the binary file which is too large(> 500kb) to upload on chain
37+
binPaths = binPaths.filter((binPath) => {
38+
const size = getBinaryFileSizeInBytes(binPath);
39+
if (size > 500 * 1024) {
40+
console.warn(
41+
`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`,
42+
);
43+
return false;
44+
}
45+
return true;
46+
});
47+
3548
const results = await deployBinaries(binPaths, privateKey, enableTypeId, ckb);
3649

3750
// record the deployed contract infos
@@ -50,7 +63,18 @@ export async function deploy(
5063
`config file not exits: ${userOffCKBConfigPath}, tips: use --config to specific the offckb.config.ts file`,
5164
);
5265
}
53-
const bins = getToDeployBinsPath(userOffCKBConfigPath);
66+
let bins = getToDeployBinsPath(userOffCKBConfigPath);
67+
68+
// ignore the binary file which is too large(> 500kb) to upload on chain
69+
bins = bins.filter((binPath) => {
70+
const size = getBinaryFileSizeInBytes(binPath);
71+
if (size > 500 * 1024) {
72+
console.warn(`[warning]: ignore deploying the binary file ${binPath} since its size is too large: ${size} bytes`);
73+
return false;
74+
}
75+
return true;
76+
});
77+
5478
const results = await deployBinaries(bins, privateKey, enableTypeId, ckb);
5579

5680
// record the deployed contract infos

src/util/fs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ export function isBinaryFile(filePath: string): boolean {
142142
return false;
143143
}
144144

145+
export function getBinaryFileSizeInBytes(filePath: string): number {
146+
const stats = fs.statSync(filePath);
147+
return stats.size;
148+
}
149+
145150
export function isAbsolutePath(filePath: string): boolean {
146151
return path.isAbsolute(filePath);
147152
}

0 commit comments

Comments
 (0)