Skip to content

Commit

Permalink
Prevent crash when connecting with Walletconnect key (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Oct 31, 2023
1 parent 6379a49 commit 2372fc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const WalletConnectActiveSessions = () => {
<ContentBoxStyled>
<div className="info">
<ul>
<li>Namespace: {session.requiredNamespaces.polkadot.chains?.join(', ')}</li>
<li>Methods: {session.requiredNamespaces.polkadot.methods?.join(', ')}</li>
<li>Namespace: {session.requiredNamespaces?.polkadot?.chains?.join(', ')}</li>
<li>Methods: {session.requiredNamespaces?.polkadot?.methods?.join(', ')}</li>
<li>Expiring: {expiryDate.toDateString()}</li>
</ul>
</div>
Expand Down
15 changes: 10 additions & 5 deletions packages/ui/src/components/modals/WalletConnectSessionProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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: []
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P
<DialogTitle>WalletConnect Connection Request</DialogTitle>
<DialogContent className="generalContainer">
<Grid container>
{!!errorMessage && <Alert severity="error">{errorMessage}</Alert>}
{!!errorMessage && <AlertStyled severity="error">{errorMessage}</AlertStyled>}
<Grid
item
xs={12}
Expand All @@ -100,11 +100,11 @@ const WalletConnectSessionProposal = ({ onClose, className, sessionProposal }: P
<AppInfoStyled>Website:</AppInfoStyled> {sessionProposal?.params.proposer.metadata.url}
<br />
<AppInfoStyled>Methods:</AppInfoStyled>{' '}
{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)
? ''
: ', '
}`
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2372fc2

Please sign in to comment.