diff --git a/src/app.js b/src/app.js index 6aab808d8c..4c3fcbff44 100644 --- a/src/app.js +++ b/src/app.js @@ -23,6 +23,7 @@ var CompilerMetadata = require('./app/files/compiler-metadata') var CompilerImport = require('./app/compiler/compiler-imports') const Blockchain = require('./blockchain/blockchain.js') +const PluginUDapp = require('./blockchain/pluginUDapp.js') const PluginManagerComponent = require('./app/components/plugin-manager-component') const CompilersArtefacts = require('./app/compiler/compiler-artefacts') @@ -223,6 +224,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org registry.put({api: fileManager, name: 'filemanager'}) const blockchain = new Blockchain(registry.get('config').api) + const pluginUdapp = new PluginUDapp(blockchain) // ----------------- compilation metadata generation servive ---------------------------- const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api) @@ -295,6 +297,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org ) const run = new RunTab( blockchain, + pluginUdapp, registry.get('config').api, registry.get('filemanager').api, registry.get('editor').api, diff --git a/src/app/udapp/run-tab.js b/src/app/udapp/run-tab.js index 7b4df5149f..bf2c89a509 100644 --- a/src/app/udapp/run-tab.js +++ b/src/app/udapp/run-tab.js @@ -33,8 +33,8 @@ const profile = { export class RunTab extends LibraryPlugin { - constructor (blockchain, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) { - super(blockchain.udapp, profile) + constructor (blockchain, pluginUDapp, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) { + super(pluginUDapp, profile) this.event = new EventManager() this.config = config this.blockchain = blockchain diff --git a/src/blockchain/pluginUDapp.js b/src/blockchain/pluginUDapp.js new file mode 100644 index 0000000000..a6ece20ddb --- /dev/null +++ b/src/blockchain/pluginUDapp.js @@ -0,0 +1,35 @@ +const { EventEmitter } = require('events') + +class PluginUdapp { + + constructor (blockchain) { + this.blockchain = blockchain + this.events = new EventEmitter() + this.setupEvents() + } + + setupEvents () { + this.blockchain.event.register('newTransaction', (tx, receipt) => { + this.events.trigger('newTransaction', [tx, receipt]) + }) + } + + createVMAccount (newAccount) { + return this.blockchain.udapp.createVMAccount(newAccount) + } + + sendTransaction (tx) { + return this.blockchain.udapp.sendTransaction(tx) + } + + getAccounts (cb) { + return this.blockchain.udapp.getAccounts(cb) + } + + pendingTransactionsCount () { + return this.blockchain.udapp.pendingTransactionsCount() + } + +} + +module.exports = PluginUdapp diff --git a/src/blockchain/universalDapp.js b/src/blockchain/universalDapp.js index b08532f8d8..ea491676d5 100644 --- a/src/blockchain/universalDapp.js +++ b/src/blockchain/universalDapp.js @@ -6,7 +6,6 @@ const { EventEmitter } = require('events') const remixLib = require('remix-lib') const TxRunner = remixLib.execution.txRunner -const txHelper = remixLib.execution.txHelper const EventManager = remixLib.EventManager const Web3 = require('web3')