move code and trace code from remix-debug to remix-lib

pull/7/head
Iuri Matias 6 years ago
parent cc0028c103
commit 4db645cb91
  1. 13
      remix-debug/index.js
  2. 4
      remix-debug/src/Ethdebugger.js
  3. 6
      remix-debug/test/decoder/localsTests/int.js
  4. 5
      remix-debug/test/decoder/localsTests/misc.js
  5. 5
      remix-debug/test/decoder/localsTests/misc2.js
  6. 5
      remix-debug/test/decoder/localsTests/structArray.js
  7. 3
      remix-debug/test/decoder/stateTests/mapping.js
  8. 6
      remix-debug/test/tests.js
  9. 11
      remix-lib/index.js
  10. 3
      remix-lib/package.json
  11. 6
      remix-lib/src/code/breakpointManager.js
  12. 8
      remix-lib/src/code/codeManager.js
  13. 0
      remix-lib/src/code/codeResolver.js
  14. 0
      remix-lib/src/code/codeUtils.js
  15. 3
      remix-lib/src/code/disassembler.js
  16. 0
      remix-lib/src/code/opcodes.js
  17. 3
      remix-lib/src/trace/traceAnalyser.js
  18. 3
      remix-lib/src/trace/traceCache.js
  19. 6
      remix-lib/src/trace/traceManager.js
  20. 0
      remix-lib/src/trace/traceRetriever.js
  21. 6
      remix-lib/src/trace/traceStepManager.js
  22. 3
      remix-lib/test/codeManager.js
  23. 0
      remix-lib/test/disassembler.js
  24. 31
      remix-lib/test/init.js
  25. 51
      remix-lib/test/resources/testWeb3.js
  26. 17
      remix-lib/test/resources/testWeb3.json
  27. 4
      remix-lib/test/tests.js
  28. 3
      remix-lib/test/traceManager.js

@ -1,11 +1,11 @@
'use strict' 'use strict'
var EthDebugger = require('./src/Ethdebugger') var EthDebugger = require('./src/Ethdebugger')
var CodeManager = require('./src/code/codeManager')
var BreakpointManager = require('./src/code/breakpointManager')
var StorageViewer = require('./src/storage/storageViewer') var StorageViewer = require('./src/storage/storageViewer')
var StorageResolver = require('./src/storage/storageResolver') var StorageResolver = require('./src/storage/storageResolver')
var TraceManager = require('./src/trace/traceManager')
var remixLib = require('remix-lib')
var BreakpointManager = remixLib.code.BreakpointManager
/* /*
Use of breakPointManager : Use of breakPointManager :
@ -24,16 +24,9 @@ module.exports = {
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location * @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/ */
BreakpointManager: BreakpointManager, BreakpointManager: BreakpointManager,
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: { storage: {
StorageViewer: StorageViewer, StorageViewer: StorageViewer,
StorageResolver: StorageResolver StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
} }
} }

@ -1,9 +1,7 @@
'use strict' 'use strict'
var CodeManager = require('./code/codeManager')
var StorageViewer = require('./storage/storageViewer') var StorageViewer = require('./storage/storageViewer')
var StorageResolver = require('./storage/storageResolver') var StorageResolver = require('./storage/storageResolver')
var TraceManager = require('./trace/traceManager')
var SolidityProxy = require('./decoder/solidityProxy') var SolidityProxy = require('./decoder/solidityProxy')
var stateDecoder = require('./decoder/stateDecoder') var stateDecoder = require('./decoder/stateDecoder')
@ -11,6 +9,8 @@ var localDecoder = require('./decoder/localDecoder')
var InternalCallTree = require('./decoder/internalCallTree') var InternalCallTree = require('./decoder/internalCallTree')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var TraceManager = remixLib.trace.traceManager
var CodeManager = remixLib.code.CodeManager
var traceHelper = remixLib.helpers.trace var traceHelper = remixLib.helpers.trace
var init = remixLib.init var init = remixLib.init
var executionContext = remixLib.execution.executionContext var executionContext = remixLib.execution.executionContext

@ -1,11 +1,11 @@
'use strict' 'use strict'
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall') var vmCall = require('../vmCall')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
var traceHelper = remixLib.helpers.trace var traceHelper = remixLib.helpers.trace
var SolidityProxy = require('../../../src/decoder/solidityProxy') var SolidityProxy = require('../../../src/decoder/solidityProxy')
var InternalCallTree = require('../../../src/decoder/internalCallTree') var InternalCallTree = require('../../../src/decoder/internalCallTree')

@ -1,6 +1,4 @@
'use strict' 'use strict'
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall') var vmCall = require('../vmCall')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace var traceHelper = remixLib.helpers.trace
@ -9,6 +7,9 @@ var InternalCallTree = require('../../../src/decoder/internalCallTree')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var helper = require('./helper') var helper = require('./helper')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) { vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {

@ -1,6 +1,4 @@
'use strict' 'use strict'
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall') var vmCall = require('../vmCall')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace var traceHelper = remixLib.helpers.trace
@ -9,6 +7,9 @@ var InternalCallTree = require('../../../src/decoder/internalCallTree')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var helper = require('./helper') var helper = require('./helper')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) { vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {

@ -1,6 +1,4 @@
'use strict' 'use strict'
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var vmCall = require('../vmCall') var vmCall = require('../vmCall')
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace var traceHelper = remixLib.helpers.trace
@ -9,6 +7,9 @@ var InternalCallTree = require('../../../src/decoder/internalCallTree')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var helper = require('./helper') var helper = require('./helper')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {
vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) { vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, contractBytecode, function (error, txHash) {
if (error) { if (error) {

@ -1,10 +1,11 @@
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput var compilerInput = remixLib.helpers.compiler.compilerInput
var TraceManager = remixLib.trace.TraceManager
var compiler = require('solc') var compiler = require('solc')
var stateDecoder = require('../../../src/decoder/stateDecoder') var stateDecoder = require('../../../src/decoder/stateDecoder')
var vmCall = require('../vmCall') var vmCall = require('../vmCall')
var TraceManager = require('../../../src/trace/traceManager')
var StorageResolver = require('../../../src/storage/storageResolver') var StorageResolver = require('../../../src/storage/storageResolver')
var StorageViewer = require('../../../src/storage/storageViewer') var StorageViewer = require('../../../src/storage/storageViewer')

@ -6,16 +6,12 @@ var vmCall = require('./vmCall')
var Debugger = require('../src/Ethdebugger') var Debugger = require('../src/Ethdebugger')
var compiler = require('solc') var compiler = require('solc')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')
require('./decoder/decodeInfo.js') require('./decoder/decodeInfo.js')
require('./decoder/storageLocation.js') require('./decoder/storageLocation.js')
require('./decoder/storageDecoder.js') require('./decoder/storageDecoder.js')
require('./decoder/localDecoder.js') require('./decoder/localDecoder.js')
var BreakpointManager = require('../src/code/breakpointManager') var BreakpointManager = remixLib.code.BreakpointManager
tape('debug contract', function (t) { tape('debug contract', function (t) {
t.plan(12) t.plan(12)

@ -22,6 +22,10 @@ var txRunner = require('./src/execution/txRunner')
var executionContext = require('./src/execution/execution-context') var executionContext = require('./src/execution/execution-context')
var typeConversion = require('./src/execution/typeConversion') var typeConversion = require('./src/execution/typeConversion')
var CodeManager = require('./src/code/codeManager')
var BreakpointManager = require('./src/code/breakpointManager')
var TraceManager = require('./src/trace/traceManager')
if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') { if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') {
module.exports = modules() module.exports = modules()
} }
@ -32,6 +36,13 @@ if (typeof (window) !== 'undefined') {
function modules () { function modules () {
return { return {
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
trace: {
TraceManager: TraceManager
},
EventManager: EventManager, EventManager: EventManager,
helpers: { helpers: {
trace: traceHelper, trace: traceHelper,

@ -50,7 +50,8 @@
"node_modules/*", "node_modules/*",
"build/*", "build/*",
"test/resources/*" "test/resources/*"
] ],
"parser": "babel-eslint"
}, },
"browserify": { "browserify": {
"transform": [ "transform": [

@ -1,7 +1,7 @@
'use strict' 'use strict'
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = require('../eventManager')
var helper = remixLib.helpers.trace var helper = require('../helpers/traceHelper')
/** /**
* allow to manage breakpoint * allow to manage breakpoint

@ -1,8 +1,8 @@
'use strict' 'use strict'
var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = require('../eventManager')
var traceHelper = remixLib.helpers.trace var traceHelper = require('../helpers/traceHelper')
var SourceMappingDecoder = remixLib.SourceMappingDecoder var SourceMappingDecoder = require('../sourceMappingDecoder')
var CodeResolver = require('./codeResolver') var CodeResolver = require('./codeResolver')
/* /*

@ -1,8 +1,7 @@
'use strict' 'use strict'
var parseCode = require('./codeUtils').parseCode var parseCode = require('./codeUtils').parseCode
var remixLib = require('remix-lib') var util = require('../util')
var util = remixLib.util
var createExpressions = function (instructions) { var createExpressions = function (instructions) {
var expressions = [] var expressions = []

@ -1,6 +1,5 @@
'use strict' 'use strict'
var remixLib = require('remix-lib') var traceHelper = require('../helpers/traceHelper')
var traceHelper = remixLib.helpers.trace
function TraceAnalyser (_cache) { function TraceAnalyser (_cache) {
this.traceCache = _cache this.traceCache = _cache

@ -1,6 +1,5 @@
'use strict' 'use strict'
var remixLib = require('remix-lib') var helper = require('../util')
var helper = remixLib.util
function TraceCache () { function TraceCache () {
this.init() this.init()

@ -3,9 +3,9 @@ var TraceAnalyser = require('./traceAnalyser')
var TraceRetriever = require('./traceRetriever') var TraceRetriever = require('./traceRetriever')
var TraceCache = require('./traceCache') var TraceCache = require('./traceCache')
var TraceStepManager = require('./traceStepManager') var TraceStepManager = require('./traceStepManager')
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace var traceHelper = require('../helpers/traceHelper')
var util = remixLib.util var util = require('../util')
function TraceManager (options) { function TraceManager (options) {
this.web3 = options.web3 this.web3 = options.web3

@ -1,7 +1,7 @@
'use strict' 'use strict'
var remixLib = require('remix-lib')
var traceHelper = remixLib.helpers.trace var traceHelper = require('../helpers/traceHelper')
var util = remixLib.util var util = require('../util')
function TraceStepManager (_traceAnalyser) { function TraceStepManager (_traceAnalyser) {
this.traceAnalyser = _traceAnalyser this.traceAnalyser = _traceAnalyser

@ -1,7 +1,6 @@
'use strict' 'use strict'
var tape = require('tape') var tape = require('tape')
var remixLib = require('remix-lib') var Web3Providers = require('../src/web3Provider/web3Providers')
var Web3Providers = remixLib.vm.Web3Providers
var TraceManager = require('../src/trace/traceManager') var TraceManager = require('../src/trace/traceManager')
var CodeManager = require('../src/code/codeManager') var CodeManager = require('../src/code/codeManager')
var web3Test = require('./resources/testWeb3') var web3Test = require('./resources/testWeb3')

@ -0,0 +1,31 @@
var init = {
overrideWeb3: function (web3, web3Override) {
web3.eth.getCode = web3Override.getCode
web3.debug.traceTransaction = web3Override.traceTransaction
web3.debug.storageRangeAt = web3Override.storageRangeAt
web3.eth.getTransaction = web3Override.getTransaction
web3.eth.getTransactionFromBlock = web3Override.getTransactionFromBlock
web3.eth.getBlockNumber = web3Override.getBlockNumber
},
readFile: function (filename, callback) {
var fs = require('fs')
try {
console.log('reading ' + filename)
if (callback) {
fs.readFile(filename, 'utf8', callback)
} else {
return fs.readFileSync(filename, 'utf8')
}
} catch (e) {
console.log(e)
if (callback) {
callback(e)
} else {
return e
}
}
}
}
module.exports = init

@ -0,0 +1,51 @@
'use strict'
var init = require('../init')
var web3Override = {}
web3Override.eth = {}
web3Override.debug = {}
var data = init.readFile(require('path').resolve(__dirname, 'testWeb3.json'))
data = JSON.parse(data)
web3Override.eth.getCode = function (address, callback) {
if (callback) {
callback(null, data.testCodes[address])
} else {
return data.testCodes[address]
}
}
web3Override.debug.traceTransaction = function (txHash, options, callback) {
callback(null, data.testTraces[txHash])
}
web3Override.debug.storageRangeAt = function (blockNumber, txIndex, address, start, maxSize, callback) {
callback(null, { storage: {}, complete: true })
}
web3Override.eth.getTransaction = function (txHash, callback) {
if (callback) {
callback(null, data.testTxs[txHash])
} else {
return data.testTxs[txHash]
}
}
web3Override.eth.getTransactionFromBlock = function (blockNumber, txIndex, callback) {
if (callback) {
callback(null, data.testTxsByBlock[blockNumber + '-' + txIndex])
} else {
return data.testTxsByBlock[blockNumber + '-' + txIndex]
}
}
web3Override.eth.getBlockNumber = function (callback) { callback('web3 modified testing purposes :)') }
web3Override.eth.setProvider = function (provider) {}
web3Override.eth.providers = { 'HttpProvider': function (url) {} }
web3Override.eth.currentProvider = {'host': 'test provider'}
if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') {
module.exports = web3Override
}

File diff suppressed because one or more lines are too long

@ -3,3 +3,7 @@ require('./eventManager.js')
require('./sourceMappingDecoder.js') require('./sourceMappingDecoder.js')
require('./util.js') require('./util.js')
require('./txFormat.js') require('./txFormat.js')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')

@ -1,8 +1,7 @@
'use strict' 'use strict'
var TraceManager = require('../src/trace/traceManager') var TraceManager = require('../src/trace/traceManager')
var tape = require('tape') var tape = require('tape')
var remixLib = require('remix-lib') var Web3Providers = require('../src/web3Provider/web3Providers')
var Web3Providers = remixLib.vm.Web3Providers
var web3Test = require('./resources/testWeb3') var web3Test = require('./resources/testWeb3')
let web3 = null let web3 = null
Loading…
Cancel
Save