Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Update SendTransactionCard.tsx #125

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ const SendTransaction = () => {
try {
setTransactionLoadingLoading(true);
const hash = await connection?.getLatestBlockhash();
if (!hash) return;

const transaction = new Transaction({
feePayer: userPublicKey,
recentBlockhash: hash?.blockhash,
...hash,
});

const lamportsAmount = Number(amount) * LAMPORTS_PER_SOL;
Expand All @@ -81,15 +83,16 @@ const SendTransaction = () => {

transaction.add(transfer);

const serializeConfig = {
const signedTransaction = await magic?.solana.signTransaction(transaction, {
requireAllSignatures: false,
verifySignatures: true,
};
});

const signature = await connection?.sendRawTransaction(
Buffer.from(signedTransaction?.rawTransaction as string, 'base64'),
);

const signedTransaction = await magic?.solana.signTransaction(transaction, serializeConfig);
const rawTransaction = Transaction.from(signedTransaction.rawTransaction);
const signature = await connection?.sendRawTransaction(rawTransaction.serialize());
setHash(signature);
setHash(signature ?? '');
showToast({
message: `Transaction successful sig: ${signature}`,
type: 'success',
Expand All @@ -114,7 +117,7 @@ const SendTransaction = () => {
<div>
<FormButton onClick={handleAirdrop} disabled={airdropLoading}>
{airdropLoading ? (
<div className="loading-container w-full">
<div className="w-full loading-container">
<Spinner />
</div>
) : (
Expand All @@ -134,7 +137,7 @@ const SendTransaction = () => {
{amountError ? <ErrorText className="error">Invalid amount</ErrorText> : null}
<FormButton onClick={sendTransaction} disabled={!toAddress || !amount || disabled}>
{transactionLoading ? (
<div className="loading-container w-full">
<div className="w-full loading-container">
<Spinner />
</div>
) : (
Expand Down
Loading