@unclaimedsol/spl-burn-close-sdk 1.1.0 → 1.2.0

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.cjs CHANGED
@@ -61,3 +61,38 @@ export async function buildBurnAndCloseTransactions(connection, programId, user,
61
61
  }
62
62
  return txs;
63
63
  }
64
+ /**
65
+ * Build a single **TransactionInstruction** that calls the on-chain
66
+ * burn+close program for a specific Token Program (either SPL Token or Token-2022).
67
+ *
68
+ * Unlike `buildBurnAndCloseTransactions`, this helper does **not**
69
+ * create or sign full transactions — it only constructs one
70
+ * instruction for a batch of (mint, ATA) pairs.
71
+ */
72
+ export async function buildBurnAndCloseInstruction(programId, user, pairs, tokenProgramId) {
73
+ if (!pairs.length) {
74
+ return null;
75
+ }
76
+ // instruction data selector: 0 = burn_and_close_token_accounts
77
+ const data = Buffer.from([0]);
78
+ // accounts order MUST match the on-chain program's expectation:
79
+ // [0] fee_payer_account (your fee recipient)
80
+ // [1] user_wallet_account (the signer)
81
+ // [2] token_program_account (SPL Token program or Token-2022 program)
82
+ // [3] system_program_account
83
+ // then repeating (mint, ata) pairs, both writable
84
+ const keys = [
85
+ { pubkey: FEE_RECIPIENT, isSigner: false, isWritable: true },
86
+ { pubkey: user, isSigner: true, isWritable: true },
87
+ { pubkey: tokenProgramId, isSigner: false, isWritable: false },
88
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
89
+ ];
90
+ for (const { mint, ata } of pairs) {
91
+ keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: ata, isSigner: false, isWritable: true });
92
+ }
93
+ return new TransactionInstruction({
94
+ programId,
95
+ keys,
96
+ data,
97
+ });
98
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Connection, PublicKey, Transaction, Commitment } from "@solana/web3.js";
1
+ import { Connection, PublicKey, Transaction, TransactionInstruction, Commitment } from "@solana/web3.js";
2
2
  /** Exporting on-chain program ID for convenience */
3
3
  export declare const PROGRAM_ID: PublicKey;
4
4
  /** Hardcoded fee recipient on-chain expectation */
@@ -37,3 +37,12 @@ export type BuildOptions = {
37
37
  * @returns Array of *unsigned* Transaction objects
38
38
  */
39
39
  export declare function buildBurnAndCloseTransactions(connection: Connection, programId: PublicKey, user: PublicKey, pairs: Pair[], options?: BuildOptions, tokenProgramId?: PublicKey): Promise<Transaction[]>;
40
+ /**
41
+ * Build a single **TransactionInstruction** that calls the on-chain
42
+ * burn+close program for a specific Token Program (either SPL Token or Token-2022).
43
+ *
44
+ * Unlike `buildBurnAndCloseTransactions`, this helper does **not**
45
+ * create or sign full transactions — it only constructs one
46
+ * instruction for a batch of (mint, ATA) pairs.
47
+ */
48
+ export declare function buildBurnAndCloseInstruction(programId: PublicKey, user: PublicKey, pairs: Pair[], tokenProgramId: PublicKey): Promise<TransactionInstruction | null>;
package/dist/index.js CHANGED
@@ -61,3 +61,38 @@ export async function buildBurnAndCloseTransactions(connection, programId, user,
61
61
  }
62
62
  return txs;
63
63
  }
64
+ /**
65
+ * Build a single **TransactionInstruction** that calls the on-chain
66
+ * burn+close program for a specific Token Program (either SPL Token or Token-2022).
67
+ *
68
+ * Unlike `buildBurnAndCloseTransactions`, this helper does **not**
69
+ * create or sign full transactions — it only constructs one
70
+ * instruction for a batch of (mint, ATA) pairs.
71
+ */
72
+ export async function buildBurnAndCloseInstruction(programId, user, pairs, tokenProgramId) {
73
+ if (!pairs.length) {
74
+ return null;
75
+ }
76
+ // instruction data selector: 0 = burn_and_close_token_accounts
77
+ const data = Buffer.from([0]);
78
+ // accounts order MUST match the on-chain program's expectation:
79
+ // [0] fee_payer_account (your fee recipient)
80
+ // [1] user_wallet_account (the signer)
81
+ // [2] token_program_account (SPL Token program or Token-2022 program)
82
+ // [3] system_program_account
83
+ // then repeating (mint, ata) pairs, both writable
84
+ const keys = [
85
+ { pubkey: FEE_RECIPIENT, isSigner: false, isWritable: true },
86
+ { pubkey: user, isSigner: true, isWritable: true },
87
+ { pubkey: tokenProgramId, isSigner: false, isWritable: false },
88
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
89
+ ];
90
+ for (const { mint, ata } of pairs) {
91
+ keys.push({ pubkey: mint, isSigner: false, isWritable: true }, { pubkey: ata, isSigner: false, isWritable: true });
92
+ }
93
+ return new TransactionInstruction({
94
+ programId,
95
+ keys,
96
+ data,
97
+ });
98
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unclaimedsol/spl-burn-close-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "SDK to burn and close SPL token accounts via the Unclaimed SOL program (with a built-in 5% fee).",
5
5
  "license": "MIT",
6
6
  "author": "Unclaimed SOL",