Clear tx timeout

This commit is contained in:
IshaVenikar 2024-11-11 10:26:12 +05:30
parent 67e5baf8ff
commit b214702a5e

View File

@ -333,6 +333,7 @@ const Configure = () => {
const senderAddress = selectedAccount; const senderAddress = selectedAccount;
const snowballAddress = await client.getAddress(); const snowballAddress = await client.getAddress();
let timeoutId;
try { try {
setIsPaymentDone(false); setIsPaymentDone(false);
@ -365,7 +366,7 @@ const Configure = () => {
window.addEventListener('message', handleTxStatus); window.addEventListener('message', handleTxStatus);
// Set a timeout, consider unsuccessful after 1 min // Set a timeout, consider unsuccessful after 1 min
setTimeout(() => { timeoutId = setTimeout(() => {
reject(new Error('Transaction timeout')); reject(new Error('Transaction timeout'));
window.removeEventListener('message', handleTxStatus); window.removeEventListener('message', handleTxStatus);
toast({ toast({
@ -382,6 +383,7 @@ const Configure = () => {
throw new Error('Error in transaction'); throw new Error('Error in transaction');
} finally { } finally {
setIsPaymentLoading(false); setIsPaymentLoading(false);
clearTimeout(timeoutId);
} }
}, },
[client, dismiss, toast], [client, dismiss, toast],