From 9ddbfb8bc06fa1e2caae0ff598a8cd86c5c962c9 Mon Sep 17 00:00:00 2001 From: Karolina Kosiorowska Date: Wed, 25 Sep 2024 13:45:56 +0200 Subject: [PATCH] Disconnect the user when failed to sign siww message There is a case where OrangeKit returns error about failed to sign siww message. We will disconnect the user and close the action statuses. --- .../ConnectWalletModal/ConnectWalletButton.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx b/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx index d09cf7be7..73372bf88 100644 --- a/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx +++ b/dapp/src/components/ConnectWalletModal/ConnectWalletButton.tsx @@ -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(false) - const hasConnectionError = connectionStatus === "error" + const hasConnectionError = connectionError || connectionStatus === "error" const hasSignMessageStatus = signMessageStatus === "error" const showStatuses = isSelected && !hasConnectionError const showRetryButton = address && hasSignMessageStatus @@ -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(