Skip to content

Commit

Permalink
fix: fix check bsc bytecode script
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink committed Sep 8, 2024
1 parent 9132efb commit dd04573
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/check-bsc-hardfork-bytecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ const compareGenesisWithHardforkBytecodes = async (genesisFile: string, files: s
log('bytecode from genesis:', bytecode.length, )

const bytecodeFromBsc = getBytecodeFromBscRepo(contractName, files)
if (!bytecodeFromBsc) {
log(`cannot find bytecode for ${contractName} in bsc repo`)
continue;
}

log('bytecode from bsc repo:', bytecodeFromBsc.length, )

if (bytecode === bytecodeFromBsc) {
Expand All @@ -111,14 +116,14 @@ const compareGenesisWithHardforkBytecodes = async (genesisFile: string, files: s
}
}

const getBytecodeFromBscRepo = (contractName: string, files: string[]): string => {
const getBytecodeFromBscRepo = (contractName: string, files: string[]): string | undefined => {
for (let i = 0; i < files.length; i++) {
const file = files[i]
if (file.includes(`/${contractName}`)) {
return clear0x((fs.readFileSync(file)).toString());
}
}
throw new Error(`cannot find bytecode for ${contractName} in bsc repo`)
return undefined
}

const searchFiles = async (searchDir: string, searchSuffix = ''): Promise<string[]> => {
Expand Down

0 comments on commit dd04573

Please sign in to comment.