@solana/transactions 2.0.0-experimental.1584fe6 → 2.0.0-experimental.211879d
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/dist/index.browser.cjs +112 -77
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +111 -78
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +114 -81
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +111 -78
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +112 -79
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +111 -78
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +11 -9
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/blockhash.d.ts.map +1 -0
- package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
- package/dist/types/compile-header.d.ts.map +1 -0
- package/dist/types/compile-instructions.d.ts.map +1 -0
- package/dist/types/compile-lifetime-token.d.ts.map +1 -0
- package/dist/types/compile-static-accounts.d.ts.map +1 -0
- package/dist/types/compile-transaction.d.ts.map +1 -0
- package/dist/types/create-transaction.d.ts.map +1 -0
- package/dist/types/durable-nonce.d.ts +11 -2
- package/dist/types/durable-nonce.d.ts.map +1 -0
- package/dist/types/fee-payer.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instructions.d.ts.map +1 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
- package/dist/types/serializers/header.d.ts.map +1 -0
- package/dist/types/serializers/instruction.d.ts.map +1 -0
- package/dist/types/serializers/message.d.ts.map +1 -0
- package/dist/types/serializers/transaction-version.d.ts.map +1 -0
- package/dist/types/serializers/transaction.d.ts.map +1 -0
- package/dist/types/serializers/unimplemented.d.ts.map +1 -0
- package/dist/types/signatures.d.ts +1 -3
- package/dist/types/signatures.d.ts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/unsigned-transaction.d.ts +4 -0
- package/dist/types/unsigned-transaction.d.ts.map +1 -0
- package/dist/types/wire-transaction.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -493,6 +493,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
495
|
|
|
496
|
+
// src/unsigned-transaction.ts
|
|
497
|
+
function getUnsignedTransaction(transaction) {
|
|
498
|
+
if ("signatures" in transaction) {
|
|
499
|
+
const {
|
|
500
|
+
signatures: _,
|
|
501
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
502
|
+
...unsignedTransaction
|
|
503
|
+
} = transaction;
|
|
504
|
+
return unsignedTransaction;
|
|
505
|
+
} else {
|
|
506
|
+
return transaction;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
496
510
|
// src/blockhash.ts
|
|
497
511
|
function assertIsBlockhash(putativeBlockhash) {
|
|
498
512
|
try {
|
|
@@ -518,23 +532,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
518
532
|
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
519
533
|
return transaction;
|
|
520
534
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
526
|
-
...unsignedTransaction
|
|
527
|
-
} = transaction;
|
|
528
|
-
out = {
|
|
529
|
-
...unsignedTransaction,
|
|
530
|
-
lifetimeConstraint: blockhashLifetimeConstraint
|
|
531
|
-
};
|
|
532
|
-
} else {
|
|
533
|
-
out = {
|
|
534
|
-
...transaction,
|
|
535
|
-
lifetimeConstraint: blockhashLifetimeConstraint
|
|
536
|
-
};
|
|
537
|
-
}
|
|
535
|
+
const out = {
|
|
536
|
+
...getUnsignedTransaction(transaction),
|
|
537
|
+
lifetimeConstraint: blockhashLifetimeConstraint
|
|
538
|
+
};
|
|
538
539
|
Object.freeze(out);
|
|
539
540
|
return out;
|
|
540
541
|
}
|
|
@@ -551,62 +552,115 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
551
552
|
return out;
|
|
552
553
|
}
|
|
553
554
|
|
|
555
|
+
// ../instructions/dist/index.browser.js
|
|
556
|
+
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
557
|
+
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
558
|
+
3] = "WRITABLE_SIGNER";
|
|
559
|
+
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
560
|
+
2] = "READONLY_SIGNER";
|
|
561
|
+
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
562
|
+
1] = "WRITABLE";
|
|
563
|
+
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
564
|
+
0] = "READONLY";
|
|
565
|
+
return AccountRole2;
|
|
566
|
+
})(AccountRole || {});
|
|
567
|
+
var IS_WRITABLE_BITMASK = 1;
|
|
568
|
+
function isSignerRole(role) {
|
|
569
|
+
return role >= 2;
|
|
570
|
+
}
|
|
571
|
+
function isWritableRole(role) {
|
|
572
|
+
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
573
|
+
}
|
|
574
|
+
function mergeRoles(roleA, roleB) {
|
|
575
|
+
return roleA | roleB;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/durable-nonce.ts
|
|
579
|
+
var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
|
|
580
|
+
var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
581
|
+
function assertIsDurableNonceTransaction(transaction) {
|
|
582
|
+
if (!isDurableNonceTransaction(transaction)) {
|
|
583
|
+
throw new Error("Transaction is not a durable nonce transaction");
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
|
|
587
|
+
return {
|
|
588
|
+
accounts: [
|
|
589
|
+
{ address: nonceAccountAddress, role: AccountRole.WRITABLE },
|
|
590
|
+
{
|
|
591
|
+
address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
|
|
592
|
+
role: AccountRole.READONLY
|
|
593
|
+
},
|
|
594
|
+
{ address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
|
|
595
|
+
],
|
|
596
|
+
data: new Uint8Array([4, 0, 0, 0]),
|
|
597
|
+
programAddress: SYSTEM_PROGRAM_ADDRESS
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function isAdvanceNonceAccountInstruction(instruction) {
|
|
601
|
+
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
602
|
+
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
603
|
+
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
604
|
+
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
605
|
+
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
606
|
+
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
|
|
607
|
+
}
|
|
608
|
+
function isAdvanceNonceAccountInstructionData(data) {
|
|
609
|
+
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
610
|
+
}
|
|
611
|
+
function isDurableNonceTransaction(transaction) {
|
|
612
|
+
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
613
|
+
}
|
|
614
|
+
function setTransactionLifetimeUsingDurableNonce({
|
|
615
|
+
nonce,
|
|
616
|
+
nonceAccountAddress,
|
|
617
|
+
nonceAuthorityAddress
|
|
618
|
+
}, transaction) {
|
|
619
|
+
const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
|
|
620
|
+
if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
|
|
621
|
+
return transaction;
|
|
622
|
+
}
|
|
623
|
+
const out = {
|
|
624
|
+
...getUnsignedTransaction(transaction),
|
|
625
|
+
instructions: [
|
|
626
|
+
createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
|
|
627
|
+
...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
|
|
628
|
+
],
|
|
629
|
+
lifetimeConstraint: {
|
|
630
|
+
nonce
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
Object.freeze(out);
|
|
634
|
+
return out;
|
|
635
|
+
}
|
|
636
|
+
|
|
554
637
|
// src/fee-payer.ts
|
|
555
638
|
function setTransactionFeePayer(feePayer, transaction) {
|
|
556
639
|
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
557
640
|
return transaction;
|
|
558
641
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
564
|
-
...unsignedTransaction
|
|
565
|
-
} = transaction;
|
|
566
|
-
out = {
|
|
567
|
-
...unsignedTransaction,
|
|
568
|
-
feePayer
|
|
569
|
-
};
|
|
570
|
-
} else {
|
|
571
|
-
out = {
|
|
572
|
-
...transaction,
|
|
573
|
-
feePayer
|
|
574
|
-
};
|
|
575
|
-
}
|
|
642
|
+
const out = {
|
|
643
|
+
...getUnsignedTransaction(transaction),
|
|
644
|
+
feePayer
|
|
645
|
+
};
|
|
576
646
|
Object.freeze(out);
|
|
577
647
|
return out;
|
|
578
648
|
}
|
|
579
649
|
|
|
580
650
|
// src/instructions.ts
|
|
581
|
-
function replaceInstructions(transaction, nextInstructions) {
|
|
582
|
-
let out;
|
|
583
|
-
if ("signatures" in transaction) {
|
|
584
|
-
const {
|
|
585
|
-
signatures: _,
|
|
586
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
587
|
-
...unsignedTransaction
|
|
588
|
-
} = transaction;
|
|
589
|
-
out = {
|
|
590
|
-
...unsignedTransaction,
|
|
591
|
-
instructions: nextInstructions
|
|
592
|
-
};
|
|
593
|
-
} else {
|
|
594
|
-
out = {
|
|
595
|
-
...transaction,
|
|
596
|
-
instructions: nextInstructions
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
return out;
|
|
600
|
-
}
|
|
601
651
|
function appendTransactionInstruction(instruction, transaction) {
|
|
602
|
-
const
|
|
603
|
-
|
|
652
|
+
const out = {
|
|
653
|
+
...getUnsignedTransaction(transaction),
|
|
654
|
+
instructions: [...transaction.instructions, instruction]
|
|
655
|
+
};
|
|
604
656
|
Object.freeze(out);
|
|
605
657
|
return out;
|
|
606
658
|
}
|
|
607
659
|
function prependTransactionInstruction(instruction, transaction) {
|
|
608
|
-
const
|
|
609
|
-
|
|
660
|
+
const out = {
|
|
661
|
+
...getUnsignedTransaction(transaction),
|
|
662
|
+
instructions: [instruction, ...transaction.instructions]
|
|
663
|
+
};
|
|
610
664
|
Object.freeze(out);
|
|
611
665
|
return out;
|
|
612
666
|
}
|
|
@@ -661,29 +715,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
661
715
|
return new Uint8Array(signedData);
|
|
662
716
|
}
|
|
663
717
|
|
|
664
|
-
// ../instructions/dist/index.browser.js
|
|
665
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
666
|
-
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
667
|
-
3] = "WRITABLE_SIGNER";
|
|
668
|
-
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
669
|
-
2] = "READONLY_SIGNER";
|
|
670
|
-
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
671
|
-
1] = "WRITABLE";
|
|
672
|
-
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
673
|
-
0] = "READONLY";
|
|
674
|
-
return AccountRole2;
|
|
675
|
-
})(AccountRole || {});
|
|
676
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
677
|
-
function isSignerRole(role) {
|
|
678
|
-
return role >= 2;
|
|
679
|
-
}
|
|
680
|
-
function isWritableRole(role) {
|
|
681
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
682
|
-
}
|
|
683
|
-
function mergeRoles(roleA, roleB) {
|
|
684
|
-
return roleA | roleB;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
718
|
// src/accounts.ts
|
|
688
719
|
function upsert(addressMap, address, update) {
|
|
689
720
|
addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
|
|
@@ -1276,11 +1307,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1276
1307
|
|
|
1277
1308
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1278
1309
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1310
|
+
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1279
1311
|
exports.createTransaction = createTransaction;
|
|
1280
1312
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1281
1313
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1282
1314
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1283
1315
|
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1316
|
+
exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
|
|
1284
1317
|
exports.signTransaction = signTransaction;
|
|
1285
1318
|
|
|
1286
1319
|
return exports;
|