From 1468191989bec180af6b0179250dd3db25b70828 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:35:01 +0200 Subject: [PATCH] fix: hydra walletconnect (#547) --- .../WalletConnectActiveSessions.tsx | 24 ++++++++++++++-- .../modals/WalletConnectSessionProposal.tsx | 28 +++++++++++-------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx b/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx index edbadc06..14fc908a 100644 --- a/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx +++ b/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx @@ -41,9 +41,27 @@ export const WalletConnectActiveSessions = () => {
diff --git a/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx b/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx index cdcc20f1..4ea8614f 100644 --- a/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx +++ b/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx @@ -31,24 +31,30 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P }, [getAccountsWithNamespace, selectedMultiProxy?.multisigs, selectedMultiProxy?.proxy]) const { methods, events, chains } = useMemo( - () => - sessionProposal?.params.requiredNamespaces?.polkadot || { - methods: [], - events: [], - chains: [] - }, - [sessionProposal?.params.requiredNamespaces?.polkadot] + () => ({ + methods: [ + ...(sessionProposal?.params.requiredNamespaces?.polkadot?.methods ?? []), + ...(sessionProposal?.params.optionalNamespaces?.polkadot?.methods ?? []) + ], + events: [ + ...(sessionProposal?.params.requiredNamespaces?.polkadot?.events ?? []), + ...(sessionProposal?.params.optionalNamespaces?.polkadot?.events ?? []) + ], + chains: [ + ...(sessionProposal?.params.requiredNamespaces?.polkadot?.chains ?? []), + ...(sessionProposal?.params.optionalNamespaces?.polkadot?.chains ?? []) + ] + }), + [sessionProposal?.params] ) useEffect(() => { if (!web3wallet || !sessionProposal) return - const wCRequestedNetwork = chains?.[0] - - if (wCRequestedNetwork !== currentNamespace) { + if (!chains.includes(currentNamespace)) { setErrorMessage( `Multix is not connected to the same network as the WalletConnect request. Please switch to the correct network. - - Requested: ${wCRequestedNetwork} + - Requested: ${chains} - Current: ${currentNamespace}` ) }