move classes from remix-lib to remix-debug

remix-libs-refactor-2
yann300 4 years ago
parent e4d0d7a649
commit 69eb5526ac
  1. 4
      apps/remix-ide/src/app/editor/contextView.js
  2. 6
      apps/remix-ide/src/app/editor/contextualListener.js
  3. 4
      apps/remix-ide/src/app/tabs/debugger-tab.js
  4. 4
      apps/remix-ide/src/app/tabs/debugger/debuggerUI.js
  5. 4
      apps/remix-ide/src/lib/cmdInterpreterAPI.js
  6. 2
      apps/remix-ide/src/lib/offsetToLineColumnConverter.js
  7. 14
      libs/remix-debug/index.js
  8. 15
      libs/remix-debug/src/Ethdebugger.js
  9. 58
      libs/remix-debug/src/cmdline/contextManager.js
  10. 17
      libs/remix-debug/src/cmdline/index.js
  11. 4
      libs/remix-debug/src/code/breakpointManager.js
  12. 4
      libs/remix-debug/src/code/codeManager.js
  13. 0
      libs/remix-debug/src/code/codeResolver.js
  14. 0
      libs/remix-debug/src/code/codeUtils.js
  15. 3
      libs/remix-debug/src/code/disassembler.js
  16. 0
      libs/remix-debug/src/code/opcodes.js
  17. 2
      libs/remix-debug/src/debugger/VmDebugger.js
  18. 11
      libs/remix-debug/src/debugger/debugger.js
  19. 3
      libs/remix-debug/src/debugger/solidityLocals.js
  20. 3
      libs/remix-debug/src/debugger/solidityState.js
  21. 2
      libs/remix-debug/src/debugger/stepManager.js
  22. 0
      libs/remix-debug/src/eventManager.js
  23. 76
      libs/remix-debug/src/init.js
  24. 3
      libs/remix-debug/src/solidity-decoder/astHelper.js
  25. 9
      libs/remix-debug/src/solidity-decoder/internalCallTree.js
  26. 2
      libs/remix-debug/src/solidity-decoder/solidityProxy.js
  27. 3
      libs/remix-debug/src/source/astWalker.js
  28. 3
      libs/remix-debug/src/source/offsetToLineColumnConverter.js
  29. 7
      libs/remix-debug/src/source/sourceLocationTracker.js
  30. 3
      libs/remix-debug/src/source/sourceMappingDecoder.js
  31. 3
      libs/remix-debug/src/storage/storageResolver.js
  32. 2
      libs/remix-debug/src/trace/traceAnalyser.js
  33. 3
      libs/remix-debug/src/trace/traceCache.js
  34. 3
      libs/remix-debug/src/trace/traceHelper.js
  35. 5
      libs/remix-debug/src/trace/traceManager.js
  36. 0
      libs/remix-debug/src/trace/traceRetriever.js
  37. 5
      libs/remix-debug/src/trace/traceStepManager.js
  38. 2
      libs/remix-debug/test/astwalker.js
  39. 37
      libs/remix-debug/test/codeManager.js
  40. 8
      libs/remix-debug/test/debugger.js
  41. 3
      libs/remix-debug/test/decoder/decodeInfo.js
  42. 3
      libs/remix-debug/test/decoder/localDecoder.js
  43. 8
      libs/remix-debug/test/decoder/localsTests/int.js
  44. 9
      libs/remix-debug/test/decoder/localsTests/misc.js
  45. 10
      libs/remix-debug/test/decoder/localsTests/misc2.js
  46. 9
      libs/remix-debug/test/decoder/localsTests/structArray.js
  47. 5
      libs/remix-debug/test/decoder/stateTests/mapping.js
  48. 3
      libs/remix-debug/test/decoder/storageDecoder.js
  49. 3
      libs/remix-debug/test/decoder/storageLocation.js
  50. 18
      libs/remix-debug/test/decoder/vmCall.js
  51. 0
      libs/remix-debug/test/disassembler.js
  52. 26
      libs/remix-debug/test/helpers/compilerHelper.js
  53. 0
      libs/remix-debug/test/resources/ast.js
  54. 0
      libs/remix-debug/test/resources/sourceMapping.js
  55. 4
      libs/remix-debug/test/sourceMappingDecoder.js
  56. 5
      libs/remix-debug/test/tests.js
  57. 20
      libs/remix-debug/test/traceManager.js
  58. 14
      libs/remix-debug/test/vmCall.js
  59. 27
      libs/remix-lib/index.js
  60. 17
      libs/remix-lib/src/web3Provider/web3VmProvider.js
  61. 51
      libs/remix-lib/test/resources/testWeb3.js
  62. 17
      libs/remix-lib/test/resources/testWeb3.json
  63. 17
      libs/remix-lib/test/resources/testWeb3.json~merged
  64. 6
      libs/remix-lib/test/tests.js
  65. 2
      libs/remix-solidity/src/compiler/compiler.ts
  66. 68
      libs/remix-solidity/src/lib/eventManager.ts

@ -1,7 +1,7 @@
'use strict'
const yo = require('yo-yo')
const remixLib = require('@remix-project/remix-lib')
const SourceMappingDecoder = remixLib.SourceMappingDecoder
const remixDebug = require('@remix-project/remix-debug')
const SourceMappingDecoder = remixDebug.SourceMappingDecoder
const globalRegistry = require('../../global/registry')
const css = require('./styles/contextView-styles')

@ -1,8 +1,8 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const remixdebug = require('@remix-project/remix-debug')
const csjs = require('csjs-inject')
const SourceMappingDecoder = remixLib.SourceMappingDecoder
const AstWalker = remixLib.AstWalker
const SourceMappingDecoder = remixdebug.SourceMappingDecoder
const AstWalker = remixdebug.AstWalker
const EventManager = require('../../lib/events')
const globalRegistry = require('../../global/registry')
import { Plugin } from '@remixproject/engine'

@ -1,5 +1,5 @@
const yo = require('yo-yo')
const remixLib = require('@remix-project/remix-lib')
const remixDebug = require('@remix-project/remix-debug')
const css = require('./styles/debugger-tab-styles')
import toaster from '../ui/tooltip'
const DebuggerUI = require('./debugger/debuggerUI')
@ -59,7 +59,7 @@ class DebuggerTab extends ViewPlugin {
this,
this.el.querySelector('#debugger'),
(address, receipt) => {
const target = (address && remixLib.helpers.trace.isContractCreation(address)) ? receipt.contractAddress : address
const target = (address && remixDebug.traceHelper.isContractCreation(address)) ? receipt.contractAddress : address
return this.call('fetchAndCompile', 'resolve', target || receipt.contractAddress || receipt.to, '.debug', this.blockchain.web3())
}
)

@ -11,9 +11,9 @@ var EventManager = require('../../../lib/events')
var globalRegistry = require('../../../global/registry')
var remixLib = require('@remix-project/remix-lib')
var remixDebug = require('@remix-project/remix-debug')
var init = remixLib.init
var init = remixDebug.init
var yo = require('yo-yo')
var csjs = require('csjs-inject')

@ -1,7 +1,7 @@
'use strict'
var yo = require('yo-yo')
var async = require('async')
var remixLib = require('@remix-project/remix-lib')
var remixDebug = require('@remix-project/remix-debug')
var EventManager = require('../lib/events')
var CompilerImport = require('../app/compiler/compiler-imports')
@ -116,7 +116,7 @@ class CmdInterpreterAPI {
}
self.d.goTo = (row) => {
if (self._deps.editor.current()) {
var breakPoint = new remixLib.code.BreakpointManager(self.d, (sourceLocation) => {
var breakPoint = new remixDebug.BreakpointManager(self.d, (sourceLocation) => {
return self._deps.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file,
self._deps.compilersArtefacts['__last'].getSourceCode().sources,
self._deps.compilersArtefacts['__last'].getAsts())

@ -1,7 +1,7 @@
'use strict'
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../package.json'
const SourceMappingDecoder = require('@remix-project/remix-lib').SourceMappingDecoder
var SourceMappingDecoder = require('@remix-project/remix-debug').SourceMappingDecoder
const profile = {
name: 'offsetToLineColumnConverter',

@ -1,4 +1,5 @@
'use strict'
const init = require('./src/init')
const EthDebugger = require('./src/Ethdebugger')
const TransactionDebugger = require('./src/debugger/debugger')
const CmdLine = require('./src/cmdline')
@ -8,8 +9,12 @@ const StorageResolver = require('./src/storage/storageResolver')
const SolidityDecoder = require('./src/solidity-decoder')
const remixLib = require('@remix-project/remix-lib')
const BreakpointManager = remixLib.code.BreakpointManager
const BreakpointManager = require('./src/code/breakpointManager')
const SourceMappingDecoder = require('./src/source/sourceMappingDecoder')
const AstWalker = require('./src/source/astWalker')
const traceHelper = require('./src/trace/traceHelper')
/*
Use of breakPointManager :
@ -20,6 +25,10 @@ const BreakpointManager = remixLib.code.BreakpointManager
this.debugger.setBreakpointManager(breakPointManager)
*/
module.exports = {
init,
traceHelper,
SourceMappingDecoder,
AstWalker,
EthDebugger: EthDebugger,
TransactionDebugger: TransactionDebugger,
/**
@ -36,4 +45,3 @@ module.exports = {
},
CmdLine: CmdLine
}

@ -1,16 +1,15 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const TraceManager = remixLib.trace.TraceManager
const CodeManager = remixLib.code.CodeManager
const traceHelper = remixLib.helpers.trace
const EventManager = remixLib.EventManager
const {SolidityProxy, stateDecoder, localDecoder, InternalCallTree} = require('./solidity-decoder')
const StorageViewer = require('./storage/storageViewer')
const StorageResolver = require('./storage/storageResolver')
const TraceManager = require('./trace/traceManager')
const CodeManager = require('./code/codeManager')
const traceHelper = require('./trace/traceHelper')
const EventManager = require('./eventManager')
const {SolidityProxy, stateDecoder, localDecoder, InternalCallTree} = require('./solidity-decoder')
/**
* Ethdebugger is a wrapper around a few classes that helps debugging a transaction
*

@ -1,58 +0,0 @@
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const Web3Providers = remixLib.vm.Web3Providers
const DummyProvider = remixLib.vm.DummyProvider
const init = remixLib.init
class ContextManager {
constructor (executionContext) {
this.executionContext = executionContext
this.web3 = this.executionContext.web3()
this.event = new EventManager()
}
initProviders () {
this.web3Providers = new Web3Providers()
this.addProvider('DUMMYWEB3', new DummyProvider())
this.switchProvider('DUMMYWEB3')
this.addProvider('vm', this.executionContext.vm())
this.addProvider('injected', this.executionContext.internalWeb3())
this.addProvider('web3', this.executionContext.internalWeb3())
this.switchProvider(this.executionContext.getProvider())
}
getWeb3 () {
return this.web3
}
addProvider (type, obj) {
this.web3Providers.addProvider(type, obj)
this.event.trigger('providerAdded', [type])
}
switchProvider (type, cb) {
this.web3Providers.get(type, (error, obj) => {
if (error) {
// console.log('provider ' + type + ' not defined')
} else {
this.web3 = obj
this.executionContext.detectNetwork((error, network) => {
if (error || !network) {
this.web3 = obj
} else {
var webDebugNode = init.web3DebugNode(network.name)
this.web3 = (!webDebugNode ? obj : webDebugNode)
}
this.event.trigger('providerChanged', [type, this.web3])
if (cb) return cb()
})
this.event.trigger('providerChanged', [type, this.web3])
}
})
}
}
module.exports = ContextManager

@ -1,14 +1,10 @@
const Web3 = require('web3')
const Debugger = require('../debugger/debugger.js')
const ContextManager = require('./contextManager.js')
import EventManager from 'events'
const remixLib = require('@remix-project/remix-lib')
const executionContext = remixLib.execution.executionContext
class CmdLine {
constructor () {
this.executionContext = executionContext
this.events = new EventManager()
this.lineColumnPos = null
this.rawLocation = null
@ -32,21 +28,10 @@ class CmdLine {
}
initDebugger (cb) {
this.contextManager = new ContextManager(this.executionContext)
this.debugger = new Debugger({
web3: this.contextManager.getWeb3(),
web3: this.web3,
compilationResult: () => { return this.compilation.compilationResult }
})
this.contextManager.event.register('providerChanged', () => {
this.debugger.updateWeb3(this.contextManager.getWeb3())
})
this.contextManager.initProviders()
this.contextManager.addProvider('debugger_web3', this.web3)
this.contextManager.switchProvider('debugger_web3', cb)
}
getSource () {

@ -1,7 +1,7 @@
'use strict'
const EventManager = require('../eventManager')
const helper = require('../helpers/traceHelper')
const helper = require('../trace/traceHelper')
/**
* allow to manage breakpoint
@ -21,7 +21,7 @@ class BreakpointManager {
this.breakpoints = {}
this.locationToRowConverter = _locationToRowConverter
this.previousLine
this.jumpToCallback = _jumpToCallback || (() => {})
this.jumpToCallback = _jumpToCallback || (() => {}) // eslint-disable-line
}
/**

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

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

@ -1,5 +1,5 @@
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const EventManager = require('../eventManager')
const ui = remixLib.helpers.ui
const StorageResolver = require('../storage/storageResolver')
const StorageViewer = require('../storage/storageViewer')

@ -1,9 +1,8 @@
'use strict'
const Ethdebugger = require('../Ethdebugger')
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const traceHelper = remixLib.helpers.trace
const OffsetToColumnConverter = remixLib.OffsetToColumnConverter
const EventManager = require('../eventManager')
const traceHelper = require('../trace/traceHelper')
const BreakpointManager = require('../code/breakpointManager')
const StepManager = require('./stepManager')
const VmDebuggerLogic = require('./VmDebugger')
@ -11,7 +10,7 @@ const VmDebuggerLogic = require('./VmDebugger')
function Debugger (options) {
this.event = new EventManager()
this.offsetToLineColumnConverter = options.offsetToLineColumnConverter || (new OffsetToColumnConverter())
this.offsetToLineColumnConverter = options.offsetToLineColumnConverter
/*
Returns a compilation result for a given address or the last one available if none are found
*/
@ -22,7 +21,7 @@ function Debugger (options) {
compilationResult: this.compilationResult
})
this.breakPointManager = new remixLib.code.BreakpointManager(this.debugger, async (sourceLocation) => {
this.breakPointManager = new BreakpointManager(this.debugger, async (sourceLocation) => {
const compilationResult = await this.compilationResult()
if (!compilationResult) return { start: null, end: null }
return this.offsetToLineColumnConverter.offsetToLineColumn(sourceLocation, sourceLocation.file, compilationResult.source.sources, compilationResult.data.sources)

@ -1,5 +1,4 @@
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const EventManager = require('../eventManager')
const localDecoder = require('../solidity-decoder/localDecoder')
const StorageViewer = require('../storage/storageViewer')

@ -1,5 +1,4 @@
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const EventManager = require('../eventManager')
const stateDecoder = require('../solidity-decoder/stateDecoder')
const StorageViewer = require('../storage/storageViewer')

@ -1,5 +1,5 @@
const remixLib = require('@remix-project/remix-lib')
const EventManager = remixLib.EventManager
const EventManager = require('../eventManager')
const util = remixLib.util
class DebuggerStepManager {

@ -0,0 +1,76 @@
'use strict'
const Web3 = require('web3')
module.exports = {
loadWeb3: function (url) {
if (!url) url = 'http://localhost:8545'
const web3 = new Web3()
web3.setProvider(new web3.providers.HttpProvider(url))
this.extend(web3)
return web3
},
extendWeb3: function (web3) {
this.extend(web3)
},
setProvider: function (web3, url) {
web3.setProvider(new web3.providers.HttpProvider(url))
},
web3DebugNode: function (network) {
if (web3DebugNodes[network]) {
return this.loadWeb3(web3DebugNodes[network])
}
return null
},
extend: function (web3) {
if (!web3.extend) {
return
}
// DEBUG
const methods = []
if (!(web3.debug && web3.debug.preimage)) {
methods.push(new web3.extend.Method({
name: 'preimage',
call: 'debug_preimage',
inputFormatter: [null],
params: 1
}))
}
if (!(web3.debug && web3.debug.traceTransaction)) {
methods.push(new web3.extend.Method({
name: 'traceTransaction',
call: 'debug_traceTransaction',
inputFormatter: [null, null],
params: 2
}))
}
if (!(web3.debug && web3.debug.storageRangeAt)) {
methods.push(new web3.extend.Method({
name: 'storageRangeAt',
call: 'debug_storageRangeAt',
inputFormatter: [null, null, null, null, null],
params: 5
}))
}
if (methods.length > 0) {
web3.extend({
property: 'debug',
methods: methods,
properties: []
})
}
}
}
const web3DebugNodes = {
'Main': 'https://gethmainnet.komputing.org',
'Rinkeby': 'https://remix-rinkeby.ethdevops.io',
'Ropsten': 'https://remix-ropsten.ethdevops.io',
'Goerli': 'https://remix-goerli.ethdevops.io',
'Kovan': 'https://remix-kovan.ethdevops.io'
}

@ -1,6 +1,5 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const AstWalker = remixLib.AstWalker
const AstWalker = require('../source/astWalker')
/**
* return all contract definitions of the given @astList

@ -1,11 +1,12 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const SourceLocationTracker = remixLib.SourceLocationTracker
const AstWalker = remixLib.AstWalker
const EventManager = remixLib.EventManager
const SourceLocationTracker = require('../source/sourceLocationTracker')
const AstWalker = require('../source/astWalker')
const EventManager = require('../eventManager')
const decodeInfo = require('./decodeInfo')
const util = remixLib.util
const traceHelper = remixLib.helpers.trace
const traceHelper = require('../trace/traceHelper')
const typesUtil = require('./types/util.js')
/**

@ -1,6 +1,6 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const traceHelper = remixLib.helpers.trace
const traceHelper = require('../trace/traceHelper')
const stateDecoder = require('./stateDecoder')
const astHelper = require('./astHelper')
const util = remixLib.util

@ -2,8 +2,7 @@
/**
* Crawl the given AST through the function walk(ast, callback)
*/
function AstWalker () {
}
function AstWalker () {} // eslint-disable-line
/**
* visit all the AST nodes

@ -4,10 +4,9 @@ const SourceMappingDecoder = require('./sourceMappingDecoder')
function offsetToColumnConverter (compilerEvent) {
this.lineBreakPositionsByContent = {}
this.sourceMappingDecoder = new SourceMappingDecoder()
var self = this
if (compilerEvent) {
compilerEvent.register('compilationFinished', (success, data, source) => {
self.clear()
this.clear()
})
}
}

@ -1,8 +1,9 @@
'use strict'
const EventManager = require('./eventManager')
const helper = require('./helpers/traceHelper')
const EventManager = require('../eventManager')
const helper = require('../trace/traceHelper')
const SourceMappingDecoder = require('./sourceMappingDecoder')
const util = require('./util')
const remixLib = require('@remix-project/remix-lib')
const util = remixLib.util
/**
* Process the source code location for the current executing bytecode

@ -1,5 +1,6 @@
'use strict'
const util = require('./util')
const remixLib = require('@remix-project/remix-lib')
const util = remixLib.util
const AstWalker = require('./astWalker')
/**

@ -1,6 +1,5 @@
'use strict'
const remixLib = require('@remix-project/remix-lib')
const traceHelper = remixLib.helpers.trace
const traceHelper = require('../trace/traceHelper')
const mappingPreimages = require('./mappingPreimages')
/**

@ -1,5 +1,5 @@
'use strict'
const traceHelper = require('../helpers/traceHelper')
const traceHelper = require('./traceHelper')
function TraceAnalyser (_cache) {
this.traceCache = _cache

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

@ -1,5 +1,6 @@
'use strict'
const ui = require('./uiHelper')
const remixLib = require('@remix-project/remix-lib')
const ui = remixLib.helpers.ui
module.exports = {
// vmTraceIndex has to point to a CALL, CODECALL, ...

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

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

@ -1,6 +1,6 @@
'use strict'
const tape = require('tape')
const AstWalker = require('../src/astWalker')
const AstWalker = require('../src/source/astWalker')
const node = require('./resources/ast')
tape('ASTWalker', function (t) {

@ -1,34 +1,19 @@
'use strict'
const tape = require('tape')
const Web3Providers = require('../src/web3Provider/web3Providers')
const TraceManager = require('../src/trace/traceManager')
const CodeManager = require('../src/code/codeManager')
const web3Test = require('./resources/testWeb3')
let web3 = null
tape('CodeManager', function (t) {
let codeManager
const web3Providers = new Web3Providers()
web3Providers.addProvider('TEST', web3Test)
web3Providers.get('TEST', function (error, obj) {
if (error) {
const mes = 'provider TEST not defined'
console.log(mes)
t.fail(mes)
} else {
web3 = obj
const traceManager = new TraceManager({web3: web3})
codeManager = new CodeManager(traceManager)
const contractCode = web3.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary
const tx = web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
traceManager.resolveTrace(tx).then(() => {
continueTesting(t, codeManager)
}).catch(() => {
t.fail(' - traceManager.resolveTrace - failed ')
})
}
const traceManager = new TraceManager({web3: web3Test})
let codeManager = new CodeManager(traceManager)
const contractCode = web3Test.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5')
codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary
const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
traceManager.resolveTrace(tx).then(() => {
continueTesting(t, codeManager)
}).catch(() => {
t.fail(' - traceManager.resolveTrace - failed ')
})
})
@ -61,7 +46,7 @@ function continueTesting (t, codeManager) {
}
}
})
const tx = web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
codeManager.resolveStep(0, tx)
codeManager.resolveStep(70, tx)
})
@ -84,4 +69,4 @@ function continueTesting (t, codeManager) {
st.fail(error)
}
})
}
}

@ -1,6 +1,8 @@
var tape = require('tape')
var remixLib = require('@remix-project/remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput
var compilerInput = require('./helpers/compilerHelper').compilerInput
var SourceMappingDecoder = require('../src/source/sourceMappingDecoder')
var vmCall = require('./vmCall')
var Debugger = require('../src/Ethdebugger')
var compiler = require('solc')
@ -146,7 +148,7 @@ contract Ballot {
}
`
var BreakpointManager = remixLib.code.BreakpointManager
var BreakpointManager = require('../src/code/breakpointManager')
var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
var vm = vmCall.initVM(privateKey)
@ -270,7 +272,7 @@ function testDebugging (debugManager) {
tape('breakPointManager', (t) => {
t.plan(2)
var sourceMappingDecoder = new remixLib.SourceMappingDecoder()
var sourceMappingDecoder = new SourceMappingDecoder()
var breakPointManager = new BreakpointManager(debugManager, (rawLocation) => {
return sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, sourceMappingDecoder.getLinebreakPositions(ballot))
})

@ -6,8 +6,7 @@ var decodeInfo = require('../../src/solidity-decoder/decodeInfo')
var stateDecoder = require('../../src/solidity-decoder/stateDecoder')
var contracts = require('./contracts/miscContracts')
var simplecontracts = require('./contracts/simpleContract')
var remixLib = require('@remix-project/remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput
var compilerInput = require('../helpers/compilerHelper').compilerInput
var util = require('../../src/solidity-decoder/types/util')
tape('solidity', function (t) {

@ -4,13 +4,12 @@ var compiler = require('solc')
var intLocal = require('./contracts/intLocal')
var miscLocal = require('./contracts/miscLocal')
var structArrayLocal = require('./contracts/structArrayLocal')
var remixLib = require('@remix-project/remix-lib')
var vmCall = require('./vmCall')
var intLocalTest = require('./localsTests/int')
var miscLocalTest = require('./localsTests/misc')
var misc2LocalTest = require('./localsTests/misc2')
var structArrayLocalTest = require('./localsTests/structArray')
var compilerInput = remixLib.helpers.compiler.compilerInput
var compilerInput = require('../helpers/compilerHelper').compilerInput
tape('solidity', function (t) {
t.test('local decoder', function (st) {

@ -3,13 +3,13 @@
var vmCall = require('../vmCall')
var remixLib = require('@remix-project/remix-lib')
var TraceManager = remixLib.trace.TraceManager
var CodeManager = remixLib.code.CodeManager
var TraceManager = require('../../../src/trace/traceManager')
var CodeManager = require('../../../src/code/codeManager')
var traceHelper = remixLib.helpers.trace
var traceHelper = require('../../../src/trace/traceHelper')
var SolidityProxy = require('../../../src/solidity-decoder/solidityProxy')
var InternalCallTree = require('../../../src/solidity-decoder/internalCallTree')
var EventManager = remixLib.EventManager
var EventManager = require('../../../src/eventManager')
var helper = require('./helper')
module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) {

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

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

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

@ -1,6 +1,5 @@
var remixLib = require('@remix-project/remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput
var TraceManager = remixLib.trace.TraceManager
var compilerInput = require('../../helpers/compilerHelper').compilerInput
var TraceManager = require('../../../src/trace/traceManager')
var compiler = require('solc')
var stateDecoder = require('../../../src/solidity-decoder/stateDecoder')

@ -3,8 +3,7 @@ var tape = require('tape')
var compiler = require('solc')
var stateDecoder = require('../../src/solidity-decoder/stateDecoder')
var MockStorageResolver = require('./mockStorageResolver')
var remixLib = require('@remix-project/remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput
var compilerInput = require('../helpers/compilerHelper').compilerInput
var testMappingStorage = require('./stateTests/mapping')
tape('solidity', function (t) {

@ -3,8 +3,7 @@ var tape = require('tape')
var compiler = require('solc')
var stateDecoder = require('../../src/solidity-decoder/stateDecoder')
var contracts = require('./contracts/miscContracts')
var remixLib = require('@remix-project/remix-lib')
var compilerInput = remixLib.helpers.compiler.compilerInput
var compilerInput = require('../helpers/compilerHelper').compilerInput
tape('solidity', function (t) {
t.test('storage location', function (st) {

@ -46,9 +46,7 @@ function createVm (hardfork) {
hardfork
})
vm.blockchain.validate = false
const web3vm = new remixLib.vm.Web3VMProvider()
web3vm.setVM(vm)
return { vm, web3vm, stateManager: vm.stateManager }
return { vm, stateManager: vm.stateManager }
}
/*
@ -68,17 +66,9 @@ function initVM (st, privateKey) {
})
})
var web3Providers = new remixLib.vm.Web3Providers()
web3Providers.addVM('VM', vm)
web3Providers.get('VM', function (error, obj) {
if (error) {
var mes = 'provider TEST not defined'
console.log(mes)
st.fail(mes)
} else {
vm.web3 = obj
}
})
var web3Provider = new remixLib.vm.Web3VMProvider()
web3Provider.setVM(vm)
vm.web3 = web3Provider
return vm
}

@ -0,0 +1,26 @@
module.exports = {
compilerInput: compilerInput
}
function compilerInput (contracts) {
return JSON.stringify({
language: 'Solidity',
sources: {
'test.sol': {
content: contracts
}
},
settings: {
optimizer: {
enabled: false,
runs: 200
},
outputSelection: {
'*': {
'': [ 'legacyAST', 'ast' ],
'*': [ 'abi', 'metadata', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates' ]
}
}
}
})
}

@ -1,9 +1,9 @@
'use strict'
const tape = require('tape')
const sourceMapping = require('./resources/sourceMapping')
const SourceMappingDecoder = require('../src/sourceMappingDecoder')
const SourceMappingDecoder = require('../src/source/sourceMappingDecoder')
const compiler = require('solc')
const compilerInput = require('../src/helpers/compilerHelper').compilerInput
const compilerInput = require('./helpers/compilerHelper').compilerInput
tape('SourceMappingDecoder', function (t) {
t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) {

@ -1,5 +1,10 @@
'use strict'
require('./astwalker.js')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')
require('./sourceMappingDecoder.js')
require('./decoder/decodeInfo.js')
require('./decoder/storageLocation.js')
require('./decoder/storageDecoder.js')

@ -1,32 +1,18 @@
'use strict'
const TraceManager = require('../src/trace/traceManager')
const tape = require('tape')
const Web3Providers = require('../src/web3Provider/web3Providers')
const web3Test = require('./resources/testWeb3')
let web3 = null
tape('TraceManager', function (t) {
let traceManager
t.test('TraceManager.init', function (st) {
const web3Providers = new Web3Providers()
web3Providers.addProvider('TEST', web3Test)
web3Providers.get('TEST', function (error, obj) {
if (error) {
const mes = 'provider TEST not defined'
console.log(mes)
st.fail(mes)
} else {
web3 = obj
traceManager = new TraceManager({web3: web3})
st.end()
}
})
traceManager = new TraceManager({web3: web3Test})
st.end()
})
t.test('TraceManager.resolveTrace', function (st) {
const tx = web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
const tx = web3Test.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51')
traceManager.resolveTrace(tx).then(() => {
st.end()
}).catch(() => {

@ -38,7 +38,6 @@ function sendTx (vm, from, to, value, data, cb) {
*/
function initVM (privateKey) {
var VM = require('ethereumjs-vm').default
var Web3Providers = remixLib.vm.Web3Providers
var address = utileth.privateToAddress(privateKey)
var vm = new VM({
enableHomestead: true,
@ -53,16 +52,9 @@ function initVM (privateKey) {
})
})
var web3Providers = new Web3Providers()
web3Providers.addVM('VM', vm)
web3Providers.get('VM', function (error, obj) {
if (error) {
var mes = 'provider TEST not defined'
console.log(mes)
} else {
vm.web3 = obj
}
})
var web3Provider = new remixLib.vm.Web3VMProvider()
web3Provider.setVM(vm)
vm.web3 = web3Provider
return vm
}

@ -1,16 +1,10 @@
const EventManager = require('./src/eventManager')
const traceHelper = require('./src/helpers/traceHelper')
const uiHelper = require('./src/helpers/uiHelper')
const compilerHelper = require('./src/helpers/compilerHelper')
const SourceMappingDecoder = require('./src/sourceMappingDecoder')
const SourceLocationTracker = require('./src/sourceLocationTracker')
const OffsetToColumnConverter = require('./src/offsetToLineColumnConverter')
const init = require('./src/init')
const util = require('./src/util')
const Web3Providers = require('./src/web3Provider/web3Providers')
const DummyProvider = require('./src/web3Provider/dummyProvider')
const Web3VMProvider = require('./src/web3Provider/web3VmProvider')
const AstWalker = require('./src/astWalker')
const Storage = require('./src/storage')
const EventsDecoder = require('./src/execution/eventsDecoder')
@ -19,13 +13,9 @@ const txHelper = require('./src/execution/txHelper')
const txFormat = require('./src/execution/txFormat')
const txListener = require('./src/execution/txListener')
const txRunner = require('./src/execution/txRunner')
const executionContext = require('./src/execution/execution-context')
const ExecutionContext = require('./src/execution/execution-context')
const typeConversion = require('./src/execution/typeConversion')
const CodeManager = require('./src/code/codeManager')
const BreakpointManager = require('./src/code/breakpointManager')
const TraceManager = require('./src/trace/traceManager')
const UniversalDApp = require('./src/universalDapp')
if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') {
@ -34,16 +24,8 @@ if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined')
function modules () {
return {
code: {
CodeManager: CodeManager,
BreakpointManager: BreakpointManager
},
trace: {
TraceManager: TraceManager
},
EventManager: EventManager,
helpers: {
trace: traceHelper,
ui: uiHelper,
compiler: compilerHelper
},
@ -52,18 +34,13 @@ function modules () {
DummyProvider: DummyProvider,
Web3VMProvider: Web3VMProvider
},
SourceMappingDecoder: SourceMappingDecoder,
SourceLocationTracker: SourceLocationTracker,
OffsetToColumnConverter: OffsetToColumnConverter,
Storage: Storage,
init: init,
util: util,
AstWalker: AstWalker,
execution: {
EventsDecoder: EventsDecoder,
txExecution: txExecution,
txHelper: txHelper,
executionContext: new executionContext(),
executionContext: new ExecutionContext(),
txFormat: txFormat,
txListener: txListener,
txRunner: txRunner,

@ -1,18 +1,17 @@
const util = require('../util')
const uiutil = require('../helpers/uiHelper')
const traceHelper = require('../helpers/traceHelper')
const ethutil = require('ethereumjs-util')
const Web3 = require('web3')
function web3VmProvider () {
this.web3 = new Web3()
this.vm
this.vm = null
this.vmTraces = {}
this.txs = {}
this.txsReceipt = {}
this.processingHash
this.processingAddress
this.processingIndex
this.processingHash = null
this.processingAddress = null
this.processingIndex = null
this.previousDepth = 0
this.incr = 0
this.eth = {}
@ -26,7 +25,7 @@ function web3VmProvider () {
this.debug.storageRangeAt = (...args) => this.storageRangeAt(...args)
this.debug.preimage = (...args) => this.preimage(...args)
this.providers = { 'HttpProvider': function (url) {} }
this.currentProvider = {'host': 'vm provider'}
this.currentProvider = { 'host': 'vm provider' }
this.storageCache = {}
this.lastProcessedStorageTxHash = {}
this.sha3Preimages = {}
@ -168,9 +167,9 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
error: data.error === false ? undefined : data.error
}
self.vmTraces[self.processingHash].structLogs.push(step)
if (traceHelper.newContextStorage(step)) {
if (step.op === 'CREATE' || step.op === 'CALL') {
if (step.op === 'CREATE') {
this.processingAddress = traceHelper.contractCreationToken(this.processingIndex)
this.processingAddress = '(Contract Creation - Step ' + this.processingIndex + ')'
this.storageCache[this.processingHash][this.processingAddress] = {}
this.lastProcessedStorageTxHash[this.processingAddress] = this.processingHash
} else {
@ -184,7 +183,7 @@ web3VmProvider.prototype.pushTrace = function (self, data) {
}
}
}
if (previousopcode && traceHelper.isSHA3Instruction(previousopcode)) {
if (previousopcode && previousopcode.op === 'SHA3') {
const preimage = getSha3Input(previousopcode.stack, previousopcode.memory)
const imageHash = step.stack[step.stack.length - 1].replace('0x', '')
self.sha3Preimages[imageHash] = {

@ -1,51 +0,0 @@
'use strict'
const init = require('../init')
const web3Override = {}
web3Override.eth = {}
web3Override.debug = {}
let 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

File diff suppressed because one or more lines are too long

@ -1,11 +1,5 @@
require('./astwalker.js')
require('./eventManager.js')
require('./sourceMappingDecoder.js')
require('./util.js')
require('./txFormat.js')
require('./txHelper.js')
require('./traceManager.js')
require('./codeManager.js')
require('./disassembler.js')
require('./txResultHelper.js')

@ -3,7 +3,7 @@
import { update } from 'solc/abi'
import * as webworkify from 'webworkify-webpack'
import compilerInput from './compiler-input'
import { EventManager } from '../lib/eventManager'
import EventManager from '../lib/eventManager'
import { default as txHelper } from './txHelper';
import { Source, SourceWithTarget, MessageFromWorker, CompilerState, CompilationResult,
visitContractsCallbackParam, visitContractsCallbackInterface, CompilationError,

@ -0,0 +1,68 @@
'use strict'
export default class EventManager {
registered: any = {} // eslint-disable-line
anonymous: any = {} // eslint-disable-line
/*
* Unregister a listener.
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
unregister (eventName: any, obj: any, func: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
return
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
}
for (const reg in this.registered[eventName]) {
if (this.registered[eventName][reg].obj === obj && this.registered[eventName][reg].func === func) {
this.registered[eventName].splice(reg, 1)
}
}
}
/*
* Register a new listener.
* Note that if obj is a function, the function registration will be associated with the dummy object {}
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
register (eventName: any, obj: any, func: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
this.registered[eventName] = []
}
if (obj instanceof Function) {
func = obj
obj = this.anonymous
}
this.registered[eventName].push({
obj: obj,
func: func
})
}
/*
* trigger event.
* Every listener have their associated function executed
*
* @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the executed function.
*/
trigger (eventName: any, args: any): void { // eslint-disable-line
if (!this.registered[eventName]) {
return
}
for (const listener in this.registered[eventName]) {
const l = this.registered[eventName][listener]
l.func.apply(l.obj === this.anonymous ? {} : l.obj, args)
}
}
}
Loading…
Cancel
Save