Fix storebytecode.sh for bytecode comparison

This commit is contained in:
Alex Beregszaszi 2018-11-22 11:33:58 +00:00
parent 60fbc32fdf
commit 780990516b

View File

@ -58,7 +58,7 @@ for (var optimize of [false, true])
if (filename !== undefined) if (filename !== undefined)
{ {
var inputs = {} var inputs = {}
inputs[filename] = fs.readFileSync(filename).toString() inputs[filename] = { content: fs.readFileSync(filename).toString() }
var input = { var input = {
language: 'Solidity', language: 'Solidity',
sources: inputs, sources: inputs,
@ -68,16 +68,22 @@ for (var optimize of [false, true])
} }
} }
var result = JSON.parse(compiler.compile(JSON.stringify(input))) 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') console.log(filename + ': ERROR')
} }
else 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'][filename][contractName].evm.bytecode.object)
console.log(contractName + ' ' + result['contracts'][contractName].metadata) console.log(contractName + ' ' + result['contracts'][filename][contractName].metadata)
} }
} }
} }