diff --git a/src/app.js b/src/app.js
index 7069bef3c6..a1111dc898 100644
--- a/src/app.js
+++ b/src/app.js
@@ -21,7 +21,7 @@ var Config = require('./config')
var Editor = require('./app/editor/editor')
var Renderer = require('./app/ui/renderer')
var Compiler = require('./app/compiler/compiler')
-var ExecutionContext = require('./execution-context')
+var executionContext = require('./execution-context')
var Debugger = require('./app/debugger/debugger')
var StaticAnalysis = require('./app/staticanalysis/staticAnalysisView')
var FilePanel = require('./app/panels/file-panel')
@@ -32,7 +32,6 @@ var modalDialogCustom = require('./app/ui/modal-dialog-custom')
var Txlistener = require('./app/execution/txListener')
var TxLogger = require('./app/execution/txLogger')
var EventsDecoder = require('./app/execution/eventsDecoder')
-var Web3VMProvider = remix.web3.web3VMProvider
var handleImports = require('./app/compiler/compiler-imports')
var FileManager = require('./app/files/fileManager')
@@ -169,22 +168,14 @@ module.exports = App
function run () {
var self = this
- // ------------------------------------------------------------
- var executionContext = new ExecutionContext()
-
// ----------------- editor ----------------------------
this._components.editor = new Editor({}) // @TODO: put into editorpanel
// ----------------- editor panel ----------------------
this._components.editorpanel = new EditorPanel({
api: {
editor: self._components.editor,
- config: self._api.config,
- web3: () => {
- return executionContext.web3()
- },
- context: () => {
- return executionContext.getProvider()
- }}
+ config: self._api.config
+ }
})
this._components.editorpanel.event.register('resize', direction => self._adjustLayout(direction))
@@ -351,7 +342,7 @@ function run () {
}
}
- var udapp = new UniversalDApp(executionContext, {
+ var udapp = new UniversalDApp({
removable: false,
removable_instances: true
})
@@ -369,12 +360,6 @@ function run () {
document.querySelector(`.${css.dragbar2}`).style.right = delta + 'px'
onResize()
},
- executionContextChange: (context) => {
- return executionContext.executionContextChange(context)
- },
- executionContextProvider: () => {
- return executionContext.getProvider()
- },
getContracts: () => {
if (compiler.lastCompilationResult && compiler.lastCompilationResult.data) {
return compiler.lastCompilationResult.data.contracts
@@ -384,9 +369,6 @@ function run () {
udapp: () => {
return udapp
},
- executionContext: () => {
- return executionContext
- },
fileProviderOf: (path) => {
return fileManager.fileProviderOf(path)
},
@@ -483,7 +465,7 @@ function run () {
return offsetToLineColumnConverter.offsetToLineColumn(location, file, compiler.lastCompilationResult)
}
}
- var transactionDebugger = new Debugger('#debugger', debugAPI, executionContext.event, editor.event)
+ var transactionDebugger = new Debugger('#debugger', debugAPI, editor.event)
transactionDebugger.addProvider('vm', executionContext.vm())
transactionDebugger.addProvider('injected', executionContext.web3())
transactionDebugger.addProvider('web3', executionContext.web3())
@@ -503,15 +485,6 @@ function run () {
node.insertBefore(staticanalysis.render(), node.childNodes[0])
// ----------------- Tx listener -----------------
- // not used right now
-
- // TODO the following should be put in execution context
- var web3VM = new Web3VMProvider()
- web3VM.setVM(executionContext.vm())
-
- var currentWeb3 = function () {
- return executionContext.isVM() ? web3VM : executionContext.web3()
- }
var transactionReceiptResolver = {
_transactionReceipts: {},
@@ -519,7 +492,7 @@ function run () {
if (this._transactionReceipts[tx.hash]) {
return cb(null, this._transactionReceipts[tx.hash])
}
- currentWeb3().eth.getTransactionReceipt(tx.hash, (error, receipt) => {
+ executionContext.web3().eth.getTransactionReceipt(tx.hash, (error, receipt) => {
if (!error) {
this._transactionReceipts[tx.hash] = receipt
cb(null, receipt)
@@ -539,18 +512,12 @@ function run () {
var txlistener = new Txlistener({
api: {
- web3: function () { return currentWeb3() },
- isVM: function () { return executionContext.isVM() },
contracts: compiledContracts,
- context: function () {
- return executionContext.getProvider()
- },
resolveReceipt: function (tx, cb) {
transactionReceiptResolver.resolve(tx, cb)
}
},
event: {
- executionContext: executionContext.event,
udapp: udapp.event
}})
@@ -575,9 +542,6 @@ function run () {
},
compiledContracts: function () {
return compiledContracts()
- },
- context: function () {
- return executionContext.getProvider()
}
},
events: {
diff --git a/src/app/debugger/debugger.js b/src/app/debugger/debugger.js
index 035649a6a7..6e150c7253 100644
--- a/src/app/debugger/debugger.js
+++ b/src/app/debugger/debugger.js
@@ -1,11 +1,12 @@
'use strict'
var remix = require('ethereum-remix')
+var executionContext = require('../../execution-context')
/**
* Manage remix and source highlighting
*/
-function Debugger (id, appAPI, executionContextEvent, editorEvent) {
+function Debugger (id, appAPI, editorEvent) {
this.el = document.querySelector(id)
this.debugger = new remix.ui.Debugger()
this.sourceMappingDecoder = new remix.util.SourceMappingDecoder()
@@ -30,7 +31,7 @@ function Debugger (id, appAPI, executionContextEvent, editorEvent) {
this.breakPointManager.add({fileName: fileName, row: row})
})
- executionContextEvent.register('contextChanged', this, function (context) {
+ executionContext.event.register('contextChanged', this, function (context) {
self.switchProvider(context)
})
diff --git a/src/app/execution/txFormat.js b/src/app/execution/txFormat.js
index 8343d20795..72c8038c6e 100644
--- a/src/app/execution/txFormat.js
+++ b/src/app/execution/txFormat.js
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN
var helper = require('./txHelper')
var TreeView = require('ethereum-remix').ui.TreeView
+var executionContext = require('../../execution-context')
module.exports = {
/**
@@ -16,10 +17,9 @@ module.exports = {
* @param {Object} funAbi - abi definition of the function to call. null if building data for the ctor.
* @param {Object} params - input paramater of the function to call
* @param {Object} udapp - udapp
- * @param {Object} executionContext - executionContext
* @param {Function} callback - callback
*/
- buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, executionContext, callback) {
+ buildData: function (contract, contracts, isConstructor, funAbi, params, udapp, callback) {
var funArgs = ''
try {
funArgs = $.parseJSON('[' + params + ']')
@@ -47,7 +47,7 @@ module.exports = {
if (isConstructor) {
var bytecodeToDeploy = contract.bytecode
if (bytecodeToDeploy.indexOf('_') >= 0) {
- this.linkBytecode(contract, contracts, executionContext, udapp, (err, bytecode) => {
+ this.linkBytecode(contract, contracts, udapp, (err, bytecode) => {
if (err) {
callback('Error deploying required libraries: ' + err)
} else {
@@ -67,7 +67,7 @@ module.exports = {
atAddress: function () {},
- linkBytecode: function (contract, contracts, executionContext, udapp, callback) {
+ linkBytecode: function (contract, contracts, udapp, callback) {
var bytecode = contract.bytecode
if (bytecode.indexOf('_') < 0) {
return callback(null, bytecode)
@@ -81,7 +81,7 @@ module.exports = {
if (!libraryabi) {
return callback('Library ' + libraryName + ' not found.')
}
- this.deployLibrary(libraryabi, executionContext, udapp, (err, address) => {
+ this.deployLibrary(libraryabi, udapp, (err, address) => {
if (err) {
return callback(err)
}
@@ -95,11 +95,11 @@ module.exports = {
bytecode = bytecode.replace(libLabel, hexAddress)
}
contract.bytecode = bytecode
- this.linkBytecode(contract, contracts, executionContext, udapp, callback)
+ this.linkBytecode(contract, contracts, udapp, callback)
})
},
- deployLibrary: function (libraryName, library, executionContext, udapp, callback) {
+ deployLibrary: function (libraryName, library, udapp, callback) {
var address = library.address
if (address) {
return callback(null, address)
diff --git a/src/app/execution/txListener.js b/src/app/execution/txListener.js
index c8da2e3355..ed34067f3f 100644
--- a/src/app/execution/txListener.js
+++ b/src/app/execution/txListener.js
@@ -5,6 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
var EventManager = require('ethereum-remix').lib.EventManager
var remix = require('ethereum-remix')
var codeUtil = remix.util.code
+var executionContext = require('../../execution-context')
/**
* poll web3 each 2s if web3
@@ -20,15 +21,15 @@ class TxListener {
this._resolvedTransactions = {}
this._resolvedContracts = {}
this.init()
- opt.event.executionContext.register('contextChanged', (context) => {
+ executionContext.event.register('contextChanged', (context) => {
if (this.loopId) {
this.startListening(context)
}
})
opt.event.udapp.register('transactionExecuted', (error, to, data, lookupOnly, txResult) => {
if (error) return
- if (this.loopId && this._api.isVM()) {
- this._api.web3().eth.getTransaction(txResult.transactionHash, (error, tx) => {
+ if (this.loopId && executionContext.isVM()) {
+ executionContext.web3().eth.getTransaction(txResult.transactionHash, (error, tx) => {
if (error) return console.log(error)
this._newBlock({
type: 'VM',
@@ -57,16 +58,16 @@ class TxListener {
startListening () {
this.stopListening()
this.init()
- if (this._api.context() === 'vm') {
+ if (executionContext.getProvider() === 'vm') {
this.loopId = 'vm-listener'
} else {
this.loopId = setInterval(() => {
- this._api.web3().eth.getBlockNumber((error, blockNumber) => {
+ executionContext.web3().eth.getBlockNumber((error, blockNumber) => {
if (this.loopId === null || this.loopId === 'vm-listener') return
if (error) return console.log(error)
if (!this.lastBlock || blockNumber > this.lastBlock) {
this.lastBlock = blockNumber
- this._api.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
+ executionContext.web3().eth.getBlock(this.lastBlock, true, (error, result) => {
if (!error) {
this._newBlock(Object.assign({type: 'web3'}, result))
}
@@ -131,6 +132,7 @@ class TxListener {
}
_resolveTx (tx, cb) {
+ console.log(tx)
var contracts = this._api.contracts()
if (!contracts) return cb()
var contractName
@@ -158,7 +160,7 @@ class TxListener {
// first check known contract, resolve against the `runtimeBytecode` if not known
contractName = this._resolvedContracts[tx.to]
if (!contractName) {
- this._api.web3().eth.getCode(tx.to, (error, code) => {
+ executionContext.web3().eth.getCode(tx.to, (error, code) => {
if (error) return cb(error)
if (code) {
var contractName = this._tryResolveContract(code, contracts, 'runtimeBytecode')
diff --git a/src/app/execution/txLogger.js b/src/app/execution/txLogger.js
index 27e869e040..d5e28a501d 100644
--- a/src/app/execution/txLogger.js
+++ b/src/app/execution/txLogger.js
@@ -5,6 +5,7 @@ var EventManager = remix.lib.EventManager
var helper = require('../../lib/helper')
var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN
+var executionContext = require('../../execution-context')
/**
* This just export a function that register to `newTransaction` and forward them to the logger.
@@ -66,7 +67,7 @@ function renderUnknownTransaction (self, data) {
}
function context (self, tx) {
- if (self.opts.api.context() === 'vm') {
+ if (executionContext.getProvider() === 'vm') {
return yo`(vm)`
} else {
return yo`block:${tx.blockNumber}, txIndex:${tx.transactionIndex}`
diff --git a/src/app/execution/txRunner.js b/src/app/execution/txRunner.js
index b7680d67e9..a754129f9b 100644
--- a/src/app/execution/txRunner.js
+++ b/src/app/execution/txRunner.js
@@ -3,15 +3,13 @@ var EthJSTX = require('ethereumjs-tx')
var EthJSBlock = require('ethereumjs-block')
var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN
+var executionContext = require('../../execution-context')
-function TxRunner (executionContext, vmaccounts, opts) {
- this.executionContext = executionContext
- this.web3 = executionContext.web3()
- this.vm = executionContext.vm()
+function TxRunner (vmaccounts, opts) {
this.queueTxs = opts.queueTxs
this.personalMode = opts.personalMode
this.blockNumber = 0
- if (this.executionContext.isVM()) {
+ if (executionContext.isVM()) {
this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block.
}
this.pendingTxs = {}
@@ -35,7 +33,7 @@ TxRunner.prototype.execute = function (args, callback) {
var gasLimit = args.gasLimit
var tx
- if (!self.executionContext.isVM()) {
+ if (!executionContext.isVM()) {
tx = {
from: from,
to: to,
@@ -44,18 +42,18 @@ TxRunner.prototype.execute = function (args, callback) {
}
if (args.useCall) {
tx.gas = gasLimit
- self.web3.eth.call(tx, function (error, result) {
+ executionContext.web3().eth.call(tx, function (error, result) {
callback(error, {
result: result,
transactionHash: result.transactionHash
})
})
} else {
- self.web3.eth.estimateGas(tx, function (err, gasEstimation) {
+ executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) {
if (err) {
return callback(err, gasEstimation)
}
- var blockGasLimit = self.executionContext.currentblockGasLimit()
+ var blockGasLimit = executionContext.currentblockGasLimit()
// NOTE: estimateGas very likely will return a large limit if execution of the code failed
// we want to be able to run the code in order to debug and find the cause for the failure
if (gasEstimation > gasLimit) {
@@ -65,7 +63,7 @@ TxRunner.prototype.execute = function (args, callback) {
return callback('Gas required exceeds block gas limit: ' + gasLimit)
}
tx.gas = gasEstimation
- var sendTransaction = self.personalMode ? self.web3.personal.sendTransaction : self.web3.eth.sendTransaction
+ var sendTransaction = self.personalMode ? executionContext.web3().personal.sendTransaction : executionContext.web3().eth.sendTransaction
sendTransaction(tx, function (err, resp) {
if (err) {
return callback(err, resp)
@@ -107,12 +105,12 @@ TxRunner.prototype.execute = function (args, callback) {
if (!args.useCall) {
++self.blockNumber
} else {
- self.vm.stateManager.checkpoint()
+ executionContext.vm().stateManager.checkpoint()
}
- self.vm.runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, function (err, result) {
+ executionContext.vm().runTx({block: block, tx: tx, skipBalance: true, skipNonce: true}, function (err, result) {
if (args.useCall) {
- self.vm.stateManager.revert(function () {})
+ executionContext.vm().stateManager.revert(function () {})
}
err = err ? err.message : err
callback(err, {
@@ -126,11 +124,11 @@ TxRunner.prototype.execute = function (args, callback) {
}
}
-function tryTillResponse (web3, txhash, done) {
- web3.eth.getTransactionReceipt(txhash, function (err, result) {
+function tryTillResponse (txhash, done) {
+ executionContext.web3().eth.getTransactionReceipt(txhash, function (err, result) {
if (!err && !result) {
// Try again with a bit of delay
- setTimeout(function () { tryTillResponse(web3, txhash, done) }, 500)
+ setTimeout(function () { tryTillResponse(txhash, done) }, 500)
} else {
done(err, {
result: result,
diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js
index 7963b11d0f..130654472d 100644
--- a/src/app/tabs/run-tab.js
+++ b/src/app/tabs/run-tab.js
@@ -6,6 +6,7 @@ var txExecution = require('../execution/txExecution')
var txFormat = require('../execution/txFormat')
var txHelper = require('../execution/txHelper')
var modalDialogCustom = require('../ui/modal-dialog-custom')
+var executionContext = require('../../execution-context')
const copy = require('clipboard-copy')
// -------------- styling ----------------------
@@ -200,15 +201,15 @@ function runTab (container, appAPI, appEvents, opts) {
// DROPDOWN
var selectExEnv = el.querySelector('#selectExEnvOptions')
selectExEnv.addEventListener('change', function (event) {
- if (!appAPI.executionContextChange(selectExEnv.options[selectExEnv.selectedIndex].value)) {
- selectExEnv.value = appAPI.executionContextProvider()
+ if (!executionContext.executionContextChange(selectExEnv.options[selectExEnv.selectedIndex].value)) {
+ selectExEnv.value = executionContext.getProvider()
}
fillAccountsList(appAPI, el)
instanceContainer.innerHTML = '' // clear the instances list
noInstancesText.style.display = 'block'
instanceContainer.appendChild(noInstancesText)
})
- selectExEnv.value = appAPI.executionContextProvider()
+ selectExEnv.value = executionContext.getProvider()
fillAccountsList(appAPI, el)
setInterval(() => {
updateAccountBalances(container, appAPI)
@@ -299,11 +300,11 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerHTML]
var constructor = txHelper.getConstructorInterface(contract.interface)
var args = createButtonInput.value
- txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), appAPI.executionContext(), (error, data) => {
+ txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), (error, data) => {
if (!error) {
txExecution.createContract(data, appAPI.udapp(), (error, txResult) => {
if (!error) {
- var isVM = appAPI.executionContext().isVM()
+ var isVM = executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
if (vmError.error) {
diff --git a/src/execution-context.js b/src/execution-context.js
index f14e91924d..5dc387fc3c 100644
--- a/src/execution-context.js
+++ b/src/execution-context.js
@@ -6,6 +6,8 @@ var EventManager = require('ethereum-remix').lib.EventManager
var EthJSVM = require('ethereumjs-vm')
var ethUtil = require('ethereumjs-util')
var StateManager = require('ethereumjs-vm/lib/stateManager')
+var remix = require('ethereum-remix')
+var Web3VMProvider = remix.web3.web3VMProvider
var injectedProvider
@@ -17,6 +19,8 @@ if (typeof window.web3 !== 'undefined') {
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
}
+var blankWeb3 = new Web3()
+
/*
extend vm state manager and instanciate VM
*/
@@ -65,6 +69,9 @@ vm.blockchain = stateManager.blockchain
vm.trie = stateManager.trie
vm.stateManager.checkpoint()
+var web3VM = new Web3VMProvider()
+web3VM.setVM(vm)
+
/*
trigger contextChanged, web3EndpointChanged
*/
@@ -82,7 +89,11 @@ function ExecutionContext () {
}
this.web3 = function () {
- return web3
+ return this.isVM() ? web3VM : web3
+ }
+
+ this.blankWeb3 = function () {
+ return blankWeb3
}
this.vm = function () {
@@ -150,4 +161,4 @@ function ExecutionContext () {
}
}
-module.exports = ExecutionContext
+module.exports = new ExecutionContext()
diff --git a/src/universal-dapp.js b/src/universal-dapp.js
index 420c7e1e04..a376826154 100644
--- a/src/universal-dapp.js
+++ b/src/universal-dapp.js
@@ -14,6 +14,7 @@ var txHelper = require('./app/execution/txHelper')
var txExecution = require('./app/execution/txExecution')
var helper = require('./lib/helper')
var modalDialogCustom = require('./app/ui/modal-dialog-custom')
+var executionContext = require('./execution-context')
// copy to copyToClipboard
const copy = require('clipboard-copy')
@@ -95,7 +96,7 @@ var css = csjs`
/*
trigger debugRequested
*/
-function UniversalDApp (executionContext, options) {
+function UniversalDApp (options) {
this.event = new EventManager()
var self = this
@@ -104,13 +105,10 @@ function UniversalDApp (executionContext, options) {
self.personalMode = self.options.personalMode || false
self.contracts
self.transactionContextAPI
- self.web3 = executionContext.web3()
- self.vm = executionContext.vm()
- self.executionContext = executionContext
- self.executionContext.event.register('contextChanged', this, function (context) {
+ executionContext.event.register('contextChanged', this, function (context) {
self.reset(self.contracts)
})
- self.txRunner = new TxRunner(executionContext, {}, {
+ self.txRunner = new TxRunner({}, {
queueTxs: true,
personalMode: this.personalMode
})
@@ -121,26 +119,26 @@ UniversalDApp.prototype.reset = function (contracts, transactionContextAPI) {
this.contracts = contracts
this.transactionContextAPI = transactionContextAPI
this.accounts = {}
- if (this.executionContext.isVM()) {
+ if (executionContext.isVM()) {
this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000')
this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c', '0x56BC75E2D63100000')
this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', '0x56BC75E2D63100000')
this._addAccount('d74aa6d18aa79a05f3473dd030a97d3305737cbc8337d940344345c1f6b72eea', '0x56BC75E2D63100000')
this._addAccount('71975fbf7fe448e004ac7ae54cad0a383c3906055a65468714156a07385e96ce', '0x56BC75E2D63100000')
- this.vm.stateManager.cache.flush(function () {})
+ executionContext.vm().stateManager.cache.flush(function () {})
}
- this.txRunner = new TxRunner(this.executionContext, this.accounts, {
+ this.txRunner = new TxRunner(this.accounts, {
queueTxs: true,
personalMode: this.personalMode
})
}
UniversalDApp.prototype.newAccount = function (password, cb) {
- if (!this.executionContext.isVM()) {
+ if (!executionContext.isVM()) {
if (!this.personalMode) {
return cb('Not running in personal mode')
}
- this.web3.personal.newAccount(password, cb)
+ executionContext.web3().personal.newAccount(password, cb)
} else {
var privateKey
do {
@@ -154,7 +152,7 @@ UniversalDApp.prototype.newAccount = function (password, cb) {
UniversalDApp.prototype._addAccount = function (privateKey, balance) {
var self = this
- if (!self.executionContext.isVM()) {
+ if (!executionContext.isVM()) {
throw new Error('_addAccount() cannot be called in non-VM mode')
}
@@ -163,7 +161,7 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
var address = ethJSUtil.privateToAddress(privateKey)
// FIXME: we don't care about the callback, but we should still make this proper
- self.vm.stateManager.putAccountBalance(address, balance || '0xf00000000000000001', function cb () {})
+ executionContext.vm().stateManager.putAccountBalance(address, balance || '0xf00000000000000001', function cb () {})
self.accounts['0x' + address.toString('hex')] = { privateKey: privateKey, nonce: 0 }
}
}
@@ -171,13 +169,13 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
UniversalDApp.prototype.getAccounts = function (cb) {
var self = this
- if (!self.executionContext.isVM()) {
+ if (!executionContext.isVM()) {
// Weirdness of web3: listAccounts() is sync, `getListAccounts()` is async
// See: https://github.com/ethereum/web3.js/issues/442
if (self.personalMode) {
- self.web3.personal.getListAccounts(cb)
+ executionContext.web3().personal.getListAccounts(cb)
} else {
- self.web3.eth.getAccounts(cb)
+ executionContext.web3().eth.getAccounts(cb)
}
} else {
if (!self.accounts) {
@@ -193,8 +191,8 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
address = ethJSUtil.stripHexPrefix(address)
- if (!self.executionContext.isVM()) {
- self.web3.eth.getBalance(address, function (err, res) {
+ if (!executionContext.isVM()) {
+ executionContext.web3().eth.getBalance(address, function (err, res) {
if (err) {
cb(err)
} else {
@@ -206,7 +204,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
return cb('No accounts?')
}
- self.vm.stateManager.getAccountBalance(new Buffer(address, 'hex'), function (err, res) {
+ executionContext.vm().stateManager.getAccountBalance(new Buffer(address, 'hex'), function (err, res) {
if (err) {
cb('Account not found')
} else {
@@ -223,7 +221,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
UniversalDApp.prototype.renderInstance = function (contract, address, contractName) {
function remove () { $instance.remove() }
var $instance = $(``)
- var context = this.executionContext.isVM() ? 'memory' : 'blockchain'
+ var context = executionContext.isVM() ? 'memory' : 'blockchain'
address = (address.slice(0, 2) === '0x' ? '' : '0x') + address.toString('hex')
var shortAddress = helper.shortenAddress(address)
@@ -306,11 +304,11 @@ UniversalDApp.prototype.getCallButton = function (args) {
})
function call () {
- txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.val(), self, self.executionContext, (error, data) => {
+ txFormat.buildData(args.contractAbi, self.contracts, false, args.funABI, inputField.val(), self, (error, data) => {
if (!error) {
txExecution.callFunction(args.address, data, args.funABI, self, (error, txResult) => {
if (!error) {
- var isVM = self.executionContext.isVM()
+ var isVM = executionContext.isVM()
if (isVM) {
var vmError = txExecution.checkVMError(txResult)
if (vmError.error) {
@@ -319,7 +317,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
if (lookupOnly) {
- txFormat.decodeResponse(self.executionContext.isVM() ? txResult.result.vm.return : ethJSUtil.toBuffer(txResult.result), args.funABI, (error, decoded) => {
+ txFormat.decodeResponse(executionContext.isVM() ? txResult.result.vm.return : ethJSUtil.toBuffer(txResult.result), args.funABI, (error, decoded) => {
$outputOverride.html(error ? 'error' + error : decoded)
})
}
@@ -429,7 +427,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
return callback('No accounts available')
}
- if (self.executionContext.isVM() && !self.accounts[ret[0]]) {
+ if (executionContext.isVM() && !self.accounts[ret[0]]) {
return callback('Invalid account selected')
}