From 4605b40dea29b542f34afd377f1b6fbdf392adb9 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 17 May 2023 15:39:25 +0200 Subject: [PATCH 1/2] call deactivate on a plugin if exposed as a method --- apps/remix-ide/src/remixAppManager.js | 14 ++++++++++++-- apps/walletconnect/src/services/RemixClient.ts | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 97aefe4d2c..561235f227 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -71,11 +71,19 @@ export class RemixAppManager extends PluginManager { } async deactivatePlugin(name) { + const profile = await this.getProfile(name) const [to, from] = [ - await this.getProfile(name), + profile, await this.getProfile(this.requestFrom) ] if (this.canDeactivatePlugin(from, to)) { + if (profile.methods.includes('deactivate')) { + try { + await this.call(name, 'deactivate') + } catch (e) { + console.log(e) + } + } await this.toggleActive(name) } } @@ -171,7 +179,9 @@ export class RemixAppManager extends PluginManager { return plugins.map(plugin => { if (plugin.name === testPluginName) plugin.url = testPluginUrl - return new IframePlugin(plugin) + let iframePlugin = new IframePlugin(plugin) + console.log('registering plugin', iframePlugin.disconnect) + return iframePlugin }) } diff --git a/apps/walletconnect/src/services/RemixClient.ts b/apps/walletconnect/src/services/RemixClient.ts index 0edd7dc691..9e88d5e6c2 100644 --- a/apps/walletconnect/src/services/RemixClient.ts +++ b/apps/walletconnect/src/services/RemixClient.ts @@ -15,7 +15,7 @@ export class RemixClient extends PluginClient { super() createClient(this) this.internalEvents = new EventManager() - this.methods = ["sendAsync", "init"] + this.methods = ["sendAsync", "init", "deactivate"] this.onload() } @@ -30,6 +30,11 @@ export class RemixClient extends PluginClient { console.log('initializing walletconnect plugin...') } + async deactivate(){ + console.log('deactivating walletconnect plugin...') + return true + } + async initClient () { try { this.chains = [arbitrum, arbitrumGoerli, mainnet, polygon, polygonMumbai, optimism, optimismGoerli, goerli, sepolia] From 7cefeb55e3889d7260c71965274145828785b0a3 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 17 May 2023 15:42:00 +0200 Subject: [PATCH 2/2] revert change --- apps/remix-ide/src/remixAppManager.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/remix-ide/src/remixAppManager.js b/apps/remix-ide/src/remixAppManager.js index 561235f227..66f2b92bc3 100644 --- a/apps/remix-ide/src/remixAppManager.js +++ b/apps/remix-ide/src/remixAppManager.js @@ -179,9 +179,7 @@ export class RemixAppManager extends PluginManager { return plugins.map(plugin => { if (plugin.name === testPluginName) plugin.url = testPluginUrl - let iframePlugin = new IframePlugin(plugin) - console.log('registering plugin', iframePlugin.disconnect) - return iframePlugin + return new IframePlugin(plugin) }) }