Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions src/components/RequestAirdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export const RequestAirdrop: FC = () => {
let signature: TransactionSignature = '';

try {
signature = await connection.requestAirdrop(publicKey, LAMPORTS_PER_SOL);

// Get the lates block hash to use on our transaction and confirmation
let latestBlockhash = await connection.getLatestBlockhash()
await connection.confirmTransaction({ signature, ...latestBlockhash }, 'confirmed');

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

getUserSOLBalance(publicKey, connection);
Expand Down
12 changes: 9 additions & 3 deletions src/components/SendTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ export const SendTransaction: FC = () => {
// Send transaction and await for signature
await connection.confirmTransaction({ signature, ...latestBlockhash }, 'confirmed');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added a new .confirmTransaction below, so you no longer need this one.

Suggested change
await connection.confirmTransaction({ signature, ...latestBlockhash }, 'confirmed');


console.log(signature);
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
await connection.confirmTransaction({
blockhash,
lastValidBlockHeight,
signature
});
console.log('Transaction Signature:', signature);
notify({ type: 'success', message: 'Transaction successful!', txid: signature });
} catch (error: any) {
notify({ type: 'error', message: `Transaction failed!`, description: error?.message, txid: signature });
Expand All @@ -66,11 +72,11 @@ export const SendTransaction: FC = () => {
<div className="hidden group-disabled:block ">
Wallet not connected
</div>
<span className="block group-disabled:hidden" >
<span className="block group-disabled:hidden" >
Send Transaction
</span>
</button>
</div>
</div>
</div>
);
};