@unclaimedsol/spl-burn-close-sdk 1.0.3 → 1.1.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 +12 -13
- package/dist/index.d.ts +8 -9
- package/dist/index.js +12 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,32 +4,31 @@ const PROGRAM_ID = new PublicKey("UNCaXzXkR3vp8mbCJyxWUvwuRk5uHgzrwe6jcWPfiUR");
|
|
|
4
4
|
/** Hardcoded fee recipient on-chain expectation */
|
|
5
5
|
const FEE_RECIPIENT = new PublicKey("uncNCRycMtNPj2kXHfwiCgNrzCTnC9xU5FS8ZeWyn3M");
|
|
6
6
|
const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
7
|
-
/** Fixed fee percentage enforced by the program (5%) */
|
|
8
|
-
const FIXED_FEE_PERCENTAGE = 5; // do not change
|
|
9
7
|
/**
|
|
10
8
|
* Build *unsigned* transactions that call the on-chain burn+close program.
|
|
11
9
|
* You sign and send them yourself (frontend wallet or backend keypair).
|
|
12
10
|
*
|
|
13
|
-
* @param connection
|
|
14
|
-
* @param programId
|
|
15
|
-
* @param user
|
|
16
|
-
* @param pairs
|
|
17
|
-
* @param options
|
|
18
|
-
* @
|
|
11
|
+
* @param connection Solana RPC connection
|
|
12
|
+
* @param programId Your deployed program ID
|
|
13
|
+
* @param user The user whose ATAs will be burned/closed
|
|
14
|
+
* @param pairs Array of { mint, ata } to process
|
|
15
|
+
* @param options Chunking / blockhash / payer tweaks
|
|
16
|
+
* @param tokenProgramId Support for multiple Token programs
|
|
17
|
+
* @returns Array of *unsigned* Transaction objects
|
|
19
18
|
*/
|
|
20
|
-
export async function buildBurnAndCloseTransactions(connection, programId, user, pairs, options = {}) {
|
|
19
|
+
export async function buildBurnAndCloseTransactions(connection, programId, user, pairs, options = {}, tokenProgramId = TOKEN_PROGRAM_ID) {
|
|
21
20
|
if (!pairs.length)
|
|
22
21
|
return [];
|
|
23
22
|
const chunkSize = Math.max(1, options.chunkSize ?? 12);
|
|
24
|
-
const commitment = options.commitment ?? "
|
|
23
|
+
const commitment = options.commitment ?? "processed";
|
|
25
24
|
const feePayer = options.feePayer ?? user;
|
|
26
25
|
// Split into chunks so we stay under CU / account limits
|
|
27
26
|
const chunks = [];
|
|
28
27
|
for (let i = 0; i < pairs.length; i += chunkSize) {
|
|
29
28
|
chunks.push(pairs.slice(i, i + chunkSize));
|
|
30
29
|
}
|
|
31
|
-
// Instruction data: [selector=0
|
|
32
|
-
const data = Buffer.from([0
|
|
30
|
+
// Instruction data: [selector=0]
|
|
31
|
+
const data = Buffer.from([0]);
|
|
33
32
|
const txs = [];
|
|
34
33
|
for (const chunk of chunks) {
|
|
35
34
|
const keys = [
|
|
@@ -37,7 +36,7 @@ export async function buildBurnAndCloseTransactions(connection, programId, user,
|
|
|
37
36
|
// the caller must actually sign the Transaction later.
|
|
38
37
|
{ pubkey: FEE_RECIPIENT, isSigner: false, isWritable: true },
|
|
39
38
|
{ pubkey: user, isSigner: true, isWritable: true },
|
|
40
|
-
{ pubkey:
|
|
39
|
+
{ pubkey: tokenProgramId, isSigner: false, isWritable: false },
|
|
41
40
|
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
42
41
|
];
|
|
43
42
|
for (const { mint, ata } of chunk) {
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export declare const PROGRAM_ID: PublicKey;
|
|
|
4
4
|
/** Hardcoded fee recipient on-chain expectation */
|
|
5
5
|
export declare const FEE_RECIPIENT: PublicKey;
|
|
6
6
|
export declare const TOKEN_PROGRAM_ID: PublicKey;
|
|
7
|
-
/** Fixed fee percentage enforced by the program (5%) */
|
|
8
|
-
export declare const FIXED_FEE_PERCENTAGE = 5;
|
|
9
7
|
export type Pair = {
|
|
10
8
|
mint: PublicKey;
|
|
11
9
|
ata: PublicKey;
|
|
@@ -30,11 +28,12 @@ export type BuildOptions = {
|
|
|
30
28
|
* Build *unsigned* transactions that call the on-chain burn+close program.
|
|
31
29
|
* You sign and send them yourself (frontend wallet or backend keypair).
|
|
32
30
|
*
|
|
33
|
-
* @param connection
|
|
34
|
-
* @param programId
|
|
35
|
-
* @param user
|
|
36
|
-
* @param pairs
|
|
37
|
-
* @param options
|
|
38
|
-
* @
|
|
31
|
+
* @param connection Solana RPC connection
|
|
32
|
+
* @param programId Your deployed program ID
|
|
33
|
+
* @param user The user whose ATAs will be burned/closed
|
|
34
|
+
* @param pairs Array of { mint, ata } to process
|
|
35
|
+
* @param options Chunking / blockhash / payer tweaks
|
|
36
|
+
* @param tokenProgramId Support for multiple Token programs
|
|
37
|
+
* @returns Array of *unsigned* Transaction objects
|
|
39
38
|
*/
|
|
40
|
-
export declare function buildBurnAndCloseTransactions(connection: Connection, programId: PublicKey, user: PublicKey, pairs: Pair[], options?: BuildOptions): Promise<Transaction[]>;
|
|
39
|
+
export declare function buildBurnAndCloseTransactions(connection: Connection, programId: PublicKey, user: PublicKey, pairs: Pair[], options?: BuildOptions, tokenProgramId?: PublicKey): Promise<Transaction[]>;
|
package/dist/index.js
CHANGED
|
@@ -4,32 +4,31 @@ export const PROGRAM_ID = new PublicKey("UNCaXzXkR3vp8mbCJyxWUvwuRk5uHgzrwe6jcWP
|
|
|
4
4
|
/** Hardcoded fee recipient on-chain expectation */
|
|
5
5
|
export const FEE_RECIPIENT = new PublicKey("uncNCRycMtNPj2kXHfwiCgNrzCTnC9xU5FS8ZeWyn3M");
|
|
6
6
|
export const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
7
|
-
/** Fixed fee percentage enforced by the program (5%) */
|
|
8
|
-
export const FIXED_FEE_PERCENTAGE = 5; // do not change
|
|
9
7
|
/**
|
|
10
8
|
* Build *unsigned* transactions that call the on-chain burn+close program.
|
|
11
9
|
* You sign and send them yourself (frontend wallet or backend keypair).
|
|
12
10
|
*
|
|
13
|
-
* @param connection
|
|
14
|
-
* @param programId
|
|
15
|
-
* @param user
|
|
16
|
-
* @param pairs
|
|
17
|
-
* @param options
|
|
18
|
-
* @
|
|
11
|
+
* @param connection Solana RPC connection
|
|
12
|
+
* @param programId Your deployed program ID
|
|
13
|
+
* @param user The user whose ATAs will be burned/closed
|
|
14
|
+
* @param pairs Array of { mint, ata } to process
|
|
15
|
+
* @param options Chunking / blockhash / payer tweaks
|
|
16
|
+
* @param tokenProgramId Support for multiple Token programs
|
|
17
|
+
* @returns Array of *unsigned* Transaction objects
|
|
19
18
|
*/
|
|
20
|
-
export async function buildBurnAndCloseTransactions(connection, programId, user, pairs, options = {}) {
|
|
19
|
+
export async function buildBurnAndCloseTransactions(connection, programId, user, pairs, options = {}, tokenProgramId = TOKEN_PROGRAM_ID) {
|
|
21
20
|
if (!pairs.length)
|
|
22
21
|
return [];
|
|
23
22
|
const chunkSize = Math.max(1, options.chunkSize ?? 12);
|
|
24
|
-
const commitment = options.commitment ?? "
|
|
23
|
+
const commitment = options.commitment ?? "processed";
|
|
25
24
|
const feePayer = options.feePayer ?? user;
|
|
26
25
|
// Split into chunks so we stay under CU / account limits
|
|
27
26
|
const chunks = [];
|
|
28
27
|
for (let i = 0; i < pairs.length; i += chunkSize) {
|
|
29
28
|
chunks.push(pairs.slice(i, i + chunkSize));
|
|
30
29
|
}
|
|
31
|
-
// Instruction data: [selector=0
|
|
32
|
-
const data = Buffer.from([0
|
|
30
|
+
// Instruction data: [selector=0]
|
|
31
|
+
const data = Buffer.from([0]);
|
|
33
32
|
const txs = [];
|
|
34
33
|
for (const chunk of chunks) {
|
|
35
34
|
const keys = [
|
|
@@ -37,7 +36,7 @@ export async function buildBurnAndCloseTransactions(connection, programId, user,
|
|
|
37
36
|
// the caller must actually sign the Transaction later.
|
|
38
37
|
{ pubkey: FEE_RECIPIENT, isSigner: false, isWritable: true },
|
|
39
38
|
{ pubkey: user, isSigner: true, isWritable: true },
|
|
40
|
-
{ pubkey:
|
|
39
|
+
{ pubkey: tokenProgramId, isSigner: false, isWritable: false },
|
|
41
40
|
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
|
|
42
41
|
];
|
|
43
42
|
for (const { mint, ata } of chunk) {
|
package/package.json
CHANGED