11import { NetworkOption , Network } from '../type/base' ;
22import path from 'path' ;
33import { deployerAccount } from '../cfg/account' ;
4- import { isAbsolutePath , getBinaryFilesFromPath } from '../util/fs' ;
4+ import { isAbsolutePath , getBinaryFilesFromPath , getBinaryFileSizeInBytes } from '../util/fs' ;
55import { validateNetworkOpt } from '../util/validator' ;
66import { deployBinaries , getToDeployBinsPath , recordDeployResult } from '../deploy' ;
77import { 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
0 commit comments