From b49c37f7d6a758fbb72e87af650f56a17c5f4768 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 29 Sep 2022 14:39:52 +0200 Subject: [PATCH] better handling of dependend modules --- .../src/app/plugins/remixd-handle.tsx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/remixd-handle.tsx b/apps/remix-ide/src/app/plugins/remixd-handle.tsx index 37076db375..2798427185 100644 --- a/apps/remix-ide/src/app/plugins/remixd-handle.tsx +++ b/apps/remix-ide/src/app/plugins/remixd-handle.tsx @@ -34,19 +34,20 @@ enum State { export class RemixdHandle extends WebsocketPlugin { localhostProvider: any appManager: PluginManager + dependentPlugins: Array constructor (localhostProvider, appManager) { super(profile) this.localhostProvider = localhostProvider this.appManager = appManager + this.dependentPlugins = ['hardhat', 'truffle', 'slither', 'foundry'] } async deactivate () { + for (const plugin of this.dependentPlugins) { + await this.appManager.deactivatePlugin(plugin) + } if (super.socket) super.deactivate() // this.appManager.deactivatePlugin('git') // plugin call doesn't work.. see issue https://github.com/ethereum/remix-plugin/issues/342 - if (this.appManager.isActive('hardhat')) this.appManager.deactivatePlugin('hardhat') - if (this.appManager.isActive('truffle')) this.appManager.deactivatePlugin('truffle') - if (this.appManager.isActive('slither')) this.appManager.deactivatePlugin('slither') - if (this.appManager.isActive('foundry')) this.appManager.deactivatePlugin('foundry') this.localhostProvider.close((error) => { if (error) console.log(error) }) @@ -58,6 +59,9 @@ export class RemixdHandle extends WebsocketPlugin { } async canceled () { + for (const plugin of this.dependentPlugins) { + await this.appManager.deactivatePlugin(plugin) + } await this.appManager.deactivatePlugin('remixd') } @@ -68,7 +72,7 @@ export class RemixdHandle extends WebsocketPlugin { * @param {String} txHash - hash of the transaction */ async connectToLocalhost () { - const connection = (error?:any) => { + const connection = async (error?:any) => { if (error) { console.log(error) const alert:AlertModal = { @@ -91,11 +95,10 @@ export class RemixdHandle extends WebsocketPlugin { }, 3000) this.localhostProvider.init(() => { this.call('filePanel', 'setWorkspace', { name: LOCALHOST, isLocalhost: true }, true) - }) - this.call('manager', 'activatePlugin', 'hardhat') - this.call('manager', 'activatePlugin', 'truffle') - this.call('manager', 'activatePlugin', 'slither') - this.call('manager', 'activatePlugin', 'foundry') + }); + for (const plugin of this.dependentPlugins) { + await this.appManager.activatePlugin(plugin) + } } } if (this.localhostProvider.isConnected()) {