Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor: Update confirmTransaction strategy
  • Loading branch information
GHesericsu committed Dec 14, 2022
commit 69ae411c75b3f0a80e6818ddbb7de6bcb7bfe55c
9 changes: 7 additions & 2 deletions src/components/RequestAirdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export const RequestAirdrop: FC = () => {
let signature: TransactionSignature = '';

try {
signature = await connection.requestAirdrop(publicKey, LAMPORTS_PER_SOL);
await connection.confirmTransaction(signature, 'confirmed');
const signature = await connection.requestAirdrop(publicKey, LAMPORTS_PER_SOL);
const latestBlockHash = await connection.getLatestBlockhash();
await connection.confirmTransaction({
blockhash: latestBlockHash.blockhash,
lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
signature
});
notify({ type: 'success', message: 'Airdrop successful!', txid: signature });

getUserSOLBalance(publicKey, connection);
Expand Down