@lightprotocol/compressed-token 0.22.1-alpha.2 → 0.22.1-alpha.4

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.
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("@lightprotocol/stateless.js"),t=require("@solana/spl-token"),o=require("../types-CJcjpvYl.cjs"),r=require("@solana/web3.js");function n(t,n,s,a,c,p,i=s){const u={withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[o.createCompressCtoken(c,0,2,1,6),o.createDecompressSpl(c,0,3,4,p.poolIndex,p.bump)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null},I=o.encodeTransfer2InstructionData(u),d=[{pubkey:o.CompressedTokenProgram.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:i,isSigner:1,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:s,isSigner:1,isWritable:0},{pubkey:t,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:p.splInterfacePda,isSigner:0,isWritable:1},{pubkey:p.tokenProgram,isSigner:0,isWritable:0},{pubkey:e.CTOKEN_PROGRAM_ID,isSigner:0,isWritable:0}];return new r.TransactionInstruction({programId:o.CompressedTokenProgram.programId,keys:d,data:I})}require("@coral-xyz/borsh"),Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return t.AccountState}}),exports.ADD_TOKEN_POOL_DISCRIMINATOR=o.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=o.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return o.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=o.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESSED_MINT_SEED=o.COMPRESSED_MINT_SEED,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=o.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=o.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=o.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=o.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=o.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=o.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=o.CompressedTokenProgram,exports.CpiContextLayout=o.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=o.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=o.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=o.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return o.ExtensionType}}),exports.IDL=o.IDL,exports.MINT_TO_DISCRIMINATOR=o.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=o.POOL_SEED,exports.REVOKE_DISCRIMINATOR=o.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=o.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=o.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return o.TokenDataVersion}}),exports.addSplInterfaces=o.addSplInterfaces,exports.addTokenPoolAccountsLayout=o.addTokenPoolAccountsLayout,exports.addTokenPools=o.addTokenPools,exports.approve=o.approve,exports.approveAccountsLayout=o.approveAccountsLayout,exports.approveAndMintTo=o.approveAndMintTo,exports.batchCompressLayout=o.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=o.calculateCompressibleLoadComputeUnits,exports.checkMint=o.checkMint,exports.checkSplInterfaceInfo=o.checkSplInterfaceInfo,exports.checkTokenPoolInfo=o.checkTokenPoolInfo,exports.compress=o.compress,exports.compressSplTokenAccount=o.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=o.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=o.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=o.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=o.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=o.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=o.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=o.createAtaInterface,exports.createAtaInterfaceIdempotent=o.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=o.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=o.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=o.createDecompressInterfaceInstruction,exports.createDecompressOutputState=o.createDecompressOutputState,exports.createLoadAccountsParams=o.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=o.createLoadAtaInstructionsFromInterface,exports.createMint=o.createMint,exports.createMintInstruction=o.createMintInstruction,exports.createMintInterface=o.createMintInterface,exports.createMintToCompressedInstruction=o.createMintToCompressedInstruction,exports.createMintToInstruction=o.createMintToInstruction,exports.createMintToInterfaceInstruction=o.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=o.createRemoveMetadataKeyInstruction,exports.createSplInterface=o.createSplInterface,exports.createTokenMetadata=o.createTokenMetadata,exports.createTokenPool=o.createTokenPool,exports.createTokenPoolAccountsLayout=o.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=o.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=o.createTransferInterfaceInstruction,exports.createTransferOutputState=o.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=o.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=o.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=o.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=o.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=o.createWrapInstruction,exports.decodeApproveInstructionData=o.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=o.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=o.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=o.decodeMintToInstructionData,exports.decodeRevokeInstructionData=o.decodeRevokeInstructionData,exports.decodeTokenMetadata=o.decodeTokenMetadata,exports.decodeTransferInstructionData=o.decodeTransferInstructionData,exports.decompress=o.decompress,exports.decompressDelegated=o.decompressDelegated,exports.decompressInterface=o.decompressInterface,exports.deriveCMintAddress=o.deriveCMintAddress,exports.deriveSplInterfaceInfo=o.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=o.deriveTokenPoolInfo,exports.deserializeMint=o.deserializeMint,exports.encodeApproveInstructionData=o.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=o.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=o.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=o.encodeMintToInstructionData,exports.encodeRevokeInstructionData=o.encodeRevokeInstructionData,exports.encodeTokenMetadata=o.encodeTokenMetadata,exports.encodeTransferInstructionData=o.encodeTransferInstructionData,exports.extractTokenMetadata=o.extractTokenMetadata,exports.findMintAddress=o.findMintAddress,exports.freezeAccountsLayout=o.freezeAccountsLayout,exports.getAccountInterface=o.getAccountInterface,exports.getAssociatedCTokenAddress=o.getAssociatedCTokenAddress,exports.getAssociatedCTokenAddressAndBump=o.getAssociatedCTokenAddressAndBump,exports.getMintInterface=o.getMintInterface,exports.getSplInterfaceInfos=o.getSplInterfaceInfos,exports.getTokenPoolInfos=o.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=o.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=o.isSingleTokenPoolInfo,exports.mergeTokenAccounts=o.mergeTokenAccounts,exports.mintTo=o.mintTo$1,exports.mintToAccountsLayout=o.mintToAccountsLayout,exports.mintToCToken=o.mintTo,exports.mintToCompressed=o.mintToCompressed,exports.mintToInterface=o.mintToInterface,exports.mintToLayout=o.mintToLayout,exports.packCompressedTokenAccounts=o.packCompressedTokenAccounts,exports.parseCTokenCold=o.parseCTokenCold,exports.parseCTokenHot=o.parseCTokenHot,exports.parseMaybeDelegatedTransfer=o.parseMaybeDelegatedTransfer,exports.parseTokenData=o.parseTokenData,exports.removeMetadataKey=o.removeMetadataKey,exports.revoke=o.revoke,exports.revokeAccountsLayout=o.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=o.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=o.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=o.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=o.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=o.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=o.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=o.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=o.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=o.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=o.selectTokenPoolInfosForDecompression,exports.serializeMint=o.serializeMint,exports.sumUpTokenAmount=o.sumUpTokenAmount,exports.thawAccountsLayout=o.thawAccountsLayout,exports.toAccountInfo=o.toAccountInfo,exports.toOffChainMetadataJson=o.toOffChainMetadataJson,exports.toTokenPoolInfo=o.toTokenPoolInfo,exports.transfer=o.transfer,exports.transferAccountsLayout=o.transferAccountsLayout,exports.transferDelegated=o.transferDelegated,exports.unpackMintData=o.unpackMintData,exports.unpackMintInterface=o.unpackMintInterface,exports.updateFreezeAuthority=o.updateFreezeAuthority,exports.updateMetadataAuthority=o.updateMetadataAuthority,exports.updateMetadataField=o.updateMetadataField,exports.updateMintAuthority=o.updateMintAuthority,exports.validateSameTokenOwner=o.validateSameTokenOwner,exports.wrap=o.wrap,exports.createLoadAtaInstructions=async function(e,t,r,n,s,a){return o.createLoadAtaInstructions(e,t,r,n,s,a,1)},exports.createUnwrapInstruction=n,exports.getAssociatedTokenAddressInterface=function(t,r,n=0,s=e.CTOKEN_PROGRAM_ID,a){if(!s.equals(e.CTOKEN_PROGRAM_ID))throw new Error("Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.");return o.getAssociatedTokenAddressInterface(t,r,n,s,a)},exports.getAtaInterface=async function(e,t,r,n,s,a){return o.getAtaInterface(e,t,r,n,s,a,1)},exports.getOrCreateAtaInterface=async function(t,r,n,s,a=0,c,p){return o._getOrCreateAtaInterface(t,r,n,s,a,c,p,e.CTOKEN_PROGRAM_ID,o.getAtaProgramId(e.CTOKEN_PROGRAM_ID),1)},exports.loadAta=async function(e,r,n,s,a,c,p){const i=await o.loadAta(e,r,n,s,a,c,p,1);if(null===i&&!await e.getAccountInfo(r))throw new t.TokenAccountNotFoundError;return i},exports.transferInterface=async function(t,r,n,s,a,c,p,i=e.CTOKEN_PROGRAM_ID,u,I){return o.transferInterface(t,r,n,s,a,c,p,i,u,I,1)},exports.unwrap=async function(t,s,a,c,p,i,u,I){let d=u;if(!d&&(d=(await o.getSplInterfaceInfos(t,p)).find((e=>e.isInitialized)),!d))throw new Error(`No initialized SPL interface found for mint: ${p.toBase58()}. Please create an SPL interface via createSplInterface().`);if(!await t.getAccountInfo(a))throw new Error(`Destination account does not exist: ${a.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`);const T=o.getAssociatedTokenAddressInterface(p,c.publicKey);await o.loadAta(t,T,c,p,s,I);const A=await t.getAccountInfo(T);if(!A)throw new Error("No c-token ATA found after loading");const f=A.data.readBigUInt64LE(64);if(f===BigInt(0))throw new Error("No c-token balance to unwrap");const l=i?BigInt(i.toString()):f;if(l>f)throw new Error(`Insufficient c-token balance. Requested: ${l}, Available: ${f}`);const x=n(T,a,c.publicKey,p,l,d,s.publicKey),{blockhash:k}=await t.getLatestBlockhash(),m=e.dedupeSigner(s,[c]),C=e.buildAndSignTx([r.ComputeBudgetProgram.setComputeUnitLimit({units:2e5}),x],s,k,m);return await e.sendAndConfirmTx(t,C,I)};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../../src/v3/instructions/unwrap.ts","../../../../../../src/v3/unified/index.ts","../../../../../../src/v3/actions/unwrap.ts"],"sourcesContent":["import { PublicKey, TransactionInstruction } from '@solana/web3.js';\nimport { CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../../program';\nimport { SplInterfaceInfo } from '../../utils/get-token-pool-infos';\nimport {\n encodeTransfer2InstructionData,\n createCompressCtoken,\n createDecompressSpl,\n Transfer2InstructionData,\n Compression,\n} from '../layout/layout-transfer2';\n\n/**\n * Create an unwrap instruction that moves tokens from a c-token account to an\n * SPL/T22 account.\n *\n * @param source Source c-token account\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the source account (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap,\n * @param splInterfaceInfo SPL interface info for the decompression\n * @param payer Fee payer (defaults to owner if not provided)\n * @returns TransactionInstruction to unwrap tokens\n */\nexport function createUnwrapInstruction(\n source: PublicKey,\n destination: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n amount: bigint,\n splInterfaceInfo: SplInterfaceInfo,\n payer: PublicKey = owner,\n): TransactionInstruction {\n const MINT_INDEX = 0;\n const OWNER_INDEX = 1;\n const SOURCE_INDEX = 2;\n const DESTINATION_INDEX = 3;\n const POOL_INDEX = 4;\n const _SPL_TOKEN_PROGRAM_INDEX = 5;\n const CTOKEN_PROGRAM_INDEX = 6;\n\n // Unwrap flow: compress from c-token, decompress to SPL\n const compressions: Compression[] = [\n createCompressCtoken(\n amount,\n MINT_INDEX,\n SOURCE_INDEX,\n OWNER_INDEX,\n CTOKEN_PROGRAM_INDEX,\n ),\n createDecompressSpl(\n amount,\n MINT_INDEX,\n DESTINATION_INDEX,\n POOL_INDEX,\n splInterfaceInfo.poolIndex,\n splInterfaceInfo.bump,\n ),\n ];\n\n const instructionData: Transfer2InstructionData = {\n withTransactionHash: false,\n withLamportsChangeAccountMerkleTreeIndex: false,\n lamportsChangeAccountMerkleTreeIndex: 0,\n lamportsChangeAccountOwnerIndex: 0,\n outputQueue: 0,\n maxTopUp: 0,\n cpiContext: null,\n compressions,\n proof: null,\n inTokenData: [],\n outTokenData: [],\n inLamports: null,\n outLamports: null,\n inTlv: null,\n outTlv: null,\n };\n\n const data = encodeTransfer2InstructionData(instructionData);\n\n // Account order matches wrap instruction for consistency\n const keys = [\n {\n pubkey: CompressedTokenProgram.deriveCpiAuthorityPda,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: owner, isSigner: true, isWritable: false },\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: splInterfaceInfo.splInterfacePda,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: splInterfaceInfo.tokenProgram,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: CTOKEN_PROGRAM_ID,\n isSigner: false,\n isWritable: false,\n },\n ];\n\n return new TransactionInstruction({\n programId: CompressedTokenProgram.programId,\n keys,\n data,\n });\n}\n","/**\n * Exports for @lightprotocol/compressed-token/unified\n *\n * Import from `/unified` to get a single unified ATA for SPL/T22 and c-token\n * mints.\n */\nimport { PublicKey, Signer, ConfirmOptions, Commitment } from '@solana/web3.js';\nimport { Rpc, CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { TokenAccountNotFoundError } from '@solana/spl-token';\n\nimport {\n getAtaInterface as _getAtaInterface,\n AccountInterface,\n} from '../get-account-interface';\nimport { getAssociatedTokenAddressInterface as _getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport {\n createLoadAtaInstructions as _createLoadAtaInstructions,\n loadAta as _loadAta,\n} from '../actions/load-ata';\nimport { transferInterface as _transferInterface } from '../actions/transfer-interface';\nimport { _getOrCreateAtaInterface } from '../actions/get-or-create-ata-interface';\nimport { getAtaProgramId } from '../ata-utils';\nimport { InterfaceOptions } from '..';\n\n/**\n * Get associated token account with unified balance\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param commitment Optional commitment level\n * @param programId Optional program ID (omit for unified behavior)\n * @returns AccountInterface with aggregated balance from all sources\n */\nexport async function getAtaInterface(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n commitment?: Commitment,\n programId?: PublicKey,\n): Promise<AccountInterface> {\n return _getAtaInterface(rpc, ata, owner, mint, commitment, programId, true);\n}\n\n/**\n * Derive the canonical token ATA for SPL/T22/c-token in the unified path.\n *\n * Enforces CTOKEN_PROGRAM_ID.\n *\n * @param mint Mint public key\n * @param owner Owner public key\n * @param allowOwnerOffCurve Allow owner to be a PDA. Default false.\n * @param programId Token program ID. Default c-token.\n * @param associatedTokenProgramId Associated token program ID. Default\n * auto-detected.\n * @returns Associated token address.\n */\nexport function getAssociatedTokenAddressInterface(\n mint: PublicKey,\n owner: PublicKey,\n allowOwnerOffCurve = false,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n associatedTokenProgramId?: PublicKey,\n): PublicKey {\n if (!programId.equals(CTOKEN_PROGRAM_ID)) {\n throw new Error(\n 'Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.',\n );\n }\n\n return _getAssociatedTokenAddressInterface(\n mint,\n owner,\n allowOwnerOffCurve,\n programId,\n associatedTokenProgramId,\n );\n}\n\n/**\n * Create instructions to load ALL token balances into a c-token ATA.\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param payer Fee payer (defaults to owner)\n * @param options Optional interface options\n * @returns Array of instructions (empty if nothing to load)\n */\nexport async function createLoadAtaInstructions(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n payer?: PublicKey,\n options?: InterfaceOptions,\n) {\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n payer,\n options,\n true,\n );\n}\n\n/**\n * Load all token balances into the c-token ATA.\n *\n * Wraps SPL/Token-2022 balances and decompresses compressed c-tokens\n * into the on-chain c-token ATA. Idempotent: returns null if nothing to load.\n *\n * @param rpc RPC connection\n * @param ata Associated token address (c-token)\n * @param owner Owner of the tokens (signer)\n * @param mint Mint public key\n * @param payer Fee payer (signer, defaults to owner)\n * @param confirmOptions Optional confirm options\n * @param interfaceOptions Optional interface options\n * @returns Transaction signature, or null if nothing to load\n */\nexport async function loadAta(\n rpc: Rpc,\n ata: PublicKey,\n owner: Signer,\n mint: PublicKey,\n payer?: Signer,\n confirmOptions?: ConfirmOptions,\n interfaceOptions?: InterfaceOptions,\n) {\n const signature = await _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n true,\n );\n\n // Unified semantics: if the canonical c-token ATA does not exist at all,\n // treat this as an error (caller has no balances to load and no ATA).\n if (signature === null) {\n const accountInfo = await rpc.getAccountInfo(ata);\n if (!accountInfo) {\n throw new TokenAccountNotFoundError();\n }\n }\n\n return signature;\n}\n\n/**\n * Transfer tokens using the unified ata interface.\n *\n * Matches SPL Token's transferChecked signature order. Destination must exist.\n *\n * @param rpc RPC connection\n * @param payer Fee payer (signer)\n * @param source Source c-token ATA address\n * @param mint Mint address\n * @param destination Destination c-token ATA address (must exist)\n * @param owner Source owner (signer)\n * @param amount Amount to transfer\n * @param programId Token program ID (default: CTOKEN_PROGRAM_ID)\n * @param confirmOptions Optional confirm options\n * @param options Optional interface options\n * @returns Transaction signature\n */\nexport async function transferInterface(\n rpc: Rpc,\n payer: Signer,\n source: PublicKey,\n mint: PublicKey,\n destination: PublicKey,\n owner: Signer,\n amount: number | bigint | BN,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n confirmOptions?: ConfirmOptions,\n options?: InterfaceOptions,\n) {\n return _transferInterface(\n rpc,\n payer,\n source,\n mint,\n destination,\n owner,\n amount,\n programId,\n confirmOptions,\n options,\n true,\n );\n}\n\n/**\n * Get or create c-token ATA with unified balance detection and auto-loading.\n *\n * Enforces CTOKEN_PROGRAM_ID. Aggregates balances from:\n * - c-token hot (on-chain) account\n * - c-token cold (compressed) accounts\n * - SPL token accounts (for unified wrapping)\n * - Token-2022 accounts (for unified wrapping)\n *\n * When owner is a Signer:\n * - Creates hot ATA if it doesn't exist\n * - Loads cold (compressed) tokens into hot ATA\n * - Wraps SPL/T22 tokens into c-token ATA\n * - Returns account with all tokens ready to use\n *\n * When owner is a PublicKey:\n * - Creates hot ATA if it doesn't exist\n * - Returns aggregated balance but does NOT auto-load (can't sign)\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param mint Mint address\n * @param owner Owner (Signer for auto-load, PublicKey for read-only)\n * @param allowOwnerOffCurve Allow PDA owners (default: false)\n * @param commitment Optional commitment level\n * @param confirmOptions Optional confirm options\n * @returns AccountInterface with unified balance and source breakdown\n */\nexport async function getOrCreateAtaInterface(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: PublicKey | Signer,\n allowOwnerOffCurve = false,\n commitment?: Commitment,\n confirmOptions?: ConfirmOptions,\n): Promise<AccountInterface> {\n return _getOrCreateAtaInterface(\n rpc,\n payer,\n mint,\n owner,\n allowOwnerOffCurve,\n commitment,\n confirmOptions,\n CTOKEN_PROGRAM_ID,\n getAtaProgramId(CTOKEN_PROGRAM_ID),\n true, // wrap=true for unified path\n );\n}\n\nexport {\n getAccountInterface,\n AccountInterface,\n TokenAccountSource,\n // Note: Account is already exported from @solana/spl-token via get-account-interface\n AccountState,\n ParsedTokenAccount,\n parseCTokenHot,\n parseCTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n} from '../get-account-interface';\n\nexport {\n createLoadAccountsParams,\n createLoadAtaInstructionsFromInterface,\n calculateCompressibleLoadComputeUnits,\n CompressibleAccountInput,\n ParsedAccountInfoInterface,\n CompressibleLoadParams,\n PackedCompressedAccount,\n LoadResult,\n} from '../actions/load-ata';\n\nexport { InterfaceOptions } from '../actions/transfer-interface';\n\nexport * from '../../actions';\nexport * from '../../utils';\nexport * from '../../constants';\nexport * from '../../idl';\nexport * from '../../layout';\nexport * from '../../program';\nexport * from '../../types';\nexport * from '../derivation';\n\nexport {\n // Instructions\n createMintInstruction,\n createTokenMetadata,\n createAssociatedCTokenAccountInstruction,\n createAssociatedCTokenAccountIdempotentInstruction,\n createAssociatedTokenAccountInterfaceInstruction,\n createAssociatedTokenAccountInterfaceIdempotentInstruction,\n createAtaInterfaceIdempotentInstruction,\n createMintToInstruction,\n createMintToCompressedInstruction,\n createMintToInterfaceInstruction,\n createUpdateMintAuthorityInstruction,\n createUpdateFreezeAuthorityInstruction,\n createUpdateMetadataFieldInstruction,\n createUpdateMetadataAuthorityInstruction,\n createRemoveMetadataKeyInstruction,\n createWrapInstruction,\n createUnwrapInstruction,\n createDecompressInterfaceInstruction,\n createTransferInterfaceInstruction,\n createCTokenTransferInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n CTokenConfig,\n CreateAssociatedCTokenAccountParams,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n // getOrCreateAtaInterface is defined locally with unified behavior\n decompressInterface,\n wrap,\n unwrap,\n mintTo as mintToCToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n // Serde\n BaseMint,\n MintContext,\n MintExtension,\n TokenMetadata,\n CompressedMint,\n deserializeMint,\n serializeMint,\n decodeTokenMetadata,\n encodeTokenMetadata,\n extractTokenMetadata,\n ExtensionType,\n // Metadata formatting\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from '..';\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { createUnwrapInstruction } from '../instructions/unwrap';\nimport {\n getSplInterfaceInfos,\n SplInterfaceInfo,\n} from '../../utils/get-token-pool-infos';\nimport { getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport { loadAta as _loadAta } from './load-ata';\n\n/**\n * Unwrap c-tokens to SPL tokens.\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the c-token (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap (defaults to all)\n * @param splInterfaceInfo SPL interface info\n * @param confirmOptions Confirm options\n *\n * @returns Transaction signature\n */\nexport async function unwrap(\n rpc: Rpc,\n payer: Signer,\n destination: PublicKey,\n owner: Signer,\n mint: PublicKey,\n amount?: number | bigint | BN,\n splInterfaceInfo?: SplInterfaceInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n // 1. Get SPL interface info if not provided\n let resolvedSplInterfaceInfo = splInterfaceInfo;\n if (!resolvedSplInterfaceInfo) {\n const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint);\n resolvedSplInterfaceInfo = splInterfaceInfos.find(\n info => info.isInitialized,\n );\n\n if (!resolvedSplInterfaceInfo) {\n throw new Error(\n `No initialized SPL interface found for mint: ${mint.toBase58()}. ` +\n `Please create an SPL interface via createSplInterface().`,\n );\n }\n }\n\n const destAtaInfo = await rpc.getAccountInfo(destination);\n if (!destAtaInfo) {\n throw new Error(\n `Destination account does not exist: ${destination.toBase58()}. ` +\n `Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`,\n );\n }\n\n // Load all tokens to c-token hot ATA\n const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);\n await _loadAta(rpc, ctokenAta, owner, mint, payer, confirmOptions);\n\n // Check c-token hot balance\n const ctokenAccountInfo = await rpc.getAccountInfo(ctokenAta);\n if (!ctokenAccountInfo) {\n throw new Error('No c-token ATA found after loading');\n }\n\n // Parse c-token account balance\n const data = ctokenAccountInfo.data;\n const ctokenBalance = data.readBigUInt64LE(64);\n\n if (ctokenBalance === BigInt(0)) {\n throw new Error('No c-token balance to unwrap');\n }\n\n const unwrapAmount = amount ? BigInt(amount.toString()) : ctokenBalance;\n\n if (unwrapAmount > ctokenBalance) {\n throw new Error(\n `Insufficient c-token balance. Requested: ${unwrapAmount}, Available: ${ctokenBalance}`,\n );\n }\n\n // Build unwrap instruction\n const ix = createUnwrapInstruction(\n ctokenAta,\n destination,\n owner.publicKey,\n mint,\n unwrapAmount,\n resolvedSplInterfaceInfo,\n payer.publicKey,\n );\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","payer","instructionData","withTransactionHash","withLamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountOwnerIndex","outputQueue","maxTopUp","cpiContext","compressions","createCompressCtoken","createDecompressSpl","poolIndex","bump","proof","inTokenData","outTokenData","inLamports","outLamports","inTlv","outTlv","data","encodeTransfer2InstructionData","keys","pubkey","CompressedTokenProgram","deriveCpiAuthorityPda","isSigner","isWritable","splInterfacePda","tokenProgram","CTOKEN_PROGRAM_ID","TransactionInstruction","programId","async","rpc","ata","options","_createLoadAtaInstructions","createLoadAtaInstructions","allowOwnerOffCurve","associatedTokenProgramId","equals","Error","_getAssociatedTokenAddressInterface","commitment","_getAtaInterface","getAtaInterface","confirmOptions","_getOrCreateAtaInterface","getAtaProgramId","interfaceOptions","signature","_loadAta","getAccountInfo","TokenAccountNotFoundError","_transferInterface","transferInterface","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","toBase58","ctokenAta","getAssociatedTokenAddressInterface","publicKey","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx"],"mappings":"kKAyBgBA,EACZC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAAmBJ,GAEnB,MA2BMK,EAA4C,CAC9CC,oBAAqB,EACrBC,yCAA0C,EAC1CC,qCAAsC,EACtCC,gCAAiC,EACjCC,YAAa,EACbC,SAAU,EACVC,WAAY,KACZC,aA1BgC,CAChCC,EAAAA,qBACIZ,EAXW,EAEE,EADD,EAKS,GAWzBa,sBACIb,EAlBW,EAGO,EACP,EAkBXC,EAAiBa,UACjBb,EAAiBc,OAarBC,MAAO,KACPC,YAAa,GACbC,aAAc,GACdC,WAAY,KACZC,YAAa,KACbC,MAAO,KACPC,OAAQ,MAGNC,EAAOC,iCAA+BrB,GAGtCsB,EAAO,CACT,CACIC,OAAQC,EAAsBA,uBAACC,sBAC/BC,SAAU,EACVC,WAAY,GAEhB,CAAEJ,OAAQxB,EAAO2B,SAAU,EAAMC,WAAY,GAC7C,CAAEJ,OAAQ3B,EAAM8B,SAAU,EAAOC,WAAY,GAC7C,CAAEJ,OAAQ5B,EAAO+B,SAAU,EAAMC,WAAY,GAC7C,CAAEJ,OAAQ9B,EAAQiC,SAAU,EAAOC,WAAY,GAC/C,CAAEJ,OAAQ7B,EAAagC,SAAU,EAAOC,WAAY,GACpD,CACIJ,OAAQzB,EAAiB8B,gBACzBF,SAAU,EACVC,WAAY,GAEhB,CACIJ,OAAQzB,EAAiB+B,aACzBH,SAAU,EACVC,WAAY,GAEhB,CACIJ,OAAQO,EAAiBA,kBACzBJ,SAAU,EACVC,WAAY,IAIpB,OAAO,IAAII,EAAAA,uBAAuB,CAC9BC,UAAWR,EAAsBA,uBAACQ,UAClCV,OACAF,QAER,y5RCtBOa,eACHC,EACAC,EACAxC,EACAC,EACAG,EACAqC,GAEA,OAAOC,EAA0BC,0BAC7BJ,EACAC,EACAxC,EACAC,EACAG,EACAqC,EACA,EAER,+EAlDgB,SACZxC,EACAD,EACA4C,EAAqB,EACrBP,EAAuBF,EAAiBA,kBACxCU,GAEA,IAAKR,EAAUS,OAAOX,EAAAA,mBAClB,MAAM,IAAIY,MACN,8IAIR,OAAOC,EAAAA,mCACH/C,EACAD,EACA4C,EACAP,EACAQ,EAER,0BA5COP,eACHC,EACAC,EACAxC,EACAC,EACAgD,EACAZ,GAEA,OAAOa,EAAgBC,gBAACZ,EAAKC,EAAKxC,EAAOC,EAAMgD,EAAYZ,EAAW,EAC1E,kCA0LOC,eACHC,EACAnC,EACAH,EACAD,EACA4C,EAAqB,EACrBK,EACAG,GAEA,OAAOC,EAAwBA,yBAC3Bd,EACAnC,EACAH,EACAD,EACA4C,EACAK,EACAG,EACAjB,EAAAA,kBACAmB,EAAAA,gBAAgBnB,EAAAA,mBAChB,EAER,kBA7HOG,eACHC,EACAC,EACAxC,EACAC,EACAG,EACAgD,EACAG,GAEA,MAAMC,QAAkBC,UACpBlB,EACAC,EACAxC,EACAC,EACAG,EACAgD,EACAG,EACA,GAKJ,GAAkB,OAAdC,UAC0BjB,EAAImB,eAAelB,GAEzC,MAAM,IAAImB,EAAyBA,0BAI3C,OAAOH,CACX,4BAmBOlB,eACHC,EACAnC,EACAN,EACAG,EACAF,EACAC,EACAE,EACAmC,EAAuBF,oBACvBiB,EACAX,GAEA,OAAOmB,EAAkBC,kBACrBtB,EACAnC,EACAN,EACAG,EACAF,EACAC,EACAE,EACAmC,EACAe,EACAX,EACA,EAER,iBCrKOH,eACHC,EACAnC,EACAL,EACAC,EACAC,EACAC,EACAC,EACAiD,GAGA,IAAIU,EAA2B3D,EAC/B,IAAK2D,IAEDA,SADgCC,EAAAA,qBAAqBxB,EAAKtC,IACb+D,MACzCC,GAAQA,EAAKC,iBAGZJ,GACD,MAAM,IAAIf,MACN,gDAAgD9C,EAAKkE,wEAOjE,UAD0B5B,EAAImB,eAAe3D,GAEzC,MAAM,IAAIgD,MACN,uCAAuChD,EAAYoE,6HAM3D,MAAMC,EAAYC,EAAkCA,mCAACpE,EAAMD,EAAMsE,iBAC3Db,EAAAA,QAASlB,EAAK6B,EAAWpE,EAAOC,EAAMG,EAAOgD,GAGnD,MAAMmB,QAA0BhC,EAAImB,eAAeU,GACnD,IAAKG,EACD,MAAM,IAAIxB,MAAM,sCAIpB,MACMyB,EADOD,EAAkB9C,KACJgD,gBAAgB,IAE3C,GAAID,IAAkBE,OAAO,GACzB,MAAM,IAAI3B,MAAM,gCAGpB,MAAM4B,EAAezE,EAASwE,OAAOxE,EAAO0E,YAAcJ,EAE1D,GAAIG,EAAeH,EACf,MAAM,IAAIzB,MACN,4CAA4C4B,iBAA4BH,KAKhF,MAAMK,EAAKhF,EACPuE,EACArE,EACAC,EAAMsE,UACNrE,EACA0E,EACAb,EACA1D,EAAMkE,YAGJQ,UAAEA,SAAoBvC,EAAIwC,qBAC1BC,EAAoBC,EAAYA,aAAC7E,EAAO,CAACJ,IAEzCkF,EAAKC,EAAcA,eACrB,CAACC,EAAAA,qBAAqBC,oBAAoB,CAAEC,MAAO,MAAYT,GAC/DzE,EACA0E,EACAE,GAKJ,aAFmBO,EAAgBA,iBAAChD,EAAK2C,EAAI9B,EAGjD"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@solana/web3.js"),t=require("@lightprotocol/stateless.js"),o=require("buffer"),n=require("@solana/spl-token"),r=require("@coral-xyz/borsh");const s=o.Buffer.from("pool"),a=o.Buffer.from("cpi_authority"),i=o.Buffer.from([23,169,27,122,147,169,209,152]),u=o.Buffer.from([241,34,48,186,37,179,123,192]),c=o.Buffer.from([65,206,101,37,147,42,221,144]),m=o.Buffer.from([163,52,200,231,140,3,69,186]),p=o.Buffer.from([112,230,105,101,145,202,157,97]),d=o.Buffer.from([69,74,217,36,115,117,97,76]),l=o.Buffer.from([170,23,31,34,133,173,93,242]),g=o.Buffer.from([114,143,210,73,96,115,1,228]);function y(e,t){if(!e.mint.equals(t))throw new Error("TokenPool mint does not match the provided mint.");if(!e.isInitialized)throw new Error(`TokenPool is not initialized. Please create a compressed token pool for mint: ${t.toBase58()} via createTokenPool().`);return 1}async function f(e,o,r){const s=Array.from({length:5},((e,t)=>ie.deriveTokenPoolPdaWithIndex(o,t))),a=await e.getMultipleAccountsInfo(s.map((e=>e[0])),r);if(null===a[0])throw new Error(`TokenPool not found. Please create a compressed token pool for mint: ${o.toBase58()} via createTokenPool().`);const i=s.map(((e,t)=>a[t]?n.unpackAccount(e[0],a[t],a[t].owner):null)),u=a[0].owner;return i.map(((e,n)=>e?{mint:o,tokenPoolPda:e.address,tokenProgram:u,activity:void 0,balance:t.bn(e.amount.toString()),isInitialized:1,poolIndex:n,bump:s[n][1]}:{mint:o,tokenPoolPda:s[n][0],tokenProgram:u,activity:void 0,balance:t.bn(0),isInitialized:0,poolIndex:n,bump:s[n][1]}))}var h;exports.Action=void 0,(h=exports.Action||(exports.Action={}))[h.Compress=1]="Compress",h[h.Decompress=2]="Decompress",h[h.Transfer=3]="Transfer";const P=e=>{for(let t=e.length-1;t>0;t--){const o=Math.floor(Math.random()*(t+1));[e[t],e[o]]=[e[o],e[t]]}return e};function k(e){const t=P(e).filter((e=>e.isInitialized));if(0===t.length)throw new Error("Please pass at least one initialized token pool info.");return t[0]}function b(e,o){if(0===e.length)throw new Error("Please pass at least one token pool info.");const n=(e=P(e)).find((e=>e.balance.gte(t.bn(o).mul(t.bn(10)))));if((e=e.filter((e=>e.isInitialized)).sort(((e,t)=>e.poolIndex-t.poolIndex))).every((e=>e.balance.isZero())))throw new Error("All provided token pool balances are zero. Please pass recent token pool infos.");return n?[n]:e}const A="Could not find accounts to select for transfer.";function S(e,t,o=4){const n=e.find((e=>e.parsed.amount.eq(t)));return n?[[n],n.parsed.amount,n.compressedAccount.lamports,n.parsed.amount]:T(e,t,o)}function T(e,o,n=4){const[r,s,a,i]=I(e,o,n);if(s.lt(t.bn(o))){const s=e.reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0));throw r.length>=n?new Error(`Account limit exceeded: max ${i.toString()} (${n} accounts) per transaction. Total balance: ${s.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${o.toString()}, available: ${s.toString()}.`)}if(0===r.length)throw new Error(A);return[r,s,a,i]}function I(e,o,n=4){if(0===e.length)throw new Error(A);let r=t.bn(0),s=t.bn(0),a=t.bn(0);const i=[];e.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const a of e){if(i.length>=n)break;if(r.gte(t.bn(o)))break;a.parsed.amount.isZero()&&a.compressedAccount.lamports.isZero()||(r=r.add(a.parsed.amount),s=s.add(a.compressedAccount.lamports),i.push(a))}if(a=e.slice(0,n).reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0)),r.lt(t.bn(o))&&console.log(`Insufficient balance for transfer. Requested: ${o.toString()}, Returns max available: ${a.toString()}.`),0===i.length)throw new Error(A);return[i,r,s,a]}function C(e,o,n=4){if(0===e.length)throw new Error(A);let r=t.bn(0),s=t.bn(0);const a=[],i=e.filter((e=>!e.parsed.amount.isZero()||!e.compressedAccount.lamports.isZero()));i.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const e of i){if(a.length>=n)break;if(r=r.add(e.parsed.amount),s=s.add(e.compressedAccount.lamports),a.push(e),r.gte(t.bn(o))){const e=i.slice(a.length);if(e.length>0){const t=e.reduce(((e,t)=>t.parsed.amount.lt(e.parsed.amount)?t:e));a.length<n&&(a.push(t),r=r.add(t.parsed.amount),s=s.add(t.compressedAccount.lamports))}break}}const u=i.slice(0,n).reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0));if(0===a.length)throw new Error(A);return[a,r,s,u]}function x(e){const{inputCompressedTokenAccounts:o,outputStateTreeInfo:n,remainingAccounts:r=[],rootIndices:s,tokenTransferOutputs:a}=e,i=r.slice();let u=null;o.length>0&&o[0].parsed.delegate&&(u=t.getIndexOrAdd(i,o[0].parsed.delegate));const c=[];if(o.forEach(((e,o)=>{const n=t.getIndexOrAdd(i,e.compressedAccount.treeInfo.tree),r=t.getIndexOrAdd(i,e.compressedAccount.treeInfo.queue);c.push({amount:e.parsed.amount,delegateIndex:u,merkleContext:{merkleTreePubkeyIndex:n,queuePubkeyIndex:r,leafIndex:e.compressedAccount.leafIndex,proveByIndex:e.compressedAccount.proveByIndex},rootIndex:s[o],lamports:e.compressedAccount.lamports.eq(t.bn(0))?null:e.compressedAccount.lamports,tlv:null})})),o.length>0&&n)throw new Error("Cannot specify both input accounts and outputStateTreeInfo");let m;if(o.length>0)m=o[0].compressedAccount.treeInfo;else{if(!n)throw new Error("Neither input accounts nor outputStateTreeInfo are available");m=n}const p=m.nextTreeInfo||m;let d=p.tree;if(p.treeType===t.TreeType.StateV2){if(!t.featureFlags.isV2())throw new Error("V2 trees are not supported yet");d=p.queue}const l=t.padOutputStateMerkleTrees(d,a.length),g=[];l.forEach(((e,o)=>{var n;const r=t.getIndexOrAdd(i,e);g.push({owner:a[o].owner,amount:a[o].amount,lamports:(null===(n=a[o].lamports)||void 0===n?void 0:n.eq(t.bn(0)))?null:a[o].lamports,merkleTreeIndex:r,tlv:null})}));const y=i.map((e=>({pubkey:e,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:c,remainingAccountMetas:y,packedOutputTokenData:g}}function w(e,t){if(!e.every((e=>e.parsed.mint.equals(t))))throw new Error("All input accounts must belong to the same mint");return 1}const M=r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")]),v=r.struct([r.publicKey("owner"),r.u64("amount"),r.option(r.u64(),"lamports"),r.u8("merkleTreeIndex"),r.option(r.vecU8(),"tlv")]),D=r.struct([r.u64("amount"),r.option(r.u8(),"delegateIndex"),r.struct([r.u8("merkleTreePubkeyIndex"),r.u8("queuePubkeyIndex"),r.u32("leafIndex"),r.bool("proveByIndex")],"merkleContext"),r.u16("rootIndex"),r.option(r.u64(),"lamports"),r.option(r.vecU8(),"tlv")]),O=r.struct([r.publicKey("owner"),r.option(r.u8(),"delegateChangeAccountIndex")]),W=r.struct([r.bool("setContext"),r.bool("firstSetContext"),r.u8("cpiContextAccountIndex")]),E=r.struct([r.option(M,"proof"),r.publicKey("mint"),r.option(O,"delegatedTransfer"),r.vec(D,"inputTokenDataWithContext"),r.vec(v,"outputCompressedAccounts"),r.bool("isCompress"),r.option(r.u64(),"compressOrDecompressAmount"),r.option(W,"cpiContext"),r.option(r.u8(),"lamportsChangeAccountMerkleTreeIndex")]),B=r.struct([r.vec(r.publicKey(),"recipients"),r.vec(r.u64(),"amounts"),r.option(r.u64(),"lamports")]),K=r.struct([r.vec(r.publicKey(),"pubkeys"),r.option(r.vec(r.u64(),"amounts"),"amounts"),r.option(r.u64(),"lamports"),r.option(r.u64(),"amount"),r.u8("index"),r.u8("bump")]),L=r.struct([r.publicKey("owner"),r.option(r.u64(),"remainingAmount"),r.option(W,"cpiContext")]);function R(e){const t=o.Buffer.alloc(1e3),n=B.encode({recipients:e.recipients,amounts:e.amounts,lamports:e.lamports},t);return o.Buffer.concat([new Uint8Array(u),new Uint8Array(t.subarray(0,n))])}function U(e){const t=o.Buffer.alloc(1e3),n=K.encode(e,t),r=o.Buffer.alloc(4);r.writeUInt32LE(n,0);const s=t.subarray(0,n);return o.Buffer.concat([new Uint8Array(c),new Uint8Array(r),new Uint8Array(s)])}function N(e){const t=o.Buffer.alloc(1e3),n=L.encode({owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext},t);return o.Buffer.concat([new Uint8Array(p),new Uint8Array(t.subarray(0,n))])}function q(e){const t=o.Buffer.alloc(1e3),n=E.encode(e,t),r=o.Buffer.alloc(4);r.writeUInt32LE(n,0);const s=t.subarray(0,n);return o.Buffer.concat([new Uint8Array(m),new Uint8Array(r),new Uint8Array(s)])}const F=e=>{const{feePayer:t,tokenPoolPda:o,systemProgram:n,mint:r,tokenProgram:s,cpiAuthorityPda:a}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:o,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0}]},_=e=>{const{feePayer:t,tokenPoolPda:o,systemProgram:n,mint:r,tokenProgram:s,cpiAuthorityPda:a,existingTokenPoolPda:i}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0}]},V=e=>{const t=ie.programId,{feePayer:o,authority:n,cpiAuthorityPda:r,mint:s,tokenPoolPda:a,tokenProgram:i,lightSystemProgram:u,registeredProgramPda:c,noopProgram:m,accountCompressionAuthority:p,accountCompressionProgram:d,merkleTree:l,selfProgram:g,systemProgram:y,solPoolPda:f}=e;return[{pubkey:o,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:1},{pubkey:g,isSigner:0,isWritable:0},{pubkey:y,isSigner:0,isWritable:0},{pubkey:null!=f?f:t,isSigner:0,isWritable:1}]},z=e=>{const t=ie.programId,{feePayer:o,authority:n,cpiAuthorityPda:r,lightSystemProgram:s,registeredProgramPda:a,noopProgram:i,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:m,tokenPoolPda:p,compressOrDecompressTokenAccount:d,tokenProgram:l,systemProgram:g}=e;return[{pubkey:o,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:null!=p?p:t,isSigner:0,isWritable:1},{pubkey:null!=d?d:t,isSigner:0,isWritable:1},{pubkey:null!=l?l:t,isSigner:0,isWritable:0},{pubkey:g,isSigner:0,isWritable:0}]},H=e=>{const{feePayer:t,authority:o,cpiAuthorityPda:n,lightSystemProgram:r,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:i,accountCompressionProgram:u,selfProgram:c,systemProgram:m}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:o,isSigner:1,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0}]},$=H,j=e=>{const{feePayer:t,authority:o,cpiAuthorityPda:n,lightSystemProgram:r,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:i,accountCompressionProgram:u,selfProgram:c,systemProgram:m,mint:p}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:o,isSigner:1,isWritable:0},{pubkey:n,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},Z=j,G=r.struct([r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")],"proof"),r.publicKey("mint"),r.vec(D,"inputTokenDataWithContext"),r.option(W,"cpiContext"),r.publicKey("delegate"),r.u64("delegatedAmount"),r.u8("delegateMerkleTreeIndex"),r.u8("changeAccountMerkleTreeIndex"),r.option(r.u64(),"delegateLamports")]),Q=r.struct([r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")],"proof"),r.publicKey("mint"),r.vec(D,"inputTokenDataWithContext"),r.option(W,"cpiContext"),r.u8("outputAccountMerkleTreeIndex")]),X={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function Y(e){return e.a.every((e=>0===e))&&e.b.every((e=>0===e))&&e.c.every((e=>0===e))}function J(e){var t;const n=o.Buffer.alloc(1e3),r=null!==(t=e.proof)&&void 0!==t?t:X,s=G.encode(Object.assign(Object.assign({},e),{proof:r}),n),a=o.Buffer.alloc(4);a.writeUInt32LE(s,0);const i=n.subarray(0,s);return o.Buffer.concat([new Uint8Array(d),new Uint8Array(a),new Uint8Array(i)])}function ee(e){var t;const n=o.Buffer.alloc(1e3),r=null!==(t=e.proof)&&void 0!==t?t:X,s=Q.encode(Object.assign(Object.assign({},e),{proof:r}),n),a=o.Buffer.alloc(4);a.writeUInt32LE(s,0);const i=n.subarray(0,s);return o.Buffer.concat([new Uint8Array(l),new Uint8Array(a),new Uint8Array(i)])}const te=e=>e.reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0)),oe=e=>{const t=e[0].parsed.owner;e.forEach((e=>{if(!e.parsed.owner.equals(t))throw new Error("Token accounts must be owned by the same owner")}))},ne=e=>({mint:e[0].parsed.mint,currentOwner:e[0].parsed.owner,delegate:e[0].parsed.delegate}),re=(e,t)=>{if(e.length<1)throw new Error("Must supply at least one input token account.");const o=e[0].parsed.owner,n=e.findIndex((e=>e.parsed.delegate));if(-1===n)return{delegatedTransfer:null,authority:o};const r=e[n].parsed.delegate;return{delegatedTransfer:{owner:o,delegateChangeAccountIndex:t.length<=1?null:0},authority:r}};function se(e,o,n){n=t.bn(n);const r=te(e),s=t.sumUpLamports(e.map((e=>e.compressedAccount))),a=r.sub(n);return t.validateSufficientBalance(a),a.eq(t.bn(0))&&s.eq(t.bn(0))?[{owner:o,amount:n,lamports:s,tlv:null}]:(t.validateSameOwner(e.map((e=>e.compressedAccount))),oe(e),[{owner:e[0].parsed.owner,amount:a,lamports:s,tlv:null},{owner:o,amount:n,lamports:t.bn(0),tlv:null}])}function ae(e,o){o=t.bn(o);const n=t.sumUpLamports(e.map((e=>e.compressedAccount))),r=te(e).sub(o);return t.validateSufficientBalance(r),r.eq(t.bn(0))&&n.eq(t.bn(0))?[]:(t.validateSameOwner(e.map((e=>e.compressedAccount))),oe(e),[{owner:e[0].parsed.owner,amount:r,lamports:n,tlv:null}])}class ie{constructor(){}static setProgramId(t){this.programId="string"==typeof t?new e.PublicKey(t):t}static deriveTokenPoolPda(t){const o=[s,t.toBuffer()],[n,r]=e.PublicKey.findProgramAddressSync(o,this.programId);return n}static findTokenPoolIndexAndBump(e,t){for(let o=0;o<5;o++){const n=ie.deriveTokenPoolPdaWithIndex(t,o);if(n[0].equals(e))return[o,n[1]]}throw new Error("Token pool not found")}static deriveTokenPoolPdaWithIndex(t,n){let r=[];r=0===n?[o.Buffer.from("pool"),t.toBuffer(),o.Buffer.from([])]:[o.Buffer.from("pool"),t.toBuffer(),o.Buffer.from([n])];const[s,a]=e.PublicKey.findProgramAddressSync(r,this.programId);return[s,a]}static get deriveCpiAuthorityPda(){const[t,o]=e.PublicKey.findProgramAddressSync([a],this.programId);return t}static async createMint({feePayer:t,mint:o,authority:r,freezeAuthority:s,decimals:a,rentExemptBalance:i,tokenProgramId:u,mintSize:c}){const m=null!=u?u:n.TOKEN_PROGRAM_ID;return[e.SystemProgram.createAccount({fromPubkey:t,lamports:i,newAccountPubkey:o,programId:m,space:null!=c?c:n.MINT_SIZE}),n.createInitializeMint2Instruction(o,a,r,s,m),await this.createTokenPool({feePayer:t,mint:o,tokenProgramId:m})]}static async createTokenPool({feePayer:t,mint:o,tokenProgramId:r}){const s=null!=r?r:n.TOKEN_PROGRAM_ID,a=this.deriveTokenPoolPdaWithIndex(o,0),u=F({mint:o,feePayer:t,tokenPoolPda:a[0],tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:e.SystemProgram.programId});return new e.TransactionInstruction({programId:this.programId,keys:u,data:i})}static async addTokenPool({feePayer:t,mint:r,poolIndex:s,tokenProgramId:a}){if(s<=0)throw new Error("Pool index must be greater than 0. For 0, use CreateTokenPool instead.");if(s>3)throw new Error(`Invalid poolIndex ${s}. Max 4 pools per mint.`);const i=null!=a?a:n.TOKEN_PROGRAM_ID,u=this.deriveTokenPoolPdaWithIndex(r,s-1),c=this.deriveTokenPoolPdaWithIndex(r,s),m=_({mint:r,feePayer:t,tokenPoolPda:c[0],existingTokenPoolPda:u[0],tokenProgram:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:e.SystemProgram.programId});return new e.TransactionInstruction({programId:this.programId,keys:m,data:o.Buffer.concat([new Uint8Array(g),new Uint8Array(o.Buffer.from([s]))])})}static async mintTo({feePayer:o,mint:n,authority:r,toPubkey:s,amount:a,outputStateTreeInfo:i,tokenPoolInfo:u}){const c=t.defaultStaticAccountsStruct(),m=u.tokenProgram;y(u,n);const p=t.toArray(a).map((e=>t.bn(e))),d=t.toArray(s);if(p.length!==d.length)throw new Error("Amount and toPubkey arrays must have the same length");const l=V({mint:n,feePayer:o,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:m,tokenPoolPda:u.tokenPoolPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:c.registeredProgramPda,noopProgram:c.noopProgram,accountCompressionAuthority:c.accountCompressionAuthority,accountCompressionProgram:c.accountCompressionProgram,merkleTree:i.treeType===t.TreeType.StateV2?i.queue:i.tree,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,solPoolPda:null}),g=R({recipients:d,amounts:p,lamports:null});return new e.TransactionInstruction({programId:this.programId,keys:l,data:g})}static async approveAndMintTo({feePayer:e,mint:t,authority:o,authorityTokenAccount:r,toPubkey:s,amount:a,outputStateTreeInfo:i,tokenPoolInfo:u}){const c=BigInt(a.toString());return[n.createMintToInstruction(t,r,o,c,[],u.tokenProgram),await this.compress({payer:e,owner:o,source:r,toAddress:s,mint:t,amount:a,outputStateTreeInfo:i,tokenPoolInfo:u})]}static async transfer({payer:o,inputCompressedTokenAccounts:n,toAddress:r,amount:s,recentValidityProof:a,recentInputStateRootIndices:i}){const u=se(n,r,s),{inputTokenDataWithContext:c,packedOutputTokenData:m,remainingAccountMetas:p}=x({inputCompressedTokenAccounts:n,rootIndices:i,tokenTransferOutputs:u}),{mint:d}=ne(n),{delegatedTransfer:l,authority:g}=re(n,u),y=q({proof:a,mint:d,delegatedTransfer:l,inputTokenDataWithContext:c,outputCompressedAccounts:m,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:f,noopProgram:h,registeredProgramPda:P,accountCompressionProgram:k}=t.defaultStaticAccountsStruct(),b=z({feePayer:o,authority:g,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:P,noopProgram:h,accountCompressionAuthority:f,accountCompressionProgram:k,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:e.SystemProgram.programId});return b.push(...p),new e.TransactionInstruction({programId:this.programId,keys:b,data:y})}static async createTokenProgramLookupTable({payer:o,authority:r,mints:s,recentSlot:a,remainingAccounts:i}){const[u,c]=e.AddressLookupTableProgram.createLookupTable({authority:r,payer:r,recentSlot:a});let m=[];s&&(m=[...s,...s.map((e=>this.deriveTokenPoolPda(e)))]);const p=[u,e.AddressLookupTableProgram.extendLookupTable({payer:o,authority:r,lookupTable:c,addresses:[e.SystemProgram.programId,e.ComputeBudgetProgram.programId,this.deriveCpiAuthorityPda,t.LightSystemProgram.programId,ie.programId,t.defaultStaticAccountsStruct().registeredProgramPda,t.defaultStaticAccountsStruct().noopProgram,t.defaultStaticAccountsStruct().accountCompressionAuthority,t.defaultStaticAccountsStruct().accountCompressionProgram,t.defaultTestStateTreeAccounts().merkleTree,t.defaultTestStateTreeAccounts().nullifierQueue,t.defaultTestStateTreeAccounts().addressTree,t.defaultTestStateTreeAccounts().addressQueue,this.programId,n.TOKEN_PROGRAM_ID,n.TOKEN_2022_PROGRAM_ID,r,...m]})];if(i&&i.length>0)for(let t=0;t<i.length;t+=25){const n=i.slice(t,t+25),s=e.AddressLookupTableProgram.extendLookupTable({payer:o,authority:r,lookupTable:c,addresses:n});p.push(s)}return{instructions:p,address:c}}static async compress({payer:o,owner:n,source:r,toAddress:s,amount:a,mint:i,outputStateTreeInfo:u,tokenPoolInfo:c}){let m;const p=t.toArray(a),d=t.toArray(s);if(y(c,i),p.length!==d.length)throw new Error("Amount and toAddress arrays must have the same length");if(t.featureFlags.isV2()){const[s,a]=this.findTokenPoolIndexAndBump(c.tokenPoolPda,i),m=U({pubkeys:d,amounts:p.length>1?p.map((e=>t.bn(e))):null,lamports:null,amount:1===p.length?t.bn(p[0]):null,index:s,bump:a}),l=V(Object.assign(Object.assign({mint:i,feePayer:o,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:c.tokenProgram,tokenPoolPda:c.tokenPoolPda,lightSystemProgram:t.LightSystemProgram.programId},t.defaultStaticAccountsStruct()),{merkleTree:u.queue,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,solPoolPda:null}));return l.push({pubkey:r,isWritable:1,isSigner:0}),new e.TransactionInstruction({programId:this.programId,keys:l,data:m})}{m=p.map(((e,o)=>{const n=t.bn(e);return{owner:d[o],amount:n,lamports:null,tlv:null}}));const{inputTokenDataWithContext:s,packedOutputTokenData:l,remainingAccountMetas:g}=x({inputCompressedTokenAccounts:[],outputStateTreeInfo:u,rootIndices:[],tokenTransferOutputs:m}),y=q({proof:null,mint:i,delegatedTransfer:null,inputTokenDataWithContext:s,outputCompressedAccounts:l,compressOrDecompressAmount:Array.isArray(a)?a.map((e=>t.bn(e))).reduce(((e,t)=>e.add(t)),t.bn(0)):t.bn(a),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),f=z(Object.assign(Object.assign({},t.defaultStaticAccountsStruct()),{feePayer:o,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,tokenPoolPda:c.tokenPoolPda,compressOrDecompressTokenAccount:r,tokenProgram:c.tokenProgram}));return f.push(...g),new e.TransactionInstruction({programId:this.programId,keys:f,data:y})}}static async decompress({payer:o,inputCompressedTokenAccounts:n,toAddress:r,amount:s,recentValidityProof:a,recentInputStateRootIndices:i,tokenPoolInfos:u}){const c=t.bn(s),m=t.toArray(u),p=ae(n,c),{inputTokenDataWithContext:d,packedOutputTokenData:l,remainingAccountMetas:g}=x({inputCompressedTokenAccounts:n,rootIndices:i,tokenTransferOutputs:p,remainingAccounts:m.slice(1).map((e=>e.tokenPoolPda))}),{mint:y}=ne(n),{delegatedTransfer:f,authority:h}=re(n,p),P=q({proof:a,mint:y,delegatedTransfer:f,inputTokenDataWithContext:d,outputCompressedAccounts:l,compressOrDecompressAmount:c,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),k=m[0].tokenProgram,{accountCompressionAuthority:b,noopProgram:A,registeredProgramPda:S,accountCompressionProgram:T}=t.defaultStaticAccountsStruct(),I=z({feePayer:o,authority:h,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:S,noopProgram:A,accountCompressionAuthority:b,accountCompressionProgram:T,selfProgram:this.programId,tokenPoolPda:m[0].tokenPoolPda,compressOrDecompressTokenAccount:r,tokenProgram:k,systemProgram:e.SystemProgram.programId});return I.push(...g),new e.TransactionInstruction({programId:this.programId,keys:I,data:P})}static async mergeTokenAccounts({payer:e,owner:o,inputCompressedTokenAccounts:n,mint:r,recentValidityProof:s,recentInputStateRootIndices:a}){if(n.length>4)throw new Error("Cannot merge more than 4 token accounts at once");return w(n,r),[await this.transfer({payer:e,inputCompressedTokenAccounts:n,toAddress:o,amount:n.reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0)),recentInputStateRootIndices:a,recentValidityProof:s})]}static async compressSplTokenAccount({feePayer:o,authority:n,tokenAccount:r,mint:s,remainingAmount:a,outputStateTreeInfo:i,tokenPoolInfo:u}){y(u,s);const c=[{pubkey:i.treeType===t.TreeType.StateV2?i.queue:i.tree,isSigner:0,isWritable:1}],m=N({owner:n,remainingAmount:null!=a?a:null,cpiContext:null}),{accountCompressionAuthority:p,noopProgram:d,registeredProgramPda:l,accountCompressionProgram:g}=t.defaultStaticAccountsStruct(),f=z({feePayer:o,authority:n,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:l,noopProgram:d,accountCompressionAuthority:p,accountCompressionProgram:g,selfProgram:this.programId,tokenPoolPda:u.tokenPoolPda,compressOrDecompressTokenAccount:r,tokenProgram:u.tokenProgram,systemProgram:e.SystemProgram.programId});return f.push(...c),new e.TransactionInstruction({programId:this.programId,keys:f,data:m})}static async getMintProgramId(e,t){var o;return null===(o=await t.getAccountInfo(e))||void 0===o?void 0:o.owner}static async approve({payer:o,inputCompressedTokenAccounts:n,toAddress:r,amount:s,recentValidityProof:a,recentInputStateRootIndices:i}){const{inputTokenDataWithContext:u,remainingAccountMetas:c}=x({inputCompressedTokenAccounts:n,rootIndices:i,tokenTransferOutputs:[]}),{mint:m,currentOwner:p}=ne(n),d=n[0].compressedAccount.treeInfo.treeType===t.TreeType.StateV2?1:0,l=J({proof:a,mint:m,inputTokenDataWithContext:u,cpiContext:null,delegate:r,delegatedAmount:t.bn(s),delegateMerkleTreeIndex:d,changeAccountMerkleTreeIndex:d,delegateLamports:null}),{accountCompressionAuthority:g,noopProgram:y,registeredProgramPda:f,accountCompressionProgram:h}=t.defaultStaticAccountsStruct(),P=H({feePayer:o,authority:p,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:f,noopProgram:y,accountCompressionAuthority:g,accountCompressionProgram:h,selfProgram:this.programId,systemProgram:e.SystemProgram.programId});return P.push(...c),new e.TransactionInstruction({programId:this.programId,keys:P,data:l})}static async revoke({payer:o,inputCompressedTokenAccounts:n,recentValidityProof:r,recentInputStateRootIndices:s}){oe(n);const{inputTokenDataWithContext:a,remainingAccountMetas:i}=x({inputCompressedTokenAccounts:n,rootIndices:s,tokenTransferOutputs:[]}),{mint:u,currentOwner:c}=ne(n),m=ee({proof:r,mint:u,inputTokenDataWithContext:a,cpiContext:null,outputAccountMerkleTreeIndex:n[0].compressedAccount.treeInfo.treeType===t.TreeType.StateV2?2:1}),{accountCompressionAuthority:p,noopProgram:d,registeredProgramPda:l,accountCompressionProgram:g}=t.defaultStaticAccountsStruct(),y=$({feePayer:o,authority:c,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:l,noopProgram:d,accountCompressionAuthority:p,accountCompressionProgram:g,selfProgram:this.programId,systemProgram:e.SystemProgram.programId});return y.push(...i),new e.TransactionInstruction({programId:this.programId,keys:y,data:m})}}ie.programId=new e.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=g,exports.APPROVE_DISCRIMINATOR=d,exports.BATCH_COMPRESS_DISCRIMINATOR=c,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=p,exports.CPI_AUTHORITY_SEED=a,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=i,exports.CompressedTokenInstructionDataApproveLayout=G,exports.CompressedTokenInstructionDataRevokeLayout=Q,exports.CompressedTokenInstructionDataTransferLayout=E,exports.CompressedTokenProgram=ie,exports.CpiContextLayout=W,exports.DelegatedTransferLayout=O,exports.ERROR_NO_ACCOUNTS_FOUND=A,exports.IDL={version:"1.2.0",name:"light_compressed_token",instructions:[{name:"createTokenPool",docs:["This instruction creates a token pool for a given mint. Every spl mint","can have one token pool. When a token is compressed the tokens are","transferrred to the token pool, and their compressed equivalent is","minted into a Merkle tree."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[]},{name:"addTokenPool",docs:["This instruction creates an additional token pool for a given mint.","The maximum number of token pools per mint is 5."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"existingTokenPoolPda",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[{name:"tokenPoolIndex",type:"u8"}]},{name:"mintTo",docs:["Mints tokens from an spl token mint to a list of compressed accounts.","Minted tokens are transferred to a pool account owned by the compressed","token program. The instruction creates one compressed output account for","every amount and pubkey input pair. A constant amount of lamports can be","transferred to each output account to enable. A use case to add lamports","to a compressed token account is to prevent spam. This is the only way","to add lamports to a compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0,docs:["programs"]},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"merkleTree",isMut:1,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"solPoolPda",isMut:1,isSigner:0,isOptional:1}],args:[{name:"publicKeys",type:{vec:"publicKey"}},{name:"amounts",type:{vec:"u64"}},{name:"lamports",type:{option:"u64"}}]},{name:"compressSplTokenAccount",docs:["Compresses the balance of an spl token account sub an optional remaining","amount. This instruction does not close the spl token account. To close","the account bundle a close spl account instruction in your transaction."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"owner",type:"publicKey"},{name:"remainingAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]},{name:"transfer",docs:["Transfers compressed tokens from one account to another. All accounts","must be of the same mint. Additional spl tokens can be compressed or","decompressed. In one transaction only compression or decompression is","possible. Lamports can be transferred alongside tokens. If output token","accounts specify less lamports than inputs the remaining lamports are","transferred to an output compressed account. Signer must be owner or","delegate. If a delegated token account is transferred the delegate is","not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"approve",docs:["Delegates an amount to a delegate. A compressed token account is either","completely delegated or not. Prior delegates are not preserved. Cannot","be called by a delegate.","The instruction creates two output accounts:","1. one account with delegated amount","2. one account with remaining(change) amount"],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"revoke",docs:["Revokes a delegation. The instruction merges all inputs into one output","account. Cannot be called by a delegate. Delegates are not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"freeze",docs:["Freezes compressed token accounts. Inputs must not be frozen. Creates as","many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"thaw",docs:["Thaws frozen compressed token accounts. Inputs must be frozen. Creates","as many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"burn",docs:["Burns compressed tokens and spl tokens from the pool account. Delegates","can burn tokens. The output compressed token account remains delegated.","Creates one output compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"stubIdlBuild",docs:["This function is a stub to allow Anchor to include the input types in","the IDL. It should not be included in production builds nor be called in","practice."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs1",type:{defined:"CompressedTokenInstructionDataTransfer"}},{name:"inputs2",type:{defined:"TokenData"}}]}],types:[{name:"AccountState",type:{kind:"enum",variants:[{name:"Initialized"},{name:"Frozen"}]}},{name:"CompressedAccount",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"lamports",type:"u64"},{name:"address",type:{option:{array:["u8",32]}}},{name:"data",type:{option:{defined:"CompressedAccountData"}}}]}},{name:"CompressedAccountData",type:{kind:"struct",fields:[{name:"discriminator",type:{array:["u8",8]}},{name:"data",type:"bytes"},{name:"dataHash",type:{array:["u8",32]}}]}},{name:"CompressedCpiContext",type:{kind:"struct",fields:[{name:"setContext",docs:["Is set by the program that is invoking the CPI to signal that is should","set the cpi context."],type:"bool"},{name:"firstSetContext",docs:["Is set to wipe the cpi context since someone could have set it before","with unrelated data."],type:"bool"},{name:"cpiContextAccountIndex",docs:["Index of cpi context account in remaining accounts."],type:"u8"}]}},{name:"CompressedProof",type:{kind:"struct",fields:[{name:"a",type:{array:["u8",32]}},{name:"b",type:{array:["u8",64]}},{name:"c",type:{array:["u8",32]}}]}},{name:"CompressedTokenInstructionDataTransfer",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"delegatedTransfer",docs:["Is required if the signer is delegate,","-> delegate is authority account,","owner = Some(owner) is the owner of the token account."],type:{option:{defined:"DelegatedTransfer"}}},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"PackedTokenTransferOutputData"}}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"lamportsChangeAccountMerkleTreeIndex",type:{option:"u8"}}]}},{name:"CompressedTokenInstructionDataRevoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"outputAccountMerkleTreeIndex",type:"u8"}]}},{name:"CompressedTokenInstructionDataApprove",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"delegate",type:"publicKey"},{name:"delegatedAmount",type:"u64"},{name:"delegateMerkleTreeIndex",type:"u8"},{name:"changeAccountMerkleTreeIndex",type:"u8"},{name:"delegateLamports",type:{option:"u64"}}]}},{name:"DelegatedTransfer",docs:["Struct to provide the owner when the delegate is signer of the transaction."],type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"delegateChangeAccountIndex",docs:["Index of change compressed account in output compressed accounts. In","case that the delegate didn't spend the complete delegated compressed","account balance the change compressed account will be delegated to her","as well."],type:{option:"u8"}}]}},{name:"InputTokenDataWithContext",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"delegateIndex",type:{option:"u8"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",type:"u16"},{name:"lamports",type:{option:"u64"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"InstructionDataInvoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"}]}},{name:"InstructionDataInvokeCpi",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]}},{name:"MerkleTreeSequenceNumber",type:{kind:"struct",fields:[{name:"pubkey",type:"publicKey"},{name:"seq",type:"u64"}]}},{name:"NewAddressParamsPacked",type:{kind:"struct",fields:[{name:"seed",type:{array:["u8",32]}},{name:"addressQueueAccountIndex",type:"u8"},{name:"addressMerkleTreeAccountIndex",type:"u8"},{name:"addressMerkleTreeRootIndex",type:"u16"}]}},{name:"OutputCompressedAccountWithPackedContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleTreeIndex",type:"u8"}]}},{name:"PackedCompressedAccountWithMerkleContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",docs:["Index of root used in inclusion validity proof."],type:"u16"},{name:"readOnly",docs:["Placeholder to mark accounts read-only unimplemented set to false."],type:"bool"}]}},{name:"PackedMerkleContext",type:{kind:"struct",fields:[{name:"merkleTreePubkeyIndex",type:"u8"},{name:"queuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"proveByIndex",type:"bool"}]}},{name:"PackedTokenTransferOutputData",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"amount",type:"u64"},{name:"lamports",type:{option:"u64"}},{name:"merkleTreeIndex",type:"u8"},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"PublicTransactionEvent",type:{kind:"struct",fields:[{name:"inputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"outputLeafIndices",type:{vec:"u32"}},{name:"sequenceNumbers",type:{vec:{defined:"MerkleTreeSequenceNumber"}}},{name:"relayFee",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"pubkeyArray",type:{vec:"publicKey"}},{name:"message",type:{option:"bytes"}}]}},{name:"QueueIndex",type:{kind:"struct",fields:[{name:"queueId",docs:["Id of queue in queue account."],type:"u8"},{name:"index",docs:["Index of compressed account hash in queue."],type:"u16"}]}},{name:"TokenData",type:{kind:"struct",fields:[{name:"mint",docs:["The mint associated with this account"],type:"publicKey"},{name:"owner",docs:["The owner of this account."],type:"publicKey"},{name:"amount",docs:["The amount of tokens this account holds."],type:"u64"},{name:"delegate",docs:["If `delegate` is `Some` then `delegated_amount` represents","the amount authorized by the delegate"],type:{option:"publicKey"}},{name:"state",docs:["The account's state"],type:{defined:"AccountState"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}}],errors:[{code:6e3,name:"PublicKeyAmountMissmatch",msg:"public keys and amounts must be of same length"},{code:6001,name:"ComputeInputSumFailed",msg:"ComputeInputSumFailed"},{code:6002,name:"ComputeOutputSumFailed",msg:"ComputeOutputSumFailed"},{code:6003,name:"ComputeCompressSumFailed",msg:"ComputeCompressSumFailed"},{code:6004,name:"ComputeDecompressSumFailed",msg:"ComputeDecompressSumFailed"},{code:6005,name:"SumCheckFailed",msg:"SumCheckFailed"},{code:6006,name:"DecompressRecipientUndefinedForDecompress",msg:"DecompressRecipientUndefinedForDecompress"},{code:6007,name:"CompressedPdaUndefinedForDecompress",msg:"CompressedPdaUndefinedForDecompress"},{code:6008,name:"DeCompressAmountUndefinedForDecompress",msg:"DeCompressAmountUndefinedForDecompress"},{code:6009,name:"CompressedPdaUndefinedForCompress",msg:"CompressedPdaUndefinedForCompress"},{code:6010,name:"DeCompressAmountUndefinedForCompress",msg:"DeCompressAmountUndefinedForCompress"},{code:6011,name:"DelegateSignerCheckFailed",msg:"DelegateSignerCheckFailed"},{code:6012,name:"MintTooLarge",msg:"Minted amount greater than u64::MAX"},{code:6013,name:"SplTokenSupplyMismatch",msg:"SplTokenSupplyMismatch"},{code:6014,name:"HeapMemoryCheckFailed",msg:"HeapMemoryCheckFailed"},{code:6015,name:"InstructionNotCallable",msg:"The instruction is not callable"},{code:6016,name:"ArithmeticUnderflow",msg:"ArithmeticUnderflow"},{code:6017,name:"HashToFieldError",msg:"HashToFieldError"},{code:6018,name:"InvalidAuthorityMint",msg:"Expected the authority to be also a mint authority"},{code:6019,name:"InvalidFreezeAuthority",msg:"Provided authority is not the freeze authority"},{code:6020,name:"InvalidDelegateIndex"},{code:6021,name:"TokenPoolPdaUndefined"},{code:6022,name:"IsTokenPoolPda",msg:"Compress or decompress recipient is the same account as the token pool pda."},{code:6023,name:"InvalidTokenPoolPda"},{code:6024,name:"NoInputTokenAccountsProvided"},{code:6025,name:"NoInputsProvided"},{code:6026,name:"MintHasNoFreezeAuthority"},{code:6027,name:"MintWithInvalidExtension"},{code:6028,name:"InsufficientTokenAccountBalance",msg:"The token account balance is less than the remaining amount."},{code:6029,name:"InvalidTokenPoolBump",msg:"Max number of token pools reached."},{code:6030,name:"FailedToDecompress"},{code:6031,name:"FailedToBurnSplTokensFromTokenPool"},{code:6032,name:"NoMatchingBumpFound"}]},exports.MINT_TO_DISCRIMINATOR=u,exports.POOL_SEED=s,exports.REVOKE_DISCRIMINATOR=l,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.TRANSFER_DISCRIMINATOR=m,exports.addTokenPoolAccountsLayout=_,exports.addTokenPools=async function(e,o,n,r,s,a){a=a||await ie.getMintProgramId(n,e);const i=[],u=(await f(e,n)).slice(0,4),c=[];for(let e=0;e<u.length;e++)u[e].isInitialized||c.push(e);for(let e=0;e<r&&!(e>=c.length);e++)i.push(await ie.addTokenPool({mint:n,feePayer:o.publicKey,tokenProgramId:a,poolIndex:c[e]}));const{blockhash:m}=await e.getLatestBlockhash(),p=t.buildAndSignTx(i,o,m);return await t.sendAndConfirmTx(e,p,s)},exports.approve=async function(o,n,r,s,a,i,u){s=t.bn(s);const c=await o.getCompressedTokenAccountsByOwner(a.publicKey,{mint:r}),[m]=S(c.items,s),p=await o.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await ie.approve({payer:n.publicKey,inputCompressedTokenAccounts:m,toAddress:i,amount:s,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:l}=await o.getLatestBlockhash(),g=t.dedupeSigner(n,[a]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),d],n,l,g);return t.sendAndConfirmTx(o,y,u)},exports.approveAccountsLayout=H,exports.approveAndMintTo=async function(o,r,s,a,i,u,c,m,p){c=null!=c?c:t.selectStateTreeInfo(await o.getStateTreeInfos()),m=null!=m?m:k(await f(o,s));const d=await n.getOrCreateAssociatedTokenAccount(o,r,s,i.publicKey,void 0,void 0,p,m.tokenProgram),l=await ie.approveAndMintTo({feePayer:r.publicKey,mint:s,authority:i.publicKey,authorityTokenAccount:d.address,amount:u,toPubkey:a,outputStateTreeInfo:c,tokenPoolInfo:m}),{blockhash:g}=await o.getLatestBlockhash(),y=t.dedupeSigner(r,[i]),h=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:15e4+2e4*t.toArray(u).length}),...l],r,g,y);return await t.sendAndConfirmTx(o,h,p)},exports.batchCompressLayout=K,exports.checkMint=w,exports.checkTokenPoolInfo=y,exports.compress=async function(o,n,r,s,a,i,u,c,m,p){c=null!=c?c:t.selectStateTreeInfo(await o.getStateTreeInfos()),m=null!=m?m:k(await f(o,r));const d=await ie.compress({payer:n.publicKey,owner:a.publicKey,source:i,toAddress:u,amount:s,mint:r,outputStateTreeInfo:c,tokenPoolInfo:m}),l=await o.getLatestBlockhash(),g=t.dedupeSigner(n,[a]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:13e4+2e4*t.toArray(s).length}),d],n,l.blockhash,g);return await t.sendAndConfirmTx(o,y,p,l)},exports.compressSplTokenAccount=async function(o,n,r,s,a,i,u,c,m){u=null!=u?u:t.selectStateTreeInfo(await o.getStateTreeInfos()),c=null!=c?c:k(await f(o,r));const p=await ie.compressSplTokenAccount({feePayer:n.publicKey,authority:s.publicKey,tokenAccount:a,mint:r,remainingAmount:i,outputStateTreeInfo:u,tokenPoolInfo:c}),d=await o.getLatestBlockhash(),l=t.dedupeSigner(n,[s]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:15e4}),p],n,d.blockhash,l);return await t.sendAndConfirmTx(o,g,m,d)},exports.compressSplTokenAccountInstructionDataLayout=L,exports.createDecompressOutputState=ae,exports.createMint=async function(o,r,s,a,i=e.Keypair.generate(),u,c,m){const p=await o.getMinimumBalanceForRentExemption(n.MINT_SIZE),d=1==c?n.TOKEN_2022_PROGRAM_ID:c||n.TOKEN_PROGRAM_ID,l=await ie.createMint({feePayer:r.publicKey,mint:i.publicKey,decimals:a,authority:"secretKey"in s?s.publicKey:s,freezeAuthority:m&&"secretKey"in m?m.publicKey:null!=m?m:null,rentExemptBalance:p,tokenProgramId:d}),{blockhash:g}=await o.getLatestBlockhash(),y=t.dedupeSigner(r,[s,m].filter((e=>null!=e&&"secretKey"in e))),f=t.buildAndSignTx(l,r,g,[...y,i]),h=await t.sendAndConfirmTx(o,f,u);return{mint:i.publicKey,transactionSignature:h}},exports.createTokenPool=async function(e,o,n,r,s){s=s||await ie.getMintProgramId(n,e);const a=await ie.createTokenPool({feePayer:o.publicKey,mint:n,tokenProgramId:s}),{blockhash:i}=await e.getLatestBlockhash(),u=t.buildAndSignTx([a],o,i);return await t.sendAndConfirmTx(e,u,r)},exports.createTokenPoolAccountsLayout=F,exports.createTokenProgramLookupTable=async function(e,o,n,r,s){const a=await e.getSlot("finalized"),{instructions:i,address:u}=await ie.createTokenProgramLookupTable({payer:o.publicKey,authority:n.publicKey,mints:r,remainingAccounts:s,recentSlot:a}),c=t.dedupeSigner(o,[n]),m=[];for(const n of i){const r=await e.getLatestBlockhash(),s=t.buildAndSignTx([n],o,r.blockhash,c),a=await t.sendAndConfirmTx(e,s,{commitment:"finalized"},r);m.push(a)}return{txIds:m,address:u}},exports.createTransferOutputState=se,exports.decodeApproveInstructionData=function(e){const t=G.decode(e.subarray(d.length));return Object.assign(Object.assign({},t),{proof:Y(t.proof)?null:t.proof})},exports.decodeBatchCompressInstructionData=function(e){return K.decode(e.subarray(c.length+4))},exports.decodeCompressSplTokenAccountInstructionData=function(e){const t=L.decode(e.subarray(p.length));return{owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext}},exports.decodeMintToInstructionData=function(e){return B.decode(e.subarray(u.length))},exports.decodeRevokeInstructionData=function(e){const t=Q.decode(e.subarray(l.length));return Object.assign(Object.assign({},t),{proof:Y(t.proof)?null:t.proof})},exports.decodeTransferInstructionData=function(e){return E.decode(e.slice(m.length+4))},exports.decompress=async function(o,n,r,s,a,i,u,c){s=t.bn(s);const m=await o.getCompressedTokenAccountsByOwner(a.publicKey,{mint:r}),[p]=T(m.items,s),d=await o.getValidityProofV0(p.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),l=b(u=null!=u?u:await f(o,r),s),g=await ie.decompress({payer:n.publicKey,inputCompressedTokenAccounts:p,toAddress:i,amount:s,tokenPoolInfos:l,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:y}=await o.getLatestBlockhash(),h=t.dedupeSigner(n,[a]),P=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),g],n,y,h);return await t.sendAndConfirmTx(o,P,c)},exports.decompressDelegated=async function(o,n,r,s,a,i,u,c){s=t.bn(s);const m=await o.getCompressedTokenAccountsByDelegate(a.publicKey,{mint:r}),[p]=T(m.items,s),d=await o.getValidityProofV0(p.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),l=null!=u?u:b(await f(o,r),s),g=await ie.decompress({payer:n.publicKey,inputCompressedTokenAccounts:p,toAddress:i,amount:s,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,tokenPoolInfos:l}),{blockhash:y}=await o.getLatestBlockhash(),h=t.dedupeSigner(n,[a]),P=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),g],n,y,h);return t.sendAndConfirmTx(o,P,c)},exports.encodeApproveInstructionData=J,exports.encodeBatchCompressInstructionData=U,exports.encodeCompressSplTokenAccountInstructionData=N,exports.encodeMintToInstructionData=R,exports.encodeRevokeInstructionData=ee,exports.encodeTransferInstructionData=q,exports.freezeAccountsLayout=j,exports.getTokenPoolInfos=f,exports.isSingleTokenPoolInfo=function(e){return!Array.isArray(e)},exports.mergeTokenAccounts=async function(o,n,r,s,a){const i=await o.getCompressedTokenAccountsByOwner(s.publicKey,{mint:r});if(0===i.items.length)throw new Error(`No compressed token accounts found for mint ${r.toBase58()}`);const u=[e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6})];for(let e=0;e<i.items.slice(0,8).length;e+=4){const a=i.items.slice(e,e+4),c=await o.getValidityProof(a.map((e=>t.bn(e.compressedAccount.hash)))),m=await ie.mergeTokenAccounts({payer:n.publicKey,owner:s.publicKey,inputCompressedTokenAccounts:a,mint:r,recentValidityProof:c.compressedProof,recentInputStateRootIndices:c.rootIndices});u.push(...m)}const{blockhash:c}=await o.getLatestBlockhash(),m=t.dedupeSigner(n,[s]),p=t.buildAndSignTx(u,n,c,m);return t.sendAndConfirmTx(o,p,a)},exports.mintTo=async function(o,n,r,s,a,i,u,c,m){u=null!=u?u:t.selectStateTreeInfo(await o.getStateTreeInfos()),c=null!=c?c:k(await f(o,r));const p=await ie.mintTo({feePayer:n.publicKey,mint:r,authority:a.publicKey,amount:i,toPubkey:s,outputStateTreeInfo:u,tokenPoolInfo:c}),{blockhash:d}=await o.getLatestBlockhash(),l=t.dedupeSigner(n,[a]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),p],n,d,l);return t.sendAndConfirmTx(o,g,m)},exports.mintToAccountsLayout=V,exports.mintToLayout=B,exports.packCompressedTokenAccounts=x,exports.parseMaybeDelegatedTransfer=re,exports.parseTokenData=ne,exports.revoke=async function(o,n,r,s,a){const i=await o.getValidityProofV0(r.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));!function(e,t){if(!e.publicKey.equals(t[0].parsed.owner))throw new Error(`Owner ${e.publicKey.toBase58()} does not match account ${t[0].parsed.owner.toBase58()}`)}(s,r),function(e){if(e.some((e=>null===e.parsed.delegate)))throw new Error("Account is not delegated")}(r);const u=await ie.revoke({payer:n.publicKey,inputCompressedTokenAccounts:r,recentInputStateRootIndices:i.rootIndices,recentValidityProof:i.compressedProof}),{blockhash:c}=await o.getLatestBlockhash(),m=t.dedupeSigner(n,[s]),p=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),u],n,c,m);return t.sendAndConfirmTx(o,p,a)},exports.revokeAccountsLayout=$,exports.selectMinCompressedTokenAccountsForDecompression=function(e,t,o=4){const[n,r,s,a]=T(e,t,o);return{selectedAccounts:n,total:r,totalLamports:s,maxPossibleAmount:a}},exports.selectMinCompressedTokenAccountsForTransfer=T,exports.selectMinCompressedTokenAccountsForTransferOrPartial=I,exports.selectSmartCompressedTokenAccountsForTransfer=function(e,o,n=4){const[r,s,a,i]=C(e,o,n);if(s.lt(t.bn(o))){const s=e.reduce(((e,t)=>e.add(t.parsed.amount)),t.bn(0));throw r.length>=n?new Error(`Account limit exceeded: max ${i.toString()} (${n} accounts) per transaction. Total balance: ${s.toString()} (${e.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${o.toString()}, available: ${s.toString()}.`)}if(0===r.length)throw new Error(A);return[r,s,a,i]},exports.selectSmartCompressedTokenAccountsForTransferOrPartial=C,exports.selectTokenAccountsForApprove=S,exports.selectTokenPoolInfo=k,exports.selectTokenPoolInfosForDecompression=b,exports.sumUpTokenAmount=te,exports.thawAccountsLayout=Z,exports.transfer=async function(o,n,r,s,a,i,u){s=t.bn(s);const c=await o.getCompressedTokenAccountsByOwner(a.publicKey,{mint:r}),[m]=T(c.items,s),p=await o.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await ie.transfer({payer:n.publicKey,inputCompressedTokenAccounts:m,toAddress:i,amount:s,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:l}=await o.getLatestBlockhash(),g=t.dedupeSigner(n,[a]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),d],n,l,g);return t.sendAndConfirmTx(o,y,u)},exports.transferAccountsLayout=z,exports.transferDelegated=async function(o,n,r,s,a,i,u){s=t.bn(s);const c=await o.getCompressedTokenAccountsByDelegate(a.publicKey,{mint:r}),[m]=T(c.items,s),p=await o.getValidityProofV0(m.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),d=await ie.transfer({payer:n.publicKey,inputCompressedTokenAccounts:m,toAddress:i,amount:s,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:l}=await o.getLatestBlockhash(),g=t.dedupeSigner(n,[a]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),d],n,l,g);return t.sendAndConfirmTx(o,y,u)},exports.validateSameTokenOwner=oe;
1
+ "use strict";var e=require("./types-BPweZlnn.cjs");require("@solana/web3.js"),require("@lightprotocol/stateless.js");var t=require("@solana/spl-token");require("buffer"),require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=e.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=e.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return e.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=e.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=e.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=e.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=e.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=e.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=e.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=e.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=e.CompressedTokenProgram,exports.CpiContextLayout=e.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=e.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=e.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=e.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return e.ExtensionType}}),exports.IDL=e.IDL,exports.MINT_TO_DISCRIMINATOR=e.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=e.POOL_SEED,exports.REVOKE_DISCRIMINATOR=e.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=e.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=e.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return e.TokenDataVersion}}),exports.addSplInterfaces=e.addSplInterfaces,exports.addTokenPoolAccountsLayout=e.addTokenPoolAccountsLayout,exports.addTokenPools=e.addTokenPools,exports.approve=e.approve,exports.approveAccountsLayout=e.approveAccountsLayout,exports.approveAndMintTo=e.approveAndMintTo,exports.batchCompressLayout=e.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=e.calculateCompressibleLoadComputeUnits,exports.checkMint=e.checkMint,exports.checkSplInterfaceInfo=e.checkSplInterfaceInfo,exports.checkTokenPoolInfo=e.checkTokenPoolInfo,exports.compress=e.compress,exports.compressSplTokenAccount=e.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=e.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=e.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=e.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=e.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=e.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=e.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=e.createAtaInterface,exports.createAtaInterfaceIdempotent=e.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=e.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=e.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=e.createDecompressInterfaceInstruction,exports.createDecompressOutputState=e.createDecompressOutputState,exports.createLoadAccountsParams=e.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=e.createLoadAtaInstructionsFromInterface,exports.createMint=e.createMint,exports.createMintInstruction=e.createMintInstruction,exports.createMintInterface=e.createMintInterface,exports.createMintToCompressedInstruction=e.createMintToCompressedInstruction,exports.createMintToInstruction=e.createMintToInstruction,exports.createMintToInterfaceInstruction=e.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=e.createRemoveMetadataKeyInstruction,exports.createSplInterface=e.createSplInterface,exports.createTokenMetadata=e.createTokenMetadata,exports.createTokenPool=e.createTokenPool,exports.createTokenPoolAccountsLayout=e.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=e.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=e.createTransferInterfaceInstruction,exports.createTransferOutputState=e.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=e.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=e.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=e.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=e.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=e.createWrapInstruction,exports.decodeApproveInstructionData=e.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=e.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=e.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=e.decodeMintToInstructionData,exports.decodeRevokeInstructionData=e.decodeRevokeInstructionData,exports.decodeTokenMetadata=e.decodeTokenMetadata,exports.decodeTransferInstructionData=e.decodeTransferInstructionData,exports.decompress=e.decompress,exports.decompressDelegated=e.decompressDelegated,exports.decompressInterface=e.decompressInterface,exports.deriveSplInterfaceInfo=e.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=e.deriveTokenPoolInfo,exports.deserializeMint=e.deserializeMint,exports.encodeApproveInstructionData=e.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=e.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=e.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=e.encodeMintToInstructionData,exports.encodeRevokeInstructionData=e.encodeRevokeInstructionData,exports.encodeTokenMetadata=e.encodeTokenMetadata,exports.encodeTransferInstructionData=e.encodeTransferInstructionData,exports.extractTokenMetadata=e.extractTokenMetadata,exports.freezeAccountsLayout=e.freezeAccountsLayout,exports.getAccountInterface=e.getAccountInterface,exports.getAssociatedTokenAddressInterface=e.getAssociatedTokenAddressInterface,exports.getMintInterface=e.getMintInterface,exports.getOrCreateAtaInterface=e.getOrCreateAtaInterface,exports.getSplInterfaceInfos=e.getSplInterfaceInfos,exports.getTokenPoolInfos=e.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=e.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=e.isSingleTokenPoolInfo,exports.mergeTokenAccounts=e.mergeTokenAccounts,exports.mintTo=e.mintTo$1,exports.mintToAccountsLayout=e.mintToAccountsLayout,exports.mintToCToken=e.mintTo,exports.mintToCompressed=e.mintToCompressed,exports.mintToInterface=e.mintToInterface,exports.mintToLayout=e.mintToLayout,exports.packCompressedTokenAccounts=e.packCompressedTokenAccounts,exports.parseCTokenCold=e.parseCTokenCold,exports.parseCTokenHot=e.parseCTokenHot,exports.parseMaybeDelegatedTransfer=e.parseMaybeDelegatedTransfer,exports.parseTokenData=e.parseTokenData,exports.removeMetadataKey=e.removeMetadataKey,exports.revoke=e.revoke,exports.revokeAccountsLayout=e.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=e.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=e.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=e.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=e.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=e.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=e.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=e.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=e.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=e.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=e.selectTokenPoolInfosForDecompression,exports.serializeMint=e.serializeMint,exports.sumUpTokenAmount=e.sumUpTokenAmount,exports.thawAccountsLayout=e.thawAccountsLayout,exports.toAccountInfo=e.toAccountInfo,exports.toOffChainMetadataJson=e.toOffChainMetadataJson,exports.toTokenPoolInfo=e.toTokenPoolInfo,exports.transfer=e.transfer,exports.transferAccountsLayout=e.transferAccountsLayout,exports.transferDelegated=e.transferDelegated,exports.transferInterface=e.transferInterface,exports.unpackMintData=e.unpackMintData,exports.unpackMintInterface=e.unpackMintInterface,exports.updateFreezeAuthority=e.updateFreezeAuthority,exports.updateMetadataAuthority=e.updateMetadataAuthority,exports.updateMetadataField=e.updateMetadataField,exports.updateMintAuthority=e.updateMintAuthority,exports.validateSameTokenOwner=e.validateSameTokenOwner,exports.wrap=e.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return t.AccountState}}),exports.createLoadAtaInstructions=async function(t,o,r,n,s,a){return e.createLoadAtaInstructions(t,o,r,n,s,a,0)},exports.getAtaInterface=async function(t,o,r,n,s,a){return e.getAtaInterface(t,o,r,n,s,a)},exports.loadAta=async function(t,o,r,n,s,a,c){return e.loadAta(t,o,r,n,s,a,c,0)};
2
2
  //# sourceMappingURL=index.cjs.map