From dd2ba18ea9c70157e26f2ed297b15f1518f0ea4b Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 7 Mar 2019 17:39:19 +0100 Subject: [PATCH] fix debugger --- src/app.js | 2 - src/app/debugger/debuggerUI.js | 96 +++++++------------------------ src/app/tabs/settings-tab.js | 1 - src/app/tabs/support-tab.js | 101 --------------------------------- 4 files changed, 22 insertions(+), 178 deletions(-) delete mode 100644 src/app/tabs/support-tab.js diff --git a/src/app.js b/src/app.js index 9ca8c69923..097d9e79c4 100644 --- a/src/app.js +++ b/src/app.js @@ -46,7 +46,6 @@ const CompileTab = require('./app/tabs/compile-tab') const SettingsTab = require('./app/tabs/settings-tab') const AnalysisTab = require('./app/tabs/analysis-tab') const DebuggerTab = require('./app/tabs/debugger-tab') -// const SupportTab = require('./app/tabs/support-tab') const TestTab = require('./app/tabs/test-tab') const RunTab = require('./app/tabs/run-tab') const FilePanel = require('./app/panels/file-panel') @@ -460,7 +459,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org let analysis = new AnalysisTab(registry) let debug = new DebuggerTab() const landingPage = new LandingPage(appManager, appStore) - // let support = new SupportTab() let test = new TestTab( registry.get('filemanager').api, registry.get('filepanel').api, diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index 1055169a18..30f69c8f1d 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -12,8 +12,6 @@ var executionContext = require('../../execution-context') var globalRegistry = require('../../global/registry') var remixLib = require('remix-lib') -var Web3Providers = remixLib.vm.Web3Providers -var DummyProvider = remixLib.vm.DummyProvider var init = remixLib.init @@ -30,72 +28,12 @@ var css = csjs` } ` -class ContextManager { - constructor () { - 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) { - var self = this - this.web3Providers.get(type, function (error, obj) { - if (error) { - console.log('provider ' + type + ' not defined') - } else { - self.web3 = obj - self.executionContext.detectNetwork((error, network) => { - if (error || !network) { - self.web3 = obj - } else { - var webDebugNode = init.web3DebugNode(network.name) - self.web3 = (!webDebugNode ? obj : webDebugNode) - } - self.event.trigger('providerChanged', [type, self.web3]) - }) - self.event.trigger('providerChanged', [type, self.web3]) - } - }) - } - -} - class DebuggerUI { constructor (container) { this.registry = globalRegistry this.event = new EventManager() - this.executionContext = executionContext - - this.contextManager = new ContextManager() - - this.contextManager.initProviders() - - this.contextManager.event.register('providerChanged', () => { - if (this.debugger) this.debugger.updateWeb3(this.contextManager.getWeb3()) - }) - this.isActive = false this.sourceHighlighter = new SourceHighlighter() @@ -173,19 +111,29 @@ class DebuggerUI { if (compilers['__last']) lastCompilationResult = compilers['__last'] // TODO debugging with source highlight is disabled. see line 98 - this.debugger = new Debugger({ - web3: this.contextManager.getWeb3(), - offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api, - compiler: { lastCompilationResult } - }) - this.listenToEvents() - - this.debugger.debugger.updateWeb3(this.executionContext.web3()) - this.debugger.debug(blockNumber, txNumber, tx, () => { - self.stepManager = new StepManagerUI(this.debugger.step_manager) - self.vmDebugger = new VmDebugger(this.debugger.vmDebuggerLogic) - self.renderDebugger() + executionContext.detectNetwork((error, network) => { + let web3 + if (error || !network) { + web3 = init.web3DebugNode(executionContext.web3()) + } else { + var webDebugNode = init.web3DebugNode(network.name) + web3 = (!webDebugNode ? executionContext.web3() : webDebugNode) + } + init.extendWeb3(web3) + this.debugger = new Debugger({ + web3, + offsetToLineColumnConverter: this.registry.get('offsettolinecolumnconverter').api, + compiler: { lastCompilationResult } + }) + + this.listenToEvents() + + this.debugger.debug(blockNumber, txNumber, tx, () => { + self.stepManager = new StepManagerUI(this.debugger.step_manager) + self.vmDebugger = new VmDebugger(this.debugger.vmDebuggerLogic) + self.renderDebugger() + }) }) } diff --git a/src/app/tabs/settings-tab.js b/src/app/tabs/settings-tab.js index 657219a964..2fb7ca8997 100644 --- a/src/app/tabs/settings-tab.js +++ b/src/app/tabs/settings-tab.js @@ -150,7 +150,6 @@ module.exports = class SettingsTab extends ApiFactory { ${this._view.config.themes} ` - var self = this function onchangeGenerateContractMetadata (event) { self.config.set('settings/generate-contract-metadata', !self.config.get('settings/generate-contract-metadata')) } diff --git a/src/app/tabs/support-tab.js b/src/app/tabs/support-tab.js deleted file mode 100644 index b168af1258..0000000000 --- a/src/app/tabs/support-tab.js +++ /dev/null @@ -1,101 +0,0 @@ -const yo = require('yo-yo') -var css = require('./styles/support-tab-styles') - -import { ApiFactory } from 'remix-plugin' - -class SupportTab extends ApiFactory { - - constructor (localRegistry) { - super() - this.el = null - this.gitterIframe = '' - this.gitterIsLoaded = false - } - - __showing () { - if (this.gitterIsLoaded) return - - const iframe = yo`` - this.gitterIframe.parentNode.replaceChild(iframe, this.gitterIframe) - this.gitterIframe = iframe - this.el.style.display = 'block' - this.gitterIsLoaded = true - } - - get profile () { - return { - name: 'support', - methods: [], - events: [], - icon: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03MDQgMTkycTAtMjYtMTktNDV0LTQ1LTE5LTQ1IDE5LTE5IDQ1IDE5IDQ1IDQ1IDE5IDQ1LTE5IDE5LTQ1em04OTYtMzJ2MzIwcTAgMTYtMTIgMjUtOCA3LTIwIDctNCAwLTctMWwtNDQ4LTk2cS0xMS0yLTE4LTExdC03LTIwaC0yNTZ2MTAycTExMSAyMyAxODMuNSAxMTF0NzIuNSAyMDN2ODAwcTAgMjYtMTkgNDV0LTQ1IDE5aC01MTJxLTI2IDAtNDUtMTl0LTE5LTQ1di04MDBxMC0xMDYgNjIuNS0xOTAuNXQxNjEuNS0xMTQuNXYtMTExaC0zMnEtNTkgMC0xMTUgMjMuNXQtOTEuNSA1My02NiA2Ni41LTQwLjUgNTMuNS0xNCAyNC41cS0xNyAzNS01NyAzNS0xNiAwLTI5LTctMjMtMTItMzEuNS0zN3QzLjUtNDlxNS0xMCAxNC41LTI2dDM3LjUtNTMuNSA2MC41LTcwIDg1LTY3IDEwOC41LTUyLjVxLTI1LTQyLTI1LTg2IDAtNjYgNDctMTEzdDExMy00NyAxMTMgNDcgNDcgMTEzcTAgMzMtMTQgNjRoMzAycTAtMTEgNy0yMHQxOC0xMWw0NDgtOTZxMy0xIDctMSAxMiAwIDIwIDcgMTIgOSAxMiAyNXoiLz48L3N2Zz4=', - description: 'help center' - } - } - - render () { - if (this.el) return this.el - - this.gitterIframe = yo`
` - - generateRemixdUI () { - const remixd = yo` -
-
Accessing local files
-
- Remixd is a tool which allow Remix IDE to access files located in your local computer. - it can also be used to setup a development environment. -
-
More infos:
- - -
Installation:
npm install remixd -g
-
` - return remixd - } - - generateLocalRemixdUI () { - const localremixd = yo` -
-
Running Remix locally
-
- as a NPM module: -
- https://www.npmjs.com/package/remix-ide -
npm install remix-ide -g
-
- as an electron app: -
- https://github.com/horizon-games/remix-app -
` - return localremixd - } - - render () { - if (this.el) return this.el - - this.gitterIframe = yo`
` - - this.el = yo` -
-
- Have a question, found a bug or want to propose a feature? Have a look at the - issues or check out - the documentation page on Remix or - Solidity. -
-
-
{ window.open('https://gitter.im/ethereum/remix') }} title='Click to open chat in Gitter'> -
ethereum/remix community chat
-
- ${this.gitterIframe} -
- ${this.generateRemixdUI()} - ${this.generateLocalRemixdUI()} -
` - - return this.el - } - -} - -module.exports = SupportTab