diff --git a/src/app/tabs/compile-tab.js b/src/app/tabs/compile-tab.js index acd2a13f9a..56fac0722b 100644 --- a/src/app/tabs/compile-tab.js +++ b/src/app/tabs/compile-tab.js @@ -7,6 +7,7 @@ const copy = require('clipboard-copy') var parseContracts = require('../contract/contractParser') var publishOnSwarm = require('../contract/publishOnSwarm') var modalDialog = require('../ui/modaldialog') +var TreeView = require('ethereum-remix').ui.TreeView // -------------- styling ---------------------- var csjs = require('csjs-inject') @@ -90,9 +91,20 @@ var css = csjs` } .log { display: flex; - flex-direction: row; + flex-direction: column; align-items: baseline } + .key { + margin-right: 5px; + color: grey; + text-transform: uppercase; + width: 100%; + } + .value { + display: flex; + width: 100%; + margin-top: 1.5%; + } .copyDetails { margin-left: 2%; font-size: 14px; @@ -103,6 +115,12 @@ var css = csjs` .copyDetails:hover { opacity: 1; } + .questionMark { + margin-left: 1%; + font-size: 14px; + color: ${styles.colors.grey}; + opacity: .3; + }, .detailsJSON { padding: 8px 0; background-color: ${styles.colors.white}; @@ -324,13 +342,55 @@ function compileTab (container, appAPI, appEvents, opts) { var keys = Object.keys(contractsDetails[contractName]) var log = yo`
` keys.map(x => { - var copyDetails = yo` { copy(details[x]) }} aria-hidden="true">` - log.appendChild(yo`
${x}: ${JSON.stringify(details[x], null, 4)}
${copyDetails}
`) + var copyDetails = yo` { copy(details[x]) }} aria-hidden="true">` + var questionMark = yo`` + log.appendChild(yo` +
+
${x} ${copyDetails} ${questionMark}
+ ${insertValue(details, x)} +
+ `) }) modalDialog(contractName, log, {label: 'OK'}, {label: ''}) } } + function insertValue (details, x) { + var value = yo`
`
+      var node
+      if (x === 'bytecode' || x === 'metadataHash' || x === 'swarmLocation' || x === 'Runtime Bytecode' || x === 'Opcodes' || x === 'name') {
+        node = yo`
${details[x]}
` + } else if (x === 'web3Deploy') { + node = yo`
${details[x]}
` + } else if (x === 'interface' || x === 'metadata') { + var treeView = new TreeView({ + extractData: function (item, parent, key) { + var ret = {} + if (item instanceof Array) { + ret.children = item.map((item, index) => { + return {key: index, value: item} + }) + ret.self = '' + } else if (item instanceof Object) { + ret.children = Object.keys(item).map((key) => { + return {key: key, value: item[key]} + }) + ret.self = '' + } else { + ret.self = item + ret.children = [] + } + return ret + } + }) + node = yo`
${treeView.render(JSON.parse(details[x]))}
` + } else { + node = yo`
${JSON.stringify(details[x], null, 4)}
` + } + value.appendChild(node) + return value + } + function publish (appAPI) { var selectContractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) if (selectContractNames.children.length > 0 && selectContractNames.selectedIndex >= 0) { @@ -347,3 +407,20 @@ function compileTab (container, appAPI, appEvents, opts) { return el } } + +function detailsHelpSection () { + return { + 'Assembly': 'Assembly opcodes describing the contract including corresponding solidity source code', + 'Opcodes': 'Assembly opcodes describing the contract', + 'Runtime Bytecode': 'Bytecode actually store in the state and executed during normal contract call', + 'bytecode': 'Bytecode executed during contract creation', + 'functionHashes': 'List of declared function and their corresonding hash', + 'gasEstimates': 'Gas estimation for each function call', + 'metadata': 'Contain all informations related to the compilation', + 'metadataHash': 'Hash representing all metadata information', + 'interface': 'ABI: Describe all the functions (input/output params, scope, ...)', + 'name': 'Name of the compiled contract', + 'swarmLocation': 'Swarm url where all metadata information can be found (contract needs to be published first)', + 'web3Deploy': 'Copy/paste this code to any JavaScript/Web3 console to deploy this contract' + } +}