You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.9 KiB
110 lines
2.9 KiB
6 years ago
|
// TODO: this file shoudl be removed at some point
|
||
6 years ago
|
var CmdLine = require('./src/cmdline/index.js')
|
||
6 years ago
|
// var compilation = require('./compilation.json')
|
||
6 years ago
|
|
||
6 years ago
|
var solc = require('solc')
|
||
|
var fs = require('fs')
|
||
|
|
||
|
var filename = 'test/sol/simple_storage.sol'
|
||
6 years ago
|
var shortFilename = 'simple_storage.sol'
|
||
6 years ago
|
|
||
6 years ago
|
var inputJson = {
|
||
6 years ago
|
language: 'Solidity',
|
||
|
sources: {
|
||
|
},
|
||
|
settings: {
|
||
|
optimizer: {
|
||
|
enabled: true,
|
||
|
runs: 200
|
||
|
},
|
||
|
outputSelection: {
|
||
|
'*': {
|
||
4 years ago
|
'': [ 'ast' ],
|
||
6 years ago
|
'*': [ 'abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
6 years ago
|
inputJson.sources[shortFilename] = {content: fs.readFileSync(filename).toString()}
|
||
6 years ago
|
|
||
6 years ago
|
console.dir(inputJson)
|
||
6 years ago
|
|
||
6 years ago
|
console.log('compiling...')
|
||
6 years ago
|
|
||
6 years ago
|
let compilationData = JSON.parse(solc.compileStandardWrapper(JSON.stringify(inputJson)))
|
||
6 years ago
|
console.dir(Object.keys(compilationData))
|
||
|
var compilation = {}
|
||
|
compilation.data = compilationData
|
||
6 years ago
|
compilation.source = { sources: inputJson.sources }
|
||
6 years ago
|
console.dir(compilation)
|
||
|
console.dir(compilation.data.errors)
|
||
|
|
||
6 years ago
|
var cmdLine = new CmdLine()
|
||
|
cmdLine.connect('http', 'http://localhost:8545')
|
||
|
cmdLine.loadCompilationResult(compilation)
|
||
|
cmdLine.initDebugger()
|
||
|
|
||
|
// var deployContract = function (cb) {
|
||
|
// let _web3 = cmdLine.debugger.debugger.web3
|
||
|
//
|
||
|
// let blockNumber = null
|
||
|
// let txNumber = null
|
||
|
// let tx = null
|
||
|
//
|
||
|
// let code = compilation.data.contracts[shortFilename].SimpleStorage.evm.bytecode.object
|
||
|
// console.dir('deploying...')
|
||
|
// console.dir(code)
|
||
|
// _web3.eth.sendTransaction({data: '0x' + code, from: _web3.eth.accounts[0], gas: 800000}, cb)
|
||
|
// }
|
||
|
|
||
|
// let _web3 = cmdLine.debugger.debugger.web3
|
||
|
var tx = '0xf510c4f0b1d9ee262d7b9e9e87b4262f275fe029c2c733feef7dfa1e2b1e32aa'
|
||
6 years ago
|
|
||
6 years ago
|
// deployContract((err, tx) => {
|
||
6 years ago
|
cmdLine.startDebug(tx, shortFilename)
|
||
6 years ago
|
|
||
6 years ago
|
cmdLine.events.on('source', () => {
|
||
|
cmdLine.getSource().forEach(console.dir)
|
||
6 years ago
|
})
|
||
|
// })
|
||
6 years ago
|
// })
|
||
6 years ago
|
|
||
|
const repl = require('repl')
|
||
|
|
||
6 years ago
|
repl.start({
|
||
6 years ago
|
prompt: '> ',
|
||
|
eval: (cmd, context, filename, cb) => {
|
||
|
let command = cmd.trim()
|
||
|
if (command === 'next' || command === 'n') {
|
||
6 years ago
|
cmdLine.stepOverForward(true)
|
||
6 years ago
|
}
|
||
|
if (command === 'previous' || command === 'p' || command === 'prev') {
|
||
6 years ago
|
cmdLine.stepOverBack(true)
|
||
6 years ago
|
}
|
||
|
if (command === 'step' || command === 's') {
|
||
6 years ago
|
cmdLine.stepIntoForward(true)
|
||
6 years ago
|
}
|
||
|
if (command === 'stepback' || command === 'sb') {
|
||
6 years ago
|
cmdLine.stepIntoBack(true)
|
||
6 years ago
|
}
|
||
|
if (command === 'exit' || command === 'quit') {
|
||
|
process.exit(0)
|
||
|
}
|
||
|
if (command === 'var local' || command === 'v l' || command === 'vl') {
|
||
6 years ago
|
cmdLine.displayLocals()
|
||
6 years ago
|
}
|
||
|
if (command === 'var global' || command === 'v g' || command === 'vg') {
|
||
6 years ago
|
cmdLine.displayGlobals()
|
||
6 years ago
|
}
|
||
|
if (command.split(' ')[0] === 'jump') {
|
||
|
let stepIndex = parseInt(command.split(' ')[1], 10)
|
||
6 years ago
|
cmdLine.jumpTo(stepIndex)
|
||
6 years ago
|
}
|
||
6 years ago
|
cb(null, '')
|
||
6 years ago
|
}
|
||
6 years ago
|
})
|
||
6 years ago
|
|
||
6 years ago
|
module.exports = cmdLine
|
||
6 years ago
|
|