From 457c83a6c13382c73d9997db62a662b7d2423da1 Mon Sep 17 00:00:00 2001 From: Thibaut Sardan Date: Tue, 31 Oct 2023 15:48:22 +0100 Subject: [PATCH] prevent crash --- .../WalletConnect/WalletConnectActiveSessions.tsx | 4 ++-- .../modals/WalletConnectSessionProposal.tsx | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx b/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx index eadb3b03..16fe2bee 100644 --- a/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx +++ b/packages/ui/src/components/WalletConnect/WalletConnectActiveSessions.tsx @@ -41,8 +41,8 @@ export const WalletConnectActiveSessions = () => {
    -
  • Namespace: {session.requiredNamespaces.polkadot.chains?.join(', ')}
  • -
  • Methods: {session.requiredNamespaces.polkadot.methods?.join(', ')}
  • +
  • Namespace: {session.requiredNamespaces?.polkadot?.chains?.join(', ')}
  • +
  • Methods: {session.requiredNamespaces?.polkadot?.methods?.join(', ')}
  • Expiring: {expiryDate.toDateString()}
diff --git a/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx b/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx index 9e6492c3..661e4249 100644 --- a/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx +++ b/packages/ui/src/components/modals/WalletConnectSessionProposal.tsx @@ -33,7 +33,7 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P useEffect(() => { if (!web3wallet || !sessionProposal) return - const wCRequestedNetwork = sessionProposal?.params.requiredNamespaces.polkadot.chains?.[0] + const wCRequestedNetwork = sessionProposal?.params.requiredNamespaces?.polkadot?.chains?.[0] if (wCRequestedNetwork !== currentNamespace) { setErrorMessage( @@ -53,7 +53,7 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P namespaces: { polkadot: { accounts: accountsToShare, - methods: sessionProposal.params.requiredNamespaces.polkadot.methods, + methods: sessionProposal.params.requiredNamespaces?.polkadot?.methods, events: [] } } @@ -90,7 +90,7 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P WalletConnect Connection Request - {!!errorMessage && {errorMessage}} + {!!errorMessage && {errorMessage}} Website: {sessionProposal?.params.proposer.metadata.url}
Methods:{' '} - {sessionProposal?.params.requiredNamespaces.polkadot?.methods.map( + {sessionProposal?.params.requiredNamespaces?.polkadot?.methods?.map( (method, index) => `${method}${ index === - (sessionProposal?.params.requiredNamespaces.polkadot?.methods.length - 1 || 0) + (sessionProposal?.params.requiredNamespaces?.polkadot?.methods?.length - 1 || 0) ? '' : ', ' }` @@ -180,6 +180,11 @@ const ButtonContainerStyled = styled(Grid)` margin-left: 1rem; } ` + +const AlertStyled = styled(Alert)` + margin-bottom: 1rem; +` + export default styled(WalletConnectSessionProposal)` .accountEdition { margin-bottom: 1rem;