From c262a65aff4c79f90204054bdca3aa4f700ce64d Mon Sep 17 00:00:00 2001 From: Govard Barkhatov Date: Wed, 12 Feb 2025 20:44:50 +0200 Subject: [PATCH 1/3] wallet on connect --- src/app/context/wallet/BTCWalletProvider.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/context/wallet/BTCWalletProvider.tsx b/src/app/context/wallet/BTCWalletProvider.tsx index ccb1b3fe..26f31a66 100644 --- a/src/app/context/wallet/BTCWalletProvider.tsx +++ b/src/app/context/wallet/BTCWalletProvider.tsx @@ -156,7 +156,11 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { useEffect(() => { if (!btcWalletProvider) return; - const cb = () => void connectBTC(btcWalletProvider); + const cb = async () => { + await btcWalletProvider.connectWallet(); + void connectBTC(btcWalletProvider); + }; + btcWalletProvider.on("accountChanged", cb); return () => void btcWalletProvider.off("accountChanged", cb); From f581cba60921a6bb368a4c591b6ec575bee6b1d4 Mon Sep 17 00:00:00 2001 From: Govard Barkhatov Date: Fri, 14 Feb 2025 15:37:56 +0200 Subject: [PATCH 2/3] rm void, move inside --- src/app/context/wallet/BTCWalletProvider.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/context/wallet/BTCWalletProvider.tsx b/src/app/context/wallet/BTCWalletProvider.tsx index 26f31a66..2a97bf49 100644 --- a/src/app/context/wallet/BTCWalletProvider.tsx +++ b/src/app/context/wallet/BTCWalletProvider.tsx @@ -97,6 +97,8 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { "Only Native SegWit and Taproot addresses are supported. Please switch the address type in your wallet and try again."; try { + await walletProvider.connectWallet(); + const address = await walletProvider.getAddress(); const supported = isSupportedAddressType(address); if (!supported) { @@ -156,10 +158,7 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { useEffect(() => { if (!btcWalletProvider) return; - const cb = async () => { - await btcWalletProvider.connectWallet(); - void connectBTC(btcWalletProvider); - }; + const cb = () => connectBTC(btcWalletProvider); btcWalletProvider.on("accountChanged", cb); From 04f4c42ab8d43326b541ec31f264bc1a59aedeb4 Mon Sep 17 00:00:00 2001 From: Govard Barkhatov Date: Mon, 17 Feb 2025 10:15:13 +0200 Subject: [PATCH 3/3] connectWallet part of effect --- src/app/context/wallet/BTCWalletProvider.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/context/wallet/BTCWalletProvider.tsx b/src/app/context/wallet/BTCWalletProvider.tsx index 2a97bf49..0b0ffaea 100644 --- a/src/app/context/wallet/BTCWalletProvider.tsx +++ b/src/app/context/wallet/BTCWalletProvider.tsx @@ -97,8 +97,6 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { "Only Native SegWit and Taproot addresses are supported. Please switch the address type in your wallet and try again."; try { - await walletProvider.connectWallet(); - const address = await walletProvider.getAddress(); const supported = isSupportedAddressType(address); if (!supported) { @@ -158,7 +156,10 @@ export const BTCWalletProvider = ({ children }: PropsWithChildren) => { useEffect(() => { if (!btcWalletProvider) return; - const cb = () => connectBTC(btcWalletProvider); + const cb = async () => { + await btcWalletProvider.connectWallet(); + connectBTC(btcWalletProvider); + }; btcWalletProvider.on("accountChanged", cb);