use blockchain module instead of executio ncontext for cmd interpreter

pull/5370/head
Iuri Matias 5 years ago
parent 8d3a4403f7
commit 7f31bc0208
  1. 2
      src/app.js
  2. 6
      src/app/panels/main-view.js
  3. 9
      src/app/panels/terminal.js
  4. 3
      src/app/tabs/runTab/model/blockchain.js
  5. 10
      src/lib/cmdInterpreterAPI.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([

@ -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) => {

@ -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) },

@ -244,6 +244,9 @@ class Blockchain {
}
}
web3 () {
return this.executionContext.web3()
}
}
module.exports = Blockchain

@ -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()
})

Loading…
Cancel
Save