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'
var EthDebugger = require('./src/Ethdebugger')
var CodeManager = require('./src/code/codeManager')
var BreakpointManager = require('./src/code/breakpointManager')
var StorageViewer = require('./src/storage/storageViewer')
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 :
@ -24,16 +24,9 @@ module.exports = {
* @return {Function} _locationToRowConverter - function implemented by editor which return a column/line position for a char source location
*/
BreakpointManager: BreakpointManager,
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
storage: {
StorageViewer: StorageViewer,
StorageResolver: StorageResolver
},
trace: {
TraceManager: TraceManager
}
}

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

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

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

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

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

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

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

@ -22,6 +22,10 @@ var txRunner = require('./src/execution/txRunner')
var executionContext = require('./src/execution/execution-context')
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') {
module.exports = modules()
}
@ -32,6 +36,13 @@ if (typeof (window) !== 'undefined') {
function modules () {
return {
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
trace: {
TraceManager: TraceManager
},
EventManager: EventManager,
helpers: {
trace: traceHelper,

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

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

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

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

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

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

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

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

@ -1,7 +1,6 @@
'use strict'
var tape = require('tape')
var remixLib = require('remix-lib')
var Web3Providers = remixLib.vm.Web3Providers
var Web3Providers = require('../src/web3Provider/web3Providers')
var TraceManager = require('../src/trace/traceManager')
var CodeManager = require('../src/code/codeManager')
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('./util.js')
require('./txFormat.js')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')

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