diff --git a/target_chains/solana/sdk/js/pyth_solana_receiver/package.json b/target_chains/solana/sdk/js/pyth_solana_receiver/package.json index 7f32568be0..8f4e4bf2a2 100644 --- a/target_chains/solana/sdk/js/pyth_solana_receiver/package.json +++ b/target_chains/solana/sdk/js/pyth_solana_receiver/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-solana-receiver", - "version": "0.10.1", + "version": "0.10.2", "description": "Pyth solana receiver SDK", "homepage": "https://pyth.network", "main": "lib/index.js", diff --git a/target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts b/target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts index da4eb7ccce..bad88f630c 100644 --- a/target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts +++ b/target_chains/solana/sdk/js/pyth_solana_receiver/src/vaa.ts @@ -133,35 +133,39 @@ async function generateVaaInstructionGroups( // Second write and verify instructions const writeSecondPartAndVerifyInstructions: InstructionWithEphemeralSigners[] = - [ - { - instruction: await wormhole.methods - .writeEncodedVaa({ - index: VAA_SPLIT_INDEX, - data: vaa.subarray(VAA_SPLIT_INDEX), - }) - .accounts({ - draftVaa: encodedVaaKeypair.publicKey, - }) - .instruction(), - signers: [], - computeUnits: WRITE_ENCODED_VAA_COMPUTE_BUDGET, - }, - { - instruction: await wormhole.methods - .verifyEncodedVaaV1() - .accounts({ - guardianSet: getGuardianSetPda( - getGuardianSetIndex(vaa), - wormhole.programId, - ), - draftVaa: encodedVaaKeypair.publicKey, - }) - .instruction(), - signers: [], - computeUnits: VERIFY_ENCODED_VAA_COMPUTE_BUDGET, - }, - ]; + []; + + // The second write instruction is only needed if there are more bytes past the split index in the VAA + if (vaa.length > VAA_SPLIT_INDEX) { + writeSecondPartAndVerifyInstructions.push({ + instruction: await wormhole.methods + .writeEncodedVaa({ + index: VAA_SPLIT_INDEX, + data: vaa.subarray(VAA_SPLIT_INDEX), + }) + .accounts({ + draftVaa: encodedVaaKeypair.publicKey, + }) + .instruction(), + signers: [], + computeUnits: WRITE_ENCODED_VAA_COMPUTE_BUDGET, + }); + } + + writeSecondPartAndVerifyInstructions.push({ + instruction: await wormhole.methods + .verifyEncodedVaaV1() + .accounts({ + guardianSet: getGuardianSetPda( + getGuardianSetIndex(vaa), + wormhole.programId, + ), + draftVaa: encodedVaaKeypair.publicKey, + }) + .instruction(), + signers: [], + computeUnits: VERIFY_ENCODED_VAA_COMPUTE_BUDGET, + }); // Close instructions const closeInstructions: InstructionWithEphemeralSigners[] = [