|
|
|
@ -1,7 +1,12 @@ |
|
|
|
|
import { CompilerAbstract } from '@remix-project/remix-solidity' |
|
|
|
|
import { EventManager } from '../../../src/eventManager' |
|
|
|
|
import { compilerInput } from '../../helpers/compilerHelper' |
|
|
|
|
import { TraceManager } from '../../../src/trace/traceManager' |
|
|
|
|
import { CodeManager } from '../../../src/code/codeManager' |
|
|
|
|
import { compile } from 'solc' |
|
|
|
|
import * as stateDecoder from '../../../src/solidity-decoder/stateDecoder' |
|
|
|
|
import { SolidityProxy } from '../../../src/solidity-decoder/solidityProxy' |
|
|
|
|
import { InternalCallTree } from '../../../src/solidity-decoder/internalCallTree' |
|
|
|
|
import * as vmCall from '../../vmCall' |
|
|
|
|
import { StorageResolver } from '../../../src/storage/storageResolver' |
|
|
|
|
import { StorageViewer } from '../../../src/storage/storageViewer' |
|
|
|
@ -12,6 +17,11 @@ module.exports = async function testMappingStorage (st, cb) { |
|
|
|
|
var privateKey = Buffer.from('503f38a9c967ed597e47fe25643985f032b072db8075426a92110f82df48dfcb', 'hex') |
|
|
|
|
var output = compile(compilerInput(mappingStorage.contract)) |
|
|
|
|
output = JSON.parse(output); |
|
|
|
|
const sources = { |
|
|
|
|
target: 'test.sol', |
|
|
|
|
sources: { 'test.sol': { content: mappingStorage.contract } } |
|
|
|
|
} |
|
|
|
|
const compilationResults = new CompilerAbstract('json', output, sources) |
|
|
|
|
const web3 = await (vmCall as any).getWeb3(); |
|
|
|
|
(vmCall as any).sendTx(web3, {nonce: 0, privateKey: privateKey}, null, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, hash) { |
|
|
|
|
if (error) { |
|
|
|
@ -26,7 +36,7 @@ module.exports = async function testMappingStorage (st, cb) { |
|
|
|
|
// const storage = await this.vm.stateManager.dumpStorage(data.to)
|
|
|
|
|
// (vmCall as any).web3().eth.getCode(tx.contractAddress).then((code) => console.log('code:', code))
|
|
|
|
|
// (vmCall as any).web3().debug.traceTransaction(hash).then((code) => console.log('trace:', code))
|
|
|
|
|
testMapping(st, privateKey, tx.contractAddress, output, web3, cb) |
|
|
|
|
testMapping(st, privateKey, tx.contractAddress, output, compilationResults, web3, cb) |
|
|
|
|
// st.end()
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -34,7 +44,7 @@ module.exports = async function testMappingStorage (st, cb) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function testMapping (st, privateKey, contractAddress, output, web3, cb) { |
|
|
|
|
function testMapping (st, privateKey, contractAddress, output, compilationResults, web3, cb) { |
|
|
|
|
(vmCall as any).sendTx(web3, {nonce: 1, privateKey: privateKey}, contractAddress, 0, '2fd0a83a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001074686973206973206120737472696e6700000000000000000000000000000000', |
|
|
|
|
function (error, hash) { |
|
|
|
|
if (error) { |
|
|
|
@ -46,8 +56,24 @@ function testMapping (st, privateKey, contractAddress, output, web3, cb) { |
|
|
|
|
console.log(error) |
|
|
|
|
st.end(error) |
|
|
|
|
} else { |
|
|
|
|
var traceManager = new TraceManager({web3}) |
|
|
|
|
traceManager.resolveTrace(tx).then(() => { |
|
|
|
|
var traceManager = new TraceManager({ web3 }) |
|
|
|
|
var codeManager = new CodeManager(traceManager) |
|
|
|
|
codeManager.clear() |
|
|
|
|
console.log(compilationResults) |
|
|
|
|
var solidityProxy = new SolidityProxy({
|
|
|
|
|
getCurrentCalledAddressAt: traceManager.getCurrentCalledAddressAt.bind(traceManager),
|
|
|
|
|
getCode: codeManager.getCode.bind(codeManager), |
|
|
|
|
compilationResult: () => compilationResults |
|
|
|
|
}) |
|
|
|
|
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('callTreeNotReady', (reason) => { |
|
|
|
|
st.fail(reason) |
|
|
|
|
}) |
|
|
|
|
callTree.event.register('callTreeReady', (scopes, scopeStarts) => { |
|
|
|
|
var storageViewer = new StorageViewer({ |
|
|
|
|
stepIndex: 268, |
|
|
|
|
tx: tx, |
|
|
|
@ -69,6 +95,12 @@ function testMapping (st, privateKey, contractAddress, output, web3, cb) { |
|
|
|
|
st.end(reason) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
traceManager.resolveTrace(tx).then(() => { |
|
|
|
|
debuggerEvent.trigger('newTraceLoaded', [traceManager.trace]) |
|
|
|
|
}).catch((error) => { |
|
|
|
|
st.fail(error) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|