@lightprotocol/compressed-token 0.22.1-alpha.0 → 0.22.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-DZs1jl_2.cjs +2 -0
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +2 -0
- package/dist/cjs/browser/unified/index.cjs.map +1 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +2 -0
- package/dist/cjs/node/types-CxnYquyR.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +2 -0
- package/dist/cjs/node/unified/index.cjs.map +1 -0
- package/dist/es/browser/index.js +2 -0
- package/dist/es/browser/index.js.map +1 -0
- package/dist/es/browser/types-Drp6Yu8A.js +2 -0
- package/dist/es/browser/types-Drp6Yu8A.js.map +1 -0
- package/dist/es/browser/unified/index.js +2 -0
- package/dist/es/browser/unified/index.js.map +1 -0
- package/dist/types/index.d.ts +2212 -121
- package/dist/types/unified/index.d.ts +5392 -0
- package/package.json +57 -13
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{CTOKEN_PROGRAM_ID as c,dedupeSigner as l,buildAndSignTx as C,sendAndConfirmTx as D}from"@lightprotocol/stateless.js";import{br as g,bs as E,bt as ea,bo as ta,am as sa,C as oa,l as na,g as ra,c as ca,E as ia,bu as ua,bv as pa}from"../types-Drp6Yu8A.js";export{aP as ADD_TOKEN_POOL_DISCRIMINATOR,aN as APPROVE_DISCRIMINATOR,an as Action,aK as BATCH_COMPRESS_DISCRIMINATOR,bx as COMPRESSED_MINT_SEED,aM as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aG as CPI_AUTHORITY_SEED,aI as CREATE_TOKEN_POOL_DISCRIMINATOR,bc as CompressedTokenInstructionDataApproveLayout,bd as CompressedTokenInstructionDataRevokeLayout,aU as CompressedTokenInstructionDataTransferLayout,aT as CpiContextLayout,aQ as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,aS as DelegatedTransferLayout,av as ERROR_NO_ACCOUNTS_FOUND,a0 as ExtensionType,aR as IDL,aJ as MINT_TO_DISCRIMINATOR,aF as POOL_SEED,aO as REVOKE_DISCRIMINATOR,aH as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,aL as TRANSFER_DISCRIMINATOR,aE as TokenDataVersion,a9 as addSplInterfaces,b5 as addTokenPoolAccountsLayout,aa as addTokenPools,a2 as approve,b8 as approveAccountsLayout,a3 as approveAndMintTo,aW as batchCompressLayout,d as calculateCompressibleLoadComputeUnits,aD as checkMint,al as checkSplInterfaceInfo,ar as checkTokenPoolInfo,a4 as compress,a5 as compressSplTokenAccount,aX as compressSplTokenAccountInstructionDataLayout,W as convertTokenDataToAccount,i as createAssociatedCTokenAccountIdempotentInstruction,h as createAssociatedCTokenAccountInstruction,k as createAssociatedTokenAccountInterfaceIdempotentInstruction,j as createAssociatedTokenAccountInterfaceInstruction,A as createAtaInterface,B as createAtaInterfaceIdempotent,m as createAtaInterfaceIdempotentInstruction,y as createCTokenTransferInstruction,w as createDecompressInterfaceInstruction,bn as createDecompressOutputState,a as createLoadAccountsParams,b as createLoadAtaInstructionsFromInterface,a6 as createMint,e as createMintInstruction,z as createMintInterface,o as createMintToCompressedInstruction,n as createMintToInstruction,p as createMintToInterfaceInstruction,u as createRemoveMetadataKeyInstruction,a7 as createSplInterface,f as createTokenMetadata,a8 as createTokenPool,b4 as createTokenPoolAccountsLayout,ab as createTokenProgramLookupTable,x as createTransferInterfaceInstruction,bm as createTransferOutputState,r as createUpdateFreezeAuthorityInstruction,t as createUpdateMetadataAuthorityInstruction,s as createUpdateMetadataFieldInstruction,q as createUpdateMintAuthorityInstruction,v as createWrapInstruction,bf as decodeApproveInstructionData,a$ as decodeBatchCompressInstructionData,b1 as decodeCompressSplTokenAccountInstructionData,aZ as decodeMintToInstructionData,bh as decodeRevokeInstructionData,Z as decodeTokenMetadata,b3 as decodeTransferInstructionData,ac as decompress,ai as decompressDelegated,F as decompressInterface,bw as deriveCMintAddress,ak as deriveSplInterfaceInfo,aq as deriveTokenPoolInfo,X as deserializeMint,be as encodeApproveInstructionData,a_ as encodeBatchCompressInstructionData,b0 as encodeCompressSplTokenAccountInstructionData,aY as encodeMintToInstructionData,bg as encodeRevokeInstructionData,_ as encodeTokenMetadata,b2 as encodeTransferInstructionData,$ as extractTokenMetadata,by as findMintAddress,ba as freezeAccountsLayout,S as getAccountInterface,bA as getAssociatedCTokenAddress,bz as getAssociatedCTokenAddressAndBump,P as getMintInterface,as as getTokenPoolInfos,bp as isSingleSplInterfaceInfo,bq as isSingleTokenPoolInfo,ad as mergeTokenAccounts,ae as mintTo,b6 as mintToAccountsLayout,H as mintToCToken,I as mintToCompressed,J as mintToInterface,aV as mintToLayout,aC as packCompressedTokenAccounts,U as parseCTokenCold,T as parseCTokenHot,bl as parseMaybeDelegatedTransfer,bk as parseTokenData,O as removeMetadataKey,af as revoke,b9 as revokeAccountsLayout,ax as selectMinCompressedTokenAccountsForDecompression,ay as selectMinCompressedTokenAccountsForTransfer,az as selectMinCompressedTokenAccountsForTransferOrPartial,aA as selectSmartCompressedTokenAccountsForTransfer,aB as selectSmartCompressedTokenAccountsForTransferOrPartial,ao as selectSplInterfaceInfo,ap as selectSplInterfaceInfosForDecompression,aw as selectTokenAccountsForApprove,at as selectTokenPoolInfo,au as selectTokenPoolInfosForDecompression,Y as serializeMint,bi as sumUpTokenAmount,bb as thawAccountsLayout,V as toAccountInfo,a1 as toOffChainMetadataJson,aj as toTokenPoolInfo,ag as transfer,b7 as transferAccountsLayout,ah as transferDelegated,R as unpackMintData,Q as unpackMintInterface,L as updateFreezeAuthority,N as updateMetadataAuthority,M as updateMetadataField,K as updateMintAuthority,bj as validateSameTokenOwner,G as wrap}from"../types-Drp6Yu8A.js";import{TransactionInstruction as da,ComputeBudgetProgram as Ia}from"@solana/web3.js";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";function Ta(a,e,t,s,o,n,r=t){const i=[g(o,0,2,1,6),E(o,0,3,4,n.poolIndex,n.bump)],u=ea({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:i,proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),p=[{pubkey:ta.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:s,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:a,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:n.splInterfacePda,isSigner:0,isWritable:1},{pubkey:n.tokenProgram,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0}];return new da({programId:ta.programId,keys:p,data:u})}async function la(a,e,t,s,o,n,r,c){let i=r;if(!i&&(i=(await sa(a,o)).find((a=>a.isInitialized)),!i))throw new Error(`No initialized SPL interface found for mint: ${o.toBase58()}. Please create an SPL interface via createSplInterface().`);if(!await a.getAccountInfo(t))throw new Error(`Destination account does not exist: ${t.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`);const u=oa(o,s.publicKey);await na(a,u,s,o,e,c);const p=await a.getAccountInfo(u);if(!p)throw new Error("No c-token ATA found after loading");const d=p.data.readBigUInt64LE(64);if(d===BigInt(0))throw new Error("No c-token balance to unwrap");const I=n?BigInt(n.toString()):d;if(I>d)throw new Error(`Insufficient c-token balance. Requested: ${I}, Available: ${d}`);const T=Ta(u,t,s.publicKey,o,I,i,e.publicKey),{blockhash:A}=await a.getLatestBlockhash(),f=l(e,[s]),k=C([Ia.setComputeUnitLimit({units:2e5}),T],e,A,f);return await D(a,k,c)}async function Aa(a,e,t,s,o,n){return ra(a,e,t,s,o,n,1)}function fa(a,e,t=0,s=c,o){if(!s.equals(c))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 oa(a,e,t,s,o)}async function ka(a,e,t,s,o,n){return ca(a,e,t,s,o,n,1)}async function ma(a,e,t,s,o,n,r){return na(a,e,t,s,o,n,r,1)}async function Ca(a,e,t,s,o,n,r,i=c,u,p){return ia(a,e,t,s,o,n,r,i,u,p,1)}async function Sa(a,e,t,s,o=0,n,r){return ua(a,e,t,s,o,n,r,c,pa(c),1)}export{ta as CompressedTokenProgram,ka as createLoadAtaInstructions,Ta as createUnwrapInstruction,fa as getAssociatedTokenAddressInterface,Aa as getAtaInterface,Sa as getOrCreateAtaInterface,sa as getSplInterfaceInfos,ma as loadAta,Ca as transferInterface,la as unwrap};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/v3/instructions/unwrap.ts","../../../../../../src/v3/actions/unwrap.ts","../../../../../../src/v3/unified/index.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","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","/**\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';\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 return _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n true,\n );\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"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","payer","compressions","createCompressCtoken","createDecompressSpl","poolIndex","bump","data","encodeTransfer2InstructionData","withTransactionHash","withLamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountOwnerIndex","outputQueue","maxTopUp","cpiContext","proof","inTokenData","outTokenData","inLamports","outLamports","inTlv","outTlv","keys","pubkey","CompressedTokenProgram","deriveCpiAuthorityPda","isSigner","isWritable","splInterfacePda","tokenProgram","CTOKEN_PROGRAM_ID","TransactionInstruction","programId","async","unwrap","rpc","confirmOptions","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","Error","toBase58","getAccountInfo","ctokenAta","getAssociatedTokenAddressInterface","publicKey","_loadAta","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","getAtaInterface","ata","commitment","_getAtaInterface","allowOwnerOffCurve","associatedTokenProgramId","equals","_getAssociatedTokenAddressInterface","createLoadAtaInstructions","options","_createLoadAtaInstructions","loadAta","interfaceOptions","transferInterface","_transferInterface","getOrCreateAtaInterface","_getOrCreateAtaInterface","getAtaProgramId"],"mappings":"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"}
|