Commit 890a1160 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #860 from ethereum/cleanVarNames

Clean var names
parents aee174a0 dde48c04
...@@ -73,11 +73,11 @@ module.exports = { ...@@ -73,11 +73,11 @@ module.exports = {
if (bytecode.indexOf('_') < 0) { if (bytecode.indexOf('_') < 0) {
return callback(null, bytecode) return callback(null, bytecode)
} }
var m = bytecode.match(/__([^_]{1,36})__/) var libraryRefMatch = bytecode.match(/__([^_]{1,36})__/)
if (!m) { if (!libraryRefMatch) {
return callback('Invalid bytecode format.') return callback('Invalid bytecode format.')
} }
var libraryName = m[1] var libraryName = libraryRefMatch[1]
var libraryabi = helper.getContractByName(libraryName, contracts) var libraryabi = helper.getContractByName(libraryName, contracts)
if (!libraryabi) { if (!libraryabi) {
return callback('Library ' + libraryName + ' not found.') return callback('Library ' + libraryName + ' not found.')
......
...@@ -359,18 +359,17 @@ function compileTab (container, appAPI, appEvents, opts) { ...@@ -359,18 +359,17 @@ function compileTab (container, appAPI, appEvents, opts) {
var select = el.querySelector('select') var select = el.querySelector('select')
if (select.children.length > 0 && select.selectedIndex >= 0) { if (select.children.length > 0 && select.selectedIndex >= 0) {
var contractName = select.children[select.selectedIndex].innerHTML var contractName = select.children[select.selectedIndex].innerHTML
var details = contractsDetails[contractName] var contractProperties = contractsDetails[contractName]
var keys = Object.keys(contractsDetails[contractName])
var log = yo`<div class="${css.detailsJSON}"></div>` var log = yo`<div class="${css.detailsJSON}"></div>`
keys.map(x => { Object.keys(contractProperties).map(propertyName => {
var copyDetails = yo`<span class="${css.copyDetails}"><i title="Copy value to clipboard" class="fa fa-clipboard" onclick=${() => { copy(details[x]) }} aria-hidden="true"></i></span>` var copyDetails = yo`<span class="${css.copyDetails}"><i title="Copy value to clipboard" class="fa fa-clipboard" onclick=${() => { copy(contractProperties[propertyName]) }} aria-hidden="true"></i></span>`
var questionMark = yo`<span class="${css.questionMark}"><i title="${detailsHelpSection()[x]}" class="fa fa-question-circle" aria-hidden="true"></i></span>` var questionMark = yo`<span class="${css.questionMark}"><i title="${detailsHelpSection()[propertyName]}" class="fa fa-question-circle" aria-hidden="true"></i></span>`
var keyDisplayName var keyDisplayName
(x === 'interface') ? keyDisplayName = 'interface - abi' : keyDisplayName = x (propertyName === 'interface') ? keyDisplayName = 'interface - abi' : keyDisplayName = propertyName
log.appendChild(yo` log.appendChild(yo`
<div class=${css.log}> <div class=${css.log}>
<div class="${css.key}">${keyDisplayName} ${copyDetails} ${questionMark}</div> <div class="${css.key}">${keyDisplayName} ${copyDetails} ${questionMark}</div>
${insertValue(details, x)} ${insertValue(contractProperties, propertyName)}
</div> </div>
`) `)
}) })
...@@ -378,14 +377,14 @@ function compileTab (container, appAPI, appEvents, opts) { ...@@ -378,14 +377,14 @@ function compileTab (container, appAPI, appEvents, opts) {
} }
} }
function insertValue (details, x) { function insertValue (details, propertyName) {
var value = yo`<pre class="${css.value}"></pre>` var value = yo`<pre class="${css.value}"></pre>`
var node var node
if (x === 'bytecode' || x === 'metadataHash' || x === 'swarmLocation' || x === 'Runtime Bytecode' || x === 'Opcodes') { if (propertyName === 'bytecode' || propertyName === 'metadataHash' || propertyName === 'swarmLocation' || propertyName === 'Runtime Bytecode' || propertyName === 'Opcodes') {
node = yo`<div>${details[x].slice(0, 60) + '...'}</div>` node = yo`<div>${details[propertyName].slice(0, 60) + '...'}</div>`
} else if (x === 'web3Deploy' || x === 'name') { } else if (propertyName === 'web3Deploy' || propertyName === 'name') {
node = yo`<pre>${details[x]}</pre>` node = yo`<pre>${details[propertyName]}</pre>`
} else if (x === 'interface' || x === 'metadata') { } else if (propertyName === 'interface' || propertyName === 'metadata') {
var treeView = new TreeView({ var treeView = new TreeView({
extractData: function (item, parent, key) { extractData: function (item, parent, key) {
var ret = {} var ret = {}
...@@ -406,17 +405,17 @@ function compileTab (container, appAPI, appEvents, opts) { ...@@ -406,17 +405,17 @@ function compileTab (container, appAPI, appEvents, opts) {
return ret return ret
} }
}) })
if (details[x] !== '') { if (details[propertyName] !== '') {
try { try {
node = yo`<div>${treeView.render(JSON.parse(details[x]))}</div>` // catch in case the parsing fails. node = yo`<div>${treeView.render(JSON.parse(details[propertyName]))}</div>` // catch in case the parsing fails.
} catch (e) { } catch (e) {
node = yo`<div>Unable to display "${x}": ${e.message}</div>` node = yo`<div>Unable to display "${propertyName}": ${e.message}</div>`
} }
} else { } else {
node = yo`<div> - </div>` node = yo`<div> - </div>`
} }
} else { } else {
node = yo`<div>${JSON.stringify(details[x], null, 4)}</div>` node = yo`<div>${JSON.stringify(details[propertyName], null, 4)}</div>`
} }
if (node) value.appendChild(node) if (node) value.appendChild(node)
return value return value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment