diff --git a/apps/remix-ide/src/app/editor/contextView.js b/apps/remix-ide/src/app/editor/contextView.js index 9ec89edc1e..0e7bec3385 100644 --- a/apps/remix-ide/src/app/editor/contextView.js +++ b/apps/remix-ide/src/app/editor/contextView.js @@ -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') diff --git a/apps/remix-ide/src/app/editor/contextualListener.js b/apps/remix-ide/src/app/editor/contextualListener.js index 8db324be53..aec3f06163 100644 --- a/apps/remix-ide/src/app/editor/contextualListener.js +++ b/apps/remix-ide/src/app/editor/contextualListener.js @@ -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' diff --git a/apps/remix-ide/src/app/tabs/debugger-tab.js b/apps/remix-ide/src/app/tabs/debugger-tab.js index 8a05c979ee..5bc5c32d95 100644 --- a/apps/remix-ide/src/app/tabs/debugger-tab.js +++ b/apps/remix-ide/src/app/tabs/debugger-tab.js @@ -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()) } ) diff --git a/apps/remix-ide/src/app/tabs/debugger/debuggerUI.js b/apps/remix-ide/src/app/tabs/debugger/debuggerUI.js index 06a7d14bc9..f37bda0d0c 100644 --- a/apps/remix-ide/src/app/tabs/debugger/debuggerUI.js +++ b/apps/remix-ide/src/app/tabs/debugger/debuggerUI.js @@ -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') diff --git a/apps/remix-ide/src/lib/cmdInterpreterAPI.js b/apps/remix-ide/src/lib/cmdInterpreterAPI.js index 010e4b016f..8f609c279a 100644 --- a/apps/remix-ide/src/lib/cmdInterpreterAPI.js +++ b/apps/remix-ide/src/lib/cmdInterpreterAPI.js @@ -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()) diff --git a/apps/remix-ide/src/lib/offsetToLineColumnConverter.js b/apps/remix-ide/src/lib/offsetToLineColumnConverter.js index e0f893a0e2..f252174df6 100644 --- a/apps/remix-ide/src/lib/offsetToLineColumnConverter.js +++ b/apps/remix-ide/src/lib/offsetToLineColumnConverter.js @@ -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', diff --git a/libs/remix-debug/index.js b/libs/remix-debug/index.js index fddf73a1cd..6cfefa6ab0 100644 --- a/libs/remix-debug/index.js +++ b/libs/remix-debug/index.js @@ -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 } - diff --git a/libs/remix-debug/src/Ethdebugger.js b/libs/remix-debug/src/Ethdebugger.js index a2b61fd8f5..432fe28db3 100644 --- a/libs/remix-debug/src/Ethdebugger.js +++ b/libs/remix-debug/src/Ethdebugger.js @@ -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 * diff --git a/libs/remix-debug/src/cmdline/contextManager.js b/libs/remix-debug/src/cmdline/contextManager.js deleted file mode 100644 index d176a6b48e..0000000000 --- a/libs/remix-debug/src/cmdline/contextManager.js +++ /dev/null @@ -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 diff --git a/libs/remix-debug/src/cmdline/index.js b/libs/remix-debug/src/cmdline/index.js index 583060a9a2..8e928f7ad0 100644 --- a/libs/remix-debug/src/cmdline/index.js +++ b/libs/remix-debug/src/cmdline/index.js @@ -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 () { diff --git a/libs/remix-lib/src/code/breakpointManager.js b/libs/remix-debug/src/code/breakpointManager.js similarity index 98% rename from libs/remix-lib/src/code/breakpointManager.js rename to libs/remix-debug/src/code/breakpointManager.js index 7c70742116..2d6474be1d 100644 --- a/libs/remix-lib/src/code/breakpointManager.js +++ b/libs/remix-debug/src/code/breakpointManager.js @@ -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 } /** diff --git a/libs/remix-lib/src/code/codeManager.js b/libs/remix-debug/src/code/codeManager.js similarity index 97% rename from libs/remix-lib/src/code/codeManager.js rename to libs/remix-debug/src/code/codeManager.js index 3f4df37b6f..806ea8bc98 100644 --- a/libs/remix-lib/src/code/codeManager.js +++ b/libs/remix-debug/src/code/codeManager.js @@ -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') /* diff --git a/libs/remix-lib/src/code/codeResolver.js b/libs/remix-debug/src/code/codeResolver.js similarity index 100% rename from libs/remix-lib/src/code/codeResolver.js rename to libs/remix-debug/src/code/codeResolver.js diff --git a/libs/remix-lib/src/code/codeUtils.js b/libs/remix-debug/src/code/codeUtils.js similarity index 100% rename from libs/remix-lib/src/code/codeUtils.js rename to libs/remix-debug/src/code/codeUtils.js diff --git a/libs/remix-lib/src/code/disassembler.js b/libs/remix-debug/src/code/disassembler.js similarity index 95% rename from libs/remix-lib/src/code/disassembler.js rename to libs/remix-debug/src/code/disassembler.js index 332cf3d78e..6c0668c59c 100644 --- a/libs/remix-lib/src/code/disassembler.js +++ b/libs/remix-debug/src/code/disassembler.js @@ -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 = [] diff --git a/libs/remix-lib/src/code/opcodes.js b/libs/remix-debug/src/code/opcodes.js similarity index 100% rename from libs/remix-lib/src/code/opcodes.js rename to libs/remix-debug/src/code/opcodes.js diff --git a/libs/remix-debug/src/debugger/VmDebugger.js b/libs/remix-debug/src/debugger/VmDebugger.js index 8892f76b57..374ba948fb 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.js +++ b/libs/remix-debug/src/debugger/VmDebugger.js @@ -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') diff --git a/libs/remix-debug/src/debugger/debugger.js b/libs/remix-debug/src/debugger/debugger.js index 434a318381..7164011925 100644 --- a/libs/remix-debug/src/debugger/debugger.js +++ b/libs/remix-debug/src/debugger/debugger.js @@ -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) diff --git a/libs/remix-debug/src/debugger/solidityLocals.js b/libs/remix-debug/src/debugger/solidityLocals.js index 9368172da2..7f2c0e7905 100644 --- a/libs/remix-debug/src/debugger/solidityLocals.js +++ b/libs/remix-debug/src/debugger/solidityLocals.js @@ -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') diff --git a/libs/remix-debug/src/debugger/solidityState.js b/libs/remix-debug/src/debugger/solidityState.js index 7bc3f6d0da..76e1517317 100644 --- a/libs/remix-debug/src/debugger/solidityState.js +++ b/libs/remix-debug/src/debugger/solidityState.js @@ -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') diff --git a/libs/remix-debug/src/debugger/stepManager.js b/libs/remix-debug/src/debugger/stepManager.js index 824bb3c7b1..736fbf79b8 100644 --- a/libs/remix-debug/src/debugger/stepManager.js +++ b/libs/remix-debug/src/debugger/stepManager.js @@ -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 { diff --git a/libs/remix-debug/src/eventManager.js b/libs/remix-debug/src/eventManager.js new file mode 100644 index 0000000000..8d1ffb9e37 --- /dev/null +++ b/libs/remix-debug/src/eventManager.js @@ -0,0 +1,70 @@ +'use strict' + +function eventManager () { + this.registered = {} + this.anonymous = {} +} + +/* + * 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 +*/ +eventManager.prototype.unregister = function (eventName, obj, func) { + if (!this.registered[eventName]) { + return + } + if (obj instanceof Function) { + func = obj + obj = this.anonymous + } + for (let 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 +*/ +eventManager.prototype.register = function (eventName, obj, func) { + 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. +*/ +eventManager.prototype.trigger = function (eventName, args) { + if (!this.registered[eventName]) { + return + } + for (let listener in this.registered[eventName]) { + const l = this.registered[eventName][listener] + l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) + } +} + +module.exports = eventManager \ No newline at end of file diff --git a/libs/remix-debug/src/init.js b/libs/remix-debug/src/init.js new file mode 100644 index 0000000000..9c709e3efd --- /dev/null +++ b/libs/remix-debug/src/init.js @@ -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' +} diff --git a/libs/remix-debug/src/solidity-decoder/astHelper.js b/libs/remix-debug/src/solidity-decoder/astHelper.js index 2ac023bcc7..ab9b030879 100644 --- a/libs/remix-debug/src/solidity-decoder/astHelper.js +++ b/libs/remix-debug/src/solidity-decoder/astHelper.js @@ -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 diff --git a/libs/remix-debug/src/solidity-decoder/internalCallTree.js b/libs/remix-debug/src/solidity-decoder/internalCallTree.js index 56d41d4faa..4c018d89d2 100644 --- a/libs/remix-debug/src/solidity-decoder/internalCallTree.js +++ b/libs/remix-debug/src/solidity-decoder/internalCallTree.js @@ -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') /** diff --git a/libs/remix-debug/src/solidity-decoder/solidityProxy.js b/libs/remix-debug/src/solidity-decoder/solidityProxy.js index e4f10a53e6..8ff81ea4fd 100644 --- a/libs/remix-debug/src/solidity-decoder/solidityProxy.js +++ b/libs/remix-debug/src/solidity-decoder/solidityProxy.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 diff --git a/libs/remix-lib/src/astWalker.js b/libs/remix-debug/src/source/astWalker.js similarity index 97% rename from libs/remix-lib/src/astWalker.js rename to libs/remix-debug/src/source/astWalker.js index 5768b3ab98..53323dfa60 100644 --- a/libs/remix-lib/src/astWalker.js +++ b/libs/remix-debug/src/source/astWalker.js @@ -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 diff --git a/libs/remix-lib/src/offsetToLineColumnConverter.js b/libs/remix-debug/src/source/offsetToLineColumnConverter.js similarity index 97% rename from libs/remix-lib/src/offsetToLineColumnConverter.js rename to libs/remix-debug/src/source/offsetToLineColumnConverter.js index fbc2bd4436..5bf63774b7 100644 --- a/libs/remix-lib/src/offsetToLineColumnConverter.js +++ b/libs/remix-debug/src/source/offsetToLineColumnConverter.js @@ -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() }) } } diff --git a/libs/remix-lib/src/sourceLocationTracker.js b/libs/remix-debug/src/source/sourceLocationTracker.js similarity index 94% rename from libs/remix-lib/src/sourceLocationTracker.js rename to libs/remix-debug/src/source/sourceLocationTracker.js index 2ce73865c2..e5fe93e4c5 100644 --- a/libs/remix-lib/src/sourceLocationTracker.js +++ b/libs/remix-debug/src/source/sourceLocationTracker.js @@ -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 diff --git a/libs/remix-lib/src/sourceMappingDecoder.js b/libs/remix-debug/src/source/sourceMappingDecoder.js similarity index 99% rename from libs/remix-lib/src/sourceMappingDecoder.js rename to libs/remix-debug/src/source/sourceMappingDecoder.js index 2aafd0c0f5..6e0d465385 100644 --- a/libs/remix-lib/src/sourceMappingDecoder.js +++ b/libs/remix-debug/src/source/sourceMappingDecoder.js @@ -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') /** diff --git a/libs/remix-debug/src/storage/storageResolver.js b/libs/remix-debug/src/storage/storageResolver.js index 8186e87368..613aa71b29 100644 --- a/libs/remix-debug/src/storage/storageResolver.js +++ b/libs/remix-debug/src/storage/storageResolver.js @@ -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') /** diff --git a/libs/remix-lib/src/trace/traceAnalyser.js b/libs/remix-debug/src/trace/traceAnalyser.js similarity index 99% rename from libs/remix-lib/src/trace/traceAnalyser.js rename to libs/remix-debug/src/trace/traceAnalyser.js index 967f83bc83..139054414f 100644 --- a/libs/remix-lib/src/trace/traceAnalyser.js +++ b/libs/remix-debug/src/trace/traceAnalyser.js @@ -1,5 +1,5 @@ 'use strict' -const traceHelper = require('../helpers/traceHelper') +const traceHelper = require('./traceHelper') function TraceAnalyser (_cache) { this.traceCache = _cache diff --git a/libs/remix-lib/src/trace/traceCache.js b/libs/remix-debug/src/trace/traceCache.js similarity index 97% rename from libs/remix-lib/src/trace/traceCache.js rename to libs/remix-debug/src/trace/traceCache.js index a4efd60934..63c5bc9038 100644 --- a/libs/remix-lib/src/trace/traceCache.js +++ b/libs/remix-debug/src/trace/traceCache.js @@ -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() diff --git a/libs/remix-lib/src/helpers/traceHelper.js b/libs/remix-debug/src/trace/traceHelper.js similarity index 95% rename from libs/remix-lib/src/helpers/traceHelper.js rename to libs/remix-debug/src/trace/traceHelper.js index 087074743d..b97cd86557 100644 --- a/libs/remix-lib/src/helpers/traceHelper.js +++ b/libs/remix-debug/src/trace/traceHelper.js @@ -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, ... diff --git a/libs/remix-lib/src/trace/traceManager.js b/libs/remix-debug/src/trace/traceManager.js similarity index 98% rename from libs/remix-lib/src/trace/traceManager.js rename to libs/remix-debug/src/trace/traceManager.js index 7109c5c744..f71cb27931 100644 --- a/libs/remix-lib/src/trace/traceManager.js +++ b/libs/remix-debug/src/trace/traceManager.js @@ -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 diff --git a/libs/remix-lib/src/trace/traceRetriever.js b/libs/remix-debug/src/trace/traceRetriever.js similarity index 100% rename from libs/remix-lib/src/trace/traceRetriever.js rename to libs/remix-debug/src/trace/traceRetriever.js diff --git a/libs/remix-lib/src/trace/traceStepManager.js b/libs/remix-debug/src/trace/traceStepManager.js similarity index 93% rename from libs/remix-lib/src/trace/traceStepManager.js rename to libs/remix-debug/src/trace/traceStepManager.js index be877f8fb9..d3ec4a13a2 100644 --- a/libs/remix-lib/src/trace/traceStepManager.js +++ b/libs/remix-debug/src/trace/traceStepManager.js @@ -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 diff --git a/libs/remix-lib/test/astwalker.js b/libs/remix-debug/test/astwalker.js similarity index 97% rename from libs/remix-lib/test/astwalker.js rename to libs/remix-debug/test/astwalker.js index e91bbe798c..0d8d34f193 100644 --- a/libs/remix-lib/test/astwalker.js +++ b/libs/remix-debug/test/astwalker.js @@ -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) { diff --git a/libs/remix-lib/test/codeManager.js b/libs/remix-debug/test/codeManager.js similarity index 64% rename from libs/remix-lib/test/codeManager.js rename to libs/remix-debug/test/codeManager.js index 5ced6c6a74..558c89b1ee 100644 --- a/libs/remix-lib/test/codeManager.js +++ b/libs/remix-debug/test/codeManager.js @@ -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) } }) -} +} \ No newline at end of file diff --git a/libs/remix-debug/test/debugger.js b/libs/remix-debug/test/debugger.js index 5526e03f3e..41046d0a02 100644 --- a/libs/remix-debug/test/debugger.js +++ b/libs/remix-debug/test/debugger.js @@ -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)) }) diff --git a/libs/remix-debug/test/decoder/decodeInfo.js b/libs/remix-debug/test/decoder/decodeInfo.js index f10c88d23c..23f836b3fb 100644 --- a/libs/remix-debug/test/decoder/decodeInfo.js +++ b/libs/remix-debug/test/decoder/decodeInfo.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/localDecoder.js b/libs/remix-debug/test/decoder/localDecoder.js index a3ab96e09b..d87e4b3e07 100644 --- a/libs/remix-debug/test/decoder/localDecoder.js +++ b/libs/remix-debug/test/decoder/localDecoder.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/localsTests/int.js b/libs/remix-debug/test/decoder/localsTests/int.js index 2e7f5036e3..7d7a3fb3fb 100644 --- a/libs/remix-debug/test/decoder/localsTests/int.js +++ b/libs/remix-debug/test/decoder/localsTests/int.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/localsTests/misc.js b/libs/remix-debug/test/decoder/localsTests/misc.js index be40d3de6e..2b6529b375 100644 --- a/libs/remix-debug/test/decoder/localsTests/misc.js +++ b/libs/remix-debug/test/decoder/localsTests/misc.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/localsTests/misc2.js b/libs/remix-debug/test/decoder/localsTests/misc2.js index 3bdff3a259..3718eed77f 100644 --- a/libs/remix-debug/test/decoder/localsTests/misc2.js +++ b/libs/remix-debug/test/decoder/localsTests/misc2.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/localsTests/structArray.js b/libs/remix-debug/test/decoder/localsTests/structArray.js index 16235d9453..3dbef57e7c 100644 --- a/libs/remix-debug/test/decoder/localsTests/structArray.js +++ b/libs/remix-debug/test/decoder/localsTests/structArray.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/stateTests/mapping.js b/libs/remix-debug/test/decoder/stateTests/mapping.js index 2fa355f7f8..0209dc4ba5 100644 --- a/libs/remix-debug/test/decoder/stateTests/mapping.js +++ b/libs/remix-debug/test/decoder/stateTests/mapping.js @@ -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') diff --git a/libs/remix-debug/test/decoder/storageDecoder.js b/libs/remix-debug/test/decoder/storageDecoder.js index f1665736d8..3191e4736f 100644 --- a/libs/remix-debug/test/decoder/storageDecoder.js +++ b/libs/remix-debug/test/decoder/storageDecoder.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/storageLocation.js b/libs/remix-debug/test/decoder/storageLocation.js index 5e3a8596af..b2c7cca688 100644 --- a/libs/remix-debug/test/decoder/storageLocation.js +++ b/libs/remix-debug/test/decoder/storageLocation.js @@ -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) { diff --git a/libs/remix-debug/test/decoder/vmCall.js b/libs/remix-debug/test/decoder/vmCall.js index 030ff9fd67..9bc184e99d 100644 --- a/libs/remix-debug/test/decoder/vmCall.js +++ b/libs/remix-debug/test/decoder/vmCall.js @@ -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 } diff --git a/libs/remix-lib/test/disassembler.js b/libs/remix-debug/test/disassembler.js similarity index 100% rename from libs/remix-lib/test/disassembler.js rename to libs/remix-debug/test/disassembler.js diff --git a/libs/remix-debug/test/helpers/compilerHelper.js b/libs/remix-debug/test/helpers/compilerHelper.js new file mode 100644 index 0000000000..ba919c2abb --- /dev/null +++ b/libs/remix-debug/test/helpers/compilerHelper.js @@ -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' ] + } + } + } + }) +} diff --git a/libs/remix-lib/test/resources/ast.js b/libs/remix-debug/test/resources/ast.js similarity index 100% rename from libs/remix-lib/test/resources/ast.js rename to libs/remix-debug/test/resources/ast.js diff --git a/libs/remix-lib/test/resources/sourceMapping.js b/libs/remix-debug/test/resources/sourceMapping.js similarity index 100% rename from libs/remix-lib/test/resources/sourceMapping.js rename to libs/remix-debug/test/resources/sourceMapping.js diff --git a/libs/remix-lib/test/sourceMappingDecoder.js b/libs/remix-debug/test/sourceMappingDecoder.js similarity index 97% rename from libs/remix-lib/test/sourceMappingDecoder.js rename to libs/remix-debug/test/sourceMappingDecoder.js index aee0cb88ec..ebf02fafa4 100644 --- a/libs/remix-lib/test/sourceMappingDecoder.js +++ b/libs/remix-debug/test/sourceMappingDecoder.js @@ -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) { diff --git a/libs/remix-debug/test/tests.js b/libs/remix-debug/test/tests.js index 7f5ffd7818..f077d2ff73 100644 --- a/libs/remix-debug/test/tests.js +++ b/libs/remix-debug/test/tests.js @@ -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') diff --git a/libs/remix-lib/test/traceManager.js b/libs/remix-debug/test/traceManager.js similarity index 92% rename from libs/remix-lib/test/traceManager.js rename to libs/remix-debug/test/traceManager.js index ee65b82ab9..83a08b666f 100644 --- a/libs/remix-lib/test/traceManager.js +++ b/libs/remix-debug/test/traceManager.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(() => { diff --git a/libs/remix-debug/test/vmCall.js b/libs/remix-debug/test/vmCall.js index 5c7cf89f0a..1a0c74c148 100644 --- a/libs/remix-debug/test/vmCall.js +++ b/libs/remix-debug/test/vmCall.js @@ -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 } diff --git a/libs/remix-lib/index.js b/libs/remix-lib/index.js index 546cbe81a6..5b0178303d 100644 --- a/libs/remix-lib/index.js +++ b/libs/remix-lib/index.js @@ -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, diff --git a/libs/remix-lib/src/web3Provider/web3VmProvider.js b/libs/remix-lib/src/web3Provider/web3VmProvider.js index f65a342bba..e1cc274068 100644 --- a/libs/remix-lib/src/web3Provider/web3VmProvider.js +++ b/libs/remix-lib/src/web3Provider/web3VmProvider.js @@ -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] = { diff --git a/libs/remix-lib/test/resources/testWeb3.js b/libs/remix-lib/test/resources/testWeb3.js deleted file mode 100644 index 79224d5fc1..0000000000 --- a/libs/remix-lib/test/resources/testWeb3.js +++ /dev/null @@ -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 -} diff --git a/libs/remix-lib/test/resources/testWeb3.json b/libs/remix-lib/test/resources/testWeb3.json deleted file mode 100644 index ba5f88cb0f..0000000000 --- a/libs/remix-lib/test/resources/testWeb3.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "testTxs": { - "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} - }, - - "testTxsByBlock": { - "105967-0": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} - }, - - "testCodes": { - "0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605757603f565b005b605560048080359060200190919050506089565b005b606260048050506078565b6040518082815260200191505060405180910390f35b600060006000505490506086565b90565b80600060005081905550602d6040516045806100f083390180828152602001915050604051809103906000f0600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550602281016000600050819055505b505660606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055505b50600a80603b6000396000f360606040526008565b00" - }, - - "testTraces": { - "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"gas":"0x0000000000000000000000000000000000000000000000000000000000019def","return":"0x","structLogs":[{"gas":"84503","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"84500","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"84497","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"84485","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"84482","gasCost":"3","op":"CALLDATALOAD","pc":"7","stack":["0x00"]},{"gas":"84479","gasCost":"3","op":"PUSH29","pc":"8","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84476","gasCost":"3","op":"SWAP1","pc":"38","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000","0x0100000000000000000000000000000000000000000000000000000000"]},{"gas":"84473","gasCost":"5","op":"DIV","pc":"39","stack":["0x0100000000000000000000000000000000000000000000000000000000","0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84468","gasCost":"3","op":"DUP1","pc":"40","stack":["0x60fe47b1"]},{"gas":"84465","gasCost":"3","op":"PUSH4","pc":"41","stack":["0x60fe47b1","0x60fe47b1"]},{"gas":"84462","gasCost":"3","op":"EQ","pc":"46","stack":["0x60fe47b1","0x60fe47b1","0x60fe47b1"]},{"gas":"84459","gasCost":"3","op":"PUSH1","pc":"47","stack":["0x60fe47b1","0x01"]},{"gas":"84456","gasCost":"10","op":"JUMPI","pc":"49","stack":["0x60fe47b1","0x01","0x41"]},{"gas":"84446","gasCost":"1","op":"JUMPDEST","pc":"65","stack":["0x60fe47b1"]},{"gas":"84445","gasCost":"3","op":"PUSH1","pc":"66","stack":["0x60fe47b1"]},{"gas":"84442","gasCost":"3","op":"PUSH1","pc":"68","stack":["0x60fe47b1","0x55"]},{"gas":"84439","gasCost":"3","op":"DUP1","pc":"70","stack":["0x60fe47b1","0x55","0x04"]},{"gas":"84436","gasCost":"3","op":"DUP1","pc":"71","stack":["0x60fe47b1","0x55","0x04","0x04"]},{"gas":"84433","gasCost":"3","op":"CALLDATALOAD","pc":"72","stack":["0x60fe47b1","0x55","0x04","0x04","0x04"]},{"gas":"84430","gasCost":"3","op":"SWAP1","pc":"73","stack":["0x60fe47b1","0x55","0x04","0x04","0x38"]},{"gas":"84427","gasCost":"3","op":"PUSH1","pc":"74","stack":["0x60fe47b1","0x55","0x04","0x38","0x04"]},{"gas":"84424","gasCost":"3","op":"ADD","pc":"76","stack":["0x60fe47b1","0x55","0x04","0x38","0x04","0x20"]},{"gas":"84421","gasCost":"3","op":"SWAP1","pc":"77","stack":["0x60fe47b1","0x55","0x04","0x38","0x24"]},{"gas":"84418","gasCost":"3","op":"SWAP2","pc":"78","stack":["0x60fe47b1","0x55","0x04","0x24","0x38"]},{"gas":"84415","gasCost":"3","op":"SWAP1","pc":"79","stack":["0x60fe47b1","0x55","0x38","0x24","0x04"]},{"gas":"84412","gasCost":"2","op":"POP","pc":"80","stack":["0x60fe47b1","0x55","0x38","0x04","0x24"]},{"gas":"84410","gasCost":"2","op":"POP","pc":"81","stack":["0x60fe47b1","0x55","0x38","0x04"]},{"gas":"84408","gasCost":"3","op":"PUSH1","pc":"82","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84405","gasCost":"8","op":"JUMP","pc":"84","stack":["0x60fe47b1","0x55","0x38","0x89"]},{"gas":"84397","gasCost":"1","op":"JUMPDEST","pc":"137","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84396","gasCost":"3","op":"DUP1","pc":"138","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84393","gasCost":"3","op":"PUSH1","pc":"139","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"84390","gasCost":"3","op":"PUSH1","pc":"141","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84387","gasCost":"2","op":"POP","pc":"143","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x00"]},{"gas":"84385","gasCost":"3","op":"DUP2","pc":"144","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84382","gasCost":"3","op":"SWAP1","pc":"145","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x38"]},{"gas":"84379","gasCost":"5000","op":"SSTORE","pc":"146","stack":["0x60fe47b1","0x55","0x38","0x38","0x38","0x00"]},{"gas":"79379","gasCost":"2","op":"POP","pc":"147","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"79377","gasCost":"3","op":"PUSH1","pc":"148","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"79374","gasCost":"3","op":"PUSH1","pc":"150","stack":["0x60fe47b1","0x55","0x38","0x2d"]},{"gas":"79371","gasCost":"3","op":"MLOAD","pc":"152","stack":["0x60fe47b1","0x55","0x38","0x2d","0x40"]},{"gas":"79368","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"153","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60"]},{"gas":"79365","gasCost":"3","op":"DUP1","pc":"155","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79362","gasCost":"3","op":"PUSH2","pc":"156","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45"]},{"gas":"79359","gasCost":"3","op":"DUP4","pc":"159","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0"]},{"gas":"79356","gasCost":"21","memexpand":"3","op":"CODECOPY","pc":"160","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0","0x60"]},{"gas":"79335","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000"],"op":"ADD","pc":"161","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79332","gasCost":"3","op":"DUP1","pc":"162","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5"]},{"gas":"79329","gasCost":"3","op":"DUP3","pc":"163","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79326","gasCost":"3","op":"DUP2","pc":"164","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d"]},{"gas":"79323","gasCost":"6","memexpand":"1","op":"MSTORE","pc":"165","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d","0xa5"]},{"gas":"79317","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"166","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79314","gasCost":"3","op":"ADD","pc":"168","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x20"]},{"gas":"79311","gasCost":"3","op":"SWAP2","pc":"169","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xc5"]},{"gas":"79308","gasCost":"2","op":"POP","pc":"170","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5","0x2d"]},{"gas":"79306","gasCost":"2","op":"POP","pc":"171","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5"]},{"gas":"79304","gasCost":"3","op":"PUSH1","pc":"172","stack":["0x60fe47b1","0x55","0x38","0xc5"]},{"gas":"79301","gasCost":"3","op":"MLOAD","pc":"174","stack":["0x60fe47b1","0x55","0x38","0xc5","0x40"]},{"gas":"79298","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"DUP1","pc":"175","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60"]},{"gas":"79295","gasCost":"3","op":"SWAP2","pc":"176","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60","0x60"]},{"gas":"79292","gasCost":"3","op":"SUB","pc":"177","stack":["0x60fe47b1","0x55","0x38","0x60","0x60","0xc5"]},{"gas":"79289","gasCost":"3","op":"SWAP1","pc":"178","stack":["0x60fe47b1","0x55","0x38","0x60","0x65"]},{"gas":"79286","gasCost":"3","op":"PUSH1","pc":"179","stack":["0x60fe47b1","0x55","0x38","0x65","0x60"]},{"gas":"79283","gasCost":"32000","op":"CREATE","pc":"181","stack":["0x60fe47b1","0x55","0x38","0x65","0x60","0x00"]},{"gas":"47283","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"47280","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"47277","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"47265","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"47262","gasCost":"3","op":"MLOAD","pc":"7","stack":["0x40"]},{"gas":"47259","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"8","stack":["0x60"]},{"gas":"47256","gasCost":"3","op":"DUP1","pc":"10","stack":["0x60","0x20"]},{"gas":"47253","gasCost":"3","op":"PUSH1","pc":"11","stack":["0x60","0x20","0x20"]},{"gas":"47250","gasCost":"3","op":"DUP4","pc":"13","stack":["0x60","0x20","0x20","0x45"]},{"gas":"47247","gasCost":"9","memexpand":"1","op":"CODECOPY","pc":"14","stack":["0x60","0x20","0x20","0x45","0x60"]},{"gas":"47238","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP2","pc":"15","stack":["0x60","0x20"]},{"gas":"47235","gasCost":"3","op":"ADD","pc":"16","stack":["0x60","0x20","0x60"]},{"gas":"47232","gasCost":"3","op":"PUSH1","pc":"17","stack":["0x60","0x80"]},{"gas":"47229","gasCost":"3","op":"MSTORE","pc":"19","stack":["0x60","0x80","0x40"]},{"gas":"47226","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP1","pc":"20","stack":["0x60"]},{"gas":"47223","gasCost":"3","op":"DUP1","pc":"21","stack":["0x60","0x60"]},{"gas":"47220","gasCost":"3","op":"MLOAD","pc":"22","stack":["0x60","0x60","0x60"]},{"gas":"47217","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"SWAP1","pc":"23","stack":["0x60","0x60","0x2d"]},{"gas":"47214","gasCost":"3","op":"PUSH1","pc":"24","stack":["0x60","0x2d","0x60"]},{"gas":"47211","gasCost":"3","op":"ADD","pc":"26","stack":["0x60","0x2d","0x60","0x20"]},{"gas":"47208","gasCost":"3","op":"SWAP1","pc":"27","stack":["0x60","0x2d","0x80"]},{"gas":"47205","gasCost":"3","op":"SWAP2","pc":"28","stack":["0x60","0x80","0x2d"]},{"gas":"47202","gasCost":"3","op":"SWAP1","pc":"29","stack":["0x2d","0x80","0x60"]},{"gas":"47199","gasCost":"2","op":"POP","pc":"30","stack":["0x2d","0x60","0x80"]},{"gas":"47197","gasCost":"2","op":"POP","pc":"31","stack":["0x2d","0x60"]},{"gas":"47195","gasCost":"1","op":"JUMPDEST","pc":"32","stack":["0x2d"]},{"gas":"47194","gasCost":"3","op":"DUP1","pc":"33","stack":["0x2d"]},{"gas":"47191","gasCost":"3","op":"PUSH1","pc":"34","stack":["0x2d","0x2d"]},{"gas":"47188","gasCost":"3","op":"ADD","pc":"36","stack":["0x2d","0x2d","0x01"]},{"gas":"47185","gasCost":"3","op":"PUSH1","pc":"37","stack":["0x2d","0x2e"]},{"gas":"47182","gasCost":"3","op":"PUSH1","pc":"39","stack":["0x2d","0x2e","0x00"]},{"gas":"47179","gasCost":"2","op":"POP","pc":"41","stack":["0x2d","0x2e","0x00","0x00"]},{"gas":"47177","gasCost":"3","op":"DUP2","pc":"42","stack":["0x2d","0x2e","0x00"]},{"gas":"47174","gasCost":"3","op":"SWAP1","pc":"43","stack":["0x2d","0x2e","0x00","0x2e"]},{"gas":"47171","gasCost":"20000","op":"SSTORE","pc":"44","stack":["0x2d","0x2e","0x2e","0x00"]},{"gas":"27171","gasCost":"2","op":"POP","pc":"45","stack":["0x2d","0x2e"]},{"gas":"27169","gasCost":"1","op":"JUMPDEST","pc":"46","stack":["0x2d"]},{"gas":"27168","gasCost":"2","op":"POP","pc":"47","stack":["0x2d"]},{"gas":"27166","gasCost":"3","op":"PUSH1","pc":"48","stack":[]},{"gas":"27163","gasCost":"3","op":"DUP1","pc":"50","stack":["0x0a"]},{"gas":"27160","gasCost":"3","op":"PUSH1","pc":"51","stack":["0x0a","0x0a"]},{"gas":"27157","gasCost":"3","op":"PUSH1","pc":"53","stack":["0x0a","0x0a","0x3b"]},{"gas":"27154","gasCost":"6","op":"CODECOPY","pc":"55","stack":["0x0a","0x0a","0x3b","0x00"]},{"gas":"27148","gasCost":"3","memory":["60606040526008565b0000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"PUSH1","pc":"56","stack":["0x0a"]},{"gas":"27145","gasCost":"0","op":"RETURN","pc":"58","stack":["0x0a","0x00"]},{"gas":"25145","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"182","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25142","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"184","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"25139","gasCost":"3","op":"PUSH2","pc":"186","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00"]},{"gas":"25136","gasCost":"10","op":"EXP","pc":"189","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x0100"]},{"gas":"25126","gasCost":"3","op":"DUP2","pc":"190","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01"]},{"gas":"25123","gasCost":"50","op":"SLOAD","pc":"191","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x01"]},{"gas":"25073","gasCost":"3","op":"DUP2","pc":"192","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25070","gasCost":"3","op":"PUSH20","pc":"193","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01"]},{"gas":"25067","gasCost":"5","op":"MUL","pc":"214","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25062","gasCost":"3","op":"NOT","pc":"215","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25059","gasCost":"3","op":"AND","pc":"216","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffff0000000000000000000000000000000000000000"]},{"gas":"25056","gasCost":"3","op":"SWAP1","pc":"217","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25053","gasCost":"3","op":"DUP4","pc":"218","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01"]},{"gas":"25050","gasCost":"5","op":"MUL","pc":"219","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25045","gasCost":"3","op":"OR","pc":"220","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25042","gasCost":"3","op":"SWAP1","pc":"221","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25039","gasCost":"20000","op":"SSTORE","pc":"222","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"5039","gasCost":"2","op":"POP","pc":"223","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"5037","gasCost":"3","op":"PUSH1","pc":"224","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"5034","gasCost":"3","op":"DUP2","pc":"226","stack":["0x60fe47b1","0x55","0x38","0x22"]},{"gas":"5031","gasCost":"3","op":"ADD","pc":"227","stack":["0x60fe47b1","0x55","0x38","0x22","0x38"]},{"gas":"5028","gasCost":"3","op":"PUSH1","pc":"228","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"5025","gasCost":"3","op":"PUSH1","pc":"230","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5022","gasCost":"2","op":"POP","pc":"232","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x00"]},{"gas":"5020","gasCost":"3","op":"DUP2","pc":"233","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5017","gasCost":"3","op":"SWAP1","pc":"234","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x5a"]},{"gas":"5014","gasCost":"5000","op":"SSTORE","pc":"235","stack":["0x60fe47b1","0x55","0x38","0x5a","0x5a","0x00"]},{"gas":"14","gasCost":"2","op":"POP","pc":"236","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"12","gasCost":"1","op":"JUMPDEST","pc":"237","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"11","gasCost":"2","op":"POP","pc":"238","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"9","gasCost":"8","op":"JUMP","pc":"239","stack":["0x60fe47b1","0x55"]},{"gas":"1","gasCost":"1","op":"JUMPDEST","pc":"85","stack":["0x60fe47b1"]},{"gas":"0","gasCost":"0","op":"STOP","pc":"86","stack":["0x60fe47b1"]}]} - } -} diff --git a/libs/remix-lib/test/resources/testWeb3.json~merged b/libs/remix-lib/test/resources/testWeb3.json~merged deleted file mode 100644 index ba5f88cb0f..0000000000 --- a/libs/remix-lib/test/resources/testWeb3.json~merged +++ /dev/null @@ -1,17 +0,0 @@ -{ - "testTxs": { - "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} - }, - - "testTxsByBlock": { - "105967-0": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} - }, - - "testCodes": { - "0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605757603f565b005b605560048080359060200190919050506089565b005b606260048050506078565b6040518082815260200191505060405180910390f35b600060006000505490506086565b90565b80600060005081905550602d6040516045806100f083390180828152602001915050604051809103906000f0600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550602281016000600050819055505b505660606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055505b50600a80603b6000396000f360606040526008565b00" - }, - - "testTraces": { - "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"gas":"0x0000000000000000000000000000000000000000000000000000000000019def","return":"0x","structLogs":[{"gas":"84503","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"84500","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"84497","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"84485","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"84482","gasCost":"3","op":"CALLDATALOAD","pc":"7","stack":["0x00"]},{"gas":"84479","gasCost":"3","op":"PUSH29","pc":"8","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84476","gasCost":"3","op":"SWAP1","pc":"38","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000","0x0100000000000000000000000000000000000000000000000000000000"]},{"gas":"84473","gasCost":"5","op":"DIV","pc":"39","stack":["0x0100000000000000000000000000000000000000000000000000000000","0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84468","gasCost":"3","op":"DUP1","pc":"40","stack":["0x60fe47b1"]},{"gas":"84465","gasCost":"3","op":"PUSH4","pc":"41","stack":["0x60fe47b1","0x60fe47b1"]},{"gas":"84462","gasCost":"3","op":"EQ","pc":"46","stack":["0x60fe47b1","0x60fe47b1","0x60fe47b1"]},{"gas":"84459","gasCost":"3","op":"PUSH1","pc":"47","stack":["0x60fe47b1","0x01"]},{"gas":"84456","gasCost":"10","op":"JUMPI","pc":"49","stack":["0x60fe47b1","0x01","0x41"]},{"gas":"84446","gasCost":"1","op":"JUMPDEST","pc":"65","stack":["0x60fe47b1"]},{"gas":"84445","gasCost":"3","op":"PUSH1","pc":"66","stack":["0x60fe47b1"]},{"gas":"84442","gasCost":"3","op":"PUSH1","pc":"68","stack":["0x60fe47b1","0x55"]},{"gas":"84439","gasCost":"3","op":"DUP1","pc":"70","stack":["0x60fe47b1","0x55","0x04"]},{"gas":"84436","gasCost":"3","op":"DUP1","pc":"71","stack":["0x60fe47b1","0x55","0x04","0x04"]},{"gas":"84433","gasCost":"3","op":"CALLDATALOAD","pc":"72","stack":["0x60fe47b1","0x55","0x04","0x04","0x04"]},{"gas":"84430","gasCost":"3","op":"SWAP1","pc":"73","stack":["0x60fe47b1","0x55","0x04","0x04","0x38"]},{"gas":"84427","gasCost":"3","op":"PUSH1","pc":"74","stack":["0x60fe47b1","0x55","0x04","0x38","0x04"]},{"gas":"84424","gasCost":"3","op":"ADD","pc":"76","stack":["0x60fe47b1","0x55","0x04","0x38","0x04","0x20"]},{"gas":"84421","gasCost":"3","op":"SWAP1","pc":"77","stack":["0x60fe47b1","0x55","0x04","0x38","0x24"]},{"gas":"84418","gasCost":"3","op":"SWAP2","pc":"78","stack":["0x60fe47b1","0x55","0x04","0x24","0x38"]},{"gas":"84415","gasCost":"3","op":"SWAP1","pc":"79","stack":["0x60fe47b1","0x55","0x38","0x24","0x04"]},{"gas":"84412","gasCost":"2","op":"POP","pc":"80","stack":["0x60fe47b1","0x55","0x38","0x04","0x24"]},{"gas":"84410","gasCost":"2","op":"POP","pc":"81","stack":["0x60fe47b1","0x55","0x38","0x04"]},{"gas":"84408","gasCost":"3","op":"PUSH1","pc":"82","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84405","gasCost":"8","op":"JUMP","pc":"84","stack":["0x60fe47b1","0x55","0x38","0x89"]},{"gas":"84397","gasCost":"1","op":"JUMPDEST","pc":"137","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84396","gasCost":"3","op":"DUP1","pc":"138","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84393","gasCost":"3","op":"PUSH1","pc":"139","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"84390","gasCost":"3","op":"PUSH1","pc":"141","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84387","gasCost":"2","op":"POP","pc":"143","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x00"]},{"gas":"84385","gasCost":"3","op":"DUP2","pc":"144","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84382","gasCost":"3","op":"SWAP1","pc":"145","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x38"]},{"gas":"84379","gasCost":"5000","op":"SSTORE","pc":"146","stack":["0x60fe47b1","0x55","0x38","0x38","0x38","0x00"]},{"gas":"79379","gasCost":"2","op":"POP","pc":"147","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"79377","gasCost":"3","op":"PUSH1","pc":"148","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"79374","gasCost":"3","op":"PUSH1","pc":"150","stack":["0x60fe47b1","0x55","0x38","0x2d"]},{"gas":"79371","gasCost":"3","op":"MLOAD","pc":"152","stack":["0x60fe47b1","0x55","0x38","0x2d","0x40"]},{"gas":"79368","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"153","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60"]},{"gas":"79365","gasCost":"3","op":"DUP1","pc":"155","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79362","gasCost":"3","op":"PUSH2","pc":"156","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45"]},{"gas":"79359","gasCost":"3","op":"DUP4","pc":"159","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0"]},{"gas":"79356","gasCost":"21","memexpand":"3","op":"CODECOPY","pc":"160","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0","0x60"]},{"gas":"79335","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000"],"op":"ADD","pc":"161","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79332","gasCost":"3","op":"DUP1","pc":"162","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5"]},{"gas":"79329","gasCost":"3","op":"DUP3","pc":"163","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79326","gasCost":"3","op":"DUP2","pc":"164","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d"]},{"gas":"79323","gasCost":"6","memexpand":"1","op":"MSTORE","pc":"165","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d","0xa5"]},{"gas":"79317","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"166","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79314","gasCost":"3","op":"ADD","pc":"168","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x20"]},{"gas":"79311","gasCost":"3","op":"SWAP2","pc":"169","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xc5"]},{"gas":"79308","gasCost":"2","op":"POP","pc":"170","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5","0x2d"]},{"gas":"79306","gasCost":"2","op":"POP","pc":"171","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5"]},{"gas":"79304","gasCost":"3","op":"PUSH1","pc":"172","stack":["0x60fe47b1","0x55","0x38","0xc5"]},{"gas":"79301","gasCost":"3","op":"MLOAD","pc":"174","stack":["0x60fe47b1","0x55","0x38","0xc5","0x40"]},{"gas":"79298","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"DUP1","pc":"175","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60"]},{"gas":"79295","gasCost":"3","op":"SWAP2","pc":"176","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60","0x60"]},{"gas":"79292","gasCost":"3","op":"SUB","pc":"177","stack":["0x60fe47b1","0x55","0x38","0x60","0x60","0xc5"]},{"gas":"79289","gasCost":"3","op":"SWAP1","pc":"178","stack":["0x60fe47b1","0x55","0x38","0x60","0x65"]},{"gas":"79286","gasCost":"3","op":"PUSH1","pc":"179","stack":["0x60fe47b1","0x55","0x38","0x65","0x60"]},{"gas":"79283","gasCost":"32000","op":"CREATE","pc":"181","stack":["0x60fe47b1","0x55","0x38","0x65","0x60","0x00"]},{"gas":"47283","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"47280","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"47277","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"47265","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"47262","gasCost":"3","op":"MLOAD","pc":"7","stack":["0x40"]},{"gas":"47259","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"8","stack":["0x60"]},{"gas":"47256","gasCost":"3","op":"DUP1","pc":"10","stack":["0x60","0x20"]},{"gas":"47253","gasCost":"3","op":"PUSH1","pc":"11","stack":["0x60","0x20","0x20"]},{"gas":"47250","gasCost":"3","op":"DUP4","pc":"13","stack":["0x60","0x20","0x20","0x45"]},{"gas":"47247","gasCost":"9","memexpand":"1","op":"CODECOPY","pc":"14","stack":["0x60","0x20","0x20","0x45","0x60"]},{"gas":"47238","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP2","pc":"15","stack":["0x60","0x20"]},{"gas":"47235","gasCost":"3","op":"ADD","pc":"16","stack":["0x60","0x20","0x60"]},{"gas":"47232","gasCost":"3","op":"PUSH1","pc":"17","stack":["0x60","0x80"]},{"gas":"47229","gasCost":"3","op":"MSTORE","pc":"19","stack":["0x60","0x80","0x40"]},{"gas":"47226","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP1","pc":"20","stack":["0x60"]},{"gas":"47223","gasCost":"3","op":"DUP1","pc":"21","stack":["0x60","0x60"]},{"gas":"47220","gasCost":"3","op":"MLOAD","pc":"22","stack":["0x60","0x60","0x60"]},{"gas":"47217","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"SWAP1","pc":"23","stack":["0x60","0x60","0x2d"]},{"gas":"47214","gasCost":"3","op":"PUSH1","pc":"24","stack":["0x60","0x2d","0x60"]},{"gas":"47211","gasCost":"3","op":"ADD","pc":"26","stack":["0x60","0x2d","0x60","0x20"]},{"gas":"47208","gasCost":"3","op":"SWAP1","pc":"27","stack":["0x60","0x2d","0x80"]},{"gas":"47205","gasCost":"3","op":"SWAP2","pc":"28","stack":["0x60","0x80","0x2d"]},{"gas":"47202","gasCost":"3","op":"SWAP1","pc":"29","stack":["0x2d","0x80","0x60"]},{"gas":"47199","gasCost":"2","op":"POP","pc":"30","stack":["0x2d","0x60","0x80"]},{"gas":"47197","gasCost":"2","op":"POP","pc":"31","stack":["0x2d","0x60"]},{"gas":"47195","gasCost":"1","op":"JUMPDEST","pc":"32","stack":["0x2d"]},{"gas":"47194","gasCost":"3","op":"DUP1","pc":"33","stack":["0x2d"]},{"gas":"47191","gasCost":"3","op":"PUSH1","pc":"34","stack":["0x2d","0x2d"]},{"gas":"47188","gasCost":"3","op":"ADD","pc":"36","stack":["0x2d","0x2d","0x01"]},{"gas":"47185","gasCost":"3","op":"PUSH1","pc":"37","stack":["0x2d","0x2e"]},{"gas":"47182","gasCost":"3","op":"PUSH1","pc":"39","stack":["0x2d","0x2e","0x00"]},{"gas":"47179","gasCost":"2","op":"POP","pc":"41","stack":["0x2d","0x2e","0x00","0x00"]},{"gas":"47177","gasCost":"3","op":"DUP2","pc":"42","stack":["0x2d","0x2e","0x00"]},{"gas":"47174","gasCost":"3","op":"SWAP1","pc":"43","stack":["0x2d","0x2e","0x00","0x2e"]},{"gas":"47171","gasCost":"20000","op":"SSTORE","pc":"44","stack":["0x2d","0x2e","0x2e","0x00"]},{"gas":"27171","gasCost":"2","op":"POP","pc":"45","stack":["0x2d","0x2e"]},{"gas":"27169","gasCost":"1","op":"JUMPDEST","pc":"46","stack":["0x2d"]},{"gas":"27168","gasCost":"2","op":"POP","pc":"47","stack":["0x2d"]},{"gas":"27166","gasCost":"3","op":"PUSH1","pc":"48","stack":[]},{"gas":"27163","gasCost":"3","op":"DUP1","pc":"50","stack":["0x0a"]},{"gas":"27160","gasCost":"3","op":"PUSH1","pc":"51","stack":["0x0a","0x0a"]},{"gas":"27157","gasCost":"3","op":"PUSH1","pc":"53","stack":["0x0a","0x0a","0x3b"]},{"gas":"27154","gasCost":"6","op":"CODECOPY","pc":"55","stack":["0x0a","0x0a","0x3b","0x00"]},{"gas":"27148","gasCost":"3","memory":["60606040526008565b0000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"PUSH1","pc":"56","stack":["0x0a"]},{"gas":"27145","gasCost":"0","op":"RETURN","pc":"58","stack":["0x0a","0x00"]},{"gas":"25145","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"182","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25142","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"184","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"25139","gasCost":"3","op":"PUSH2","pc":"186","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00"]},{"gas":"25136","gasCost":"10","op":"EXP","pc":"189","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x0100"]},{"gas":"25126","gasCost":"3","op":"DUP2","pc":"190","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01"]},{"gas":"25123","gasCost":"50","op":"SLOAD","pc":"191","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x01"]},{"gas":"25073","gasCost":"3","op":"DUP2","pc":"192","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25070","gasCost":"3","op":"PUSH20","pc":"193","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01"]},{"gas":"25067","gasCost":"5","op":"MUL","pc":"214","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25062","gasCost":"3","op":"NOT","pc":"215","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25059","gasCost":"3","op":"AND","pc":"216","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffff0000000000000000000000000000000000000000"]},{"gas":"25056","gasCost":"3","op":"SWAP1","pc":"217","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25053","gasCost":"3","op":"DUP4","pc":"218","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01"]},{"gas":"25050","gasCost":"5","op":"MUL","pc":"219","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25045","gasCost":"3","op":"OR","pc":"220","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25042","gasCost":"3","op":"SWAP1","pc":"221","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25039","gasCost":"20000","op":"SSTORE","pc":"222","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"5039","gasCost":"2","op":"POP","pc":"223","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"5037","gasCost":"3","op":"PUSH1","pc":"224","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"5034","gasCost":"3","op":"DUP2","pc":"226","stack":["0x60fe47b1","0x55","0x38","0x22"]},{"gas":"5031","gasCost":"3","op":"ADD","pc":"227","stack":["0x60fe47b1","0x55","0x38","0x22","0x38"]},{"gas":"5028","gasCost":"3","op":"PUSH1","pc":"228","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"5025","gasCost":"3","op":"PUSH1","pc":"230","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5022","gasCost":"2","op":"POP","pc":"232","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x00"]},{"gas":"5020","gasCost":"3","op":"DUP2","pc":"233","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5017","gasCost":"3","op":"SWAP1","pc":"234","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x5a"]},{"gas":"5014","gasCost":"5000","op":"SSTORE","pc":"235","stack":["0x60fe47b1","0x55","0x38","0x5a","0x5a","0x00"]},{"gas":"14","gasCost":"2","op":"POP","pc":"236","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"12","gasCost":"1","op":"JUMPDEST","pc":"237","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"11","gasCost":"2","op":"POP","pc":"238","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"9","gasCost":"8","op":"JUMP","pc":"239","stack":["0x60fe47b1","0x55"]},{"gas":"1","gasCost":"1","op":"JUMPDEST","pc":"85","stack":["0x60fe47b1"]},{"gas":"0","gasCost":"0","op":"STOP","pc":"86","stack":["0x60fe47b1"]}]} - } -} diff --git a/libs/remix-lib/test/tests.js b/libs/remix-lib/test/tests.js index 21afbd9e75..6f8565ebb9 100644 --- a/libs/remix-lib/test/tests.js +++ b/libs/remix-lib/test/tests.js @@ -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') diff --git a/libs/remix-solidity/package.json b/libs/remix-solidity/package.json index 0a8e07033f..e2e55b091e 100644 --- a/libs/remix-solidity/package.json +++ b/libs/remix-solidity/package.json @@ -16,7 +16,6 @@ ], "dependencies": { "eslint-scope": "^5.0.0", - "@remix-project/remix-lib": "0.4.30", "solc": "^0.6.0", "webworkify-webpack": "^2.1.5" }, diff --git a/libs/remix-solidity/src/compiler/compiler.ts b/libs/remix-solidity/src/compiler/compiler.ts index 1a5886537f..5a7168db8e 100644 --- a/libs/remix-solidity/src/compiler/compiler.ts +++ b/libs/remix-solidity/src/compiler/compiler.ts @@ -3,7 +3,7 @@ import { update } from 'solc/abi' import * as webworkify from 'webworkify-webpack' import compilerInput from './compiler-input' -import { EventManager } from '@remix-project/remix-lib' +import EventManager from '../lib/eventManager' import { default as txHelper } from './txHelper'; import { Source, SourceWithTarget, MessageFromWorker, CompilerState, CompilationResult, visitContractsCallbackParam, visitContractsCallbackInterface, CompilationError, diff --git a/libs/remix-solidity/src/lib/eventManager.ts b/libs/remix-solidity/src/lib/eventManager.ts new file mode 100644 index 0000000000..289b2ec4eb --- /dev/null +++ b/libs/remix-solidity/src/lib/eventManager.ts @@ -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) + } + } +}