Merge pull request #1362 from ethereum/refactor_executionContext

refactor execution context
pull/5370/head
Iuri Matias 5 years ago committed by GitHub
commit 2e42714241
  1. 43
      package-lock.json
  2. 3
      remix-debug/src/cmdline/contextManager.js
  3. 5
      remix-debug/src/cmdline/index.js
  4. 29
      remix-lib/src/execution/txListener.js
  5. 38
      remix-lib/src/execution/txRunner.js
  6. 56
      remix-lib/src/universalDapp.js
  7. 4
      remix-simulator/src/genesis.js
  8. 11
      remix-simulator/src/methods/accounts.js
  9. 17
      remix-simulator/src/methods/blocks.js
  10. 24
      remix-simulator/src/methods/filters.js
  11. 30
      remix-simulator/src/methods/transactions.js
  12. 5
      remix-simulator/src/methods/txProcess.js
  13. 14
      remix-simulator/src/provider.js

43
package-lock.json generated

@ -1,5 +1,5 @@
{ {
"version": "0.1.21", "version": "0.1.24",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1721,7 +1721,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -1742,12 +1743,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -1762,17 +1765,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -1889,7 +1895,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -1901,6 +1908,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -1915,6 +1923,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -1922,12 +1931,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -1946,6 +1957,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2026,7 +2038,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2038,6 +2051,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2123,7 +2137,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -2159,6 +2174,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -2178,6 +2194,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -2221,12 +2238,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },

@ -1,13 +1,12 @@
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var EventManager = remixLib.EventManager var EventManager = remixLib.EventManager
var executionContext = remixLib.execution.executionContext
var Web3Providers = remixLib.vm.Web3Providers var Web3Providers = remixLib.vm.Web3Providers
var DummyProvider = remixLib.vm.DummyProvider var DummyProvider = remixLib.vm.DummyProvider
var init = remixLib.init var init = remixLib.init
class ContextManager { class ContextManager {
constructor () { constructor (executionContext) {
this.executionContext = executionContext this.executionContext = executionContext
this.web3 = this.executionContext.web3() this.web3 = this.executionContext.web3()
this.event = new EventManager() this.event = new EventManager()

@ -2,10 +2,13 @@ var Web3 = require('web3')
var Debugger = require('../debugger/debugger.js') var Debugger = require('../debugger/debugger.js')
var ContextManager = require('./contextManager.js') var ContextManager = require('./contextManager.js')
var EventManager = require('events') var EventManager = require('events')
var remixLib = require('remix-lib')
var executionContext = remixLib.execution.executionContext
class CmdLine { class CmdLine {
constructor () { constructor () {
this.executionContext = executionContext
this.events = new EventManager() this.events = new EventManager()
this.lineColumnPos = null this.lineColumnPos = null
this.rawLocation = null this.rawLocation = null
@ -30,7 +33,7 @@ class CmdLine {
initDebugger (cb) { initDebugger (cb) {
const self = this const self = this
this.contextManager = new ContextManager() this.contextManager = new ContextManager(this.executionContext)
this.debugger = new Debugger({ this.debugger = new Debugger({
web3: this.contextManager.getWeb3(), web3: this.contextManager.getWeb3(),

@ -5,7 +5,7 @@ var ethJSUtil = require('ethereumjs-util')
var EventManager = require('../eventManager') var EventManager = require('../eventManager')
var codeUtil = require('../util') var codeUtil = require('../util')
var executionContext = require('./execution-context') var defaultExecutionContext = require('./execution-context')
var txFormat = require('./txFormat') var txFormat = require('./txFormat')
var txHelper = require('./txHelper') var txHelper = require('./txHelper')
@ -17,8 +17,10 @@ var txHelper = require('./txHelper')
* *
*/ */
class TxListener { class TxListener {
constructor (opt) { constructor (opt, executionContext) {
this.event = new EventManager() this.event = new EventManager()
// has a default for now for backwards compatability
this.executionContext = executionContext || defaultExecutionContext
this._api = opt.api this._api = opt.api
this._resolvedTransactions = {} this._resolvedTransactions = {}
this._resolvedContracts = {} this._resolvedContracts = {}
@ -26,7 +28,7 @@ class TxListener {
this._listenOnNetwork = false this._listenOnNetwork = false
this._loopId = null this._loopId = null
this.init() this.init()
executionContext.event.register('contextChanged', (context) => { this.executionContext.event.register('contextChanged', (context) => {
if (this._isListening) { if (this._isListening) {
this.stopListening() this.stopListening()
this.startListening() this.startListening()
@ -39,15 +41,16 @@ class TxListener {
// in VM mode // in VM mode
// in web3 mode && listen remix txs only // in web3 mode && listen remix txs only
if (!this._isListening) return // we don't listen if (!this._isListening) return // we don't listen
if (this._loopId && executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network if (this._loopId && this.executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network
var call = { var call = {
from: from, from: from,
to: to, to: to,
input: data, input: data,
hash: txResult.transactionHash ? txResult.transactionHash : 'call' + (from || '') + to + data, hash: txResult.transactionHash ? txResult.transactionHash : 'call' + (from || '') + to + data,
isCall: true, isCall: true,
returnValue: executionContext.isVM() ? txResult.result.execResult.returnValue : ethJSUtil.toBuffer(txResult.result), returnValue: this.executionContext.isVM() ? txResult.result.execResult.returnValue : ethJSUtil.toBuffer(txResult.result),
envMode: executionContext.getProvider() envMode: this.executionContext.getProvider()
} }
addExecutionCosts(txResult, call) addExecutionCosts(txResult, call)
@ -65,12 +68,12 @@ class TxListener {
// in VM mode // in VM mode
// in web3 mode && listen remix txs only // in web3 mode && listen remix txs only
if (!this._isListening) return // we don't listen if (!this._isListening) return // we don't listen
if (this._loopId && executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network if (this._loopId && this.executionContext.getProvider() !== 'vm') return // we seems to already listen on a "web3" network
executionContext.web3().eth.getTransaction(txResult.transactionHash, (error, tx) => { this.executionContext.web3().eth.getTransaction(txResult.transactionHash, (error, tx) => {
if (error) return console.log(error) if (error) return console.log(error)
addExecutionCosts(txResult, tx) addExecutionCosts(txResult, tx)
tx.envMode = executionContext.getProvider() tx.envMode = this.executionContext.getProvider()
tx.status = txResult.result.status // 0x0 or 0x1 tx.status = txResult.result.status // 0x0 or 0x1
this._resolve([tx], () => { this._resolve([tx], () => {
}) })
@ -120,7 +123,7 @@ class TxListener {
startListening () { startListening () {
this.init() this.init()
this._isListening = true this._isListening = true
if (this._listenOnNetwork && executionContext.getProvider() !== 'vm') { if (this._listenOnNetwork && this.executionContext.getProvider() !== 'vm') {
this._startListenOnNetwork() this._startListenOnNetwork()
} }
} }
@ -142,7 +145,7 @@ class TxListener {
_startListenOnNetwork () { _startListenOnNetwork () {
this._loopId = setInterval(() => { this._loopId = setInterval(() => {
var currentLoopId = this._loopId var currentLoopId = this._loopId
executionContext.web3().eth.getBlockNumber((error, blockNumber) => { this.executionContext.web3().eth.getBlockNumber((error, blockNumber) => {
if (this._loopId === null) return if (this._loopId === null) return
if (error) return console.log(error) if (error) return console.log(error)
if (currentLoopId === this._loopId && (!this.lastBlock || blockNumber > this.lastBlock)) { if (currentLoopId === this._loopId && (!this.lastBlock || blockNumber > this.lastBlock)) {
@ -163,7 +166,7 @@ class TxListener {
} }
_manageBlock (blockNumber) { _manageBlock (blockNumber) {
executionContext.web3().eth.getBlock(blockNumber, true, (error, result) => { this.executionContext.web3().eth.getBlock(blockNumber, true, (error, result) => {
if (!error) { if (!error) {
this._newBlock(Object.assign({type: 'web3'}, result)) this._newBlock(Object.assign({type: 'web3'}, result))
} }
@ -240,7 +243,7 @@ class TxListener {
// first check known contract, resolve against the `runtimeBytecode` if not known // first check known contract, resolve against the `runtimeBytecode` if not known
contractName = this._resolvedContracts[tx.to] contractName = this._resolvedContracts[tx.to]
if (!contractName) { if (!contractName) {
executionContext.web3().eth.getCode(tx.to, (error, code) => { this.executionContext.web3().eth.getCode(tx.to, (error, code) => {
if (error) return cb(error) if (error) return cb(error)
if (code) { if (code) {
var contractName = this._tryResolveContract(code, contracts, false) var contractName = this._tryResolveContract(code, contracts, false)

@ -3,16 +3,18 @@ var EthJSTX = require('ethereumjs-tx').Transaction
var EthJSBlock = require('ethereumjs-block') var EthJSBlock = require('ethereumjs-block')
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
var executionContext = require('./execution-context') var defaultExecutionContext = require('./execution-context')
var EventManager = require('../eventManager') var EventManager = require('../eventManager')
class TxRunner { class TxRunner {
constructor (vmaccounts, api) { constructor (vmaccounts, api, executionContext) {
this.event = new EventManager() this.event = new EventManager()
// has a default for now for backwards compatability
this.executionContext = executionContext || defaultExecutionContext
this._api = api this._api = api
this.blockNumber = 0 this.blockNumber = 0
this.runAsync = true this.runAsync = true
if (executionContext.isVM()) { if (this.executionContext.isVM()) {
// this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block. // this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block.
this.blockNumber = 0 // The VM is running in Homestead mode, which started at this block. this.blockNumber = 0 // The VM is running in Homestead mode, which started at this block.
this.runAsync = false // We have to run like this cause the VM Event Manager does not support running multiple txs at the same time. this.runAsync = false // We have to run like this cause the VM Event Manager does not support running multiple txs at the same time.
@ -32,18 +34,18 @@ class TxRunner {
} }
_executeTx (tx, gasPrice, api, promptCb, callback) { _executeTx (tx, gasPrice, api, promptCb, callback) {
if (gasPrice) tx.gasPrice = executionContext.web3().utils.toHex(gasPrice) if (gasPrice) tx.gasPrice = this.executionContext.web3().toHex(gasPrice)
if (api.personalMode()) { if (api.personalMode()) {
promptCb( promptCb(
(value) => { (value) => {
this._sendTransaction(executionContext.web3().personal.sendTransaction, tx, value, callback) this._sendTransaction(this.executionContext.web3().personal.sendTransaction, tx, value, callback)
}, },
() => { () => {
return callback('Canceled by user.') return callback('Canceled by user.')
} }
) )
} else { } else {
this._sendTransaction(executionContext.web3().eth.sendTransaction, tx, null, callback) this._sendTransaction(this.executionContext.web3().eth.sendTransaction, tx, null, callback)
} }
} }
@ -83,7 +85,7 @@ class TxRunner {
data = '0x' + data data = '0x' + data
} }
if (!executionContext.isVM()) { if (!this.executionContext.isVM()) {
self.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, confirmationCb, gasEstimationForceSend, promptCb, callback) self.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, confirmationCb, gasEstimationForceSend, promptCb, callback)
} else { } else {
try { try {
@ -101,7 +103,7 @@ class TxRunner {
return callback('Invalid account selected') return callback('Invalid account selected')
} }
executionContext.vm().stateManager.getAccount(Buffer.from(from.replace('0x', ''), 'hex'), (err, res) => { this.executionContext.vm().stateManager.getAccount(Buffer.from(from.replace('0x', ''), 'hex'), (err, res) => {
if (err) { if (err) {
callback('Account not found') callback('Account not found')
} else { } else {
@ -132,9 +134,9 @@ class TxRunner {
++self.blockNumber ++self.blockNumber
this.runBlockInVm(tx, block, callback) this.runBlockInVm(tx, block, callback)
} else { } else {
executionContext.vm().stateManager.checkpoint(() => { this.executionContext.vm().stateManager.checkpoint(() => {
this.runBlockInVm(tx, block, (err, result) => { this.runBlockInVm(tx, block, (err, result) => {
executionContext.vm().stateManager.revert(() => { this.executionContext.vm().stateManager.revert(() => {
callback(err, result) callback(err, result)
}) })
}) })
@ -145,14 +147,14 @@ class TxRunner {
} }
runBlockInVm (tx, block, callback) { runBlockInVm (tx, block, callback) {
executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }).then(function (results) { this.executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }).then((results) => {
let result = results.results[0] let result = results.results[0]
if (result) { if (result) {
const status = result.execResult.exceptionError ? 0 : 1 const status = result.execResult.exceptionError ? 0 : 1
result.status = `0x${status}` result.status = `0x${status}`
} }
executionContext.addBlock(block) this.executionContext.addBlock(block)
executionContext.trackTx('0x' + tx.hash().toString('hex'), block) this.executionContext.trackTx('0x' + tx.hash().toString('hex'), block)
callback(null, { callback(null, {
result: result, result: result,
transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash())) transactionHash: ethJSUtil.bufferToHex(Buffer.from(tx.hash()))
@ -168,14 +170,14 @@ class TxRunner {
if (useCall) { if (useCall) {
tx.gas = gasLimit tx.gas = gasLimit
return executionContext.web3().eth.call(tx, function (error, result) { return this.executionContext.web3().eth.call(tx, function (error, result) {
callback(error, { callback(error, {
result: result, result: result,
transactionHash: result ? result.transactionHash : null transactionHash: result ? result.transactionHash : null
}) })
}) })
} }
executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) { this.executionContext.web3().eth.estimateGas(tx, function (err, gasEstimation) {
gasEstimationForceSend(err, () => { gasEstimationForceSend(err, () => {
// callback is called whenever no error // callback is called whenever no error
tx.gas = !gasEstimation ? gasLimit : gasEstimation tx.gas = !gasEstimation ? gasLimit : gasEstimation
@ -197,7 +199,7 @@ class TxRunner {
}) })
}) })
}, () => { }, () => {
var blockGasLimit = executionContext.currentblockGasLimit() var blockGasLimit = self.executionContext.currentblockGasLimit()
// NOTE: estimateGas very likely will return a large limit if execution of the code failed // 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 // we want to be able to run the code in order to debug and find the cause for the failure
if (err) return callback(err) if (err) return callback(err)
@ -218,7 +220,7 @@ class TxRunner {
async function tryTillReceiptAvailable (txhash, done) { async function tryTillReceiptAvailable (txhash, done) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
executionContext.web3().eth.getTransactionReceipt(txhash, async (err, receipt) => { this.executionContext.web3().eth.getTransactionReceipt(txhash, async (err, receipt) => {
if (err || !receipt) { if (err || !receipt) {
// Try again with a bit of delay if error or if result still null // Try again with a bit of delay if error or if result still null
await pause() await pause()
@ -232,7 +234,7 @@ async function tryTillReceiptAvailable (txhash, done) {
async function tryTillTxAvailable (txhash, done) { async function tryTillTxAvailable (txhash, done) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
executionContext.web3().eth.getTransaction(txhash, async (err, tx) => { this.executionContext.web3().eth.getTransaction(txhash, async (err, tx) => {
if (err || !tx) { if (err || !tx) {
// Try again with a bit of delay if error or if result still null // Try again with a bit of delay if error or if result still null
await pause() await pause()

@ -6,27 +6,29 @@ const { EventEmitter } = require('events')
const TxRunner = require('./execution/txRunner') const TxRunner = require('./execution/txRunner')
const txHelper = require('./execution/txHelper') const txHelper = require('./execution/txHelper')
const EventManager = require('./eventManager') const EventManager = require('./eventManager')
const executionContext = require('./execution/execution-context') const defaultExecutionContext = require('./execution/execution-context')
const { resultToRemixTx } = require('./helpers/txResultHelper') const { resultToRemixTx } = require('./helpers/txResultHelper')
module.exports = class UniversalDApp { module.exports = class UniversalDApp {
constructor (config) { constructor (config, executionContext) {
this.events = new EventEmitter() this.events = new EventEmitter()
this.event = new EventManager() this.event = new EventManager()
// has a default for now for backwards compatability
this.executionContext = executionContext || defaultExecutionContext
this.config = config this.config = config
this.txRunner = new TxRunner({}, { this.txRunner = new TxRunner({}, {
config: config, config: config,
detectNetwork: (cb) => { detectNetwork: (cb) => {
executionContext.detectNetwork(cb) this.executionContext.detectNetwork(cb)
}, },
personalMode: () => { personalMode: () => {
return executionContext.getProvider() === 'web3' ? this.config.get('settings/personal-mode') : false return this.executionContext.getProvider() === 'web3' ? this.config.get('settings/personal-mode') : false
} }
}) }, this.executionContext)
this.accounts = {} this.accounts = {}
executionContext.event.register('contextChanged', this.resetEnvironment.bind(this)) this.executionContext.event.register('contextChanged', this.resetEnvironment.bind(this))
} }
// TODO : event should be triggered by Udapp instead of TxListener // TODO : event should be triggered by Udapp instead of TxListener
@ -39,7 +41,7 @@ module.exports = class UniversalDApp {
resetEnvironment () { resetEnvironment () {
this.accounts = {} this.accounts = {}
if (executionContext.isVM()) { if (this.executionContext.isVM()) {
this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000') this._addAccount('3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511', '0x56BC75E2D63100000')
this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c', '0x56BC75E2D63100000') this._addAccount('2ac6c190b09897cd8987869cc7b918cfea07ee82038d492abce033c75c1b1d0c', '0x56BC75E2D63100000')
this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', '0x56BC75E2D63100000') this._addAccount('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', '0x56BC75E2D63100000')
@ -52,14 +54,14 @@ module.exports = class UniversalDApp {
config: this.config, config: this.config,
// TODO: to refactor, TxRunner already has access to executionContext // TODO: to refactor, TxRunner already has access to executionContext
detectNetwork: (cb) => { detectNetwork: (cb) => {
executionContext.detectNetwork(cb) this.executionContext.detectNetwork(cb)
}, },
personalMode: () => { personalMode: () => {
return executionContext.getProvider() === 'web3' ? this.config.get('settings/personal-mode') : false return this.executionContext.getProvider() === 'web3' ? this.config.get('settings/personal-mode') : false
} }
}) }, this.executionContext)
this.txRunner.event.register('transactionBroadcasted', (txhash) => { this.txRunner.event.register('transactionBroadcasted', (txhash) => {
executionContext.detectNetwork((error, network) => { this.executionContext.detectNetwork((error, network) => {
if (error || !network) return if (error || !network) return
this.event.trigger('transactionBroadcasted', [txhash, network.name]) this.event.trigger('transactionBroadcasted', [txhash, network.name])
}) })
@ -76,7 +78,7 @@ module.exports = class UniversalDApp {
*/ */
createVMAccount (newAccount) { createVMAccount (newAccount) {
const { privateKey, balance } = newAccount const { privateKey, balance } = newAccount
if (executionContext.getProvider() !== 'vm') { if (this.executionContext.getProvider() !== 'vm') {
throw new Error('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed') throw new Error('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed')
} }
this._addAccount(privateKey, balance) this._addAccount(privateKey, balance)
@ -85,12 +87,12 @@ module.exports = class UniversalDApp {
} }
newAccount (password, passwordPromptCb, cb) { newAccount (password, passwordPromptCb, cb) {
if (!executionContext.isVM()) { if (!this.executionContext.isVM()) {
if (!this.config.get('settings/personal-mode')) { if (!this.config.get('settings/personal-mode')) {
return cb('Not running in personal mode') return cb('Not running in personal mode')
} }
passwordPromptCb((passphrase) => { passwordPromptCb((passphrase) => {
executionContext.web3().personal.newAccount(passphrase, cb) this.executionContext.web3().personal.newAccount(passphrase, cb)
}) })
} else { } else {
let privateKey let privateKey
@ -104,7 +106,7 @@ module.exports = class UniversalDApp {
/** Add an account to the list of account (only for Javascript VM) */ /** Add an account to the list of account (only for Javascript VM) */
_addAccount (privateKey, balance) { _addAccount (privateKey, balance) {
if (!executionContext.isVM()) { if (!this.executionContext.isVM()) {
throw new Error('_addAccount() cannot be called in non-VM mode') throw new Error('_addAccount() cannot be called in non-VM mode')
} }
@ -113,7 +115,7 @@ module.exports = class UniversalDApp {
const address = privateToAddress(privateKey) const address = privateToAddress(privateKey)
// FIXME: we don't care about the callback, but we should still make this proper // FIXME: we don't care about the callback, but we should still make this proper
let stateManager = executionContext.vm().stateManager let stateManager = this.executionContext.vm().stateManager
stateManager.getAccount(address, (error, account) => { stateManager.getAccount(address, (error, account) => {
if (error) return console.log(error) if (error) return console.log(error)
account.balance = balance || '0xf00000000000000001' account.balance = balance || '0xf00000000000000001'
@ -129,7 +131,7 @@ module.exports = class UniversalDApp {
/** Return the list of accounts */ /** Return the list of accounts */
getAccounts (cb) { getAccounts (cb) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const provider = executionContext.getProvider() const provider = this.executionContext.getProvider()
switch (provider) { switch (provider) {
case 'vm': { case 'vm': {
if (!this.accounts) { if (!this.accounts) {
@ -143,13 +145,13 @@ module.exports = class UniversalDApp {
break break
case 'web3': { case 'web3': {
if (this.config.get('settings/personal-mode')) { if (this.config.get('settings/personal-mode')) {
return executionContext.web3().personal.getListAccounts((error, accounts) => { return this.executionContext.web3().personal.getListAccounts((error, accounts) => {
if (cb) cb(error, accounts) if (cb) cb(error, accounts)
if (error) return reject(error) if (error) return reject(error)
resolve(accounts) resolve(accounts)
}) })
} else { } else {
executionContext.web3().eth.getAccounts((error, accounts) => { this.executionContext.web3().eth.getAccounts((error, accounts) => {
if (cb) cb(error, accounts) if (cb) cb(error, accounts)
if (error) return reject(error) if (error) return reject(error)
resolve(accounts) resolve(accounts)
@ -158,7 +160,7 @@ module.exports = class UniversalDApp {
} }
break break
case 'injected': { case 'injected': {
executionContext.web3().eth.getAccounts((error, accounts) => { this.executionContext.web3().eth.getAccounts((error, accounts) => {
if (cb) cb(error, accounts) if (cb) cb(error, accounts)
if (error) return reject(error) if (error) return reject(error)
resolve(accounts) resolve(accounts)
@ -172,8 +174,8 @@ module.exports = class UniversalDApp {
getBalance (address, cb) { getBalance (address, cb) {
address = stripHexPrefix(address) address = stripHexPrefix(address)
if (!executionContext.isVM()) { if (!this.executionContext.isVM()) {
executionContext.web3().eth.getBalance(address, (err, res) => { this.executionContext.web3().eth.getBalance(address, (err, res) => {
if (err) { if (err) {
cb(err) cb(err)
} else { } else {
@ -185,7 +187,7 @@ module.exports = class UniversalDApp {
return cb('No accounts?') return cb('No accounts?')
} }
executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, res) => { this.executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, res) => {
if (err) { if (err) {
cb('Account not found') cb('Account not found')
} else { } else {
@ -201,7 +203,7 @@ module.exports = class UniversalDApp {
if (error) { if (error) {
callback(error) callback(error)
} else { } else {
callback(null, executionContext.web3().utils.fromWei(balance, 'ether')) callback(null, this.executionContext.web3().fromWei(balance, 'ether'))
} }
}) })
} }
@ -240,7 +242,7 @@ module.exports = class UniversalDApp {
} }
context () { context () {
return (executionContext.isVM() ? 'memory' : 'blockchain') return (this.executionContext.isVM() ? 'memory' : 'blockchain')
} }
getABI (contract) { getABI (contract) {
@ -266,7 +268,7 @@ module.exports = class UniversalDApp {
*/ */
sendTransaction (tx) { sendTransaction (tx) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
executionContext.detectNetwork((error, network) => { this.executionContext.detectNetwork((error, network) => {
if (error) return reject(error) if (error) return reject(error)
if (network.name === 'Main' && network.id === '1') { if (network.name === 'Main' && network.id === '1') {
return reject(new Error('It is not allowed to make this action against mainnet')) return reject(new Error('It is not allowed to make this action against mainnet'))
@ -334,7 +336,7 @@ module.exports = class UniversalDApp {
if (err) return next(err) if (err) return next(err)
if (!address) return next('No accounts available') if (!address) return next('No accounts available')
if (executionContext.isVM() && !self.accounts[address]) { if (self.executionContext.isVM() && !self.accounts[address]) {
return next('Invalid account selected') return next('Invalid account selected')
} }
next(null, address, value, gasLimit) next(null, address, value, gasLimit)

@ -1,10 +1,8 @@
var EthJSBlock = require('ethereumjs-block') var EthJSBlock = require('ethereumjs-block')
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
function generateBlock () { function generateBlock (executionContext) {
var block = new EthJSBlock({ var block = new EthJSBlock({
header: { header: {
timestamp: (new Date().getTime() / 1000 | 0), timestamp: (new Date().getTime() / 1000 | 0),

@ -1,17 +1,16 @@
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
var Web3 = require('web3') var Web3 = require('web3')
var Accounts = function () { var Accounts = function (executionContext) {
this.web3 = new Web3() this.web3 = new Web3()
this.executionContext = executionContext
// TODO: make it random and/or use remix-libs // TODO: make it random and/or use remix-libs
this.accountsList = [this.web3.eth.accounts.create(['abcd']), this.web3.eth.accounts.create(['ef12']), this.web3.eth.accounts.create(['ef34'])] this.accountsList = [this.web3.eth.accounts.create(['abcd']), this.web3.eth.accounts.create(['ef12']), this.web3.eth.accounts.create(['ef34'])]
this.accounts = {} this.accounts = {}
this.accountsKeys = {} this.accountsKeys = {}
executionContext.init({get: () => { return true }}) this.executionContext.init({get: () => { return true }})
} }
Accounts.prototype.init = async function () { Accounts.prototype.init = async function () {
@ -20,7 +19,7 @@ Accounts.prototype.init = async function () {
this.accountsKeys[ethJSUtil.toChecksumAddress(account.address)] = account.privateKey this.accountsKeys[ethJSUtil.toChecksumAddress(account.address)] = account.privateKey
this.accounts[ethJSUtil.toChecksumAddress(account.address)] = { privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'), nonce: 0 } this.accounts[ethJSUtil.toChecksumAddress(account.address)] = { privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'), nonce: 0 }
executionContext.vm().stateManager.getAccount(Buffer.from(account.address.replace('0x', ''), 'hex'), (err, account) => { this.executionContext.vm().stateManager.getAccount(Buffer.from(account.address.replace('0x', ''), 'hex'), (err, account) => {
if (err) { if (err) {
throw new Error(err) throw new Error(err)
} }
@ -52,7 +51,7 @@ Accounts.prototype.eth_getBalance = function (payload, cb) {
let address = payload.params[0] let address = payload.params[0]
address = ethJSUtil.stripHexPrefix(address) address = ethJSUtil.stripHexPrefix(address)
executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, account) => { this.executionContext.vm().stateManager.getAccount(Buffer.from(address, 'hex'), (err, account) => {
if (err) { if (err) {
return cb(err) return cb(err)
} }

@ -1,7 +1,6 @@
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var Blocks = function (_options) { var Blocks = function (executionContext, _options) {
this.executionContext = executionContext
const options = _options || {} const options = _options || {}
this.coinbase = options.coinbase || '0x0000000000000000000000000000000000000000' this.coinbase = options.coinbase || '0x0000000000000000000000000000000000000000'
this.blockNumber = 0 this.blockNumber = 0
@ -25,10 +24,10 @@ Blocks.prototype.methods = function () {
Blocks.prototype.eth_getBlockByNumber = function (payload, cb) { Blocks.prototype.eth_getBlockByNumber = function (payload, cb) {
let blockIndex = payload.params[0] let blockIndex = payload.params[0]
if (blockIndex === 'latest') { if (blockIndex === 'latest') {
blockIndex = executionContext.latestBlockNumber blockIndex = this.executionContext.latestBlockNumber
} }
const block = executionContext.blocks[blockIndex] const block = this.executionContext.blocks[blockIndex]
if (!block) { if (!block) {
return cb(new Error('block not found')) return cb(new Error('block not found'))
@ -65,7 +64,7 @@ function toHex (value) {
} }
Blocks.prototype.eth_getBlockByHash = function (payload, cb) { Blocks.prototype.eth_getBlockByHash = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]] var block = this.executionContext.blocks[payload.params[0]]
let b = { let b = {
'number': toHex(block.header.number), 'number': toHex(block.header.number),
@ -104,13 +103,13 @@ Blocks.prototype.eth_blockNumber = function (payload, cb) {
} }
Blocks.prototype.eth_getBlockTransactionCountByHash = function (payload, cb) { Blocks.prototype.eth_getBlockTransactionCountByHash = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]] var block = this.executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length) cb(null, block.transactions.length)
} }
Blocks.prototype.eth_getBlockTransactionCountByNumber = function (payload, cb) { Blocks.prototype.eth_getBlockTransactionCountByNumber = function (payload, cb) {
var block = executionContext.blocks[payload.params[0]] var block = this.executionContext.blocks[payload.params[0]]
cb(null, block.transactions.length) cb(null, block.transactions.length)
} }
@ -126,7 +125,7 @@ Blocks.prototype.eth_getUncleCountByBlockNumber = function (payload, cb) {
Blocks.prototype.eth_getStorageAt = function (payload, cb) { Blocks.prototype.eth_getStorageAt = function (payload, cb) {
const [address, position, blockNumber] = payload.params const [address, position, blockNumber] = payload.params
executionContext.web3().debug.storageRangeAt(blockNumber, 'latest', address.toLowerCase(), position, 1, (err, result) => { this.executionContext.web3().debug.storageRangeAt(blockNumber, 'latest', address.toLowerCase(), position, 1, (err, result) => {
if (err || (result.storage && Object.values(result.storage).length === 0)) { if (err || (result.storage && Object.values(result.storage).length === 0)) {
return cb(err, '') return cb(err, '')
} }

@ -1,8 +1,6 @@
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var Filters = function (_options) { var Filters = function (executionContext) {
// const options = _options || {} this.executionContext = executionContext
} }
Filters.prototype.methods = function () { Filters.prototype.methods = function () {
@ -14,49 +12,49 @@ Filters.prototype.methods = function () {
} }
Filters.prototype.eth_getLogs = function (payload, cb) { Filters.prototype.eth_getLogs = function (payload, cb) {
let results = executionContext.logsManager.getLogsFor(payload.params[0]) let results = this.executionContext.logsManager.getLogsFor(payload.params[0])
cb(null, results) cb(null, results)
} }
Filters.prototype.eth_subscribe = function (payload, cb) { Filters.prototype.eth_subscribe = function (payload, cb) {
let subscriptionId = executionContext.logsManager.subscribe(payload.params) let subscriptionId = this.executionContext.logsManager.subscribe(payload.params)
cb(null, subscriptionId) cb(null, subscriptionId)
} }
Filters.prototype.eth_unsubscribe = function (payload, cb) { Filters.prototype.eth_unsubscribe = function (payload, cb) {
executionContext.logsManager.unsubscribe(payload.params[0]) this.executionContext.logsManager.unsubscribe(payload.params[0])
cb(null, true) cb(null, true)
} }
Filters.prototype.eth_newFilter = function (payload, cb) { Filters.prototype.eth_newFilter = function (payload, cb) {
const filterId = executionContext.logsManager.newFilter('filter', payload.params[0]) const filterId = this.executionContext.logsManager.newFilter('filter', payload.params[0])
cb(null, filterId) cb(null, filterId)
} }
Filters.prototype.eth_newBlockFilter = function (payload, cb) { Filters.prototype.eth_newBlockFilter = function (payload, cb) {
const filterId = executionContext.logsManager.newFilter('block') const filterId = this.executionContext.logsManager.newFilter('block')
cb(null, filterId) cb(null, filterId)
} }
Filters.prototype.eth_newPendingTransactionFilter = function (payload, cb) { Filters.prototype.eth_newPendingTransactionFilter = function (payload, cb) {
const filterId = executionContext.logsManager.newFilter('pendingTransactions') const filterId = this.executionContext.logsManager.newFilter('pendingTransactions')
cb(null, filterId) cb(null, filterId)
} }
Filters.prototype.eth_uninstallfilter = function (payload, cb) { Filters.prototype.eth_uninstallfilter = function (payload, cb) {
const result = executionContext.logsManager.uninstallFilter(payload.params[0]) const result = this.executionContext.logsManager.uninstallFilter(payload.params[0])
cb(null, result) cb(null, result)
} }
Filters.prototype.eth_getFilterChanges = function (payload, cb) { Filters.prototype.eth_getFilterChanges = function (payload, cb) {
const filterId = payload.params[0] const filterId = payload.params[0]
let results = executionContext.logsManager.getLogsForFilter(filterId) let results = this.executionContext.logsManager.getLogsForFilter(filterId)
cb(null, results) cb(null, results)
} }
Filters.prototype.eth_getFilterLogs = function (payload, cb) { Filters.prototype.eth_getFilterLogs = function (payload, cb) {
const filterId = payload.params[0] const filterId = payload.params[0]
let results = executionContext.logsManager.getLogsForFilter(filterId, true) let results = this.executionContext.logsManager.getLogsForFilter(filterId, true)
cb(null, results) cb(null, results)
} }

@ -1,11 +1,11 @@
var Web3 = require('web3') var Web3 = require('web3')
var RemixLib = require('remix-lib')
var executionContext = RemixLib.execution.executionContext
var ethJSUtil = require('ethereumjs-util') var ethJSUtil = require('ethereumjs-util')
var processTx = require('./txProcess.js') var processTx = require('./txProcess.js')
var BN = ethJSUtil.BN var BN = ethJSUtil.BN
var Transactions = function () {} var Transactions = function (executionContext) {
this.executionContext = executionContext
}
Transactions.prototype.init = function (accounts) { Transactions.prototype.init = function (accounts) {
this.accounts = accounts this.accounts = accounts
@ -30,16 +30,16 @@ Transactions.prototype.eth_sendTransaction = function (payload, cb) {
if (payload.params && payload.params.length > 0 && payload.params[0].from) { if (payload.params && payload.params.length > 0 && payload.params[0].from) {
payload.params[0].from = ethJSUtil.toChecksumAddress(payload.params[0].from) payload.params[0].from = ethJSUtil.toChecksumAddress(payload.params[0].from)
} }
processTx(this.accounts, payload, false, cb) processTx(this.executionContext, this.accounts, payload, false, cb)
} }
Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => { this.executionContext.web3().eth.getTransactionReceipt(payload.params[0], (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
} }
var txBlock = executionContext.txs[receipt.hash] var txBlock = this.executionContext.txs[receipt.hash]
var r = { var r = {
'transactionHash': receipt.hash, 'transactionHash': receipt.hash,
@ -68,7 +68,7 @@ Transactions.prototype.eth_estimateGas = function (payload, cb) {
Transactions.prototype.eth_getCode = function (payload, cb) { Transactions.prototype.eth_getCode = function (payload, cb) {
let address = payload.params[0] let address = payload.params[0]
executionContext.web3().eth.getCode(address, (error, result) => { this.executionContext.web3().eth.getCode(address, (error, result) => {
if (error) { if (error) {
console.dir('error getting code') console.dir('error getting code')
console.dir(error) console.dir(error)
@ -88,13 +88,13 @@ Transactions.prototype.eth_call = function (payload, cb) {
payload.params[0].value = undefined payload.params[0].value = undefined
processTx(this.accounts, payload, true, cb) processTx(this.executionContext, this.accounts, payload, true, cb)
} }
Transactions.prototype.eth_getTransactionCount = function (payload, cb) { Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
let address = payload.params[0] let address = payload.params[0]
executionContext.vm().stateManager.getAccount(address, (err, account) => { this.executionContext.vm().stateManager.getAccount(address, (err, account) => {
if (err) { if (err) {
return cb(err) return cb(err)
} }
@ -106,12 +106,12 @@ Transactions.prototype.eth_getTransactionCount = function (payload, cb) {
Transactions.prototype.eth_getTransactionByHash = function (payload, cb) { Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
const address = payload.params[0] const address = payload.params[0]
executionContext.web3().eth.getTransactionReceipt(address, (error, receipt) => { this.executionContext.web3().eth.getTransactionReceipt(address, (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
} }
var txBlock = executionContext.txs[receipt.transactionHash] var txBlock = this.executionContext.txs[receipt.transactionHash]
// TODO: params to add later // TODO: params to add later
let r = { let r = {
@ -151,10 +151,10 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) {
Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload, cb) { Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload, cb) {
const txIndex = payload.params[1] const txIndex = payload.params[1]
var txBlock = executionContext.blocks[payload.params[0]] var txBlock = this.executionContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex')
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { this.executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
} }
@ -193,10 +193,10 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload
Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (payload, cb) { Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (payload, cb) {
const txIndex = payload.params[1] const txIndex = payload.params[1]
var txBlock = executionContext.blocks[payload.params[0]] var txBlock = this.executionContext.blocks[payload.params[0]]
const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex')
executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { this.executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => {
if (error) { if (error) {
return cb(error) return cb(error)
} }

@ -1,7 +1,6 @@
var RemixLib = require('remix-lib') var RemixLib = require('remix-lib')
var TxExecution = RemixLib.execution.txExecution var TxExecution = RemixLib.execution.txExecution
var TxRunner = RemixLib.execution.txRunner var TxRunner = RemixLib.execution.txRunner
var executionContext = RemixLib.execution.executionContext
function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) {
let finalCallback = function (err, result) { let finalCallback = function (err, result) {
@ -40,7 +39,7 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac
let txRunnerInstance let txRunnerInstance
function processTx (accounts, payload, isCall, callback) { function processTx (executionContext, accounts, payload, isCall, callback) {
let api = { let api = {
logMessage: (msg) => { logMessage: (msg) => {
}, },
@ -66,7 +65,7 @@ function processTx (accounts, payload, isCall, callback) {
// let txRunner = new TxRunner(accounts, api) // let txRunner = new TxRunner(accounts, api)
if (!txRunnerInstance) { if (!txRunnerInstance) {
txRunnerInstance = new TxRunner(accounts, api) txRunnerInstance = new TxRunner(accounts, api, executionContext)
} }
txRunnerInstance.vmaccounts = accounts txRunnerInstance.vmaccounts = accounts
let { from, to, data, value, gas } = payload.params[0] let { from, to, data, value, gas } = payload.params[0]

@ -15,18 +15,20 @@ const generateBlock = require('./genesis.js')
var Provider = function (options) { var Provider = function (options) {
this.options = options || {} this.options = options || {}
this.Accounts = new Accounts() // TODO: init executionContext here
this.Transactions = new Transactions() this.executionContext = executionContext
this.Accounts = new Accounts(this.executionContext)
this.Transactions = new Transactions(this.executionContext)
this.methods = {} this.methods = {}
this.methods = merge(this.methods, this.Accounts.methods()) this.methods = merge(this.methods, this.Accounts.methods())
this.methods = merge(this.methods, (new Blocks(options)).methods()) this.methods = merge(this.methods, (new Blocks(this.executionContext, options)).methods())
this.methods = merge(this.methods, (new Misc()).methods()) this.methods = merge(this.methods, (new Misc()).methods())
this.methods = merge(this.methods, (new Filters()).methods()) this.methods = merge(this.methods, (new Filters(this.executionContext)).methods())
this.methods = merge(this.methods, (new Net()).methods()) this.methods = merge(this.methods, (new Net()).methods())
this.methods = merge(this.methods, this.Transactions.methods()) this.methods = merge(this.methods, this.Transactions.methods())
generateBlock() generateBlock(this.executionContext)
this.init() this.init()
} }
@ -67,7 +69,7 @@ Provider.prototype.isConnected = function () {
} }
Provider.prototype.on = function (type, cb) { Provider.prototype.on = function (type, cb) {
executionContext.logsManager.addListener(type, cb) this.executionContext.logsManager.addListener(type, cb)
} }
module.exports = Provider module.exports = Provider

Loading…
Cancel
Save