From 9febad6be1946673d35af1f39e7dab4c62b5ce9e Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 2 Oct 2018 09:29:23 +0200 Subject: [PATCH 1/2] add "addProvider" "removeProvider" to execution context --- remix-lib/src/execution/execution-context.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/remix-lib/src/execution/execution-context.js b/remix-lib/src/execution/execution-context.js index b8c459973a..07cd4ee079 100644 --- a/remix-lib/src/execution/execution-context.js +++ b/remix-lib/src/execution/execution-context.js @@ -85,6 +85,7 @@ function ExecutionContext () { this.blockGasLimitDefault = 4300000 this.blockGasLimit = this.blockGasLimitDefault + this.customNetWorks = {} this.init = function (config) { if (config.get('settings/always-use-vm')) { @@ -134,6 +135,16 @@ function ExecutionContext () { } } + this.removeProvider = function (name) { + delete this.customNetWorks[name] + self.event.trigger('removeProvider', [name]) + } + + this.addProvider = function (network) { + this.customNetWorks[network.name] = network + self.event.trigger('addProvider', [network]) + } + this.internalWeb3 = function () { return web3 } @@ -182,6 +193,11 @@ function ExecutionContext () { if (context === 'web3') { confirmCb(cb) } + + if (this.customNetWorks[context]) { + var provider = this.customNetWorks[context] + setProviderFromEndpoint(provider.url, provider.name, () => { cb() }) + } } this.currentblockGasLimit = function () { From f265dffd070ecbddc8ab22f8a419f1331be0367a Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 11 Oct 2018 09:40:29 +0200 Subject: [PATCH 2/2] test before adding/removing --- remix-lib/src/execution/execution-context.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/remix-lib/src/execution/execution-context.js b/remix-lib/src/execution/execution-context.js index 07cd4ee079..fef1a1544b 100644 --- a/remix-lib/src/execution/execution-context.js +++ b/remix-lib/src/execution/execution-context.js @@ -136,13 +136,17 @@ function ExecutionContext () { } this.removeProvider = function (name) { - delete this.customNetWorks[name] - self.event.trigger('removeProvider', [name]) + if (name && this.customNetWorks[name]) { + delete this.customNetWorks[name] + self.event.trigger('removeProvider', [name]) + } } this.addProvider = function (network) { - this.customNetWorks[network.name] = network - self.event.trigger('addProvider', [network]) + if (network && network.name && network.url) { + this.customNetWorks[network.name] = network + self.event.trigger('addProvider', [network]) + } } this.internalWeb3 = function () {