solana-token-extension-boost
Version:
SDK for Solana Token Extensions with wallet adapter support
121 lines (120 loc) • 4.79 kB
TypeScript
import { Connection, PublicKey, TransactionInstruction, Transaction, Signer } from "@solana/web3.js";
import { Account } from "@solana/spl-token";
import { Token } from "../../core/token";
export declare class CloseAccountExtension extends Token {
constructor(connection: Connection, mint: PublicKey, decimals?: number);
/**
* Find token accounts with zero balance for an address
*
* @param owner - Address of the token accounts owner
* @param excludeTokens - List of token mints to exclude (optional)
* @returns List of token accounts with zero balance
*/
findZeroBalanceAccounts(owner: PublicKey, excludeTokens?: PublicKey[]): Promise<{
address: PublicKey;
mint: PublicKey;
}[]>;
/**
* Create instruction to close a token account
*
* @param account - Address of the token account to close
* @param owner - Address of the account owner
* @param destination - Address to receive SOL from closing the account (defaults to owner)
* @returns Transaction instruction to close the account
*/
createCloseAccountInstruction(account: PublicKey, owner: PublicKey, destination?: PublicKey): TransactionInstruction;
/**
* Create instructions to close multiple token accounts at once
*
* @param accounts - List of addresses of token accounts to close
* @param owner - Address of the account owner
* @param destination - Address to receive SOL from closing the account (defaults to owner)
* @param adminFeeReceiver - Admin fee receiver address (if applicable)
* @param adminFeeBasisPoints - Admin fee in basis points (1% = 100)
* @returns List of transaction instructions to close accounts
*/
createBulkCloseAccountInstructions(accounts: PublicKey[], owner: PublicKey, options?: {
destination?: PublicKey;
adminFeeReceiver?: PublicKey;
adminFeeBasisPoints?: number;
}): TransactionInstruction[];
/**
* Verify if a token account can be closed (zero balance)
*
* @param account - Address of the token account to check
* @returns Result of checking if account can be closed
*/
canCloseAccount(account: PublicKey): Promise<{
closeable: boolean;
account: Account | null;
reason?: string;
}>;
/**
* Get estimated SOL to be reclaimed when closing accounts
*
* @param accounts - List of token accounts to close
* @param adminFeeBasisPoints - Admin fee in basis points (1% = 100)
* @returns Estimated SOL to be reclaimed (in lamports)
*/
estimateReclaimableRent(accounts: PublicKey[], adminFeeBasisPoints?: number): Promise<{
totalRent: number;
userRent: number;
adminRent: number;
accountsInfo: {
address: PublicKey;
lamports: number;
closeable: boolean;
reason?: string;
}[];
}>;
/**
* Close token accounts and reclaim SOL
*
* @param owner - Signer who owns the accounts
* @param accounts - List of token accounts to close
* @param options - Additional options
* @returns Information about the transaction
*/
closeAccounts(owner: Signer, accounts: PublicKey[], options?: {
destination?: PublicKey;
adminFeeReceiver?: PublicKey;
adminFeeBasisPoints?: number;
}): Promise<{
signature: string;
closedAccounts: PublicKey[];
totalRentReclaimed: number;
}>;
/**
* Prepare transaction to close accounts (supports wallet-adapter)
*
* @param accounts - List of addresses of token accounts to close
* @param owner - Address of the account owner
* @param options - Additional options
* @returns Transaction prepared for signing and sending through wallet-adapter
*/
prepareCloseAccountsTransaction(accounts: PublicKey[], owner: PublicKey, options?: {
destination?: PublicKey;
adminFeeReceiver?: PublicKey;
adminFeeBasisPoints?: number;
}): Promise<{
transaction: Transaction;
closeableAccounts: PublicKey[];
estimatedRent: {
totalRent: number;
userRent: number;
adminRent: number;
};
}>;
/**
* Create instructions to burn tokens
*
* @param account - Address of the token account to burn from
* @param owner - Address of the account owner
* @param amount - Amount of tokens to burn
* @param decimals - Decimals of the token
* @returns Object containing transaction instructions to burn tokens
*/
createBurnInstructions(account: PublicKey, owner: PublicKey, amount: bigint, decimals: number): {
instructions: TransactionInstruction[];
};
}