bunsenstraat 4 years ago committed by GitHub
parent e2589978cf
commit 9dbc172787
  1. 3
      apps/remix-ide/src/app.js
  2. 18
      apps/remix-ide/src/app/tabs/runTab/settings.js
  3. 66
      apps/remix-ide/src/app/udapp/run-tab.js
  4. 33
      apps/remix-ide/src/blockchain/pluginUDapp.js

@ -41,7 +41,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')
@ -256,7 +255,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)
@ -357,7 +355,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,

@ -215,6 +215,13 @@ class SettingsUI {
selectExEnv.addEventListener('change', (event) => { selectExEnv.addEventListener('change', (event) => {
const context = selectExEnv.options[selectExEnv.selectedIndex].value const context = selectExEnv.options[selectExEnv.selectedIndex].value
this.setExecutionContext(context)
})
selectExEnv.value = this.blockchain.getProvider()
}
setExecutionContext (context) {
this.blockchain.changeExecutionContext(context, () => { this.blockchain.changeExecutionContext(context, () => {
modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => { modalDialogCustom.prompt('External node request', this.web3ProviderDialogBody(), 'http://127.0.0.1:8545', (target) => {
this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => { this.blockchain.setProviderFromEndpoint(target, context, (alertMsg) => {
@ -225,9 +232,6 @@ class SettingsUI {
}, (alertMsg) => { }, (alertMsg) => {
addTooltip(alertMsg) addTooltip(alertMsg)
}, this.setFinalContext.bind(this)) }, this.setFinalContext.bind(this))
})
selectExEnv.value = this.blockchain.getProvider()
} }
web3ProviderDialogBody () { web3ProviderDialogBody () {
@ -319,6 +323,14 @@ class SettingsUI {
) )
} }
getSelectedAccount () {
return this.el.querySelector('#txorigin').selectedOptions[0].value
}
getEnvironment () {
return this.blockchain.getProvider()
}
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')
@ -14,6 +14,7 @@ const Recorder = require('../tabs/runTab/model/recorder.js')
const RecorderUI = require('../tabs/runTab/recorder.js') const RecorderUI = require('../tabs/runTab/recorder.js')
const DropdownLogic = require('../tabs/runTab/model/dropdownlogic.js') const DropdownLogic = require('../tabs/runTab/model/dropdownlogic.js')
const ContractDropdownUI = require('../tabs/runTab/contractDropdown.js') const ContractDropdownUI = require('../tabs/runTab/contractDropdown.js')
const toaster = require('../ui/tooltip')
const UniversalDAppUI = require('../ui/universal-dapp-ui') const UniversalDAppUI = require('../ui/universal-dapp-ui')
@ -28,12 +29,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', 'setEnvironmentMode']
} }
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 +45,61 @@ 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.blockchain.getProvider(),
networkEnvironment: this.container.querySelector('*[data-id="settingsNetworkEnv"]').textContent
}
)
}
})
}
async setEnvironmentMode (env) {
const canCall = await this.askUserPermission('setEnvironmentMode', 'change the environment used')
if (canCall) {
toaster(yo`
<div>
<i class="fas fa-exclamation-triangle text-danger mr-1"></i>
<span>
${this.currentRequest.from}
<span class="font-weight-bold text-warning">
is changing your environment to
</span> ${env}
</span>
</div>
`, '', { time: 3000 })
this.settingsUI.setExecutionContext(env)
}
}
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