Migrate runtab to viewplugin, method getSettings

rm unused

rm pluginudapp

use settingsUI
pull/740/head
filip mertens 4 years ago
parent 8790f3949f
commit 0a40c3a6cf
  1. 3
      apps/remix-ide/src/app.js
  2. 4
      apps/remix-ide/src/app/tabs/runTab/settings.js
  3. 47
      apps/remix-ide/src/app/udapp/run-tab.js
  4. 33
      apps/remix-ide/src/blockchain/pluginUDapp.js

@ -42,7 +42,6 @@ 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')
@ -257,7 +256,6 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const contentImport = new CompilerImport(fileManager) const contentImport = new CompilerImport(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 service --------- // ----------------- compilation metadata generation service ---------
const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api) const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api)
@ -359,7 +357,6 @@ 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,

@ -319,6 +319,10 @@ class SettingsUI {
) )
} }
getSelectedAccount () {
return this.el.querySelector('#txorigin').selectedOptions[0].value
}
signMessage () { signMessage () {
this.blockchain.getAccounts((err, accounts) => { this.blockchain.getAccounts((err, accounts) => {
if (err) { if (err) {

@ -1,4 +1,4 @@
import { LibraryPlugin } from '@remixproject/engine' import { ViewPlugin } from '@remixproject/engine-web'
import * as packageJson from '../../../../../package.json' import * as packageJson from '../../../../../package.json'
const $ = require('jquery') const $ = require('jquery')
@ -28,12 +28,12 @@ const profile = {
version: packageJson.version, version: packageJson.version,
permission: true, permission: true,
events: ['newTransaction'], events: ['newTransaction'],
methods: ['createVMAccount', 'sendTransaction', 'getAccounts', 'pendingTransactionsCount'] methods: ['createVMAccount', 'sendTransaction', 'getAccounts', 'pendingTransactionsCount', 'getSettings']
} }
export class RunTab extends LibraryPlugin { export class RunTab extends ViewPlugin {
constructor (blockchain, pluginUDapp, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView, fileProvider) { constructor (blockchain, config, fileManager, editor, filePanel, compilersArtefacts, networkModule, mainView, fileProvider) {
super(pluginUDapp, profile) super(profile)
this.event = new EventManager() this.event = new EventManager()
this.config = config this.config = config
this.blockchain = blockchain this.blockchain = blockchain
@ -44,6 +44,43 @@ export class RunTab extends LibraryPlugin {
this.compilersArtefacts = compilersArtefacts this.compilersArtefacts = compilersArtefacts
this.networkModule = networkModule this.networkModule = networkModule
this.fileProvider = fileProvider this.fileProvider = fileProvider
this.setupEvents()
}
setupEvents () {
this.blockchain.events.on('newTransaction', (tx, receipt) => {
this.emit('newTransaction', tx, receipt)
})
}
getSettings () {
return new Promise((resolve, reject) => {
if (!this.container) reject(new Error('UI not ready'))
else {
resolve({
selectedAccount: this.settingsUI.getSelectedAccount(),
selectedEnvMode: this.container.querySelector('#selectExEnvOptions').selectedOptions[0].value,
networkEnvironment: this.container.querySelector('*[data-id="settingsNetworkEnv"]').textContent
}
)
}
})
}
createVMAccount (newAccount) {
return this.blockchain.createVMAccount(newAccount)
}
sendTransaction (tx) {
return this.blockchain.sendTransaction(tx)
}
getAccounts (cb) {
return this.blockchain.getAccounts(cb)
}
pendingTransactionsCount () {
return this.blockchain.pendingTransactionsCount()
} }
renderContainer () { renderContainer () {

@ -1,33 +0,0 @@
const { EventEmitter } = require('events')
class PluginUdapp {
constructor (blockchain) {
this.blockchain = blockchain
this.events = new EventEmitter()
this.setupEvents()
}
setupEvents () {
this.blockchain.events.on('newTransaction', (tx, receipt) => {
this.events.emit('newTransaction', tx, receipt)
})
}
createVMAccount (newAccount) {
return this.blockchain.createVMAccount(newAccount)
}
sendTransaction (tx) {
return this.blockchain.sendTransaction(tx)
}
getAccounts (cb) {
return this.blockchain.getAccounts(cb)
}
pendingTransactionsCount () {
return this.blockchain.pendingTransactionsCount()
}
}
module.exports = PluginUdapp
Loading…
Cancel
Save