UNPKG

solana-token-extension-boost

Version:

SDK for Solana Token Extensions with wallet adapter support

85 lines (84 loc) 2.77 kB
import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js"; import { AccountState } from "@solana/spl-token"; /** * TokenAccountBuilder - Helper class for creating token accounts with extensions * * ImmutableOwner and other extensions for token accounts */ export declare class TokenAccountBuilder { private connection; private extensions; private mint?; private owner?; private defaultAccountState?; /** * Initialize builder with connection * * @param connection - Connection to Solana cluster */ constructor(connection: Connection); /** * Set basic information for token account * * @param mint - Mint address of the token * @param owner - Owner of the token account */ setTokenAccountInfo(mint: PublicKey, owner: PublicKey): TokenAccountBuilder; /** * Add ImmutableOwner extension * ImmutableOwner prevents changing the owner of the token account */ addImmutableOwner(): TokenAccountBuilder; /** * Add DefaultAccountState extension * * @param state - Default state of the account (frozen or unlocked) */ addDefaultAccountState(state: AccountState): TokenAccountBuilder; /** * Create instructions for standard (non-associated) token account * * @param payer - Public key of the transaction fee payer * @returns Instructions, signers and token account address */ buildStandardAccountInstructions(payer: PublicKey): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; tokenAccount: PublicKey; }>; /** * Create standard (non-associated) token account * * @param payer - Transaction fee payer * @returns Information about the created token account */ buildStandardAccount(payer: Keypair): Promise<{ tokenAccount: PublicKey; tokenAccountKeypair: Keypair; transactionSignature: string; }>; /** * Create instructions for Associated Token Account with extensions * * Note: Not all extensions work with ATA * * @param payer - Public key of the transaction fee payer * @returns Instructions and token account address */ buildAssociatedAccountInstructions(payer: PublicKey): { instructions: TransactionInstruction[]; tokenAccount: PublicKey; }; /** * Create Associated Token Account with extensions * * Note: Not all extensions work with ATA * * @param payer - Transaction fee payer * @returns Information about the created token account */ buildAssociatedAccount(payer: Keypair): Promise<{ tokenAccount: PublicKey; transactionSignature: string; }>; }