@lightprotocol/compressed-token 0.23.0-beta.3 → 0.23.0-beta.5
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/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-txB3ZZWl.cjs +2 -0
- package/dist/cjs/browser/types-txB3ZZWl.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +1 -1
- package/dist/cjs/browser/unified/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-ClkYErSH.cjs +2 -0
- package/dist/cjs/node/types-ClkYErSH.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +1 -1
- package/dist/cjs/node/unified/index.cjs.map +1 -1
- package/dist/es/browser/index.js +1 -1
- package/dist/es/browser/index.js.map +1 -1
- package/dist/es/browser/types-mr7N4aLT.js +2 -0
- package/dist/es/browser/types-mr7N4aLT.js.map +1 -0
- package/dist/es/browser/unified/index.js +1 -1
- package/dist/es/browser/unified/index.js.map +1 -1
- package/dist/types/index.d.ts +91 -9
- package/dist/types/unified/index.d.ts +91 -9
- package/package.json +4 -3
- package/dist/cjs/browser/types-BYVvBJS4.cjs +0 -2
- package/dist/cjs/browser/types-BYVvBJS4.cjs.map +0 -1
- package/dist/cjs/node/types-C6bFjLLI.cjs +0 -2
- package/dist/cjs/node/types-C6bFjLLI.cjs.map +0 -1
- package/dist/es/browser/types-Z2gqWJ9V.js +0 -2
- package/dist/es/browser/types-Z2gqWJ9V.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{SystemProgram as c,TransactionInstruction as l,ComputeBudgetProgram as k}from"@solana/web3.js";import{CTOKEN_PROGRAM_ID as C,assertBetaEnabled as E,dedupeSigner as g,buildAndSignTx as F,sendAndConfirmTx as ea}from"@lightprotocol/stateless.js";import{bJ as ta,bK as sa,bL as oa,bG as na,an as ra,C as ca,l as ia,g as ua,c as Ta,k as pa,F as Ia,bM as da,bN as la}from"../types-mr7N4aLT.js";export{aV as ADD_TOKEN_POOL_DISCRIMINATOR,aT as APPROVE_DISCRIMINATOR,ao as Action,aX as BASE_RENT_PER_EPOCH,aQ as BATCH_COMPRESS_DISCRIMINATOR,bP as COMPRESSED_MINT_SEED,b1 as COMPRESSIBLE_CTOKEN_ACCOUNT_SIZE,b3 as COMPRESSIBLE_CTOKEN_RENT_PER_EPOCH,a_ as COMPRESSION_COST,a$ as COMPRESSION_INCENTIVE,aS as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aM as CPI_AUTHORITY_SEED,aO as CREATE_TOKEN_POOL_DISCRIMINATOR,bu as CompressedTokenInstructionDataApproveLayout,bv as CompressedTokenInstructionDataRevokeLayout,ba as CompressedTokenInstructionDataTransferLayout,b9 as CpiContextLayout,aW as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,D as DEFAULT_COMPRESSIBLE_CONFIG,b4 as DEFAULT_PREPAY_EPOCHS,b5 as DEFAULT_WRITE_TOP_UP,b8 as DelegatedTransferLayout,ax as ERROR_MIXED_TREE_TYPES,aw as ERROR_NO_ACCOUNTS_FOUND,a1 as ExtensionType,b7 as IDL,aI as LIGHT_TOKEN_CONFIG,aJ as LIGHT_TOKEN_RENT_SPONSOR,aP as MINT_TO_DISCRIMINATOR,aL as POOL_SEED,aY as RENT_PER_BYTE_PER_EPOCH,aU as REVOKE_DISCRIMINATOR,aZ as SLOTS_PER_RENT_EPOCH,aN as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,b0 as TOTAL_COMPRESSION_COST,aR as TRANSFER_DISCRIMINATOR,aK as TokenDataVersion,aa as addSplInterfaces,bn as addTokenPoolAccountsLayout,ab as addTokenPools,a3 as approve,bq as approveAccountsLayout,a4 as approveAndMintTo,bc as batchCompressLayout,d as calculateCompressibleLoadComputeUnits,b6 as calculateFeePayerCostAtCreation,aH as checkMint,am as checkSplInterfaceInfo,as as checkTokenPoolInfo,a5 as compress,a6 as compressSplTokenAccount,bd as compressSplTokenAccountInstructionDataLayout,X as convertTokenDataToAccount,i as createAssociatedCTokenAccountIdempotentInstruction,h as createAssociatedCTokenAccountInstruction,j as createAssociatedTokenAccountInterfaceInstruction,A as createAtaInterface,B as createAtaInterfaceIdempotent,m as createAtaInterfaceIdempotentInstruction,y as createCTokenTransferInstruction,w as createDecompressInterfaceInstruction,bF as createDecompressOutputState,a as createLoadAccountsParams,b as createLoadAtaInstructionsFromInterface,a7 as createMint,e as createMintInstruction,z as createMintInterface,o as createMintToCompressedInstruction,n as createMintToInstruction,p as createMintToInterfaceInstruction,u as createRemoveMetadataKeyInstruction,a8 as createSplInterface,f as createTokenMetadata,a9 as createTokenPool,bm as createTokenPoolAccountsLayout,ac as createTokenProgramLookupTable,x as createTransferInterfaceInstruction,bE as createTransferOutputState,r as createUpdateFreezeAuthorityInstruction,t as createUpdateMetadataAuthorityInstruction,s as createUpdateMetadataFieldInstruction,q as createUpdateMintAuthorityInstruction,v as createWrapInstruction,bx as decodeApproveInstructionData,bh as decodeBatchCompressInstructionData,bj as decodeCompressSplTokenAccountInstructionData,bf as decodeMintToInstructionData,bz as decodeRevokeInstructionData,_ as decodeTokenMetadata,bl as decodeTransferInstructionData,ad as decompress,aj as decompressDelegated,G as decompressInterface,bO as deriveCMintAddress,al as deriveSplInterfaceInfo,ar as deriveTokenPoolInfo,Y as deserializeMint,bw as encodeApproveInstructionData,bg as encodeBatchCompressInstructionData,bi as encodeCompressSplTokenAccountInstructionData,be as encodeMintToInstructionData,by as encodeRevokeInstructionData,$ as encodeTokenMetadata,bk as encodeTransferInstructionData,a0 as extractTokenMetadata,bQ as findMintAddress,bs as freezeAccountsLayout,T as getAccountInterface,bS as getAssociatedCTokenAddress,bR as getAssociatedCTokenAddressAndBump,Q as getMintInterface,at as getTokenPoolInfos,ay as groupAccountsByTreeType,bH as isSingleSplInterfaceInfo,bI as isSingleTokenPoolInfo,ae as mergeTokenAccounts,af as mintTo,bo as mintToAccountsLayout,I as mintToCToken,J as mintToCompressed,K as mintToInterface,bb as mintToLayout,aG as packCompressedTokenAccounts,V as parseCTokenCold,U as parseCTokenHot,bD as parseMaybeDelegatedTransfer,bC as parseTokenData,P as removeMetadataKey,b2 as rentPerEpoch,ag as revoke,br as revokeAccountsLayout,az as selectAccountsByPreferredTreeType,aB as selectMinCompressedTokenAccountsForDecompression,aC as selectMinCompressedTokenAccountsForTransfer,aD as selectMinCompressedTokenAccountsForTransferOrPartial,aE as selectSmartCompressedTokenAccountsForTransfer,aF as selectSmartCompressedTokenAccountsForTransferOrPartial,ap as selectSplInterfaceInfo,aq as selectSplInterfaceInfosForDecompression,aA as selectTokenAccountsForApprove,au as selectTokenPoolInfo,av as selectTokenPoolInfosForDecompression,Z as serializeMint,bA as sumUpTokenAmount,bt as thawAccountsLayout,W as toAccountInfo,a2 as toOffChainMetadataJson,ak as toTokenPoolInfo,ah as transfer,bp as transferAccountsLayout,ai as transferDelegated,S as unpackMintData,R as unpackMintInterface,M as updateFreezeAuthority,O as updateMetadataAuthority,N as updateMetadataField,L as updateMintAuthority,bB as validateSameTokenOwner,H as wrap}from"../types-mr7N4aLT.js";import{getMint as Aa}from"@solana/spl-token";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";function fa(a,e,t,s,o,n,r,i=t){const u=[ta(o,0,2,1,6),sa(o,0,3,4,n.poolIndex,n.bump,r)],T=oa({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:u,proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),p=[{pubkey:na.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:i,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},{pubkey:c.programId,isSigner:0,isWritable:0}];return new l({programId:na.programId,keys:p,data:T})}async function ka(a,e,t,s,o,n,r,c){E();let i=r;if(!i&&(i=(await ra(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=ca(o,s.publicKey);await ia(a,u,s,o,e,c);const T=await a.getAccountInfo(u);if(!T)throw new Error("No c-token ATA found after loading");const p=T.data.readBigUInt64LE(64);if(p===BigInt(0))throw new Error("No c-token balance to unwrap");const I=n?BigInt(n.toString()):p;if(I>p)throw new Error(`Insufficient c-token balance. Requested: ${I}, Available: ${p}`);const d=await Aa(a,o,void 0,i.tokenProgram),l=fa(u,t,s.publicKey,o,I,i,d.decimals,e.publicKey),{blockhash:A}=await a.getLatestBlockhash(),b=g(e,[s]),f=F([k.setComputeUnitLimit({units:2e5}),l],e,A,b);return await ea(a,f,c)}async function Ca(a,e,t,s,o,n){return ua(a,e,t,s,o,n,1)}function ma(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 ca(a,e,t,s,o)}async function Sa(a,e,t,s,o,n){return Ta(a,e,t,s,o,n,1)}async function Ea(a,e,t,s,o,n,r){o??=t;const c=await ia(a,e,t,s,o,n,r,1);if(null===c&&!await a.getAccountInfo(e)){const r=pa(o.publicKey,e,t.publicKey,s,C),{blockhash:c}=await a.getLatestBlockhash(),i=F([k.setComputeUnitLimit({units:3e4}),r],o,c,o.publicKey.equals(t.publicKey)?[]:[t]);return ea(a,i,n)}return c}async function Oa(a,e,t,s,o,n,r,c=C,i,u){return Ia(a,e,t,s,o,n,r,c,i,u,1)}async function _a(a,e,t,s,o=0,n,r){return da(a,e,t,s,o,n,r,C,la(C),1)}export{na as CompressedTokenProgram,pa as createAssociatedTokenAccountInterfaceIdempotentInstruction,Sa as createLoadAtaInstructions,fa as createUnwrapInstruction,ma as getAssociatedTokenAddressInterface,Ca as getAtaInterface,_a as getOrCreateAtaInterface,ra as getSplInterfaceInfos,Ea as loadAta,Oa as transferInterface,ka as unwrap};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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 decimals Mint decimals (required for transfer_checked)\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 decimals: number,\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 decimals,\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 assertBetaEnabled,\n} from '@lightprotocol/stateless.js';\nimport { getMint } from '@solana/spl-token';\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 assertBetaEnabled();\n\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 // Get mint info to get decimals\n const mintInfo = await getMint(\n rpc,\n mint,\n undefined,\n resolvedSplInterfaceInfo.tokenProgram,\n );\n\n // Build unwrap instruction\n const ix = createUnwrapInstruction(\n ctokenAta,\n destination,\n owner.publicKey,\n mint,\n unwrapAmount,\n resolvedSplInterfaceInfo,\n mintInfo.decimals,\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 {\n PublicKey,\n Signer,\n ConfirmOptions,\n Commitment,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n Rpc,\n CTOKEN_PROGRAM_ID,\n buildAndSignTx,\n sendAndConfirmTx,\n} 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 { createAssociatedTokenAccountInterfaceIdempotentInstruction } from '../instructions/create-ata-interface';\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. If no balances exist and the ATA doesn't\n * exist, creates an empty ATA (idempotent).\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 ATA exists and 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 payer ??= owner;\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 // If nothing to load, ensure ATA exists (idempotent).\n if (signature === null) {\n const accountInfo = await rpc.getAccountInfo(ata);\n if (!accountInfo) {\n const ix =\n createAssociatedTokenAccountInterfaceIdempotentInstruction(\n payer.publicKey,\n ata,\n owner.publicKey,\n mint,\n CTOKEN_PROGRAM_ID,\n );\n const { blockhash } = await rpc.getLatestBlockhash();\n const tx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({ units: 30_000 }),\n ix,\n ],\n payer,\n blockhash,\n payer.publicKey.equals(owner.publicKey) ? [] : [owner],\n );\n return sendAndConfirmTx(rpc, tx, confirmOptions);\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"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","decimals","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","assertBetaEnabled","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","Error","toBase58","getAccountInfo","ctokenAta","getAssociatedTokenAddressInterface","publicKey","_loadAta","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","mintInfo","getMint","undefined","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","getAtaInterface","ata","commitment","_getAtaInterface","allowOwnerOffCurve","associatedTokenProgramId","equals","_getAssociatedTokenAddressInterface","createLoadAtaInstructions","options","_createLoadAtaInstructions","loadAta","interfaceOptions","signature","createAssociatedTokenAccountInterfaceIdempotentInstruction","transferInterface","_transferInterface","getOrCreateAtaInterface","_getOrCreateAtaInterface","getAtaProgramId"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/v3/instructions/unwrap.ts","../../../../../../src/v3/actions/unwrap.ts","../../../../../../src/v3/unified/index.ts"],"sourcesContent":["import {\n PublicKey,\n TransactionInstruction,\n SystemProgram,\n} 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 decimals Mint decimals (required for transfer_checked)\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 decimals: number,\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 decimals,\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 // System program needed for top-up CPIs when source has compressible extension\n {\n pubkey: SystemProgram.programId,\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 assertBetaEnabled,\n} from '@lightprotocol/stateless.js';\nimport { getMint } from '@solana/spl-token';\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 assertBetaEnabled();\n\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 // Get mint info to get decimals\n const mintInfo = await getMint(\n rpc,\n mint,\n undefined,\n resolvedSplInterfaceInfo.tokenProgram,\n );\n\n // Build unwrap instruction\n const ix = createUnwrapInstruction(\n ctokenAta,\n destination,\n owner.publicKey,\n mint,\n unwrapAmount,\n resolvedSplInterfaceInfo,\n mintInfo.decimals,\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 {\n PublicKey,\n Signer,\n ConfirmOptions,\n Commitment,\n ComputeBudgetProgram,\n} from '@solana/web3.js';\nimport {\n Rpc,\n CTOKEN_PROGRAM_ID,\n buildAndSignTx,\n sendAndConfirmTx,\n} 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 { createAssociatedTokenAccountInterfaceIdempotentInstruction } from '../instructions/create-ata-interface';\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. If no balances exist and the ATA doesn't\n * exist, creates an empty ATA (idempotent).\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 ATA exists and 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 payer ??= owner;\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 // If nothing to load, ensure ATA exists (idempotent).\n if (signature === null) {\n const accountInfo = await rpc.getAccountInfo(ata);\n if (!accountInfo) {\n const ix =\n createAssociatedTokenAccountInterfaceIdempotentInstruction(\n payer.publicKey,\n ata,\n owner.publicKey,\n mint,\n CTOKEN_PROGRAM_ID,\n );\n const { blockhash } = await rpc.getLatestBlockhash();\n const tx = buildAndSignTx(\n [\n ComputeBudgetProgram.setComputeUnitLimit({ units: 30_000 }),\n ix,\n ],\n payer,\n blockhash,\n payer.publicKey.equals(owner.publicKey) ? [] : [owner],\n );\n return sendAndConfirmTx(rpc, tx, confirmOptions);\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 // Constants for rent sponsor\n DEFAULT_COMPRESSIBLE_CONFIG,\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","decimals","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","SystemProgram","programId","TransactionInstruction","async","unwrap","rpc","confirmOptions","assertBetaEnabled","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","Error","toBase58","getAccountInfo","ctokenAta","getAssociatedTokenAddressInterface","publicKey","_loadAta","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","mintInfo","getMint","undefined","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","getAtaInterface","ata","commitment","_getAtaInterface","allowOwnerOffCurve","associatedTokenProgramId","equals","_getAssociatedTokenAddressInterface","createLoadAtaInstructions","options","_createLoadAtaInstructions","loadAta","interfaceOptions","signature","createAssociatedTokenAccountInterfaceIdempotentInstruction","transferInterface","_transferInterface","getOrCreateAtaInterface","_getOrCreateAtaInterface","getAtaProgramId"],"mappings":"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e0B,GAC3B,CACd,MAAMZ,EACFyB,GACIrF,EAAMiD,UACNuB,EACA7E,EAAMsD,UACNrD,EACAkC,IAEF+B,UAAEA,SAAoBzB,EAAI0B,qBAC1BG,EAAKC,EACP,CACIC,EAAqBC,oBAAoB,CAAEC,MAAO,MAClDT,GAEJ5D,EACA6D,EACA7D,EAAMiD,UAAU4B,OAAOlF,EAAMsD,WAAa,GAAK,CAACtD,IAEpD,OAAO2E,GAAiBlC,EAAK6B,EAAI5B,EACpC,CAGL,OAAO+C,CACX,CAmBOlD,eAAeoD,GAClBlD,EACApC,EACAP,EACAG,EACAF,EACAC,EACAE,EACAmC,EAAuBF,EACvBO,EACA2C,GAEA,OAAOO,GACHnD,EACApC,EACAP,EACAG,EACAF,EACAC,EACAE,EACAmC,EACAK,EACA2C,EACA,EAER,CA8BO9C,eAAesD,GAClBpD,EACApC,EACAJ,EACAD,EACAgF,EAAqB,EACrBF,EACApC,GAEA,OAAOoD,GACHrD,EACApC,EACAJ,EACAD,EACAgF,EACAF,EACApC,EACAP,EACA4D,GAAgB5D,GAChB,EAER"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -665,7 +665,6 @@ interface CompressToPubkey {
|
|
|
665
665
|
interface CompressibleConfig {
|
|
666
666
|
tokenAccountVersion: number;
|
|
667
667
|
rentPayment: number;
|
|
668
|
-
hasTopUp: number;
|
|
669
668
|
compressionOnly: number;
|
|
670
669
|
writeTopUp: number;
|
|
671
670
|
compressToAccountPubkey?: CompressToPubkey | null;
|
|
@@ -674,26 +673,60 @@ interface CreateAssociatedCTokenAccountParams {
|
|
|
674
673
|
bump: number;
|
|
675
674
|
compressibleConfig?: CompressibleConfig;
|
|
676
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* Default compressible config for c-token ATAs - matches Rust SDK defaults.
|
|
678
|
+
*
|
|
679
|
+
* - tokenAccountVersion: 3 (ShaFlat) - latest hashing scheme
|
|
680
|
+
* - rentPayment: 16 - prepay 16 epochs (~24 hours rent)
|
|
681
|
+
* - compressionOnly: 1 - required for ATAs
|
|
682
|
+
* - writeTopUp: 766 - per-write top-up (~2 epochs rent) when rent < 2 epochs
|
|
683
|
+
* - compressToAccountPubkey: null - required for ATAs
|
|
684
|
+
*
|
|
685
|
+
* Cost breakdown at ATA creation:
|
|
686
|
+
* - Rent sponsor PDA (LIGHT_TOKEN_RENT_SPONSOR) pays: rent exemption (~890,880 lamports)
|
|
687
|
+
* - Fee payer pays: compression_cost (11K) + 16 epochs rent (~6,400) = ~17,400 lamports + tx fees
|
|
688
|
+
*
|
|
689
|
+
* Per-write top-up (transfers):
|
|
690
|
+
* - When account rent is below 2 epochs, fee payer pays 766 lamports top-up
|
|
691
|
+
* - This keeps the account perpetually funded when actively used
|
|
692
|
+
*
|
|
693
|
+
* Rent calculation (272-byte compressible ctoken account):
|
|
694
|
+
* - rent_per_epoch = base_rent (128) + bytes * rent_per_byte (272 * 1) = 400 lamports
|
|
695
|
+
* - 16 epochs = 16 * 400 = 6,400 lamports (24 hours)
|
|
696
|
+
* - 2 epochs = 2 * 400 = 800 lamports (~3 hours, writeTopUp = 766 is conservative)
|
|
697
|
+
*
|
|
698
|
+
* Account size breakdown (272 bytes):
|
|
699
|
+
* - 165 bytes: SPL token base layout
|
|
700
|
+
* - 1 byte: account_type discriminator
|
|
701
|
+
* - 1 byte: Option discriminator for extensions
|
|
702
|
+
* - 4 bytes: Vec length prefix
|
|
703
|
+
* - 1 byte: extension type discriminant
|
|
704
|
+
* - 4 bytes: CompressibleExtension header (decimals_option, decimals, compression_only, is_ata)
|
|
705
|
+
* - 96 bytes: CompressionInfo struct
|
|
706
|
+
*/
|
|
707
|
+
declare const DEFAULT_COMPRESSIBLE_CONFIG: CompressibleConfig;
|
|
677
708
|
/**
|
|
678
709
|
* Create instruction for creating an associated compressed token account.
|
|
710
|
+
* Uses the default rent sponsor PDA by default.
|
|
679
711
|
*
|
|
680
712
|
* @param feePayer Fee payer public key.
|
|
681
713
|
* @param owner Owner of the associated token account.
|
|
682
714
|
* @param mint Mint address.
|
|
683
|
-
* @param compressibleConfig
|
|
684
|
-
* @param configAccount
|
|
685
|
-
* @param rentPayerPda
|
|
715
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
716
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
717
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
686
718
|
*/
|
|
687
719
|
declare function createAssociatedCTokenAccountInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
688
720
|
/**
|
|
689
721
|
* Create idempotent instruction for creating an associated compressed token account.
|
|
722
|
+
* Uses the default rent sponsor PDA by default.
|
|
690
723
|
*
|
|
691
724
|
* @param feePayer Fee payer public key.
|
|
692
725
|
* @param owner Owner of the associated token account.
|
|
693
726
|
* @param mint Mint address.
|
|
694
|
-
* @param compressibleConfig
|
|
695
|
-
* @param configAccount
|
|
696
|
-
* @param rentPayerPda
|
|
727
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
728
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
729
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
697
730
|
*/
|
|
698
731
|
declare function createAssociatedCTokenAccountIdempotentInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
699
732
|
|
|
@@ -752,6 +785,10 @@ declare const createAtaInterfaceIdempotentInstruction: typeof createAssociatedTo
|
|
|
752
785
|
*/
|
|
753
786
|
declare function createMintToInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, outputStateTreeInfo: TreeInfo, recipientAccount: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
754
787
|
|
|
788
|
+
/** Default compressible config PDA (V1) */
|
|
789
|
+
declare const LIGHT_TOKEN_CONFIG: PublicKey;
|
|
790
|
+
/** Default rent sponsor PDA (V1) */
|
|
791
|
+
declare const LIGHT_TOKEN_RENT_SPONSOR: PublicKey;
|
|
755
792
|
/**
|
|
756
793
|
* Token data version enum - mirrors Rust TokenDataVersion
|
|
757
794
|
* Used for compressed token account hashing strategy
|
|
@@ -776,6 +813,47 @@ declare const APPROVE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
|
776
813
|
declare const REVOKE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
777
814
|
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
778
815
|
declare const DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
816
|
+
/**
|
|
817
|
+
* Rent configuration constants for compressible ctoken accounts.
|
|
818
|
+
* These match the Rust SDK defaults in program-libs/compressible/src/rent/config.rs
|
|
819
|
+
*/
|
|
820
|
+
/** Base rent per epoch (lamports) */
|
|
821
|
+
declare const BASE_RENT_PER_EPOCH = 128;
|
|
822
|
+
/** Rent per byte per epoch (lamports) */
|
|
823
|
+
declare const RENT_PER_BYTE_PER_EPOCH = 1;
|
|
824
|
+
/** Slots per rent epoch (1.5 hours) */
|
|
825
|
+
declare const SLOTS_PER_RENT_EPOCH = 13500;
|
|
826
|
+
/** Compression cost (lamports) - paid at account creation */
|
|
827
|
+
declare const COMPRESSION_COST = 10000;
|
|
828
|
+
/** Compression incentive (lamports) - paid at account creation */
|
|
829
|
+
declare const COMPRESSION_INCENTIVE = 1000;
|
|
830
|
+
/** Total compression cost (COMPRESSION_COST + COMPRESSION_INCENTIVE) */
|
|
831
|
+
declare const TOTAL_COMPRESSION_COST: number;
|
|
832
|
+
/**
|
|
833
|
+
* Compressible ctoken account size in bytes.
|
|
834
|
+
* = 165 (base SPL token) + 1 (account_type) + 1 (Option) + 4 (Vec len) + 1 (ext disc) + 4 (ext header) + 96 (CompressionInfo) = 272
|
|
835
|
+
* Source: program-libs/token-interface/src/state/token/top_up.rs MIN_SIZE_WITH_COMPRESSIBLE
|
|
836
|
+
*/
|
|
837
|
+
declare const COMPRESSIBLE_CTOKEN_ACCOUNT_SIZE = 272;
|
|
838
|
+
/**
|
|
839
|
+
* Calculate rent per epoch for a given account size.
|
|
840
|
+
* Formula: base_rent + (bytes * lamports_per_byte_per_epoch)
|
|
841
|
+
*/
|
|
842
|
+
declare function rentPerEpoch(bytes: number): number;
|
|
843
|
+
/**
|
|
844
|
+
* Default rent per epoch for a compressible ctoken account (272 bytes).
|
|
845
|
+
* = 128 + 272 = 400 lamports
|
|
846
|
+
*/
|
|
847
|
+
declare const COMPRESSIBLE_CTOKEN_RENT_PER_EPOCH: number;
|
|
848
|
+
/** Default prepaid epochs (24 hours = 16 epochs * 1.5h) */
|
|
849
|
+
declare const DEFAULT_PREPAY_EPOCHS = 16;
|
|
850
|
+
/** Default write top-up (lamports) - ~2 epochs rent */
|
|
851
|
+
declare const DEFAULT_WRITE_TOP_UP = 766;
|
|
852
|
+
/**
|
|
853
|
+
* Calculate fee payer cost at ATA creation.
|
|
854
|
+
* = compression_cost (11K) + (prepay_epochs * rent_per_epoch)
|
|
855
|
+
*/
|
|
856
|
+
declare function calculateFeePayerCostAtCreation(prepayEpochs?: number, accountBytes?: number): number;
|
|
779
857
|
|
|
780
858
|
/**
|
|
781
859
|
* Create instruction for minting tokens from a c-mint to compressed accounts.
|
|
@@ -815,13 +893,17 @@ declare function createMintToInterfaceInstruction(mintInterface: MintInterface,
|
|
|
815
893
|
/**
|
|
816
894
|
* Create a c-token transfer instruction.
|
|
817
895
|
*
|
|
896
|
+
* For c-token accounts with compressible extension, the program needs
|
|
897
|
+
* system_program and fee_payer to handle rent top-ups.
|
|
898
|
+
*
|
|
818
899
|
* @param source Source c-token account
|
|
819
900
|
* @param destination Destination c-token account
|
|
820
901
|
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
821
902
|
* @param amount Amount to transfer
|
|
903
|
+
* @param feePayer Optional fee payer for top-ups (defaults to owner)
|
|
822
904
|
* @returns Transaction instruction for c-token transfer
|
|
823
905
|
*/
|
|
824
|
-
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
906
|
+
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
|
|
825
907
|
/**
|
|
826
908
|
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
827
909
|
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
@@ -5452,4 +5534,4 @@ declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: Publ
|
|
|
5452
5534
|
*/
|
|
5453
5535
|
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions): Promise<TransactionSignature | null>;
|
|
5454
5536
|
|
|
5455
|
-
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CTokenConfig, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleAccountInput, type CompressibleConfig, type CompressibleLoadParams, CpiContextLayout, type CreateAssociatedCTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, type LightCompressedToken, type LoadResult, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedCompressedAccount, type PackedTokenTransferOutputData, type ParsedAccountInfoInterface, REVOKE_DISCRIMINATOR, type RevokeParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, calculateCompressibleLoadComputeUnits, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createAssociatedCTokenAccountIdempotentInstruction, createAssociatedCTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createCTokenTransferInstruction, createDecompressInterfaceInstruction, createDecompressOutputState, createLoadAccountsParams, createLoadAtaInstructions, createLoadAtaInstructionsFromInterface, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstruction, createTransferOutputState, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, decompressInterface, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintTo$1 as mintToCToken, mintToCompressed, mintToInterface, mintToLayout, packCompressedTokenAccounts, parseCTokenCold, parseCTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectAccountsByPreferredTreeType, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, unpackMintData, unpackMintInterface, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|
|
5537
|
+
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BASE_RENT_PER_EPOCH, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESSIBLE_CTOKEN_ACCOUNT_SIZE, COMPRESSIBLE_CTOKEN_RENT_PER_EPOCH, COMPRESSION_COST, COMPRESSION_INCENTIVE, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CTokenConfig, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleAccountInput, type CompressibleConfig, type CompressibleLoadParams, CpiContextLayout, type CreateAssociatedCTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR, DEFAULT_COMPRESSIBLE_CONFIG, DEFAULT_PREPAY_EPOCHS, DEFAULT_WRITE_TOP_UP, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, LIGHT_TOKEN_CONFIG, LIGHT_TOKEN_RENT_SPONSOR, type LightCompressedToken, type LoadResult, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedCompressedAccount, type PackedTokenTransferOutputData, type ParsedAccountInfoInterface, RENT_PER_BYTE_PER_EPOCH, REVOKE_DISCRIMINATOR, type RevokeParams, SLOTS_PER_RENT_EPOCH, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TOTAL_COMPRESSION_COST, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, calculateCompressibleLoadComputeUnits, calculateFeePayerCostAtCreation, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createAssociatedCTokenAccountIdempotentInstruction, createAssociatedCTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createCTokenTransferInstruction, createDecompressInterfaceInstruction, createDecompressOutputState, createLoadAccountsParams, createLoadAtaInstructions, createLoadAtaInstructionsFromInterface, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstruction, createTransferOutputState, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, decompressInterface, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintTo$1 as mintToCToken, mintToCompressed, mintToInterface, mintToLayout, packCompressedTokenAccounts, parseCTokenCold, parseCTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, rentPerEpoch, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectAccountsByPreferredTreeType, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, unpackMintData, unpackMintInterface, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|
|
@@ -1330,7 +1330,6 @@ interface CompressToPubkey {
|
|
|
1330
1330
|
interface CompressibleConfig {
|
|
1331
1331
|
tokenAccountVersion: number;
|
|
1332
1332
|
rentPayment: number;
|
|
1333
|
-
hasTopUp: number;
|
|
1334
1333
|
compressionOnly: number;
|
|
1335
1334
|
writeTopUp: number;
|
|
1336
1335
|
compressToAccountPubkey?: CompressToPubkey | null;
|
|
@@ -1339,26 +1338,60 @@ interface CreateAssociatedCTokenAccountParams {
|
|
|
1339
1338
|
bump: number;
|
|
1340
1339
|
compressibleConfig?: CompressibleConfig;
|
|
1341
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Default compressible config for c-token ATAs - matches Rust SDK defaults.
|
|
1343
|
+
*
|
|
1344
|
+
* - tokenAccountVersion: 3 (ShaFlat) - latest hashing scheme
|
|
1345
|
+
* - rentPayment: 16 - prepay 16 epochs (~24 hours rent)
|
|
1346
|
+
* - compressionOnly: 1 - required for ATAs
|
|
1347
|
+
* - writeTopUp: 766 - per-write top-up (~2 epochs rent) when rent < 2 epochs
|
|
1348
|
+
* - compressToAccountPubkey: null - required for ATAs
|
|
1349
|
+
*
|
|
1350
|
+
* Cost breakdown at ATA creation:
|
|
1351
|
+
* - Rent sponsor PDA (LIGHT_TOKEN_RENT_SPONSOR) pays: rent exemption (~890,880 lamports)
|
|
1352
|
+
* - Fee payer pays: compression_cost (11K) + 16 epochs rent (~6,400) = ~17,400 lamports + tx fees
|
|
1353
|
+
*
|
|
1354
|
+
* Per-write top-up (transfers):
|
|
1355
|
+
* - When account rent is below 2 epochs, fee payer pays 766 lamports top-up
|
|
1356
|
+
* - This keeps the account perpetually funded when actively used
|
|
1357
|
+
*
|
|
1358
|
+
* Rent calculation (272-byte compressible ctoken account):
|
|
1359
|
+
* - rent_per_epoch = base_rent (128) + bytes * rent_per_byte (272 * 1) = 400 lamports
|
|
1360
|
+
* - 16 epochs = 16 * 400 = 6,400 lamports (24 hours)
|
|
1361
|
+
* - 2 epochs = 2 * 400 = 800 lamports (~3 hours, writeTopUp = 766 is conservative)
|
|
1362
|
+
*
|
|
1363
|
+
* Account size breakdown (272 bytes):
|
|
1364
|
+
* - 165 bytes: SPL token base layout
|
|
1365
|
+
* - 1 byte: account_type discriminator
|
|
1366
|
+
* - 1 byte: Option discriminator for extensions
|
|
1367
|
+
* - 4 bytes: Vec length prefix
|
|
1368
|
+
* - 1 byte: extension type discriminant
|
|
1369
|
+
* - 4 bytes: CompressibleExtension header (decimals_option, decimals, compression_only, is_ata)
|
|
1370
|
+
* - 96 bytes: CompressionInfo struct
|
|
1371
|
+
*/
|
|
1372
|
+
declare const DEFAULT_COMPRESSIBLE_CONFIG: CompressibleConfig;
|
|
1342
1373
|
/**
|
|
1343
1374
|
* Create instruction for creating an associated compressed token account.
|
|
1375
|
+
* Uses the default rent sponsor PDA by default.
|
|
1344
1376
|
*
|
|
1345
1377
|
* @param feePayer Fee payer public key.
|
|
1346
1378
|
* @param owner Owner of the associated token account.
|
|
1347
1379
|
* @param mint Mint address.
|
|
1348
|
-
* @param compressibleConfig
|
|
1349
|
-
* @param configAccount
|
|
1350
|
-
* @param rentPayerPda
|
|
1380
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
1381
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
1382
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
1351
1383
|
*/
|
|
1352
1384
|
declare function createAssociatedCTokenAccountInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
1353
1385
|
/**
|
|
1354
1386
|
* Create idempotent instruction for creating an associated compressed token account.
|
|
1387
|
+
* Uses the default rent sponsor PDA by default.
|
|
1355
1388
|
*
|
|
1356
1389
|
* @param feePayer Fee payer public key.
|
|
1357
1390
|
* @param owner Owner of the associated token account.
|
|
1358
1391
|
* @param mint Mint address.
|
|
1359
|
-
* @param compressibleConfig
|
|
1360
|
-
* @param configAccount
|
|
1361
|
-
* @param rentPayerPda
|
|
1392
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
1393
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
1394
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
1362
1395
|
*/
|
|
1363
1396
|
declare function createAssociatedCTokenAccountIdempotentInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
1364
1397
|
|
|
@@ -1417,6 +1450,10 @@ declare const createAtaInterfaceIdempotentInstruction: typeof createAssociatedTo
|
|
|
1417
1450
|
*/
|
|
1418
1451
|
declare function createMintToInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, outputStateTreeInfo: TreeInfo, recipientAccount: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
1419
1452
|
|
|
1453
|
+
/** Default compressible config PDA (V1) */
|
|
1454
|
+
declare const LIGHT_TOKEN_CONFIG: PublicKey;
|
|
1455
|
+
/** Default rent sponsor PDA (V1) */
|
|
1456
|
+
declare const LIGHT_TOKEN_RENT_SPONSOR: PublicKey;
|
|
1420
1457
|
/**
|
|
1421
1458
|
* Token data version enum - mirrors Rust TokenDataVersion
|
|
1422
1459
|
* Used for compressed token account hashing strategy
|
|
@@ -1441,6 +1478,47 @@ declare const APPROVE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
|
1441
1478
|
declare const REVOKE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1442
1479
|
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1443
1480
|
declare const DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1481
|
+
/**
|
|
1482
|
+
* Rent configuration constants for compressible ctoken accounts.
|
|
1483
|
+
* These match the Rust SDK defaults in program-libs/compressible/src/rent/config.rs
|
|
1484
|
+
*/
|
|
1485
|
+
/** Base rent per epoch (lamports) */
|
|
1486
|
+
declare const BASE_RENT_PER_EPOCH = 128;
|
|
1487
|
+
/** Rent per byte per epoch (lamports) */
|
|
1488
|
+
declare const RENT_PER_BYTE_PER_EPOCH = 1;
|
|
1489
|
+
/** Slots per rent epoch (1.5 hours) */
|
|
1490
|
+
declare const SLOTS_PER_RENT_EPOCH = 13500;
|
|
1491
|
+
/** Compression cost (lamports) - paid at account creation */
|
|
1492
|
+
declare const COMPRESSION_COST = 10000;
|
|
1493
|
+
/** Compression incentive (lamports) - paid at account creation */
|
|
1494
|
+
declare const COMPRESSION_INCENTIVE = 1000;
|
|
1495
|
+
/** Total compression cost (COMPRESSION_COST + COMPRESSION_INCENTIVE) */
|
|
1496
|
+
declare const TOTAL_COMPRESSION_COST: number;
|
|
1497
|
+
/**
|
|
1498
|
+
* Compressible ctoken account size in bytes.
|
|
1499
|
+
* = 165 (base SPL token) + 1 (account_type) + 1 (Option) + 4 (Vec len) + 1 (ext disc) + 4 (ext header) + 96 (CompressionInfo) = 272
|
|
1500
|
+
* Source: program-libs/token-interface/src/state/token/top_up.rs MIN_SIZE_WITH_COMPRESSIBLE
|
|
1501
|
+
*/
|
|
1502
|
+
declare const COMPRESSIBLE_CTOKEN_ACCOUNT_SIZE = 272;
|
|
1503
|
+
/**
|
|
1504
|
+
* Calculate rent per epoch for a given account size.
|
|
1505
|
+
* Formula: base_rent + (bytes * lamports_per_byte_per_epoch)
|
|
1506
|
+
*/
|
|
1507
|
+
declare function rentPerEpoch(bytes: number): number;
|
|
1508
|
+
/**
|
|
1509
|
+
* Default rent per epoch for a compressible ctoken account (272 bytes).
|
|
1510
|
+
* = 128 + 272 = 400 lamports
|
|
1511
|
+
*/
|
|
1512
|
+
declare const COMPRESSIBLE_CTOKEN_RENT_PER_EPOCH: number;
|
|
1513
|
+
/** Default prepaid epochs (24 hours = 16 epochs * 1.5h) */
|
|
1514
|
+
declare const DEFAULT_PREPAY_EPOCHS = 16;
|
|
1515
|
+
/** Default write top-up (lamports) - ~2 epochs rent */
|
|
1516
|
+
declare const DEFAULT_WRITE_TOP_UP = 766;
|
|
1517
|
+
/**
|
|
1518
|
+
* Calculate fee payer cost at ATA creation.
|
|
1519
|
+
* = compression_cost (11K) + (prepay_epochs * rent_per_epoch)
|
|
1520
|
+
*/
|
|
1521
|
+
declare function calculateFeePayerCostAtCreation(prepayEpochs?: number, accountBytes?: number): number;
|
|
1444
1522
|
|
|
1445
1523
|
/**
|
|
1446
1524
|
* Create instruction for minting tokens from a c-mint to compressed accounts.
|
|
@@ -1480,13 +1558,17 @@ declare function createMintToInterfaceInstruction(mintInterface: MintInterface,
|
|
|
1480
1558
|
/**
|
|
1481
1559
|
* Create a c-token transfer instruction.
|
|
1482
1560
|
*
|
|
1561
|
+
* For c-token accounts with compressible extension, the program needs
|
|
1562
|
+
* system_program and fee_payer to handle rent top-ups.
|
|
1563
|
+
*
|
|
1483
1564
|
* @param source Source c-token account
|
|
1484
1565
|
* @param destination Destination c-token account
|
|
1485
1566
|
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
1486
1567
|
* @param amount Amount to transfer
|
|
1568
|
+
* @param feePayer Optional fee payer for top-ups (defaults to owner)
|
|
1487
1569
|
* @returns Transaction instruction for c-token transfer
|
|
1488
1570
|
*/
|
|
1489
|
-
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
1571
|
+
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
|
|
1490
1572
|
/**
|
|
1491
1573
|
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
1492
1574
|
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
@@ -5505,4 +5587,4 @@ declare function transferInterface(rpc: Rpc, payer: Signer, source: PublicKey, m
|
|
|
5505
5587
|
*/
|
|
5506
5588
|
declare function getOrCreateAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey | Signer, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions): Promise<AccountInterface>;
|
|
5507
5589
|
|
|
5508
|
-
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESSED_MINT_SEED, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CTokenConfig, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleAccountInput, type CompressibleConfig, type CompressibleLoadParams, CpiContextLayout, type CreateAssociatedCTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, type LightCompressedToken, type LoadResult, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedCompressedAccount, type PackedTokenTransferOutputData, type ParsedAccountInfoInterface, REVOKE_DISCRIMINATOR, type RevokeParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, calculateCompressibleLoadComputeUnits, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createAssociatedCTokenAccountIdempotentInstruction, createAssociatedCTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createCTokenTransferInstruction, createDecompressInterfaceInstruction, createDecompressOutputState, createLoadAccountsParams, createLoadAtaInstructions, createLoadAtaInstructionsFromInterface, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstruction, createTransferOutputState, createUnwrapInstruction, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, decompressInterface, deriveCMintAddress, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, findMintAddress, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedCTokenAddress, getAssociatedCTokenAddressAndBump, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintTo$1 as mintToCToken, mintToCompressed, mintToInterface, mintToLayout, packCompressedTokenAccounts, parseCTokenCold, parseCTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectAccountsByPreferredTreeType, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, unpackMintData, unpackMintInterface, unwrap, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|
|
5590
|
+
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BASE_RENT_PER_EPOCH, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESSED_MINT_SEED, COMPRESSIBLE_CTOKEN_ACCOUNT_SIZE, COMPRESSIBLE_CTOKEN_RENT_PER_EPOCH, COMPRESSION_COST, COMPRESSION_INCENTIVE, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CTokenConfig, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleAccountInput, type CompressibleConfig, type CompressibleLoadParams, CpiContextLayout, type CreateAssociatedCTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR, DEFAULT_COMPRESSIBLE_CONFIG, DEFAULT_PREPAY_EPOCHS, DEFAULT_WRITE_TOP_UP, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, LIGHT_TOKEN_CONFIG, LIGHT_TOKEN_RENT_SPONSOR, type LightCompressedToken, type LoadResult, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedCompressedAccount, type PackedTokenTransferOutputData, type ParsedAccountInfoInterface, RENT_PER_BYTE_PER_EPOCH, REVOKE_DISCRIMINATOR, type RevokeParams, SLOTS_PER_RENT_EPOCH, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TOTAL_COMPRESSION_COST, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, calculateCompressibleLoadComputeUnits, calculateFeePayerCostAtCreation, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createAssociatedCTokenAccountIdempotentInstruction, createAssociatedCTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createCTokenTransferInstruction, createDecompressInterfaceInstruction, createDecompressOutputState, createLoadAccountsParams, createLoadAtaInstructions, createLoadAtaInstructionsFromInterface, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstruction, createTransferOutputState, createUnwrapInstruction, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, decompressInterface, deriveCMintAddress, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, findMintAddress, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedCTokenAddress, getAssociatedCTokenAddressAndBump, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintTo$1 as mintToCToken, mintToCompressed, mintToInterface, mintToLayout, packCompressedTokenAccounts, parseCTokenCold, parseCTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, rentPerEpoch, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectAccountsByPreferredTreeType, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, unpackMintData, unpackMintInterface, unwrap, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightprotocol/compressed-token",
|
|
3
|
-
"version": "0.23.0-beta.
|
|
3
|
+
"version": "0.23.0-beta.5",
|
|
4
4
|
"description": "JS client to interact with the compressed-token program",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/node/index.cjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@coral-xyz/borsh": "^0.29.0",
|
|
43
43
|
"@solana/spl-token": ">=0.3.9",
|
|
44
44
|
"@solana/web3.js": ">=1.73.5",
|
|
45
|
-
"@lightprotocol/stateless.js": "0.23.0-beta.
|
|
45
|
+
"@lightprotocol/stateless.js": "0.23.0-beta.5"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@solana/buffer-layout": "^4.0.1",
|
|
@@ -137,6 +137,7 @@
|
|
|
137
137
|
"test:e2e:multi-pool": "pnpm test-validator && vitest run tests/e2e/multi-pool.test.ts --reporter=verbose",
|
|
138
138
|
"test:e2e:legacy:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/delegate.test.ts && vitest run tests/e2e/transfer-delegated.test.ts && vitest run tests/e2e/multi-pool.test.ts && vitest run tests/e2e/decompress-delegated.test.ts && vitest run tests/e2e/merge-token-accounts.test.ts && pnpm test-validator-skip-prover && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/compress-spl-token-account.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/create-token-pool.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/select-accounts.test.ts",
|
|
139
139
|
"test:e2e:wrap": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/wrap.test.ts --reporter=verbose",
|
|
140
|
+
"test:e2e:interface:all": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-mint-interface.test.ts tests/e2e/create-ata-interface.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/transfer-interface.test.ts tests/e2e/wrap.test.ts tests/e2e/unwrap.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-or-create-ata-interface.test.ts --bail=1",
|
|
140
141
|
"test:e2e:get-mint-interface": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-mint-interface.test.ts --reporter=verbose",
|
|
141
142
|
"test:e2e:get-or-create-ata-interface": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-or-create-ata-interface.test.ts --reporter=verbose",
|
|
142
143
|
"test:e2e:get-account-interface": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-account-interface.test.ts --reporter=verbose",
|
|
@@ -145,7 +146,7 @@
|
|
|
145
146
|
"test:e2e:load-ata-combined": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-combined.test.ts --reporter=verbose",
|
|
146
147
|
"test:e2e:load-ata-spl-t22": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-spl-t22.test.ts --reporter=verbose",
|
|
147
148
|
"test:e2e:load-ata:all": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
148
|
-
"test:e2e:ctoken:all": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-compressed-mint.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-associated-ctoken.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-ctoken.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-compressed.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-workflow.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/update-mint.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/update-metadata.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/compressible-load.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/wrap.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-mint-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-account-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-mint-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-ata-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-or-create-ata-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/transfer-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/unwrap.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/decompress2.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/payment-flows.test.ts --bail=1 && vitest run tests/e2e/v1-v2-migration.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
149
|
+
"test:e2e:ctoken:all": "pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-compressed-mint.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-associated-ctoken.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-ctoken.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-compressed.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-to-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/mint-workflow.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/update-mint.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/update-metadata.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/compressible-load.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/wrap.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-mint-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-account-interface.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-mint-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/create-ata-interface.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/get-or-create-ata-interface.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/transfer-interface.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/unwrap.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/decompress2.test.ts --bail=1 && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/payment-flows.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/v1-v2-migration.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && LIGHT_PROTOCOL_BETA=true vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
149
150
|
"test:e2e:all": "pnpm test:e2e:legacy:all && pnpm test:e2e:ctoken:all",
|
|
150
151
|
"pull-idl": "../../scripts/push-compressed-token-idl.sh",
|
|
151
152
|
"build": "if [ \"$LIGHT_PROTOCOL_VERSION\" = \"V2\" ]; then LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle; else LIGHT_PROTOCOL_VERSION=V1 pnpm build:bundle; fi",
|