From 1818c86ebad26f948b74d9f13708b5a3d4486431 Mon Sep 17 00:00:00 2001 From: Govard Barkhatov Date: Thu, 19 Dec 2024 18:48:21 +0200 Subject: [PATCH] Update src/components/WalletProvider/index.stories.tsx Co-authored-by: David Totrashvili <8580261+totraev@users.noreply.github.com> --- .../WalletProvider/index.stories.tsx | 71 ++++--------------- 1 file changed, 12 insertions(+), 59 deletions(-) diff --git a/src/components/WalletProvider/index.stories.tsx b/src/components/WalletProvider/index.stories.tsx index fa627dc..55ef18e 100644 --- a/src/components/WalletProvider/index.stories.tsx +++ b/src/components/WalletProvider/index.stories.tsx @@ -38,7 +38,6 @@ export const Default: Story = { return ; }, }; - export const WithConnectedData: Story = { args: { onError: console.log, @@ -53,69 +52,23 @@ export const WithConnectedData: Story = { ), ], render: () => { - const { open } = useWidgetState(); - const [walletData, setWalletData] = useState<{ - BTC?: { address: string; publicKeyHex: string }; - BBN?: { address: string; publicKeyHex: string }; - }>({}); - const connectors = useChainProviders(); - - useEffect(() => { - // Subscribe to connect events for both chains - const btcUnsub = connectors.BTC?.on("connect", async (wallet) => { - console.log("BTC Wallet connected", wallet); - if (wallet.account) { - const { address, publicKeyHex } = wallet.account; - if (address && publicKeyHex) { - setWalletData((prev) => ({ - ...prev, - BTC: { address, publicKeyHex }, - })); - } - } - }); - - const bbnUnsub = connectors.BBN?.on("connect", async (wallet) => { - console.log("BBN Wallet connected", wallet); - if (wallet.account) { - const { address, publicKeyHex } = wallet.account; - if (address && publicKeyHex) { - setWalletData((prev) => ({ - ...prev, - BBN: { address, publicKeyHex }, - })); - } - } - }); - - return () => { - btcUnsub?.(); - bbnUnsub?.(); - }; - }, [connectors]); + const { open, selectedWallets } = useWidgetState(); return (
- {walletData.BTC && ( -
- - BTC Wallet - - Address: {walletData.BTC.address} - Public Key: {walletData.BTC.publicKeyHex} -
- )} - - {walletData.BBN && ( -
- - BBN Wallet - - Address: {walletData.BBN.address} - Public Key: {walletData.BBN.publicKeyHex} -
+ {Object.entries(selectedWallets).map( + ([chainName, wallet]) => + wallet?.account && ( +
+ + {chainName} Wallet + + Address: {wallet.account.address} + Public Key: {wallet.account.publicKeyHex} +
+ ), )}