abstract udapp plugin so it maintains backwards compatibilify with the plugin api

pull/5370/head
Iuri Matias 5 years ago committed by yann300
parent 053b1ccdf4
commit 9ef61b64e0
  1. 3
      src/app.js
  2. 4
      src/app/udapp/run-tab.js
  3. 35
      src/blockchain/pluginUDapp.js
  4. 1
      src/blockchain/universalDapp.js

@ -23,6 +23,7 @@ var CompilerMetadata = require('./app/files/compiler-metadata')
var CompilerImport = require('./app/compiler/compiler-imports') var CompilerImport = require('./app/compiler/compiler-imports')
const Blockchain = require('./blockchain/blockchain.js') const Blockchain = require('./blockchain/blockchain.js')
const PluginUDapp = require('./blockchain/pluginUDapp.js')
const PluginManagerComponent = require('./app/components/plugin-manager-component') const PluginManagerComponent = require('./app/components/plugin-manager-component')
const CompilersArtefacts = require('./app/compiler/compiler-artefacts') 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'}) registry.put({api: fileManager, name: 'filemanager'})
const blockchain = new Blockchain(registry.get('config').api) const blockchain = new Blockchain(registry.get('config').api)
const pluginUdapp = new PluginUDapp(blockchain)
// ----------------- compilation metadata generation servive ---------------------------- // ----------------- compilation metadata generation servive ----------------------------
const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api) 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( const run = new RunTab(
blockchain, blockchain,
pluginUdapp,
registry.get('config').api, registry.get('config').api,
registry.get('filemanager').api, registry.get('filemanager').api,
registry.get('editor').api, registry.get('editor').api,

@ -33,8 +33,8 @@ const profile = {
export class RunTab extends LibraryPlugin { export class RunTab extends LibraryPlugin {
constructor (blockchain, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) { constructor (blockchain, pluginUDapp, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView) {
super(blockchain.udapp, profile) super(pluginUDapp, profile)
this.event = new EventManager() this.event = new EventManager()
this.config = config this.config = config
this.blockchain = blockchain this.blockchain = blockchain

@ -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

@ -6,7 +6,6 @@ const { EventEmitter } = require('events')
const remixLib = require('remix-lib') const remixLib = require('remix-lib')
const TxRunner = remixLib.execution.txRunner const TxRunner = remixLib.execution.txRunner
const txHelper = remixLib.execution.txHelper
const EventManager = remixLib.EventManager const EventManager = remixLib.EventManager
const Web3 = require('web3') const Web3 = require('web3')

Loading…
Cancel
Save