diff --git a/src/app.js b/src/app.js index 7401d6d61b..b0e27dda13 100644 --- a/src/app.js +++ b/src/app.js @@ -256,7 +256,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // LAYOUT & SYSTEM VIEWS const appPanel = new MainPanel() - const mainview = new MainView(editor, appPanel, fileManager, appManager, txlistener, eventsDecoder, executionContext) + const mainview = new MainView(editor, appPanel, fileManager, appManager, txlistener, eventsDecoder, executionContext, blockchain) registry.put({ api: mainview, name: 'mainview' }) appManager.register([ diff --git a/src/app/panels/main-view.js b/src/app/panels/main-view.js index 6d8f1bde65..5bbb312f5c 100644 --- a/src/app/panels/main-view.js +++ b/src/app/panels/main-view.js @@ -20,7 +20,7 @@ var css = csjs` ` export class MainView { - constructor (editor, mainPanel, fileManager, appManager, txListener, eventsDecoder, executionContext) { + constructor (editor, mainPanel, fileManager, appManager, txListener, eventsDecoder, executionContext, blockchain) { var self = this self.event = new EventManager() self._view = {} @@ -32,6 +32,7 @@ export class MainView { self.txListener = txListener self.eventsDecoder = eventsDecoder self.executionContext = executionContext + self.blockchain = blockchain this.appManager = appManager this.init() } @@ -101,7 +102,8 @@ export class MainView { appManager: this.appManager, eventsDecoder: this.eventsDecoder, txListener: this.txListener, - executionContext: this.executionContext + executionContext: this.executionContext, + blockchain: this.blockchain }, { getPosition: (event) => { diff --git a/src/app/panels/terminal.js b/src/app/panels/terminal.js index ea9d103cc6..af20a0e2be 100644 --- a/src/app/panels/terminal.js +++ b/src/app/panels/terminal.js @@ -42,6 +42,7 @@ class Terminal extends Plugin { var self = this self.event = new EventManager() self.executionContext = opts.executionContext + self.blockchain = opts.blockchain self._api = api self._opts = opts self.data = { @@ -52,7 +53,7 @@ class Terminal extends Plugin { } self._view = { el: null, bar: null, input: null, term: null, journal: null, cli: null } self._components = {} - self._components.cmdInterpreter = new CommandInterpreterAPI(this, null, self.executionContext) + self._components.cmdInterpreter = new CommandInterpreterAPI(this, null, self.blockchain) self._components.autoCompletePopup = new AutoCompletePopup(self._opts) self._components.autoCompletePopup.event.register('handleSelect', function (input) { let textList = self._view.input.innerText.split(' ') @@ -668,7 +669,7 @@ class Terminal extends Plugin { return done(null, 'This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.') } var self = this - var context = domTerminalFeatures(self, scopedCommands, self.executionContext) + var context = domTerminalFeatures(self, scopedCommands, self.blockchain) try { var cmds = vm.createContext(Object.assign(self._jsSandboxContext, context, self._jsSandboxRegistered)) var result = vm.runInContext(script, cmds) @@ -680,12 +681,12 @@ class Terminal extends Plugin { } } -function domTerminalFeatures (self, scopedCommands, executionContext) { +function domTerminalFeatures (self, scopedCommands, blockchain) { return { swarmgw, ethers, remix: self._components.cmdInterpreter, - web3: new Web3(executionContext.web3().currentProvider), + web3: new Web3(blockchain.web3().currentProvider), console: { log: function () { scopedCommands.log.apply(scopedCommands, arguments) }, info: function () { scopedCommands.info.apply(scopedCommands, arguments) }, diff --git a/src/app/tabs/runTab/model/blockchain.js b/src/app/tabs/runTab/model/blockchain.js index 3412a8df71..943abeec54 100644 --- a/src/app/tabs/runTab/model/blockchain.js +++ b/src/app/tabs/runTab/model/blockchain.js @@ -244,6 +244,9 @@ class Blockchain { } } + web3 () { + return this.executionContext.web3() + } } module.exports = Blockchain diff --git a/src/lib/cmdInterpreterAPI.js b/src/lib/cmdInterpreterAPI.js index fffeb24f59..93a71ab308 100644 --- a/src/lib/cmdInterpreterAPI.js +++ b/src/lib/cmdInterpreterAPI.js @@ -14,10 +14,10 @@ var solidityTypeFormatter = require('../app/tabs/debugger/debuggerUI/vmDebugger/ var GistHandler = require('./gist-handler') class CmdInterpreterAPI { - constructor (terminal, localRegistry, executionContext) { + constructor (terminal, localRegistry, blockchain) { const self = this self.event = new EventManager() - self.executionContext = executionContext + self.blockchain = blockchain self._components = {} self._components.registry = localRegistry || globalRegistry self._components.terminal = terminal @@ -62,14 +62,14 @@ class CmdInterpreterAPI { debug (hash, cb) { var self = this delete self.d - self.executionContext.web3().eth.getTransaction(hash, (error, tx) => { + self.blockchain.web3().eth.getTransaction(hash, (error, tx) => { if (error) return cb(error) var debugSession = new RemixDebug({ compilationResult: () => { return self._deps.compilersArtefacts['__last'].getData() } }) - debugSession.addProvider('web3', self.executionContext.web3()) + debugSession.addProvider('web3', self.blockchain.web3()) debugSession.switchProvider('web3') debugSession.debug(tx) self.d = debugSession @@ -180,7 +180,7 @@ class CmdInterpreterAPI { }) } setproviderurl (url, cb) { - this.executionContext.setProviderFromEndpoint(url, 'web3', (error) => { + this.blockchain.setProviderFromEndpoint(url, 'web3', (error) => { if (error) toolTip(error) if (cb) cb() })