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.
62 lines
2.4 KiB
62 lines
2.4 KiB
8 years ago
|
'use strict'
|
||
7 years ago
|
var vmCall = require('../vmCall')
|
||
4 years ago
|
var traceHelper = require('../../../src/trace/traceHelper')
|
||
6 years ago
|
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy')
|
||
|
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree')
|
||
4 years ago
|
var EventManager = require('../../../src/eventManager')
|
||
|
|
||
8 years ago
|
var helper = require('./helper')
|
||
|
|
||
4 years ago
|
var TraceManager = require('../../../src/trace/traceManager')
|
||
|
var CodeManager = require('../../../src/code/codeManager')
|
||
6 years ago
|
|
||
8 years ago
|
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
|
||
4 years ago
|
vmCall.sendTx(vm, { nonce: 0, privateKey: privateKey }, null, 0, contractBytecode, function (error, txHash) {
|
||
8 years ago
|
if (error) {
|
||
4 years ago
|
return st.fail(error)
|
||
|
}
|
||
|
vm.web3.eth.getTransaction(txHash, function (error, tx) {
|
||
|
if (error) {
|
||
|
return st.fail(error)
|
||
|
}
|
||
|
tx.to = traceHelper.contractCreationToken('0')
|
||
|
var traceManager = new TraceManager({ web3: vm.web3 })
|
||
|
var codeManager = new CodeManager(traceManager)
|
||
|
codeManager.clear()
|
||
4 years ago
|
var solidityProxy = new SolidityProxy({ getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager), getCode: codeManager.getCode.bind(codeManager) })
|
||
4 years ago
|
solidityProxy.reset(compilationResult)
|
||
|
var debuggerEvent = new EventManager()
|
||
|
var callTree = new InternalCallTree(debuggerEvent, traceManager, solidityProxy, codeManager, { includeLocalVariables: true })
|
||
|
callTree.event.register('callTreeBuildFailed', (error) => {
|
||
|
st.fail(error)
|
||
|
})
|
||
|
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
|
||
|
helper.decodeLocals(st, 49, traceManager, callTree, function (locals) {
|
||
|
try {
|
||
|
st.equals(locals['dynbytes'].value, '0x64796e616d69636279746573')
|
||
|
st.equals(locals['smallstring'].value, 'test_test_test')
|
||
|
st.equals(Object.keys(locals).length, 2)
|
||
|
} catch (e) {
|
||
|
st.fail(e.message)
|
||
|
}
|
||
|
})
|
||
8 years ago
|
|
||
4 years ago
|
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
|
||
|
try {
|
||
|
// st.equals(Object.keys(locals).length, 0)
|
||
|
st.equals(0, 0)
|
||
|
} catch (e) {
|
||
|
st.fail(e.message)
|
||
|
}
|
||
|
cb()
|
||
|
})
|
||
8 years ago
|
})
|
||
4 years ago
|
traceManager.resolveTrace(tx).then(() => {
|
||
|
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace])
|
||
|
}).catch((error) => {
|
||
|
st.fail(error)
|
||
|
})
|
||
|
})
|
||
8 years ago
|
})
|
||
|
}
|