set lastValidBlockHeight for tx confirmation

This commit is contained in:
tjs 2022-09-05 17:36:42 -04:00
parent 3e462c5530
commit fc63328af1
1 changed files with 5 additions and 3 deletions

View File

@ -8,9 +8,11 @@ export async function sendTransaction(
) {
const connection = provider.connection;
const payer = provider.wallet;
transaction.recentBlockhash = (
await connection.getLatestBlockhash(opts.preflightCommitment)
).blockhash;
const latestBlockhash = await connection.getLatestBlockhash(
opts.preflightCommitment,
);
transaction.recentBlockhash = latestBlockhash.blockhash;
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
transaction.feePayer = payer.publicKey;
if (opts.additionalSigners?.length > 0) {
transaction.partialSign(...opts.additionalSigners);