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.
66 lines
2.5 KiB
66 lines
2.5 KiB
8 years ago
|
'use strict'
|
||
7 years ago
|
var remixCore = require('remix-core')
|
||
|
var TraceManager = remixCore.trace.TraceManager
|
||
|
var CodeManager = remixCore.code.CodeManager
|
||
8 years ago
|
var vmSendTx = require('./vmCall')
|
||
7 years ago
|
var remixLib = require('remix-lib')
|
||
|
var traceHelper = remixLib.helpers.trace
|
||
|
var global = remixLib.global
|
||
7 years ago
|
var SolidityProxy = require('../../../src/decoder/solidityProxy')
|
||
|
var InternalCallTree = require('../../../src/decoder/internalCallTree')
|
||
7 years ago
|
var EventManager = remixLib.EventManager
|
||
8 years ago
|
var helper = require('./helper')
|
||
|
|
||
|
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
|
||
|
vmSendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) {
|
||
|
if (error) {
|
||
|
st.fail(error)
|
||
|
} else {
|
||
7 years ago
|
global.web3.getTransaction(txHash, function (error, tx) {
|
||
8 years ago
|
if (error) {
|
||
|
st.fail(error)
|
||
|
} else {
|
||
|
tx.to = traceHelper.contractCreationToken('0')
|
||
|
var traceManager = new TraceManager()
|
||
|
var codeManager = new CodeManager(traceManager)
|
||
|
codeManager.clear()
|
||
|
var solidityProxy = new SolidityProxy(traceManager, codeManager)
|
||
|
solidityProxy.reset(compilationResult)
|
||
|
var debuggerEvent = new EventManager()
|
||
8 years ago
|
var callTree = new InternalCallTree(debuggerEvent, traceManager, solidityProxy, codeManager, { includeLocalVariables: true })
|
||
8 years ago
|
callTree.event.register('callTreeBuildFailed', (error) => {
|
||
|
st.fail(error)
|
||
|
})
|
||
8 years ago
|
callTree.event.register('callTreeReady', (scopes, scopeStarts) => {
|
||
7 years ago
|
helper.decodeLocals(st, 88, traceManager, callTree, function (locals) {
|
||
8 years ago
|
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)
|
||
|
}
|
||
|
})
|
||
|
|
||
|
helper.decodeLocals(st, 7, traceManager, callTree, function (locals) {
|
||
|
try {
|
||
8 years ago
|
st.equals(Object.keys(locals).length, 0)
|
||
8 years ago
|
} catch (e) {
|
||
|
st.fail(e.message)
|
||
|
}
|
||
|
cb()
|
||
|
})
|
||
|
})
|
||
|
traceManager.resolveTrace(tx, (error, result) => {
|
||
|
if (error) {
|
||
|
st.fail(error)
|
||
|
} else {
|
||
|
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace])
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
}
|