From 3908f1a2991419229c967f3f93dc9b8b3088cd23 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 31 Dec 2019 11:54:47 -0500 Subject: [PATCH] replace executionContext for network module with blockchain object --- src/app.js | 2 +- src/app/tabs/network-module.js | 18 +++++++++--------- src/app/tabs/runTab/model/blockchain.js | 7 +++++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/app.js b/src/app.js index ccde06d65d..fedec3572e 100644 --- a/src/app.js +++ b/src/app.js @@ -235,7 +235,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const {eventsDecoder, txlistener} = makeUdapp(blockchain, compilersArtefacts, (domEl) => mainview.getTerminal().logHtml(domEl)) // ----------------- network service (resolve network id / name) ---------------------------- - const networkModule = new NetworkModule(executionContext) + const networkModule = new NetworkModule(blockchain) // ----------------- convert offset to line/column service ---------------------------- var offsetToLineColumnConverter = new OffsetToLineColumnConverter() registry.put({api: offsetToLineColumnConverter, name: 'offsettolinecolumnconverter'}) diff --git a/src/app/tabs/network-module.js b/src/app/tabs/network-module.js index 4ead25261e..2174040135 100644 --- a/src/app/tabs/network-module.js +++ b/src/app/tabs/network-module.js @@ -14,11 +14,11 @@ export const profile = { // - methods: ['getNetworkProvider', 'getEndpoint', 'detectNetwork', 'addNetwork', 'removeNetwork'] export class NetworkModule extends Plugin { - constructor (executionContext) { + constructor (blockchain) { super(profile) - this.executionContext = executionContext + this.blockchain = blockchain // TODO: See with remix-lib to make sementic coherent - this.executionContext.event.register('contextChanged', (provider) => { + this.blockchain.event.register('contextChanged', (provider) => { this.emit('providerChanged', provider) }) /* @@ -37,13 +37,13 @@ export class NetworkModule extends Plugin { /** Return the current network provider (web3, vm, injected) */ getNetworkProvider () { - return this.executionContext.getProvider() + return this.blockchain.getProvider() } /** Return the current network */ detectNetwork () { return new Promise((resolve, reject) => { - this.executionContext.detectNetwork((error, network) => { + this.blockchain.detectNetwork((error, network) => { error ? reject(error) : resolve(network) }) }) @@ -51,20 +51,20 @@ export class NetworkModule extends Plugin { /** Return the url only if network provider is 'web3' */ getEndpoint () { - const provider = this.executionContext.getProvider() + const provider = this.blockchain.getProvider() if (provider !== 'web3') { throw new Error('no endpoint: current provider is either injected or vm') } - return this.executionContext.web3().currentProvider.host + return this.blockchain.web3().currentProvider.host } /** Add a custom network to the list of available networks */ addNetwork (customNetwork) { - this.executionContext.addProvider(customNetwork) + this.blockchain.addProvider(customNetwork) } /** Remove a network to the list of availble networks */ removeNetwork (name) { - this.executionContext.removeProvider(name) + this.blockchain.removeProvider(name) } } diff --git a/src/app/tabs/runTab/model/blockchain.js b/src/app/tabs/runTab/model/blockchain.js index 19b15d4303..e98ab93511 100644 --- a/src/app/tabs/runTab/model/blockchain.js +++ b/src/app/tabs/runTab/model/blockchain.js @@ -323,6 +323,13 @@ class Blockchain { this.udapp.resetEnvironment() } + addNetwork (customNetwork) { + this.executionContext.addProvider(customNetwork) + } + + removeNetwork (name) { + this.executionContext.removeProvider(name) + } } module.exports = Blockchain