@solana/kit 6.1.0 → 6.2.0-canary-20260223183038

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.
@@ -184,6 +184,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
184
184
  var SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED = 5663021;
185
185
  var SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE = 5663022;
186
186
  var SOLANA_ERROR__TRANSACTION__MALFORMED_MESSAGE_BYTES = 5663023;
187
+ var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_MESSAGE_BYTES = 5663024;
188
+ var SOLANA_ERROR__TRANSACTION__CANNOT_DECODE_EMPTY_TRANSACTION_BYTES = 5663025;
189
+ var SOLANA_ERROR__TRANSACTION__VERSION_ZERO_MUST_BE_ENCODED_WITH_SIGNATURES_FIRST = 5663026;
190
+ var SOLANA_ERROR__TRANSACTION__SIGNATURE_COUNT_TOO_HIGH_FOR_TRANSACTION_BYTES = 5663027;
191
+ var SOLANA_ERROR__TRANSACTION__INVALID_CONFIG_MASK_PRIORITY_FEE_BITS = 5663028;
187
192
  var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
188
193
  var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
189
194
  var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
@@ -255,6 +260,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
255
260
  var SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = 8078021;
256
261
  var SOLANA_ERROR__CODECS__CANNOT_USE_LEXICAL_VALUES_AS_ENUM_DISCRIMINATORS = 8078022;
257
262
  var SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY = 8078023;
263
+ var SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE = 8078024;
264
+ var SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES = 8078025;
258
265
  var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
259
266
  var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
260
267
  var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
@@ -322,6 +329,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
322
329
  [SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
323
330
  [SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
324
331
  [SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY]: "This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",
332
+ [SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE]: "Invalid pattern match value. The provided value does not match any of the specified patterns.",
333
+ [SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES]: "Invalid pattern match bytes. The provided byte array does not match any of the specified patterns.",
325
334
  [SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED]: "No random values implementation could be found.",
326
335
  [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_ALREADY_INITIALIZED]: "instruction requires an uninitialized account",
327
336
  [SOLANA_ERROR__INSTRUCTION_ERROR__ACCOUNT_BORROW_FAILED]: "instruction tries to borrow reference for an account which is already borrowed",
@@ -549,7 +558,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
549
558
  [SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE]: "Transaction version must be in the range [0, 127]. `$actualVersion` given",
550
559
  [SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED]: "This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",
551
560
  [SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE]: "The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction.",
552
- [SOLANA_ERROR__TRANSACTION__MALFORMED_MESSAGE_BYTES]: "Transaction message bytes are malformed: $messageBytes"
561
+ [SOLANA_ERROR__TRANSACTION__INVALID_CONFIG_MASK_PRIORITY_FEE_BITS]: "Invalid transaction config mask: $mask. Bits 0 and 1 must match (both set or both unset)",
562
+ [SOLANA_ERROR__TRANSACTION__MALFORMED_MESSAGE_BYTES]: "Transaction message bytes are malformed: $messageBytes",
563
+ [SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_MESSAGE_BYTES]: "Transaction message bytes are empty, so the transaction cannot be encoded",
564
+ [SOLANA_ERROR__TRANSACTION__CANNOT_DECODE_EMPTY_TRANSACTION_BYTES]: "Transaction bytes are empty, so no transaction can be decoded",
565
+ [SOLANA_ERROR__TRANSACTION__VERSION_ZERO_MUST_BE_ENCODED_WITH_SIGNATURES_FIRST]: "Transaction version 0 must be encoded with signatures first. This transaction was encoded with first byte $firstByte, which is expected to be a signature count for v0 transactions.",
566
+ [SOLANA_ERROR__TRANSACTION__SIGNATURE_COUNT_TOO_HIGH_FOR_TRANSACTION_BYTES]: "The provided transaction bytes expect that there should be $numExpectedSignatures signatures, but the bytes are not long enough to contain a transaction message with this many signatures. The provided bytes are $transactionBytesLength bytes long."
553
567
  };
554
568
  var START_INDEX = "i";
555
569
  var TYPE = "t";
@@ -3449,6 +3463,83 @@ this.globalThis.solanaWeb3 = (function (exports) {
3449
3463
  lifetimeConstraint: Object.freeze(blockhashLifetimeConstraint)
3450
3464
  });
3451
3465
  }
3466
+ var memoizedU8Encoder;
3467
+ function getMemoizedU8Encoder() {
3468
+ if (!memoizedU8Encoder) memoizedU8Encoder = getU8Encoder();
3469
+ return memoizedU8Encoder;
3470
+ }
3471
+ var memoizedU8Decoder;
3472
+ function getMemoizedU8Decoder() {
3473
+ if (!memoizedU8Decoder) memoizedU8Decoder = getU8Decoder();
3474
+ return memoizedU8Decoder;
3475
+ }
3476
+ function getMessageHeaderEncoder() {
3477
+ return getStructEncoder([
3478
+ ["numSignerAccounts", getMemoizedU8Encoder()],
3479
+ ["numReadonlySignerAccounts", getMemoizedU8Encoder()],
3480
+ ["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
3481
+ ]);
3482
+ }
3483
+ function getMessageHeaderDecoder() {
3484
+ return getStructDecoder([
3485
+ ["numSignerAccounts", getMemoizedU8Decoder()],
3486
+ ["numReadonlySignerAccounts", getMemoizedU8Decoder()],
3487
+ ["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
3488
+ ]);
3489
+ }
3490
+ var memoizedGetInstructionEncoder;
3491
+ function getInstructionEncoder() {
3492
+ if (!memoizedGetInstructionEncoder) {
3493
+ memoizedGetInstructionEncoder = transformEncoder(
3494
+ getStructEncoder([
3495
+ ["programAddressIndex", getU8Encoder()],
3496
+ ["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
3497
+ ["data", addEncoderSizePrefix(getBytesEncoder(), getShortU16Encoder())]
3498
+ ]),
3499
+ // Convert an instruction to have all fields defined
3500
+ (instruction) => {
3501
+ var _a, _b;
3502
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
3503
+ return instruction;
3504
+ }
3505
+ return {
3506
+ ...instruction,
3507
+ accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
3508
+ data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
3509
+ };
3510
+ }
3511
+ );
3512
+ }
3513
+ return memoizedGetInstructionEncoder;
3514
+ }
3515
+ var memoizedGetInstructionDecoder;
3516
+ function getInstructionDecoder() {
3517
+ if (!memoizedGetInstructionDecoder) {
3518
+ memoizedGetInstructionDecoder = transformDecoder(
3519
+ getStructDecoder([
3520
+ ["programAddressIndex", getU8Decoder()],
3521
+ ["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
3522
+ [
3523
+ "data",
3524
+ addDecoderSizePrefix(getBytesDecoder(), getShortU16Decoder())
3525
+ ]
3526
+ ]),
3527
+ // Convert an instruction to exclude optional fields if they are empty
3528
+ (instruction) => {
3529
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
3530
+ return instruction;
3531
+ }
3532
+ const { accountIndices, data, ...rest } = instruction;
3533
+ return {
3534
+ ...rest,
3535
+ ...accountIndices.length ? { accountIndices } : null,
3536
+ ...data.byteLength ? { data } : null
3537
+ };
3538
+ }
3539
+ );
3540
+ }
3541
+ return memoizedGetInstructionDecoder;
3542
+ }
3452
3543
  function assertValidBaseString2(alphabet4, testValue, givenValue = testValue) {
3453
3544
  if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
3454
3545
  throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
@@ -3526,108 +3617,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
3526
3617
  var alphabet22 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3527
3618
  var getBase58Encoder2 = () => getBaseXEncoder2(alphabet22);
3528
3619
  var getBase58Decoder2 = () => getBaseXDecoder2(alphabet22);
3529
- var memoizedAddressTableLookupEncoder;
3530
- function getAddressTableLookupEncoder() {
3531
- if (!memoizedAddressTableLookupEncoder) {
3532
- const indexEncoder = getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() });
3533
- memoizedAddressTableLookupEncoder = getStructEncoder([
3534
- ["lookupTableAddress", getAddressEncoder()],
3535
- ["writableIndexes", indexEncoder],
3536
- ["readonlyIndexes", indexEncoder]
3537
- ]);
3538
- }
3539
- return memoizedAddressTableLookupEncoder;
3540
- }
3541
- var memoizedAddressTableLookupDecoder;
3542
- function getAddressTableLookupDecoder() {
3543
- if (!memoizedAddressTableLookupDecoder) {
3544
- const indexEncoder = getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() });
3545
- memoizedAddressTableLookupDecoder = getStructDecoder([
3546
- ["lookupTableAddress", getAddressDecoder()],
3547
- ["writableIndexes", indexEncoder],
3548
- ["readonlyIndexes", indexEncoder]
3549
- ]);
3550
- }
3551
- return memoizedAddressTableLookupDecoder;
3552
- }
3553
- var memoizedU8Encoder;
3554
- function getMemoizedU8Encoder() {
3555
- if (!memoizedU8Encoder) memoizedU8Encoder = getU8Encoder();
3556
- return memoizedU8Encoder;
3557
- }
3558
- var memoizedU8Decoder;
3559
- function getMemoizedU8Decoder() {
3560
- if (!memoizedU8Decoder) memoizedU8Decoder = getU8Decoder();
3561
- return memoizedU8Decoder;
3562
- }
3563
- function getMessageHeaderEncoder() {
3564
- return getStructEncoder([
3565
- ["numSignerAccounts", getMemoizedU8Encoder()],
3566
- ["numReadonlySignerAccounts", getMemoizedU8Encoder()],
3567
- ["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
3568
- ]);
3569
- }
3570
- function getMessageHeaderDecoder() {
3571
- return getStructDecoder([
3572
- ["numSignerAccounts", getMemoizedU8Decoder()],
3573
- ["numReadonlySignerAccounts", getMemoizedU8Decoder()],
3574
- ["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
3575
- ]);
3576
- }
3577
- var memoizedGetInstructionEncoder;
3578
- function getInstructionEncoder() {
3579
- if (!memoizedGetInstructionEncoder) {
3580
- memoizedGetInstructionEncoder = transformEncoder(
3581
- getStructEncoder([
3582
- ["programAddressIndex", getU8Encoder()],
3583
- ["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
3584
- ["data", addEncoderSizePrefix(getBytesEncoder(), getShortU16Encoder())]
3585
- ]),
3586
- // Convert an instruction to have all fields defined
3587
- (instruction) => {
3588
- var _a, _b;
3589
- if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
3590
- return instruction;
3591
- }
3592
- return {
3593
- ...instruction,
3594
- accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
3595
- data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
3596
- };
3597
- }
3598
- );
3599
- }
3600
- return memoizedGetInstructionEncoder;
3620
+ function getLifetimeTokenEncoder() {
3621
+ return transformEncoder(
3622
+ getNullableEncoder(fixEncoderSize(getBase58Encoder2(), 32), {
3623
+ noneValue: "zeroes",
3624
+ prefix: null
3625
+ }),
3626
+ (token) => token != null ? token : null
3627
+ );
3601
3628
  }
3602
- var memoizedGetInstructionDecoder;
3603
- function getInstructionDecoder() {
3604
- if (!memoizedGetInstructionDecoder) {
3605
- memoizedGetInstructionDecoder = transformDecoder(
3606
- getStructDecoder([
3607
- ["programAddressIndex", getU8Decoder()],
3608
- ["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
3609
- [
3610
- "data",
3611
- addDecoderSizePrefix(getBytesDecoder(), getShortU16Decoder())
3612
- ]
3613
- ]),
3614
- // Convert an instruction to exclude optional fields if they are empty
3615
- (instruction) => {
3616
- if (instruction.accountIndices.length && instruction.data.byteLength) {
3617
- return instruction;
3618
- }
3619
- const { accountIndices, data, ...rest } = instruction;
3620
- return {
3621
- ...rest,
3622
- ...accountIndices.length ? { accountIndices } : null,
3623
- ...data.byteLength ? { data } : null
3624
- };
3625
- }
3626
- );
3627
- }
3628
- return memoizedGetInstructionDecoder;
3629
+ function getLifetimeTokenDecoder() {
3630
+ return fixDecoderSize(getBase58Decoder2(), 32);
3629
3631
  }
3630
- var MAX_SUPPORTED_TRANSACTION_VERSION = 0;
3632
+ var MAX_SUPPORTED_TRANSACTION_VERSION = 1;
3631
3633
  var VERSION_FLAG_MASK = 128;
3632
3634
  function getTransactionVersionEncoder() {
3633
3635
  return createEncoder({
@@ -3674,6 +3676,30 @@ this.globalThis.solanaWeb3 = (function (exports) {
3674
3676
  function getTransactionVersionCodec() {
3675
3677
  return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
3676
3678
  }
3679
+ var memoizedAddressTableLookupEncoder;
3680
+ function getAddressTableLookupEncoder() {
3681
+ if (!memoizedAddressTableLookupEncoder) {
3682
+ const indexEncoder = getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() });
3683
+ memoizedAddressTableLookupEncoder = getStructEncoder([
3684
+ ["lookupTableAddress", getAddressEncoder()],
3685
+ ["writableIndexes", indexEncoder],
3686
+ ["readonlyIndexes", indexEncoder]
3687
+ ]);
3688
+ }
3689
+ return memoizedAddressTableLookupEncoder;
3690
+ }
3691
+ var memoizedAddressTableLookupDecoder;
3692
+ function getAddressTableLookupDecoder() {
3693
+ if (!memoizedAddressTableLookupDecoder) {
3694
+ const indexEncoder = getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() });
3695
+ memoizedAddressTableLookupDecoder = getStructDecoder([
3696
+ ["lookupTableAddress", getAddressDecoder()],
3697
+ ["writableIndexes", indexEncoder],
3698
+ ["readonlyIndexes", indexEncoder]
3699
+ ]);
3700
+ }
3701
+ return memoizedAddressTableLookupDecoder;
3702
+ }
3677
3703
  function getCompiledMessageLegacyEncoder() {
3678
3704
  return getStructEncoder(getPreludeStructEncoderTuple());
3679
3705
  }
@@ -3696,20 +3722,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
3696
3722
  );
3697
3723
  }
3698
3724
  function getPreludeStructEncoderTuple() {
3699
- const lifetimeTokenEncoder = getUnionEncoder(
3700
- [
3701
- // Use a 32-byte constant encoder for a missing lifetime token (index 0).
3702
- getConstantEncoder(new Uint8Array(32)),
3703
- // Use a 32-byte base58 encoder for a valid lifetime token (index 1).
3704
- fixEncoderSize(getBase58Encoder2(), 32)
3705
- ],
3706
- (value) => value === void 0 ? 0 : 1
3707
- );
3708
3725
  return [
3709
3726
  ["version", getTransactionVersionEncoder()],
3710
3727
  ["header", getMessageHeaderEncoder()],
3711
3728
  ["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
3712
- ["lifetimeToken", lifetimeTokenEncoder],
3729
+ ["lifetimeToken", getLifetimeTokenEncoder()],
3713
3730
  ["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
3714
3731
  ];
3715
3732
  }
@@ -3718,7 +3735,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3718
3735
  ["version", getTransactionVersionDecoder()],
3719
3736
  ["header", getMessageHeaderDecoder()],
3720
3737
  ["staticAccounts", getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],
3721
- ["lifetimeToken", fixDecoderSize(getBase58Decoder2(), 32)],
3738
+ ["lifetimeToken", getLifetimeTokenDecoder()],
3722
3739
  ["instructions", getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],
3723
3740
  ["addressTableLookups", getAddressTableLookupArrayDecoder()]
3724
3741
  ];
@@ -4328,6 +4345,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4328
4345
  config == null ? void 0 : config.lastValidBlockHeight
4329
4346
  );
4330
4347
  return pipe(
4348
+ // We don't currently support v1 transactions
4331
4349
  createTransactionMessage({ version: compiledTransactionMessage.version }),
4332
4350
  (m) => setTransactionMessageFeePayer(feePayer, m),
4333
4351
  (m) => instructions.reduce(
@@ -4565,16 +4583,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
4565
4583
  getSignaturesToEncode
4566
4584
  );
4567
4585
  }
4568
- var LEGACY_VERSION_FLAG_MASK = 128;
4586
+ var SIGNATURE_COUNT_FLAG_MASK = 128;
4569
4587
  var VERSION_FLAG_MASK2 = 127;
4570
- function getEncodeShapeForMessageBytes(messageBytes) {
4571
- const firstByte = messageBytes[0];
4572
- if ((firstByte & LEGACY_VERSION_FLAG_MASK) === 0) {
4588
+ function getEnvelopeShapeFromMessageBytes(messageBytes) {
4589
+ if (messageBytes.length === 0) {
4590
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_MESSAGE_BYTES);
4591
+ }
4592
+ const version = getTransactionVersionDecoder().decode(messageBytes);
4593
+ return version === 1 ? "messageFirst" : "signaturesFirst";
4594
+ }
4595
+ function getEnvelopeShapeFromTransactionBytes(transactionBytes) {
4596
+ if (transactionBytes.length === 0) {
4597
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__CANNOT_DECODE_EMPTY_TRANSACTION_BYTES);
4598
+ }
4599
+ const firstByte = transactionBytes[0];
4600
+ if ((firstByte & SIGNATURE_COUNT_FLAG_MASK) === 0) {
4573
4601
  return "signaturesFirst";
4574
4602
  }
4575
4603
  const version = firstByte & VERSION_FLAG_MASK2;
4576
4604
  if (version === 0) {
4577
- return "signaturesFirst";
4605
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__VERSION_ZERO_MUST_BE_ENCODED_WITH_SIGNATURES_FIRST, {
4606
+ firstByte,
4607
+ transactionBytes
4608
+ });
4578
4609
  }
4579
4610
  if (version === 1) {
4580
4611
  return "messageFirst";
@@ -4585,7 +4616,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4585
4616
  }
4586
4617
  function getTransactionEncoder() {
4587
4618
  return getPredicateEncoder(
4588
- (transaction) => getEncodeShapeForMessageBytes(transaction.messageBytes) === "signaturesFirst",
4619
+ (transaction) => getEnvelopeShapeFromMessageBytes(transaction.messageBytes) === "signaturesFirst",
4589
4620
  getTransactionEncoderWithSignaturesFirst(),
4590
4621
  getTransactionEncoderWithMessageFirst()
4591
4622
  );
@@ -4596,24 +4627,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
4596
4627
  ["messageBytes", getBytesEncoder()]
4597
4628
  ]);
4598
4629
  }
4599
- function getSignatureCountForVersionedOrThrow(messageBytes) {
4600
- if (messageBytes.length < 2) {
4630
+ function getSignatureCountForVersionedOrThrow(messageBytes, offset) {
4631
+ if (messageBytes.length < offset + 2) {
4601
4632
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__MALFORMED_MESSAGE_BYTES, {
4602
4633
  messageBytes
4603
4634
  });
4604
4635
  }
4605
- return messageBytes[1];
4636
+ return messageBytes[offset + 1];
4606
4637
  }
4607
4638
  function getTransactionEncoderWithMessageFirst() {
4608
4639
  const bytesEncoder = getBytesEncoder();
4609
4640
  return createEncoder({
4610
4641
  getSizeFromValue: (transaction) => {
4611
- const signatureCount = getSignatureCountForVersionedOrThrow(transaction.messageBytes);
4642
+ const signatureCount = getSignatureCountForVersionedOrThrow(transaction.messageBytes, 0);
4612
4643
  return transaction.messageBytes.length + signatureCount * 64;
4613
4644
  },
4614
4645
  write: (transaction, bytes, offset) => {
4615
4646
  offset = bytesEncoder.write(transaction.messageBytes, bytes, offset);
4616
- const signatureCount = getSignatureCountForVersionedOrThrow(transaction.messageBytes);
4647
+ const signatureCount = getSignatureCountForVersionedOrThrow(transaction.messageBytes, 0);
4617
4648
  const signaturesEncoder = getSignaturesEncoderWithLength(signatureCount);
4618
4649
  offset = signaturesEncoder.write(transaction.signatures, bytes, offset);
4619
4650
  return offset;
@@ -4621,18 +4652,58 @@ this.globalThis.solanaWeb3 = (function (exports) {
4621
4652
  });
4622
4653
  }
4623
4654
  function getTransactionDecoder() {
4655
+ return getPredicateDecoder(
4656
+ (transactionBytes) => getEnvelopeShapeFromTransactionBytes(transactionBytes) === "signaturesFirst",
4657
+ getTransactionDecoderWithSignaturesFirst(),
4658
+ getTransactionDecoderWithMessageFirst()
4659
+ );
4660
+ }
4661
+ function getTransactionDecoderWithSignaturesFirst() {
4624
4662
  return transformDecoder(
4625
4663
  getStructDecoder([
4626
4664
  ["signatures", getArrayDecoder(fixDecoderSize(getBytesDecoder(), 64), { size: getShortU16Decoder() })],
4627
4665
  ["messageBytes", getBytesDecoder()]
4628
4666
  ]),
4629
- decodePartiallyDecodedTransaction
4667
+ decodePartiallyDecodedLegacyOrV0Transaction
4668
+ );
4669
+ }
4670
+ function getTransactionDecoderWithMessageFirst() {
4671
+ return transformDecoder(
4672
+ getPartiallyDecodedTransactionDecoderWithMessageFirst(),
4673
+ decodePartiallyDecodedV1Transaction
4630
4674
  );
4631
4675
  }
4676
+ function getPartiallyDecodedTransactionDecoderWithMessageFirst() {
4677
+ return createDecoder({
4678
+ read(bytes, offset) {
4679
+ const signatureCount = getSignatureCountForVersionedOrThrow(bytes, offset);
4680
+ const signatureByteLength = signatureCount * 64;
4681
+ const messageBytesLength = bytes.length - offset - signatureByteLength;
4682
+ if (messageBytesLength < 0) {
4683
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__SIGNATURE_COUNT_TOO_HIGH_FOR_TRANSACTION_BYTES, {
4684
+ numExpectedSignatures: signatureCount,
4685
+ transactionBytes: bytes.subarray(offset),
4686
+ transactionBytesLength: bytes.length - offset
4687
+ });
4688
+ }
4689
+ const messageBytes = bytes.subarray(offset, offset + messageBytesLength);
4690
+ const [signatures, finalOffset] = getArrayDecoder(fixDecoderSize(getBytesDecoder(), 64), {
4691
+ size: signatureCount
4692
+ }).read(bytes, offset + messageBytesLength);
4693
+ return [
4694
+ {
4695
+ messageBytes,
4696
+ signatures
4697
+ },
4698
+ finalOffset
4699
+ ];
4700
+ }
4701
+ });
4702
+ }
4632
4703
  function getTransactionCodec() {
4633
4704
  return combineCodec(getTransactionEncoder(), getTransactionDecoder());
4634
4705
  }
4635
- function decodePartiallyDecodedTransaction(transaction) {
4706
+ function decodePartiallyDecodedLegacyOrV0Transaction(transaction) {
4636
4707
  const { messageBytes, signatures } = transaction;
4637
4708
  const signerAddressesDecoder = getTupleDecoder([
4638
4709
  // read transaction version
@@ -4652,6 +4723,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
4652
4723
  signerAddresses
4653
4724
  });
4654
4725
  }
4726
+ const signaturesMap = makeSignaturesMap(signerAddresses, signatures);
4727
+ return {
4728
+ messageBytes,
4729
+ signatures: Object.freeze(signaturesMap)
4730
+ };
4731
+ }
4732
+ function decodePartiallyDecodedV1Transaction(transaction) {
4733
+ const { messageBytes, signatures } = transaction;
4734
+ const numRequiredSignatures = messageBytes[1];
4735
+ const staticAddressOffset = 1 + 3 + 4 + 4 + 1 + 1;
4736
+ const signerAddresses = getArrayDecoder(getAddressDecoder(), { size: numRequiredSignatures }).decode(
4737
+ messageBytes,
4738
+ staticAddressOffset
4739
+ );
4740
+ if (signerAddresses.length !== signatures.length) {
4741
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH, {
4742
+ numRequiredSignatures,
4743
+ signaturesLength: signatures.length,
4744
+ signerAddresses
4745
+ });
4746
+ }
4747
+ const signaturesMap = makeSignaturesMap(signerAddresses, signatures);
4748
+ return {
4749
+ messageBytes,
4750
+ signatures: signaturesMap
4751
+ };
4752
+ }
4753
+ function makeSignaturesMap(signerAddresses, signatures) {
4655
4754
  const signaturesMap = {};
4656
4755
  signerAddresses.forEach((address2, index) => {
4657
4756
  const signatureForAddress = signatures[index];
@@ -4661,10 +4760,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4661
4760
  signaturesMap[address2] = signatureForAddress;
4662
4761
  }
4663
4762
  });
4664
- return {
4665
- messageBytes,
4666
- signatures: Object.freeze(signaturesMap)
4667
- };
4763
+ return Object.freeze(signaturesMap);
4668
4764
  }
4669
4765
  var SYSTEM_PROGRAM_ADDRESS2 = "11111111111111111111111111111111";
4670
4766
  function compiledInstructionIsAdvanceNonceInstruction(instruction, staticAddresses) {
@@ -7688,7 +7784,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
7688
7784
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
7689
7785
  ...{
7690
7786
  // Keep these headers lowercase so they will override any user-supplied headers above.
7691
- "solana-client": `js/${"6.1.0"}`
7787
+ "solana-client": `js/${"6.2.0-canary-20260223183038"}`
7692
7788
  }
7693
7789
  }
7694
7790
  }),
@@ -9736,6 +9832,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
9736
9832
  exports.SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT = SOLANA_ERROR__CODECS__INVALID_ENUM_VARIANT;
9737
9833
  exports.SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT = SOLANA_ERROR__CODECS__INVALID_LITERAL_UNION_VARIANT;
9738
9834
  exports.SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS = SOLANA_ERROR__CODECS__INVALID_NUMBER_OF_ITEMS;
9835
+ exports.SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES = SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES;
9836
+ exports.SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE = SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE;
9739
9837
  exports.SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE = SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE;
9740
9838
  exports.SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE;
9741
9839
  exports.SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE;
@@ -9948,6 +10046,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
9948
10046
  exports.SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT = SOLANA_ERROR__TRANSACTION_ERROR__WOULD_EXCEED_MAX_VOTE_COST_LIMIT;
9949
10047
  exports.SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION = SOLANA_ERROR__TRANSACTION__ADDRESSES_CANNOT_SIGN_TRANSACTION;
9950
10048
  exports.SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING = SOLANA_ERROR__TRANSACTION__ADDRESS_MISSING;
10049
+ exports.SOLANA_ERROR__TRANSACTION__CANNOT_DECODE_EMPTY_TRANSACTION_BYTES = SOLANA_ERROR__TRANSACTION__CANNOT_DECODE_EMPTY_TRANSACTION_BYTES;
10050
+ exports.SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_MESSAGE_BYTES = SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_MESSAGE_BYTES;
9951
10051
  exports.SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES;
9952
10052
  exports.SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT = SOLANA_ERROR__TRANSACTION__EXCEEDS_SIZE_LIMIT;
9953
10053
  exports.SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME = SOLANA_ERROR__TRANSACTION__EXPECTED_BLOCKHASH_LIFETIME;
@@ -9960,6 +10060,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
9960
10060
  exports.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT;
9961
10061
  exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING;
9962
10062
  exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING;
10063
+ exports.SOLANA_ERROR__TRANSACTION__INVALID_CONFIG_MASK_PRIORITY_FEE_BITS = SOLANA_ERROR__TRANSACTION__INVALID_CONFIG_MASK_PRIORITY_FEE_BITS;
9963
10064
  exports.SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE;
9964
10065
  exports.SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING = SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_INSTRUCTIONS_MISSING;
9965
10066
  exports.SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES = SOLANA_ERROR__TRANSACTION__INVOKED_PROGRAMS_CANNOT_PAY_FEES;
@@ -9968,8 +10069,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
9968
10069
  exports.SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH;
9969
10070
  exports.SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE = SOLANA_ERROR__TRANSACTION__NONCE_ACCOUNT_CANNOT_BE_IN_LOOKUP_TABLE;
9970
10071
  exports.SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING = SOLANA_ERROR__TRANSACTION__SIGNATURES_MISSING;
10072
+ exports.SOLANA_ERROR__TRANSACTION__SIGNATURE_COUNT_TOO_HIGH_FOR_TRANSACTION_BYTES = SOLANA_ERROR__TRANSACTION__SIGNATURE_COUNT_TOO_HIGH_FOR_TRANSACTION_BYTES;
9971
10073
  exports.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED = SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED;
9972
10074
  exports.SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE = SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_OUT_OF_RANGE;
10075
+ exports.SOLANA_ERROR__TRANSACTION__VERSION_ZERO_MUST_BE_ENCODED_WITH_SIGNATURES_FIRST = SOLANA_ERROR__TRANSACTION__VERSION_ZERO_MUST_BE_ENCODED_WITH_SIGNATURES_FIRST;
9973
10076
  exports.SolanaError = SolanaError;
9974
10077
  exports.TRANSACTION_PACKET_HEADER = TRANSACTION_PACKET_HEADER;
9975
10078
  exports.TRANSACTION_PACKET_SIZE = TRANSACTION_PACKET_SIZE;