UNPKG

solana-token-extension-boost

Version:

SDK for Solana Token Extensions with wallet adapter support

110 lines (109 loc) 3.7 kB
import { ExtensionType } from '@solana/spl-token'; import { Keypair, PublicKey, Connection, TransactionInstruction } from '@solana/web3.js'; /** * Helper class for better handling of metadata when combined with other extensions */ export declare class MetadataHelper { /** * Calculate the size needed for metadata * * @param metadata - Metadata information * @returns Estimated size (bytes) */ static calculateMetadataSize(metadata: { name: string; symbol: string; uri: string; additionalMetadata?: Record<string, string>; }): number; /** * Calculate the size needed for mint account with extensions and metadata * * @param extensionTypes - Types of extensions to add * @param metadata - Metadata information (if any) * @returns Total required size (bytes) */ static calculateMintSize(extensionTypes: ExtensionType[], metadata?: { name: string; symbol: string; uri: string; additionalMetadata?: Record<string, string>; }): number; /** * Create token with integrated metadata in a simple way * This function follows the correct initialization order to ensure proper operation * * @param connection - Solana connection * @param payer - Fee payer * @param params - Initialization parameters * @returns Information about the created token */ static createTokenWithMetadata(connection: Connection, payer: Keypair, params: { decimals: number; mintAuthority: PublicKey; name: string; symbol: string; uri: string; additionalMetadata?: Record<string, string>; extensions?: ExtensionType[]; }): Promise<{ mint: PublicKey; txId: string; }>; /** * Check if extensions are compatible with each other * * @param extensionTypes - Array of extension types to check * @returns Compatibility check result */ static checkExtensionCompatibility(extensionTypes: ExtensionType[]): { isCompatible: boolean; incompatiblePairs?: [ExtensionType, ExtensionType][]; reason?: string; }; /** * Create metadata address based on mint * * @param mint - Mint address * @returns Metadata address */ static findMetadataAddress(mint: PublicKey): PublicKey; /** * Create the sequence of steps to initialize metadata correctly * * @param mint - Mint address * @param updateAuthority - Address with authority to update metadata * @param metadata - Metadata information * @returns Sequence of steps */ static getMetadataInstructions(mint: PublicKey, updateAuthority: PublicKey, metadata: { name: string; symbol: string; uri: string; additionalMetadata?: Record<string, string>; }): { metadataAddress: PublicKey; setupOrder: string[]; }; /** * Create instructions for initializing tokens with metadata * * @param connection - Solana connection * @param payer - Public key of the fee payer * @param params - Initialization parameters * @returns Instructions, signers, and mint address */ static createTokenWithMetadataInstructions(connection: Connection, payer: PublicKey, params: { decimals: number; mintAuthority: PublicKey; name: string; symbol: string; uri: string; additionalMetadata?: Record<string, string>; extensions?: ExtensionType[]; }): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; mint: PublicKey; }>; }