@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.d.mts
CHANGED
|
@@ -2333,6 +2333,14 @@ interface AccountEntry {
|
|
|
2333
2333
|
declare class AccountMetaTable {
|
|
2334
2334
|
private readonly accounts;
|
|
2335
2335
|
private readonly accountOrder;
|
|
2336
|
+
private payerKey;
|
|
2337
|
+
/**
|
|
2338
|
+
* Set the fee payer for this transaction.
|
|
2339
|
+
* The fee payer is always pinned at index 0 in the sorted account list,
|
|
2340
|
+
* regardless of lexicographic ordering. This matches Solana's invariant
|
|
2341
|
+
* that account_keys[0] is always the fee payer.
|
|
2342
|
+
*/
|
|
2343
|
+
setFeePayer(pubkey: PublicKey): void;
|
|
2336
2344
|
/**
|
|
2337
2345
|
* Add or update an account in the table.
|
|
2338
2346
|
* If account already exists, merges signer/writable flags (OR operation).
|
package/dist/index.d.ts
CHANGED
|
@@ -2333,6 +2333,14 @@ interface AccountEntry {
|
|
|
2333
2333
|
declare class AccountMetaTable {
|
|
2334
2334
|
private readonly accounts;
|
|
2335
2335
|
private readonly accountOrder;
|
|
2336
|
+
private payerKey;
|
|
2337
|
+
/**
|
|
2338
|
+
* Set the fee payer for this transaction.
|
|
2339
|
+
* The fee payer is always pinned at index 0 in the sorted account list,
|
|
2340
|
+
* regardless of lexicographic ordering. This matches Solana's invariant
|
|
2341
|
+
* that account_keys[0] is always the fee payer.
|
|
2342
|
+
*/
|
|
2343
|
+
setFeePayer(pubkey: PublicKey): void;
|
|
2336
2344
|
/**
|
|
2337
2345
|
* Add or update an account in the table.
|
|
2338
2346
|
* If account already exists, merges signer/writable flags (OR operation).
|
package/dist/index.js
CHANGED
|
@@ -8726,6 +8726,17 @@ function deserializeBorsh(data, type) {
|
|
|
8726
8726
|
var AccountMetaTable = class {
|
|
8727
8727
|
accounts = /* @__PURE__ */ new Map();
|
|
8728
8728
|
accountOrder = [];
|
|
8729
|
+
payerKey = null;
|
|
8730
|
+
/**
|
|
8731
|
+
* Set the fee payer for this transaction.
|
|
8732
|
+
* The fee payer is always pinned at index 0 in the sorted account list,
|
|
8733
|
+
* regardless of lexicographic ordering. This matches Solana's invariant
|
|
8734
|
+
* that account_keys[0] is always the fee payer.
|
|
8735
|
+
*/
|
|
8736
|
+
setFeePayer(pubkey) {
|
|
8737
|
+
this.payerKey = pubkey.toString();
|
|
8738
|
+
this.add({ pubkey, isSigner: true, isWritable: true });
|
|
8739
|
+
}
|
|
8729
8740
|
/**
|
|
8730
8741
|
* Add or update an account in the table.
|
|
8731
8742
|
* If account already exists, merges signer/writable flags (OR operation).
|
|
@@ -8766,7 +8777,16 @@ var AccountMetaTable = class {
|
|
|
8766
8777
|
*/
|
|
8767
8778
|
getSortedAccounts() {
|
|
8768
8779
|
const entries = this.accountOrder.map((key) => this.accounts.get(key));
|
|
8769
|
-
|
|
8780
|
+
let payerEntry = null;
|
|
8781
|
+
const rest = [];
|
|
8782
|
+
for (const entry of entries) {
|
|
8783
|
+
if (this.payerKey !== null && entry.pubkey.toString() === this.payerKey) {
|
|
8784
|
+
payerEntry = entry;
|
|
8785
|
+
} else {
|
|
8786
|
+
rest.push(entry);
|
|
8787
|
+
}
|
|
8788
|
+
}
|
|
8789
|
+
rest.sort((a, b) => {
|
|
8770
8790
|
const aPriority = a.isSigner && a.isWritable ? 0 : a.isSigner ? 1 : a.isWritable ? 2 : 3;
|
|
8771
8791
|
const bPriority = b.isSigner && b.isWritable ? 0 : b.isSigner ? 1 : b.isWritable ? 2 : 3;
|
|
8772
8792
|
if (aPriority !== bPriority) {
|
|
@@ -8781,6 +8801,10 @@ var AccountMetaTable = class {
|
|
|
8781
8801
|
}
|
|
8782
8802
|
return 0;
|
|
8783
8803
|
});
|
|
8804
|
+
if (payerEntry !== null) {
|
|
8805
|
+
return [payerEntry, ...rest];
|
|
8806
|
+
}
|
|
8807
|
+
return rest;
|
|
8784
8808
|
}
|
|
8785
8809
|
/**
|
|
8786
8810
|
* Get the message header based on sorted accounts.
|
|
@@ -9573,11 +9597,7 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9573
9597
|
throw TransactionError.noInstructions();
|
|
9574
9598
|
}
|
|
9575
9599
|
const accountTable = new AccountMetaTable();
|
|
9576
|
-
accountTable.
|
|
9577
|
-
pubkey: this.payer,
|
|
9578
|
-
isSigner: true,
|
|
9579
|
-
isWritable: true
|
|
9580
|
-
});
|
|
9600
|
+
accountTable.setFeePayer(this.payer);
|
|
9581
9601
|
for (const instruction of this.instructions) {
|
|
9582
9602
|
accountTable.addAll(instruction.accounts);
|
|
9583
9603
|
accountTable.add({
|