Skip to content

Commit

Permalink
Fixed Pending Confirmations Modal (#106)
Browse files Browse the repository at this point in the history
## Pull Request Title: Improved transaction verification in verifyTx
function
## Fixes: #104 
 
## Issue:

The original verifyTx function only checked the transaction status once
after a fixed delay, leading to unreliable verification.

## Fix:

Refactored the verifyTx function to continuously check the transaction
status until confirmation or rejection. Implemented recursive checking
using setTimeout for regular status updates.

---------

Co-authored-by: Bruno <[email protected]>
  • Loading branch information
Ronnieraj37 and ceilican authored Apr 23, 2024
1 parent 9f778d9 commit 38a657f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 58 deletions.
2 changes: 1 addition & 1 deletion craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ module.exports = {
return webpackConfig;
}
}
};
};
75 changes: 21 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/utils/ethereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,14 @@ export const promiseTx = (isWalletConnected, tx, signer) => {

export const verifyTx = (web3, hash) => {
return new Promise((res) => {
setTimeout(() => {
web3.eth.getTransactionReceipt(hash).then((receipt) => res(receipt.status));
}, CONFIRMATION_WAIT_PERIOD);
const checkStatus = () => {
web3.eth.getTransactionReceipt(hash).then((receipt) => {
receipt != null ?
res(receipt.status) :
setTimeout(checkStatus, CONFIRMATION_WAIT_PERIOD);
});
};
checkStatus();
});
};

Expand Down

0 comments on commit 38a657f

Please sign in to comment.