@solana/transaction-messages 2.2.0-canary-20250708184753 → 2.2.0

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.
Files changed (43) hide show
  1. package/README.md +9 -9
  2. package/dist/index.browser.cjs +32 -34
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.mjs +34 -34
  5. package/dist/index.browser.mjs.map +1 -1
  6. package/dist/index.native.mjs +34 -34
  7. package/dist/index.native.mjs.map +1 -1
  8. package/dist/index.node.cjs +32 -34
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.mjs +34 -34
  11. package/dist/index.node.mjs.map +1 -1
  12. package/dist/types/blockhash.d.ts +3 -2
  13. package/dist/types/blockhash.d.ts.map +1 -1
  14. package/dist/types/compilable-transaction-message.d.ts +5 -4
  15. package/dist/types/compilable-transaction-message.d.ts.map +1 -1
  16. package/dist/types/compile/accounts.d.ts +3 -3
  17. package/dist/types/compile/accounts.d.ts.map +1 -1
  18. package/dist/types/compile/instructions.d.ts +2 -2
  19. package/dist/types/compile/instructions.d.ts.map +1 -1
  20. package/dist/types/compress-transaction-message.d.ts +5 -5
  21. package/dist/types/compress-transaction-message.d.ts.map +1 -1
  22. package/dist/types/create-transaction-message.d.ts +3 -7
  23. package/dist/types/create-transaction-message.d.ts.map +1 -1
  24. package/dist/types/decompile-message.d.ts.map +1 -1
  25. package/dist/types/durable-nonce.d.ts +49 -47
  26. package/dist/types/durable-nonce.d.ts.map +1 -1
  27. package/dist/types/fee-payer.d.ts +3 -8
  28. package/dist/types/fee-payer.d.ts.map +1 -1
  29. package/dist/types/index.d.ts +0 -3
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/types/instructions.d.ts +6 -21
  32. package/dist/types/instructions.d.ts.map +1 -1
  33. package/dist/types/transaction-message.d.ts +5 -5
  34. package/dist/types/transaction-message.d.ts.map +1 -1
  35. package/package.json +10 -10
  36. package/dist/types/deprecated.d.ts +0 -65
  37. package/dist/types/deprecated.d.ts.map +0 -1
  38. package/dist/types/durable-nonce-instruction.d.ts +0 -43
  39. package/dist/types/durable-nonce-instruction.d.ts.map +0 -1
  40. package/dist/types/lifetime.d.ts +0 -12
  41. package/dist/types/lifetime.d.ts.map +0 -1
  42. package/dist/types/transaction-message-size.d.ts +0 -13
  43. package/dist/types/transaction-message-size.d.ts.map +0 -1
@@ -11,7 +11,14 @@ var functional = require('@solana/functional');
11
11
 
12
12
  // src/blockhash.ts
13
13
  function isTransactionMessageWithBlockhashLifetime(transactionMessage) {
14
- return "lifetimeConstraint" in transactionMessage && typeof transactionMessage.lifetimeConstraint.blockhash === "string" && typeof transactionMessage.lifetimeConstraint.lastValidBlockHeight === "bigint" && rpcTypes.isBlockhash(transactionMessage.lifetimeConstraint.blockhash);
14
+ const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transactionMessage && typeof transactionMessage.lifetimeConstraint.blockhash === "string" && typeof transactionMessage.lifetimeConstraint.lastValidBlockHeight === "bigint";
15
+ if (!lifetimeConstraintShapeMatches) return false;
16
+ try {
17
+ rpcTypes.assertIsBlockhash(transactionMessage.lifetimeConstraint.blockhash);
18
+ return true;
19
+ } catch {
20
+ return false;
21
+ }
15
22
  }
16
23
  function assertIsTransactionMessageWithBlockhashLifetime(transactionMessage) {
17
24
  if (!isTransactionMessageWithBlockhashLifetime(transactionMessage)) {
@@ -19,13 +26,15 @@ function assertIsTransactionMessageWithBlockhashLifetime(transactionMessage) {
19
26
  }
20
27
  }
21
28
  function setTransactionMessageLifetimeUsingBlockhash(blockhashLifetimeConstraint, transactionMessage) {
22
- if ("lifetimeConstraint" in transactionMessage && transactionMessage.lifetimeConstraint && "blockhash" in transactionMessage.lifetimeConstraint && transactionMessage.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transactionMessage.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
29
+ if ("lifetimeConstraint" in transactionMessage && transactionMessage.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transactionMessage.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
23
30
  return transactionMessage;
24
31
  }
25
- return Object.freeze({
32
+ const out = {
26
33
  ...transactionMessage,
27
34
  lifetimeConstraint: Object.freeze(blockhashLifetimeConstraint)
28
- });
35
+ };
36
+ Object.freeze(out);
37
+ return out;
29
38
  }
30
39
  function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
31
40
  if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
@@ -651,14 +660,21 @@ function compressTransactionMessageUsingAddressLookupTables(transactionMessage,
651
660
  }
652
661
 
653
662
  // src/create-transaction-message.ts
654
- function createTransactionMessage(config) {
663
+ function createTransactionMessage({
664
+ version
665
+ }) {
655
666
  return Object.freeze({
656
667
  instructions: Object.freeze([]),
657
- version: config.version
668
+ version
658
669
  });
659
670
  }
660
671
  var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
661
672
  var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
673
+ function assertIsDurableNonceTransactionMessage(transactionMessage) {
674
+ if (!isDurableNonceTransaction(transactionMessage)) {
675
+ throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME);
676
+ }
677
+ }
662
678
  function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
663
679
  return {
664
680
  accounts: [
@@ -684,16 +700,9 @@ function isAdvanceNonceAccountInstruction(instruction) {
684
700
  function isAdvanceNonceAccountInstructionData(data) {
685
701
  return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
686
702
  }
687
-
688
- // src/durable-nonce.ts
689
- function isTransactionMessageWithDurableNonceLifetime(transactionMessage) {
703
+ function isDurableNonceTransaction(transactionMessage) {
690
704
  return "lifetimeConstraint" in transactionMessage && typeof transactionMessage.lifetimeConstraint.nonce === "string" && transactionMessage.instructions[0] != null && isAdvanceNonceAccountInstruction(transactionMessage.instructions[0]);
691
705
  }
692
- function assertIsTransactionMessageWithDurableNonceLifetime(transactionMessage) {
693
- if (!isTransactionMessageWithDurableNonceLifetime(transactionMessage)) {
694
- throw new errors.SolanaError(errors.SOLANA_ERROR__TRANSACTION__EXPECTED_NONCE_LIFETIME);
695
- }
696
- }
697
706
  function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
698
707
  return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
699
708
  }
@@ -706,7 +715,7 @@ function setTransactionMessageLifetimeUsingDurableNonce({
706
715
  const firstInstruction = transactionMessage.instructions[0];
707
716
  if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
708
717
  if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
709
- if (isTransactionMessageWithDurableNonceLifetime(transactionMessage) && transactionMessage.lifetimeConstraint.nonce === nonce) {
718
+ if (isDurableNonceTransaction(transactionMessage) && transactionMessage.lifetimeConstraint.nonce === nonce) {
710
719
  return transactionMessage;
711
720
  } else {
712
721
  newInstructions = [firstInstruction, ...transactionMessage.instructions.slice(1)];
@@ -726,7 +735,9 @@ function setTransactionMessageLifetimeUsingDurableNonce({
726
735
  return Object.freeze({
727
736
  ...transactionMessage,
728
737
  instructions: Object.freeze(newInstructions),
729
- lifetimeConstraint: Object.freeze({ nonce })
738
+ lifetimeConstraint: Object.freeze({
739
+ nonce
740
+ })
730
741
  });
731
742
  }
732
743
 
@@ -753,10 +764,7 @@ function appendTransactionMessageInstruction(instruction, transactionMessage) {
753
764
  function appendTransactionMessageInstructions(instructions, transactionMessage) {
754
765
  return Object.freeze({
755
766
  ...transactionMessage,
756
- instructions: Object.freeze([
757
- ...transactionMessage.instructions,
758
- ...instructions
759
- ])
767
+ instructions: Object.freeze([...transactionMessage.instructions, ...instructions])
760
768
  });
761
769
  }
762
770
  function prependTransactionMessageInstruction(instruction, transactionMessage) {
@@ -765,10 +773,7 @@ function prependTransactionMessageInstruction(instruction, transactionMessage) {
765
773
  function prependTransactionMessageInstructions(instructions, transactionMessage) {
766
774
  return Object.freeze({
767
775
  ...transactionMessage,
768
- instructions: Object.freeze([
769
- ...instructions,
770
- ...transactionMessage.instructions
771
- ])
776
+ instructions: Object.freeze([...instructions, ...transactionMessage.instructions])
772
777
  });
773
778
  }
774
779
 
@@ -910,23 +915,17 @@ function decompileTransactionMessage(compiledTransactionMessage, config) {
910
915
  return functional.pipe(
911
916
  createTransactionMessage({ version: compiledTransactionMessage.version }),
912
917
  (m) => setTransactionMessageFeePayer(feePayer, m),
913
- (m) => instructions.reduce(
914
- (acc, instruction) => appendTransactionMessageInstruction(instruction, acc),
915
- m
916
- ),
918
+ (m) => instructions.reduce((acc, instruction) => {
919
+ return appendTransactionMessageInstruction(instruction, acc);
920
+ }, m),
917
921
  (m) => "blockhash" in lifetimeConstraint ? setTransactionMessageLifetimeUsingBlockhash(lifetimeConstraint, m) : setTransactionMessageLifetimeUsingDurableNonce(lifetimeConstraint, m)
918
922
  );
919
923
  }
920
924
 
921
- // src/deprecated.ts
922
- var assertIsDurableNonceTransactionMessage = assertIsTransactionMessageWithDurableNonceLifetime;
923
- var isDurableNonceTransaction = isTransactionMessageWithDurableNonceLifetime;
924
-
925
925
  exports.appendTransactionMessageInstruction = appendTransactionMessageInstruction;
926
926
  exports.appendTransactionMessageInstructions = appendTransactionMessageInstructions;
927
927
  exports.assertIsDurableNonceTransactionMessage = assertIsDurableNonceTransactionMessage;
928
928
  exports.assertIsTransactionMessageWithBlockhashLifetime = assertIsTransactionMessageWithBlockhashLifetime;
929
- exports.assertIsTransactionMessageWithDurableNonceLifetime = assertIsTransactionMessageWithDurableNonceLifetime;
930
929
  exports.compileTransactionMessage = compileTransactionMessage;
931
930
  exports.compressTransactionMessageUsingAddressLookupTables = compressTransactionMessageUsingAddressLookupTables;
932
931
  exports.createTransactionMessage = createTransactionMessage;
@@ -940,7 +939,6 @@ exports.getTransactionVersionEncoder = getTransactionVersionEncoder;
940
939
  exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
941
940
  exports.isDurableNonceTransaction = isDurableNonceTransaction;
942
941
  exports.isTransactionMessageWithBlockhashLifetime = isTransactionMessageWithBlockhashLifetime;
943
- exports.isTransactionMessageWithDurableNonceLifetime = isTransactionMessageWithDurableNonceLifetime;
944
942
  exports.prependTransactionMessageInstruction = prependTransactionMessageInstruction;
945
943
  exports.prependTransactionMessageInstructions = prependTransactionMessageInstructions;
946
944
  exports.setTransactionMessageFeePayer = setTransactionMessageFeePayer;