Skip to content

Commit

Permalink
Use formatAssemblyText from solc-js
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jan 21, 2019
1 parent cb8d69c commit b2448c0
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions src/app/contract/contractParser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

var solcTranslate = require('solc/translate')
var remixLib = require('remix-lib')
var txHelper = remixLib.execution.txHelper

Expand Down Expand Up @@ -42,7 +43,7 @@ var getDetails = function (contractName, contract, source) {
}

if (source && contract.assembly !== null) {
detail['Assembly'] = formatAssemblyText(contract.evm.legacyAssembly, '', source.content)
detail['Assembly'] = solcTranslate.prettyPrintLegacyAssemblyJSON(contract.evm.legacyAssembly, source.content)
}

return detail
Expand All @@ -58,36 +59,6 @@ var retrieveMetadataHash = function (bytecode) {
}
}

var formatAssemblyText = function (asm, prefix, source) {
if (typeof asm === typeof '' || asm === null || asm === undefined) {
return prefix + asm + '\n'
}
var text = prefix + '.code\n'
asm['.code'].forEach(function (item, _i) {
var v = item.value === undefined ? '' : item.value
var src = ''
if (item.begin !== undefined && item.end !== undefined) {
src = source.slice(item.begin, item.end).replace('\n', '\\n', 'g')
}
if (src.length > 30) {
src = src.slice(0, 30) + '...'
}
if (item.name !== 'tag') {
text += ' '
}
text += prefix + item.name + ' ' + v + '\t\t\t' + src + '\n'
})
text += prefix + '.data\n'
let asmData = (asm['.data'] || [])
for (let i in asmData) {
let item = asmData[i]

text += ' ' + prefix + '' + i + ':\n'
text += formatAssemblyText(item, prefix + ' ', source)
}
return text
}

var gethDeploy = function (contractName, jsonInterface, bytecode) {
var code = ''
var funABI = txHelper.getConstructorInterface(jsonInterface)
Expand Down

0 comments on commit b2448c0

Please sign in to comment.