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