diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-11-22 19:33:58 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-11-22 23:27:38 +0800 |
commit | 780990516b5285c74010c2791a13e01e668ed2dd (patch) | |
tree | 6c460f878a73f61195eb3008ca92f3efad0e0a60 /scripts | |
parent | 60fbc32fdfa4657edd3ebb047b7f65626ac3baba (diff) | |
download | dexon-solidity-780990516b5285c74010c2791a13e01e668ed2dd.tar.gz dexon-solidity-780990516b5285c74010c2791a13e01e668ed2dd.tar.zst dexon-solidity-780990516b5285c74010c2791a13e01e668ed2dd.zip |
Fix storebytecode.sh for bytecode comparison
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bytecodecompare/storebytecode.sh | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/scripts/bytecodecompare/storebytecode.sh b/scripts/bytecodecompare/storebytecode.sh index ccf6e60e..b14b23d0 100755 --- a/scripts/bytecodecompare/storebytecode.sh +++ b/scripts/bytecodecompare/storebytecode.sh @@ -58,7 +58,7 @@ for (var optimize of [false, true]) if (filename !== undefined) { var inputs = {} - inputs[filename] = fs.readFileSync(filename).toString() + inputs[filename] = { content: fs.readFileSync(filename).toString() } var input = { language: 'Solidity', sources: inputs, @@ -68,16 +68,22 @@ for (var optimize of [false, true]) } } var result = JSON.parse(compiler.compile(JSON.stringify(input))) - if (!('contracts' in result) || Object.keys(result['contracts']).length === 0) + if ( + !('contracts' in result) || + Object.keys(result['contracts']).length === 0 || + !result['contracts'][filename] || + Object.keys(result['contracts'][filename]).length === 0 + ) { + // NOTE: do not exit here because this may be run on source which cannot be compiled console.log(filename + ': ERROR') } else { - for (var contractName in result['contracts']) + for (var contractName in result['contracts'][filename]) { - console.log(contractName + ' ' + result['contracts'][contractName].evm.bytecode.object) - console.log(contractName + ' ' + result['contracts'][contractName].metadata) + console.log(contractName + ' ' + result['contracts'][filename][contractName].evm.bytecode.object) + console.log(contractName + ' ' + result['contracts'][filename][contractName].metadata) } } } |