Skip to content

Commit

Permalink
fix: hydra walletconnect (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaut authored Jul 2, 2024
1 parent efe0e1e commit 1468191
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,27 @@ 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>Events: {session.requiredNamespaces?.polkadot?.events?.join(', ')}</li>
<li>
Namespace:{' '}
{(
session.requiredNamespaces?.polkadot?.chains ||
session.optionalNamespaces?.polkadot?.chains
)?.join(', ')}
</li>
<li>
Methods:{' '}
{(
session.requiredNamespaces?.polkadot?.methods ||
session.optionalNamespaces?.polkadot?.methods
)?.join(', ')}
</li>
<li>
Events:{' '}
{(
session.requiredNamespaces?.polkadot?.events ||
session.optionalNamespaces?.polkadot?.events
)?.join(', ')}
</li>
<li>Expiring: {expiryDate.toDateString()}</li>
</ul>
</div>
Expand Down
28 changes: 17 additions & 11 deletions packages/ui/src/components/modals/WalletConnectSessionProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
)
}
Expand Down

0 comments on commit 1468191

Please sign in to comment.