From 92e9032e88fb997db5e9e9801089671604f0a9bc Mon Sep 17 00:00:00 2001 From: LouisWT <18911761491@163.com> Date: Sat, 1 Apr 2023 03:09:40 +0800 Subject: [PATCH] fix(bridge-ui): only request connect if require (#13519) --- packages/bridge-ui/src/components/buttons/Connect.svelte | 7 ++++++- .../starter-dapp/src/components/buttons/Connect.svelte | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/bridge-ui/src/components/buttons/Connect.svelte b/packages/bridge-ui/src/components/buttons/Connect.svelte index 883f79d8b51..c1becafa744 100644 --- a/packages/bridge-ui/src/components/buttons/Connect.svelte +++ b/packages/bridge-ui/src/components/buttons/Connect.svelte @@ -70,7 +70,12 @@ async function connectWithConnector(connector: Connector) { try { - await wagmiConnect({ connector }); + if ( + !$wagmiClient.connector || + $wagmiClient.connector.id !== connector.id + ) { + await wagmiConnect({ connector }); + } await onConnect(); successToast('Connected'); } catch (error) { diff --git a/packages/starter-dapp/src/components/buttons/Connect.svelte b/packages/starter-dapp/src/components/buttons/Connect.svelte index 9c9cc8e819e..cfa35b30cde 100644 --- a/packages/starter-dapp/src/components/buttons/Connect.svelte +++ b/packages/starter-dapp/src/components/buttons/Connect.svelte @@ -53,7 +53,9 @@ async function connectWithConnector(connector: Connector) { try { - await wagmiConnect({ connector }); + if (!$wagmiClient.connector || $wagmiClient.connector.id !== connector.id) { + await wagmiConnect({ connector }); + } await onConnect(); successToast("Connected"); } catch (error) {