Skip to content

Commit

Permalink
Catch error on disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Sep 20, 2023
1 parent e679f63 commit 0688b36
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/wallet-connect/hooks/useWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,18 @@ const useWalletConnect = (): useWalletConnectType => {
)

const wcApproveSession = useCallback(async () => {
if (!sessionProposal || !walletConnect) {
throw new Error('Cannot approve session without pending session proposal')
}
try {
if (!sessionProposal || !walletConnect) {
throw new Error('Cannot approve session without pending session proposal')
}

await walletConnect.approveSessionProposal(sessionProposal, () => {
setWcState(WC_CONNECT_STATE.APPROVE_INVALID_SESSION)
})
await walletConnect.approveSessionProposal(sessionProposal, () => {
setWcState(WC_CONNECT_STATE.APPROVE_INVALID_SESSION)
})
} catch (e) {
setError((e as Error).message)
return
}

setSessionProposal(undefined)
setError(undefined)
Expand Down

0 comments on commit 0688b36

Please sign in to comment.