From 198ccd98c34d6dd1ad12acda4ecfcd13606f860d Mon Sep 17 00:00:00 2001 From: Isha Date: Fri, 8 Nov 2024 14:33:27 +0530 Subject: [PATCH] Handle reject tx --- src/screens/WalletEmbed.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/screens/WalletEmbed.tsx b/src/screens/WalletEmbed.tsx index 8dcf038..4cbd1b5 100644 --- a/src/screens/WalletEmbed.tsx +++ b/src/screens/WalletEmbed.tsx @@ -200,7 +200,7 @@ export const WalletEmbed = () => { useEffect(() => { window.addEventListener('message', handleTxRequested); return () => window.removeEventListener('message', handleTxRequested); - }, [networksData, handleTxRequested]); + }, [handleTxRequested]); const acceptRequestHandler = async () => { try { @@ -242,7 +242,7 @@ export const WalletEmbed = () => { const event = txEventRef.current; if (event?.source) { - sendMessage(event.source as Window, 'TRANSACTION_SUCCESS', txResult.transactionHash, event.origin); + sendMessage(event.source as Window, 'TRANSACTION_RESPONSE', txResult.transactionHash, event.origin); } else { console.error('No event source available to send message'); } @@ -255,9 +255,15 @@ export const WalletEmbed = () => { }; const rejectRequestHandler = () => { + const event = txEventRef.current; + setIsTxRequested(false); setTransactionDetails(null); - sendMessage(window, 'TRANSACTION_REJECTED', null, '*'); + if (event?.source) { + sendMessage(event.source as Window, 'TRANSACTION_RESPONSE', null, event.origin); + } else { + console.error('No event source available to send message'); + } }; return (