@solana/transactions 2.0.0-experimental.c2d0ddc → 2.0.0-experimental.c5061ae
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 +83 -62
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +82 -61
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +85 -64
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +84 -61
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +83 -60
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +82 -63
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +10 -8
- package/dist/types/blockhash.d.ts +5 -0
- package/dist/types/durable-nonce.d.ts +11 -6
- package/dist/types/signatures.d.ts +1 -3
- package/dist/types/unsigned-transaction.d.ts +4 -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 {
|
|
@@ -514,6 +528,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
514
528
|
});
|
|
515
529
|
}
|
|
516
530
|
}
|
|
531
|
+
function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
|
|
532
|
+
if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
|
|
533
|
+
return transaction;
|
|
534
|
+
}
|
|
535
|
+
const out = {
|
|
536
|
+
...getUnsignedTransaction(transaction),
|
|
537
|
+
lifetimeConstraint: blockhashLifetimeConstraint
|
|
538
|
+
};
|
|
539
|
+
Object.freeze(out);
|
|
540
|
+
return out;
|
|
541
|
+
}
|
|
517
542
|
|
|
518
543
|
// src/create-transaction.ts
|
|
519
544
|
function createTransaction({
|
|
@@ -527,62 +552,79 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
527
552
|
return out;
|
|
528
553
|
}
|
|
529
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 isAdvanceNonceAccountInstruction(instruction) {
|
|
587
|
+
return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
|
|
588
|
+
instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
|
|
589
|
+
instruction.accounts?.length === 3 && // First account is nonce account address
|
|
590
|
+
instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
|
|
591
|
+
instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
|
|
592
|
+
instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
|
|
593
|
+
}
|
|
594
|
+
function isAdvanceNonceAccountInstructionData(data) {
|
|
595
|
+
return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
|
|
596
|
+
}
|
|
597
|
+
function isDurableNonceTransaction(transaction) {
|
|
598
|
+
return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
|
|
599
|
+
}
|
|
600
|
+
|
|
530
601
|
// src/fee-payer.ts
|
|
531
602
|
function setTransactionFeePayer(feePayer, transaction) {
|
|
532
603
|
if ("feePayer" in transaction && feePayer === transaction.feePayer) {
|
|
533
604
|
return transaction;
|
|
534
605
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
540
|
-
...unsignedTransaction
|
|
541
|
-
} = transaction;
|
|
542
|
-
out = {
|
|
543
|
-
...unsignedTransaction,
|
|
544
|
-
feePayer
|
|
545
|
-
};
|
|
546
|
-
} else {
|
|
547
|
-
out = {
|
|
548
|
-
...transaction,
|
|
549
|
-
feePayer
|
|
550
|
-
};
|
|
551
|
-
}
|
|
606
|
+
const out = {
|
|
607
|
+
...getUnsignedTransaction(transaction),
|
|
608
|
+
feePayer
|
|
609
|
+
};
|
|
552
610
|
Object.freeze(out);
|
|
553
611
|
return out;
|
|
554
612
|
}
|
|
555
613
|
|
|
556
614
|
// src/instructions.ts
|
|
557
|
-
function replaceInstructions(transaction, nextInstructions) {
|
|
558
|
-
let out;
|
|
559
|
-
if ("signatures" in transaction) {
|
|
560
|
-
const {
|
|
561
|
-
signatures: _,
|
|
562
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
563
|
-
...unsignedTransaction
|
|
564
|
-
} = transaction;
|
|
565
|
-
out = {
|
|
566
|
-
...unsignedTransaction,
|
|
567
|
-
instructions: nextInstructions
|
|
568
|
-
};
|
|
569
|
-
} else {
|
|
570
|
-
out = {
|
|
571
|
-
...transaction,
|
|
572
|
-
instructions: nextInstructions
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
return out;
|
|
576
|
-
}
|
|
577
615
|
function appendTransactionInstruction(instruction, transaction) {
|
|
578
|
-
const
|
|
579
|
-
|
|
616
|
+
const out = {
|
|
617
|
+
...getUnsignedTransaction(transaction),
|
|
618
|
+
instructions: [...transaction.instructions, instruction]
|
|
619
|
+
};
|
|
580
620
|
Object.freeze(out);
|
|
581
621
|
return out;
|
|
582
622
|
}
|
|
583
623
|
function prependTransactionInstruction(instruction, transaction) {
|
|
584
|
-
const
|
|
585
|
-
|
|
624
|
+
const out = {
|
|
625
|
+
...getUnsignedTransaction(transaction),
|
|
626
|
+
instructions: [instruction, ...transaction.instructions]
|
|
627
|
+
};
|
|
586
628
|
Object.freeze(out);
|
|
587
629
|
return out;
|
|
588
630
|
}
|
|
@@ -637,29 +679,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
637
679
|
return new Uint8Array(signedData);
|
|
638
680
|
}
|
|
639
681
|
|
|
640
|
-
// ../instructions/dist/index.browser.js
|
|
641
|
-
var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
|
|
642
|
-
AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
|
|
643
|
-
3] = "WRITABLE_SIGNER";
|
|
644
|
-
AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
|
|
645
|
-
2] = "READONLY_SIGNER";
|
|
646
|
-
AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
|
|
647
|
-
1] = "WRITABLE";
|
|
648
|
-
AccountRole2[AccountRole2["READONLY"] = /* 0 */
|
|
649
|
-
0] = "READONLY";
|
|
650
|
-
return AccountRole2;
|
|
651
|
-
})(AccountRole || {});
|
|
652
|
-
var IS_WRITABLE_BITMASK = 1;
|
|
653
|
-
function isSignerRole(role) {
|
|
654
|
-
return role >= 2;
|
|
655
|
-
}
|
|
656
|
-
function isWritableRole(role) {
|
|
657
|
-
return (role & IS_WRITABLE_BITMASK) !== 0;
|
|
658
|
-
}
|
|
659
|
-
function mergeRoles(roleA, roleB) {
|
|
660
|
-
return roleA | roleB;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
682
|
// src/accounts.ts
|
|
664
683
|
function upsert(addressMap, address, update) {
|
|
665
684
|
addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
|
|
@@ -1252,10 +1271,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
1252
1271
|
|
|
1253
1272
|
exports.appendTransactionInstruction = appendTransactionInstruction;
|
|
1254
1273
|
exports.assertIsBlockhash = assertIsBlockhash;
|
|
1274
|
+
exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
|
|
1255
1275
|
exports.createTransaction = createTransaction;
|
|
1256
1276
|
exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
|
|
1257
1277
|
exports.prependTransactionInstruction = prependTransactionInstruction;
|
|
1258
1278
|
exports.setTransactionFeePayer = setTransactionFeePayer;
|
|
1279
|
+
exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
|
|
1259
1280
|
exports.signTransaction = signTransaction;
|
|
1260
1281
|
|
|
1261
1282
|
return exports;
|