Merge pull request #156 from ethereum/dont-display-empty-fields

Dont display empty compiler output fields
pull/1/head
Alex Beregszaszi 8 years ago committed by GitHub
commit 07ca143009
  1. 45
      src/app/renderer.js

@ -74,12 +74,17 @@ function Renderer (editor, executionContext, updateFiles, transactionDebugger) {
removable_instances: true,
renderOutputModifier: function (contractName, $contractOutput) {
var contract = data.contracts[contractName];
return $contractOutput
.append(textRow('Bytecode', contract.bytecode))
.append(textRow('Interface', contract['interface']))
.append(textRow('Web3 deploy', gethDeploy(contractName.toLowerCase(), contract['interface'], contract.bytecode), 'deploy'))
.append(textRow('uDApp', combined(contractName, contract['interface'], contract.bytecode), 'deploy'))
.append(getDetails(contract, source, contractName));
if (contract.bytecode) {
$contractOutput.append(textRow('Bytecode', contract.bytecode));
}
$contractOutput.append(textRow('Interface', contract['interface']));
if (contract.bytecode) {
$contractOutput.append(textRow('Web3 deploy', gethDeploy(contractName.toLowerCase(), contract['interface'], contract.bytecode), 'deploy'));
$contractOutput.append(textRow('uDApp', combined(contractName, contract['interface'], contract.bytecode), 'deploy'));
}
return $contractOutput.append(getDetails(contract, source, contractName));
}
}, transactionDebugger);
@ -129,24 +134,35 @@ function Renderer (editor, executionContext, updateFiles, transactionDebugger) {
var getDetails = function (contract, source, contractName) {
var button = $('<button>Toggle Details</button>');
var details = $('<div style="display: none;"/>')
.append(tableRow('Solidity Interface', contract.solidity_interface))
.append(tableRow('Opcodes', contract.opcodes));
.append(tableRow('Solidity Interface', contract.solidity_interface));
if (contract.opcodes !== '') {
details.append(tableRow('Opcodes', contract.opcodes));
}
var funHashes = '';
for (var fun in contract.functionHashes) {
funHashes += contract.functionHashes[fun] + ' ' + fun + '\n';
}
details.append($('<span class="col1">Functions</span>'));
details.append($('<pre/>').text(funHashes));
var gasEstimates = formatGasEstimates(contract.gasEstimates);
if (gasEstimates) {
details.append($('<span class="col1">Gas Estimates</span>'));
details.append($('<pre/>').text(formatGasEstimates(contract.gasEstimates)));
details.append($('<pre/>').text(gasEstimates));
}
if (contract.runtimeBytecode && contract.runtimeBytecode.length > 0) {
details.append(tableRow('Runtime Bytecode', contract.runtimeBytecode));
}
if (contract.assembly !== null) {
details.append($('<span class="col1">Assembly</span>'));
var assembly = $('<pre/>').text(formatAssemblyText(contract.assembly, '', source));
details.append(assembly);
}
button.click(function () { detailsOpen[contractName] = !detailsOpen[contractName]; details.toggle(); });
if (detailsOpen[contractName]) {
details.show();
@ -155,20 +171,31 @@ function Renderer (editor, executionContext, updateFiles, transactionDebugger) {
};
var formatGasEstimates = function (data) {
// FIXME: the whole gasEstimates object should be nil instead
if (data.creation === undefined && data.external === undefined && data.internal === undefined) {
return;
}
var gasToText = function (g) { return g === null ? 'unknown' : g; };
var text = '';
var fun;
if ('creation' in data) {
text += 'Creation: ' + gasToText(data.creation[0]) + ' + ' + gasToText(data.creation[1]) + '\n';
}
if ('external' in data) {
text += 'External:\n';
for (fun in data.external) {
text += ' ' + fun + ': ' + gasToText(data.external[fun]) + '\n';
}
}
if ('internal' in data) {
text += 'Internal:\n';
for (fun in data.internal) {
text += ' ' + fun + ': ' + gasToText(data.internal[fun]) + '\n';
}
}
return text;
};

Loading…
Cancel
Save