@solana/transaction-messages 2.4.0-canary-20250709085504 → 2.4.0-canary-20250709090646

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { SolanaError, SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME, SO
2
2
  import { isBlockhash } from '@solana/rpc-types';
3
3
  import { getAddressDecoder, getAddressComparator, assertIsAddress, getAddressEncoder } from '@solana/addresses';
4
4
  import { createEncoder, createDecoder, combineCodec, transformDecoder, transformEncoder, fixDecoderSize, fixEncoderSize, addDecoderSizePrefix, addEncoderSizePrefix } from '@solana/codecs-core';
5
- import { getStructDecoder, getStructEncoder, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder } from '@solana/codecs-data-structures';
5
+ import { getStructDecoder, getStructEncoder, getArrayDecoder, getUnionEncoder, getConstantEncoder, getArrayEncoder, getBytesDecoder, getBytesEncoder } from '@solana/codecs-data-structures';
6
6
  import { getShortU16Decoder, getShortU16Encoder, getU8Decoder, getU8Encoder } from '@solana/codecs-numbers';
7
7
  import { isSignerRole, AccountRole, isWritableRole, mergeRoles } from '@solana/instructions';
8
8
  import { pipe } from '@solana/functional';
@@ -269,11 +269,20 @@ function getCompiledMessageVersionedEncoder() {
269
269
  );
270
270
  }
271
271
  function getPreludeStructEncoderTuple() {
272
+ const lifetimeTokenEncoder = getUnionEncoder(
273
+ [
274
+ // Use a 32-byte constant encoder for a missing lifetime token (index 0).
275
+ getConstantEncoder(new Uint8Array(32)),
276
+ // Use a 32-byte base58 encoder for a valid lifetime token (index 1).
277
+ fixEncoderSize(getBase58Encoder(), 32)
278
+ ],
279
+ (value) => value === void 0 ? 0 : 1
280
+ );
272
281
  return [
273
282
  ["version", getTransactionVersionEncoder()],
274
283
  ["header", getMessageHeaderEncoder()],
275
284
  ["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
276
- ["lifetimeToken", fixEncoderSize(getBase58Encoder(), 32)],
285
+ ["lifetimeToken", lifetimeTokenEncoder],
277
286
  ["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
278
287
  ];
279
288
  }
@@ -585,22 +594,18 @@ function getCompiledStaticAccounts(orderedAccounts) {
585
594
  }
586
595
 
587
596
  // src/compile/message.ts
588
- var EMPTY_BLOCKHASH_LIFETIME_CONSTRAINT = {
589
- blockhash: "11111111111111111111111111111111",
590
- lastValidBlockHeight: 0n
591
- };
592
597
  function compileTransactionMessage(transactionMessage) {
593
598
  const addressMap = getAddressMapFromInstructions(
594
599
  transactionMessage.feePayer.address,
595
600
  transactionMessage.instructions
596
601
  );
597
602
  const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
598
- const lifetimeConstraint = transactionMessage.lifetimeConstraint ?? EMPTY_BLOCKHASH_LIFETIME_CONSTRAINT;
603
+ const lifetimeConstraint = transactionMessage.lifetimeConstraint;
599
604
  return {
600
605
  ...transactionMessage.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
606
+ ...lifetimeConstraint ? { lifetimeToken: getCompiledLifetimeToken(lifetimeConstraint) } : null,
601
607
  header: getCompiledMessageHeader(orderedAccounts),
602
608
  instructions: getCompiledInstructions(transactionMessage.instructions, orderedAccounts),
603
- lifetimeToken: getCompiledLifetimeToken(lifetimeConstraint),
604
609
  staticAccounts: getCompiledStaticAccounts(orderedAccounts),
605
610
  version: transactionMessage.version
606
611
  };