@rialo/ts-cdk 0.2.0-alpha.2 → 0.2.0-alpha.4
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.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -8724,6 +8724,17 @@ function deserializeBorsh(data, type) {
|
|
|
8724
8724
|
var AccountMetaTable = class {
|
|
8725
8725
|
accounts = /* @__PURE__ */ new Map();
|
|
8726
8726
|
accountOrder = [];
|
|
8727
|
+
payerKey = null;
|
|
8728
|
+
/**
|
|
8729
|
+
* Set the fee payer for this transaction.
|
|
8730
|
+
* The fee payer is always pinned at index 0 in the sorted account list,
|
|
8731
|
+
* regardless of lexicographic ordering. This matches Solana's invariant
|
|
8732
|
+
* that account_keys[0] is always the fee payer.
|
|
8733
|
+
*/
|
|
8734
|
+
setFeePayer(pubkey) {
|
|
8735
|
+
this.payerKey = pubkey.toString();
|
|
8736
|
+
this.add({ pubkey, isSigner: true, isWritable: true });
|
|
8737
|
+
}
|
|
8727
8738
|
/**
|
|
8728
8739
|
* Add or update an account in the table.
|
|
8729
8740
|
* If account already exists, merges signer/writable flags (OR operation).
|
|
@@ -8764,7 +8775,16 @@ var AccountMetaTable = class {
|
|
|
8764
8775
|
*/
|
|
8765
8776
|
getSortedAccounts() {
|
|
8766
8777
|
const entries = this.accountOrder.map((key) => this.accounts.get(key));
|
|
8767
|
-
|
|
8778
|
+
let payerEntry = null;
|
|
8779
|
+
const rest = [];
|
|
8780
|
+
for (const entry of entries) {
|
|
8781
|
+
if (this.payerKey !== null && entry.pubkey.toString() === this.payerKey) {
|
|
8782
|
+
payerEntry = entry;
|
|
8783
|
+
} else {
|
|
8784
|
+
rest.push(entry);
|
|
8785
|
+
}
|
|
8786
|
+
}
|
|
8787
|
+
rest.sort((a, b) => {
|
|
8768
8788
|
const aPriority = a.isSigner && a.isWritable ? 0 : a.isSigner ? 1 : a.isWritable ? 2 : 3;
|
|
8769
8789
|
const bPriority = b.isSigner && b.isWritable ? 0 : b.isSigner ? 1 : b.isWritable ? 2 : 3;
|
|
8770
8790
|
if (aPriority !== bPriority) {
|
|
@@ -8779,6 +8799,10 @@ var AccountMetaTable = class {
|
|
|
8779
8799
|
}
|
|
8780
8800
|
return 0;
|
|
8781
8801
|
});
|
|
8802
|
+
if (payerEntry !== null) {
|
|
8803
|
+
return [payerEntry, ...rest];
|
|
8804
|
+
}
|
|
8805
|
+
return rest;
|
|
8782
8806
|
}
|
|
8783
8807
|
/**
|
|
8784
8808
|
* Get the message header based on sorted accounts.
|
|
@@ -9571,11 +9595,7 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9571
9595
|
throw TransactionError.noInstructions();
|
|
9572
9596
|
}
|
|
9573
9597
|
const accountTable = new AccountMetaTable();
|
|
9574
|
-
accountTable.
|
|
9575
|
-
pubkey: this.payer,
|
|
9576
|
-
isSigner: true,
|
|
9577
|
-
isWritable: true
|
|
9578
|
-
});
|
|
9598
|
+
accountTable.setFeePayer(this.payer);
|
|
9579
9599
|
for (const instruction of this.instructions) {
|
|
9580
9600
|
accountTable.addAll(instruction.accounts);
|
|
9581
9601
|
accountTable.add({
|