From c3f9f7c2453a2a073b8ed792729ccfc9be7eebbf Mon Sep 17 00:00:00 2001 From: Adwait Gharpure <69599306+Adw8@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:40:16 +0530 Subject: [PATCH] Add support for rejecting transaction request (#119) * Implement functionality to reject request * Change button label --- src/screens/ApproveTransaction.tsx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/screens/ApproveTransaction.tsx b/src/screens/ApproveTransaction.tsx index 8af48bf..f149388 100644 --- a/src/screens/ApproveTransaction.tsx +++ b/src/screens/ApproveTransaction.tsx @@ -23,6 +23,7 @@ import { getPathKey } from '../utils/misc'; import { WalletConnectRequests, approveWalletConnectRequest, + rejectWalletConnectRequest, } from '../utils/wallet-connect/wallet-connect-requests'; import { web3wallet } from '../utils/wallet-connect/WalletConnectUtils'; import { MEMO } from './ApproveTransfer'; @@ -95,9 +96,9 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { setCosmosStargateClient(client); } catch (error: any) { setTxError(error.message); + setIsTxErrorDialogOpen(true); const response = formatJsonRpcError(requestEventId, error.message); await web3wallet!.respondSessionRequest({ topic, response }); - setIsTxErrorDialogOpen(true); } }; @@ -144,9 +145,9 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { ); } catch (error: any) { setTxError(error.message); + setIsTxErrorDialogOpen(true); const response = formatJsonRpcError(requestEventId, error.message); await web3wallet!.respondSessionRequest({ topic, response }); - setIsTxErrorDialogOpen(true); } }; getCosmosGas(); @@ -207,12 +208,22 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { navigation.navigate('Laconic'); } catch (error: any) { setTxError(error.message); + setIsTxErrorDialogOpen(true); const response = formatJsonRpcError(requestEventId, error.message); await web3wallet!.respondSessionRequest({ topic, response }); - setIsTxErrorDialogOpen(true); } }; + const rejectRequestHandler = async () => { + const response = rejectWalletConnectRequest(requestEvent); + await web3wallet!.respondSessionRequest({ + topic, + response, + }); + + navigation.navigate('Laconic'); + }; + return ( <> @@ -256,7 +267,13 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => { /> +