From 59cb6328e3f5eb4a592e5e71dd4ec5ad2fb1ff48 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 7 Nov 2023 10:49:57 +0100 Subject: [PATCH] fix spamming the network --- .../walletconnect/src/services/WalletConnectRemixClient.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/walletconnect/src/services/WalletConnectRemixClient.ts b/apps/walletconnect/src/services/WalletConnectRemixClient.ts index bdbf84efcf..b28cf448f7 100644 --- a/apps/walletconnect/src/services/WalletConnectRemixClient.ts +++ b/apps/walletconnect/src/services/WalletConnectRemixClient.ts @@ -24,6 +24,7 @@ export class WalletConnectRemixClient extends PluginClient { chains: Chain[] currentChain: number internalEvents: EventManager + connected: boolean constructor() { super() @@ -76,13 +77,15 @@ export class WalletConnectRemixClient extends PluginClient { subscribeToEvents() { this.wagmiConfig.subscribe((event) => { - if (event.status === 'connected') { + if (event.status === 'connected' && !this.connected) { + this.connected = true this.emit('accountsChanged', [event.data.account]) if (this.currentChain !== event.data.chain.id) { this.currentChain = event.data.chain.id this.emit('chainChanged', event.data.chain.id) } - } else if (event.status === 'disconnected') { + } else if (event.status === 'disconnected' && this.connected) { + this.connected = false this.emit('accountsChanged', []) this.emit('chainChanged', 0) this.currentChain = 0