Skip to content

Commit

Permalink
Disconnect the user when failed to sign siww message
Browse files Browse the repository at this point in the history
There is a case where OrangeKit returns error about failed to sign siww message. We will disconnect the user and close the action statuses.
  • Loading branch information
kkosiorowska committed Sep 25, 2024
1 parent 9dee3b5 commit 9ddbfb8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ export default function ConnectWalletButton({
} = useWallet()
const { signMessageStatus, resetMessageStatus, signMessageAndCreateSession } =
useSignMessageAndCreateSession()
const { setConnectionError, resetConnectionError } =
const { connectionError, setConnectionError, resetConnectionError } =
useWalletConnectionError()
const { closeModal } = useModal()
const dispatch = useAppDispatch()

const [isLoading, setIsLoading] = useState<boolean>(false)

const hasConnectionError = connectionStatus === "error"
const hasConnectionError = connectionError || connectionStatus === "error"
const hasSignMessageStatus = signMessageStatus === "error"
const showStatuses = isSelected && !hasConnectionError
const showRetryButton = address && hasSignMessageStatus
Expand All @@ -92,11 +92,17 @@ export default function ConnectWalletButton({
} catch (error) {
if (eip1193.didUserRejectRequest(error)) return

onDisconnect()
console.error("Failed to sign siww message", error)
setConnectionError(CONNECTION_ERRORS.INVALID_SIWW_SIGNATURE)
}
},
[signMessageAndCreateSession, onSuccessSignMessage, setConnectionError],
[
signMessageAndCreateSession,
onSuccessSignMessage,
onDisconnect,
setConnectionError,
],
)

const onSuccessConnection = useCallback(
Expand Down

0 comments on commit 9ddbfb8

Please sign in to comment.