From ccda65313f2f3e269448f73d45d1cc62ca662dcd Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 3 Oct 2022 17:03:04 +0200 Subject: [PATCH 1/3] handle connections in plugins --- apps/remix-ide/src/app/files/foundry-handle.js | 8 ++++++++ apps/remix-ide/src/app/files/hardhat-handle.js | 8 ++++++++ apps/remix-ide/src/app/files/truffle-handle.js | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/foundry-handle.js b/apps/remix-ide/src/app/files/foundry-handle.js index cf20f03e79..94efd7b04b 100644 --- a/apps/remix-ide/src/app/files/foundry-handle.js +++ b/apps/remix-ide/src/app/files/foundry-handle.js @@ -15,4 +15,12 @@ export class FoundryHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/hardhat-handle.js b/apps/remix-ide/src/app/files/hardhat-handle.js index 7b64f489dc..84a2c1d28a 100644 --- a/apps/remix-ide/src/app/files/hardhat-handle.js +++ b/apps/remix-ide/src/app/files/hardhat-handle.js @@ -15,4 +15,12 @@ export class HardhatHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/truffle-handle.js b/apps/remix-ide/src/app/files/truffle-handle.js index bdeed78592..707f1fae80 100644 --- a/apps/remix-ide/src/app/files/truffle-handle.js +++ b/apps/remix-ide/src/app/files/truffle-handle.js @@ -12,7 +12,16 @@ const profile = { } export class TruffleHandle extends WebsocketPlugin { - constructor () { + constructor() { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } + } From 1a55024d4da39adee198bb0454a20fe3b08b3123 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 3 Oct 2022 17:05:03 +0200 Subject: [PATCH 2/3] add space --- apps/remix-ide/src/app/files/truffle-handle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/files/truffle-handle.js b/apps/remix-ide/src/app/files/truffle-handle.js index 707f1fae80..1111cba60d 100644 --- a/apps/remix-ide/src/app/files/truffle-handle.js +++ b/apps/remix-ide/src/app/files/truffle-handle.js @@ -12,7 +12,7 @@ const profile = { } export class TruffleHandle extends WebsocketPlugin { - constructor() { + constructor () { super(profile) } From 9723b790d9e834b816ae19aac3b60c12e7be2de1 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Tue, 4 Oct 2022 07:41:50 +0200 Subject: [PATCH 3/3] more handles --- apps/remix-ide/src/app/files/git-handle.js | 8 ++++++++ apps/remix-ide/src/app/files/slither-handle.js | 8 ++++++++ apps/remix-ide/src/app/plugins/remixd-handle.tsx | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/apps/remix-ide/src/app/files/git-handle.js b/apps/remix-ide/src/app/files/git-handle.js index a935068679..596bf77015 100644 --- a/apps/remix-ide/src/app/files/git-handle.js +++ b/apps/remix-ide/src/app/files/git-handle.js @@ -15,4 +15,12 @@ export class GitHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/files/slither-handle.js b/apps/remix-ide/src/app/files/slither-handle.js index 9604202d7e..27c7b3cbd8 100644 --- a/apps/remix-ide/src/app/files/slither-handle.js +++ b/apps/remix-ide/src/app/files/slither-handle.js @@ -16,4 +16,12 @@ export class SlitherHandle extends WebsocketPlugin { constructor () { super(profile) } + + callPluginMethod(key, payload = []) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } } diff --git a/apps/remix-ide/src/app/plugins/remixd-handle.tsx b/apps/remix-ide/src/app/plugins/remixd-handle.tsx index 56855d4caf..35353d774d 100644 --- a/apps/remix-ide/src/app/plugins/remixd-handle.tsx +++ b/apps/remix-ide/src/app/plugins/remixd-handle.tsx @@ -71,6 +71,14 @@ export class RemixdHandle extends WebsocketPlugin { } + async callPluginMethod(key: string, payload?: any[]) { + if (this.socket.readyState !== this.socket.OPEN) { + console.log(`${this.profile.name} connection is not opened.`) + return false + } + return super.callPluginMethod(key, payload) + } + /** * connect to localhost if no connection and render the explorer * disconnect from localhost if connected and remove the explorer