better handling of dependend modules

pull/2956/head
yann300 2 years ago
parent 25210117c0
commit b49c37f7d6
  1. 23
      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<string>
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()) {

Loading…
Cancel
Save