@lightprotocol/compressed-token 0.22.1-alpha.9 → 0.23.0-beta.1
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-BYVvBJS4.cjs +2 -0
- package/dist/cjs/browser/types-BYVvBJS4.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-C6bFjLLI.cjs +2 -0
- package/dist/cjs/node/types-C6bFjLLI.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-Z2gqWJ9V.js +2 -0
- package/dist/es/browser/types-Z2gqWJ9V.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 +72 -16
- package/dist/types/unified/index.d.ts +72 -16
- package/package.json +16 -36
- package/dist/cjs/browser/types-DiKZshjI.cjs +0 -2
- package/dist/cjs/browser/types-DiKZshjI.cjs.map +0 -1
- package/dist/cjs/node/types-DaJDA3il.cjs +0 -2
- package/dist/cjs/node/types-DaJDA3il.cjs.map +0 -1
- package/dist/es/browser/types-f0sdegvS.js +0 -2
- package/dist/es/browser/types-f0sdegvS.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TransactionInstruction as c,ComputeBudgetProgram as l}from"@solana/web3.js";import{CTOKEN_PROGRAM_ID as k,
|
|
1
|
+
import{TransactionInstruction as c,ComputeBudgetProgram as l}from"@solana/web3.js";import{CTOKEN_PROGRAM_ID as k,assertBetaEnabled as C,dedupeSigner as D,buildAndSignTx as g,sendAndConfirmTx as E}from"@lightprotocol/stateless.js";import{bu as ea,bv as ta,bw as sa,br as oa,am as na,C as ra,l as ca,g as ia,c as ua,k as pa,E as da,bx as Ia,by as Ta}from"../types-Z2gqWJ9V.js";export{aS as ADD_TOKEN_POOL_DISCRIMINATOR,aQ as APPROVE_DISCRIMINATOR,an as Action,aN as BATCH_COMPRESS_DISCRIMINATOR,bA as COMPRESSED_MINT_SEED,aP as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aJ as CPI_AUTHORITY_SEED,aL as CREATE_TOKEN_POOL_DISCRIMINATOR,bf as CompressedTokenInstructionDataApproveLayout,bg as CompressedTokenInstructionDataRevokeLayout,aX as CompressedTokenInstructionDataTransferLayout,aW as CpiContextLayout,aT as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,aV as DelegatedTransferLayout,aw as ERROR_MIXED_TREE_TYPES,av as ERROR_NO_ACCOUNTS_FOUND,a0 as ExtensionType,aU as IDL,aM as MINT_TO_DISCRIMINATOR,aI as POOL_SEED,aR as REVOKE_DISCRIMINATOR,aK as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,aO as TRANSFER_DISCRIMINATOR,aH as TokenDataVersion,a9 as addSplInterfaces,b8 as addTokenPoolAccountsLayout,aa as addTokenPools,a2 as approve,bb as approveAccountsLayout,a3 as approveAndMintTo,aZ as batchCompressLayout,d as calculateCompressibleLoadComputeUnits,aG as checkMint,al as checkSplInterfaceInfo,ar as checkTokenPoolInfo,a4 as compress,a5 as compressSplTokenAccount,a_ as compressSplTokenAccountInstructionDataLayout,W 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,bq as createDecompressOutputState,a as createLoadAccountsParams,b as createLoadAtaInstructionsFromInterface,a6 as createMint,e as createMintInstruction,z as createMintInterface,o as createMintToCompressedInstruction,n as createMintToInstruction,p as createMintToInterfaceInstruction,u as createRemoveMetadataKeyInstruction,a7 as createSplInterface,f as createTokenMetadata,a8 as createTokenPool,b7 as createTokenPoolAccountsLayout,ab as createTokenProgramLookupTable,x as createTransferInterfaceInstruction,bp as createTransferOutputState,r as createUpdateFreezeAuthorityInstruction,t as createUpdateMetadataAuthorityInstruction,s as createUpdateMetadataFieldInstruction,q as createUpdateMintAuthorityInstruction,v as createWrapInstruction,bi as decodeApproveInstructionData,b2 as decodeBatchCompressInstructionData,b4 as decodeCompressSplTokenAccountInstructionData,b0 as decodeMintToInstructionData,bk as decodeRevokeInstructionData,Z as decodeTokenMetadata,b6 as decodeTransferInstructionData,ac as decompress,ai as decompressDelegated,F as decompressInterface,bz as deriveCMintAddress,ak as deriveSplInterfaceInfo,aq as deriveTokenPoolInfo,X as deserializeMint,bh as encodeApproveInstructionData,b1 as encodeBatchCompressInstructionData,b3 as encodeCompressSplTokenAccountInstructionData,a$ as encodeMintToInstructionData,bj as encodeRevokeInstructionData,_ as encodeTokenMetadata,b5 as encodeTransferInstructionData,$ as extractTokenMetadata,bB as findMintAddress,bd as freezeAccountsLayout,S as getAccountInterface,bD as getAssociatedCTokenAddress,bC as getAssociatedCTokenAddressAndBump,P as getMintInterface,as as getTokenPoolInfos,ax as groupAccountsByTreeType,bs as isSingleSplInterfaceInfo,bt as isSingleTokenPoolInfo,ad as mergeTokenAccounts,ae as mintTo,b9 as mintToAccountsLayout,H as mintToCToken,I as mintToCompressed,J as mintToInterface,aY as mintToLayout,aF as packCompressedTokenAccounts,U as parseCTokenCold,T as parseCTokenHot,bo as parseMaybeDelegatedTransfer,bn as parseTokenData,O as removeMetadataKey,af as revoke,bc as revokeAccountsLayout,ay as selectAccountsByPreferredTreeType,aA as selectMinCompressedTokenAccountsForDecompression,aB as selectMinCompressedTokenAccountsForTransfer,aC as selectMinCompressedTokenAccountsForTransferOrPartial,aD as selectSmartCompressedTokenAccountsForTransfer,aE as selectSmartCompressedTokenAccountsForTransferOrPartial,ao as selectSplInterfaceInfo,ap as selectSplInterfaceInfosForDecompression,az as selectTokenAccountsForApprove,at as selectTokenPoolInfo,au as selectTokenPoolInfosForDecompression,Y as serializeMint,bl as sumUpTokenAmount,be as thawAccountsLayout,V as toAccountInfo,a1 as toOffChainMetadataJson,aj as toTokenPoolInfo,ag as transfer,ba as transferAccountsLayout,ah as transferDelegated,R as unpackMintData,Q as unpackMintInterface,L as updateFreezeAuthority,N as updateMetadataAuthority,M as updateMetadataField,K as updateMintAuthority,bm as validateSameTokenOwner,G as wrap}from"../types-Z2gqWJ9V.js";import{getMint as la}from"@solana/spl-token";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";function Aa(a,e,t,s,o,n,r,i=t){const u=[ea(o,0,2,1,6),ta(o,0,3,4,n.poolIndex,n.bump,r)],p=sa({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}),d=[{pubkey:oa.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:k,isSigner:0,isWritable:0}];return new c({programId:oa.programId,keys:d,data:p})}async function fa(a,e,t,s,o,n,r,c){C();let i=r;if(!i&&(i=(await na(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=ra(o,s.publicKey);await ca(a,u,s,o,e,c);const p=await a.getAccountInfo(u);if(!p)throw new Error("No c-token ATA found after loading");const d=p.data.readBigUInt64LE(64);if(d===BigInt(0))throw new Error("No c-token balance to unwrap");const I=n?BigInt(n.toString()):d;if(I>d)throw new Error(`Insufficient c-token balance. Requested: ${I}, Available: ${d}`);const T=await la(a,o,void 0,i.tokenProgram),A=Aa(u,t,s.publicKey,o,I,i,T.decimals,e.publicKey),{blockhash:f}=await a.getLatestBlockhash(),k=D(e,[s]),m=g([l.setComputeUnitLimit({units:2e5}),A],e,f,k);return await E(a,m,c)}async function ka(a,e,t,s,o,n){return ia(a,e,t,s,o,n,1)}function ma(a,e,t=0,s=k,o){if(!s.equals(k))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 ra(a,e,t,s,o)}async function Ca(a,e,t,s,o,n){return ua(a,e,t,s,o,n,1)}async function Sa(a,e,t,s,o,n,r){o??=t;const c=await ca(a,e,t,s,o,n,r,1);if(null===c&&!await a.getAccountInfo(e)){const r=pa(o.publicKey,e,t.publicKey,s,k),{blockhash:c}=await a.getLatestBlockhash(),i=g([l.setComputeUnitLimit({units:3e4}),r],o,c,o.publicKey.equals(t.publicKey)?[]:[t]);return E(a,i,n)}return c}async function ya(a,e,t,s,o,n,r,c=k,i,u){return da(a,e,t,s,o,n,r,c,i,u,1)}async function Ma(a,e,t,s,o=0,n,r){return Ia(a,e,t,s,o,n,r,k,Ta(k),1)}export{oa as CompressedTokenProgram,pa as createAssociatedTokenAccountInterfaceIdempotentInstruction,Ca as createLoadAtaInstructions,Aa as createUnwrapInstruction,ma as getAssociatedTokenAddressInterface,ka as getAtaInterface,Ma as getOrCreateAtaInterface,na as getSplInterfaceInfos,Sa as loadAta,ya as transferInterface,fa 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} 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 // 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","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 { 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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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { PublicKey, TransactionInstruction, Commitment, AccountInfo, Signer, ConfirmOptions, TransactionSignature, AccountMeta, Keypair, Connection } from '@solana/web3.js';
|
|
3
|
-
import { ValidityProofWithContext, AddressTreeInfo, TreeInfo, MerkleContext, Rpc, ParsedTokenAccount, CompressedAccountWithMerkleContext, ValidityProof, PackedMerkleContextLegacy, CompressedCpiContext, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
3
|
+
import { ValidityProofWithContext, AddressTreeInfo, TreeInfo, MerkleContext, Rpc, ParsedTokenAccount, CompressedAccountWithMerkleContext, ValidityProof, TreeType, PackedMerkleContextLegacy, CompressedCpiContext, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
4
4
|
export { ParsedTokenAccount as ParsedTokenAccountInterface } from '@lightprotocol/stateless.js';
|
|
5
5
|
import { Mint, Account } from '@solana/spl-token';
|
|
6
6
|
export { Account, AccountState } from '@solana/spl-token';
|
|
@@ -2373,9 +2373,13 @@ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: nu
|
|
|
2373
2373
|
|
|
2374
2374
|
/**
|
|
2375
2375
|
* Merge multiple compressed token accounts for a given mint into fewer
|
|
2376
|
-
* accounts. Each call merges up to 4 accounts
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2376
|
+
* accounts. Each call merges up to 4 accounts at a time.
|
|
2377
|
+
*
|
|
2378
|
+
* Supports automatic V1 -> V2 migration: when running in V2 mode,
|
|
2379
|
+
* merging V1 token accounts will produce a V2 output.
|
|
2380
|
+
*
|
|
2381
|
+
* IMPORTANT: Only accounts from the same tree type can be merged in one
|
|
2382
|
+
* transaction. If you have mixed V1+V2 accounts, merge them separately.
|
|
2379
2383
|
*
|
|
2380
2384
|
* @param rpc RPC connection to use
|
|
2381
2385
|
* @param payer Fee payer
|
|
@@ -2415,6 +2419,7 @@ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: Publ
|
|
|
2415
2419
|
* @param rpc Rpc connection to use
|
|
2416
2420
|
* @param payer Fee payer
|
|
2417
2421
|
* @param accounts Delegated compressed token accounts to revoke
|
|
2422
|
+
* (must all be from the same tree type)
|
|
2418
2423
|
* @param owner Owner of the compressed tokens
|
|
2419
2424
|
* @param confirmOptions Options for confirming the transaction
|
|
2420
2425
|
*
|
|
@@ -2423,7 +2428,10 @@ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: Publ
|
|
|
2423
2428
|
declare function revoke(rpc: Rpc, payer: Signer, accounts: ParsedTokenAccount[], owner: Signer, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2424
2429
|
|
|
2425
2430
|
/**
|
|
2426
|
-
* Transfer compressed tokens from one owner to another
|
|
2431
|
+
* Transfer compressed tokens from one owner to another.
|
|
2432
|
+
*
|
|
2433
|
+
* Supports automatic V1 -> V2 migration: when running in V2 mode,
|
|
2434
|
+
* V1 token inputs will produce V2 token outputs.
|
|
2427
2435
|
*
|
|
2428
2436
|
* @param rpc Rpc connection to use
|
|
2429
2437
|
* @param payer Fee payer
|
|
@@ -2471,12 +2479,54 @@ declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amo
|
|
|
2471
2479
|
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2472
2480
|
|
|
2473
2481
|
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
|
|
2482
|
+
declare const ERROR_MIXED_TREE_TYPES = "Cannot select accounts from different tree types (V1/V2) in the same batch. Filter accounts by tree type first.";
|
|
2483
|
+
/**
|
|
2484
|
+
* Options for input account selection
|
|
2485
|
+
*/
|
|
2486
|
+
interface SelectInputAccountsOptions {
|
|
2487
|
+
/**
|
|
2488
|
+
* Filter accounts by tree type. If provided, only accounts in trees of
|
|
2489
|
+
* this type will be selected. This prevents mixed V1/V2 batches which
|
|
2490
|
+
* fail at proof generation.
|
|
2491
|
+
*/
|
|
2492
|
+
treeType?: TreeType;
|
|
2493
|
+
}
|
|
2494
|
+
/**
|
|
2495
|
+
* Groups accounts by tree type for separate processing
|
|
2496
|
+
*/
|
|
2497
|
+
declare function groupAccountsByTreeType(accounts: ParsedTokenAccount[]): Map<TreeType, ParsedTokenAccount[]>;
|
|
2498
|
+
/**
|
|
2499
|
+
* Result of selectAccountsByPreferredTreeType
|
|
2500
|
+
*/
|
|
2501
|
+
interface SelectedAccountsResult {
|
|
2502
|
+
/** The selected accounts (all from the same tree type) */
|
|
2503
|
+
accounts: ParsedTokenAccount[];
|
|
2504
|
+
/** The tree type of the selected accounts */
|
|
2505
|
+
treeType: TreeType;
|
|
2506
|
+
/** Total balance of selected accounts */
|
|
2507
|
+
totalBalance: BN;
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Selects accounts by preferred tree type with automatic fallback.
|
|
2511
|
+
*
|
|
2512
|
+
* In V2 mode, prefers StateV2 accounts. Falls back to StateV1 if V2
|
|
2513
|
+
* has insufficient balance.
|
|
2514
|
+
*
|
|
2515
|
+
* This ensures all returned accounts are from the same tree type,
|
|
2516
|
+
* preventing mixed V1/V2 batch proof failures.
|
|
2517
|
+
*
|
|
2518
|
+
* @param accounts All available accounts (can be mixed V1/V2)
|
|
2519
|
+
* @param requiredAmount Minimum amount needed (optional - if not provided, returns all from preferred type)
|
|
2520
|
+
* @returns Selected accounts from a single tree type
|
|
2521
|
+
*/
|
|
2522
|
+
declare function selectAccountsByPreferredTreeType(accounts: ParsedTokenAccount[], requiredAmount?: BN): SelectedAccountsResult;
|
|
2474
2523
|
/**
|
|
2475
2524
|
* Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
|
|
2476
2525
|
*
|
|
2477
2526
|
* @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
|
|
2478
2527
|
* @param {BN} approveAmount - Amount to approve.
|
|
2479
2528
|
* @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
|
|
2529
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2480
2530
|
* @returns {[
|
|
2481
2531
|
* selectedAccounts: ParsedTokenAccount[],
|
|
2482
2532
|
* total: BN,
|
|
@@ -2488,7 +2538,7 @@ declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for t
|
|
|
2488
2538
|
* - totalLamports: Total lamports from selected accounts.
|
|
2489
2539
|
* - maxPossibleAmount: Max approvable amount given maxInputs.
|
|
2490
2540
|
*/
|
|
2491
|
-
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number): [
|
|
2541
|
+
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2492
2542
|
selectedAccounts: ParsedTokenAccount[],
|
|
2493
2543
|
total: BN,
|
|
2494
2544
|
totalLamports: BN | null,
|
|
@@ -2502,10 +2552,11 @@ declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], a
|
|
|
2502
2552
|
* @param {BN} amount Amount to decompress.
|
|
2503
2553
|
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
2504
2554
|
* is 4.
|
|
2555
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2505
2556
|
*
|
|
2506
2557
|
* @returns Returns selected accounts and their totals.
|
|
2507
2558
|
*/
|
|
2508
|
-
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number): {
|
|
2559
|
+
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): {
|
|
2509
2560
|
selectedAccounts: ParsedTokenAccount[];
|
|
2510
2561
|
total: BN;
|
|
2511
2562
|
totalLamports: BN | null;
|
|
@@ -2519,6 +2570,8 @@ declare function selectMinCompressedTokenAccountsForDecompression(accounts: Pars
|
|
|
2519
2570
|
* @param {BN} transferAmount Amount to transfer or decompress.
|
|
2520
2571
|
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
2521
2572
|
* is 4.
|
|
2573
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2574
|
+
* Use treeType to filter by V1/V2.
|
|
2522
2575
|
*
|
|
2523
2576
|
* @returns Returns selected accounts and their totals. [
|
|
2524
2577
|
* selectedAccounts: ParsedTokenAccount[],
|
|
@@ -2527,7 +2580,7 @@ declare function selectMinCompressedTokenAccountsForDecompression(accounts: Pars
|
|
|
2527
2580
|
* maxPossibleAmount: BN
|
|
2528
2581
|
* ]
|
|
2529
2582
|
*/
|
|
2530
|
-
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
2583
|
+
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2531
2584
|
selectedAccounts: ParsedTokenAccount[],
|
|
2532
2585
|
total: BN,
|
|
2533
2586
|
totalLamports: BN | null,
|
|
@@ -2555,6 +2608,8 @@ declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts:
|
|
|
2555
2608
|
* @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
|
|
2556
2609
|
* @param {BN} transferAmount - The token amount to be transferred.
|
|
2557
2610
|
* @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
|
|
2611
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2612
|
+
* Use treeType to filter by V1/V2.
|
|
2558
2613
|
* @returns {[
|
|
2559
2614
|
* selectedAccounts: ParsedTokenAccount[],
|
|
2560
2615
|
* total: BN,
|
|
@@ -2583,7 +2638,7 @@ declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts:
|
|
|
2583
2638
|
* console.log(totalLamports!.toString()); // '15'
|
|
2584
2639
|
* console.log(maxPossibleAmount.toString()); // '150'
|
|
2585
2640
|
*/
|
|
2586
|
-
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
2641
|
+
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2587
2642
|
selectedAccounts: ParsedTokenAccount[],
|
|
2588
2643
|
total: BN,
|
|
2589
2644
|
totalLamports: BN | null,
|
|
@@ -2765,9 +2820,9 @@ type PackCompressedTokenAccountsParams = {
|
|
|
2765
2820
|
/** Input state to be consumed */
|
|
2766
2821
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2767
2822
|
/**
|
|
2768
|
-
*
|
|
2769
|
-
*
|
|
2770
|
-
*
|
|
2823
|
+
* Output state tree. Required for mint/compress (no inputs).
|
|
2824
|
+
* For transfer/merge with V1 inputs: pass a V2 tree for migration.
|
|
2825
|
+
* If not provided with inputs, uses input tree.
|
|
2771
2826
|
*/
|
|
2772
2827
|
outputStateTreeInfo?: TreeInfo;
|
|
2773
2828
|
/** Optional remaining accounts to append to */
|
|
@@ -5237,7 +5292,9 @@ declare class CompressedTokenProgram {
|
|
|
5237
5292
|
*/
|
|
5238
5293
|
static approveAndMintTo({ feePayer, mint, authority, authorityTokenAccount, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
|
|
5239
5294
|
/**
|
|
5240
|
-
* Construct transfer instruction for compressed tokens
|
|
5295
|
+
* Construct transfer instruction for compressed tokens.
|
|
5296
|
+
*
|
|
5297
|
+
* V1 inputs automatically migrate to V2 outputs when in V2 mode.
|
|
5241
5298
|
*
|
|
5242
5299
|
* @param payer Fee payer.
|
|
5243
5300
|
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
@@ -5296,7 +5353,7 @@ declare class CompressedTokenProgram {
|
|
|
5296
5353
|
*/
|
|
5297
5354
|
static decompress({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, tokenPoolInfos, }: DecompressParams): Promise<TransactionInstruction>;
|
|
5298
5355
|
/**
|
|
5299
|
-
* Create `mergeTokenAccounts` instruction
|
|
5356
|
+
* Create `mergeTokenAccounts` instruction.
|
|
5300
5357
|
*
|
|
5301
5358
|
* @param payer Fee payer.
|
|
5302
5359
|
* @param owner Owner of the compressed token
|
|
@@ -5305,7 +5362,6 @@ declare class CompressedTokenProgram {
|
|
|
5305
5362
|
* @param mint SPL Token mint address.
|
|
5306
5363
|
* @param recentValidityProof Recent validity proof.
|
|
5307
5364
|
* @param recentInputStateRootIndices Recent state root indices.
|
|
5308
|
-
*
|
|
5309
5365
|
* @returns instruction
|
|
5310
5366
|
*/
|
|
5311
5367
|
static mergeTokenAccounts({ payer, owner, inputCompressedTokenAccounts, mint, recentValidityProof, recentInputStateRootIndices, }: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
|
|
@@ -5396,4 +5452,4 @@ declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: Publ
|
|
|
5396
5452
|
*/
|
|
5397
5453
|
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions): Promise<TransactionSignature | null>;
|
|
5398
5454
|
|
|
5399
|
-
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_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 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, 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, 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 };
|
|
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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
3
3
|
import { PublicKey, AccountInfo, Commitment, TransactionInstruction, Signer, AccountMeta, Keypair, ConfirmOptions, TransactionSignature, Connection } from '@solana/web3.js';
|
|
4
|
-
import { MerkleContext, CompressedAccountWithMerkleContext, Rpc, ValidityProofWithContext, AddressTreeInfo, TreeInfo, ParsedTokenAccount, ValidityProof, PackedMerkleContextLegacy, CompressedCpiContext, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
4
|
+
import { MerkleContext, CompressedAccountWithMerkleContext, Rpc, ValidityProofWithContext, AddressTreeInfo, TreeInfo, ParsedTokenAccount, ValidityProof, TreeType, PackedMerkleContextLegacy, CompressedCpiContext, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
5
5
|
export { ParsedTokenAccount } from '@lightprotocol/stateless.js';
|
|
6
6
|
import { Account, Mint } from '@solana/spl-token';
|
|
7
7
|
export { AccountState } from '@solana/spl-token';
|
|
@@ -2361,9 +2361,13 @@ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: nu
|
|
|
2361
2361
|
|
|
2362
2362
|
/**
|
|
2363
2363
|
* Merge multiple compressed token accounts for a given mint into fewer
|
|
2364
|
-
* accounts. Each call merges up to 4 accounts
|
|
2365
|
-
*
|
|
2366
|
-
*
|
|
2364
|
+
* accounts. Each call merges up to 4 accounts at a time.
|
|
2365
|
+
*
|
|
2366
|
+
* Supports automatic V1 -> V2 migration: when running in V2 mode,
|
|
2367
|
+
* merging V1 token accounts will produce a V2 output.
|
|
2368
|
+
*
|
|
2369
|
+
* IMPORTANT: Only accounts from the same tree type can be merged in one
|
|
2370
|
+
* transaction. If you have mixed V1+V2 accounts, merge them separately.
|
|
2367
2371
|
*
|
|
2368
2372
|
* @param rpc RPC connection to use
|
|
2369
2373
|
* @param payer Fee payer
|
|
@@ -2403,6 +2407,7 @@ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: Publ
|
|
|
2403
2407
|
* @param rpc Rpc connection to use
|
|
2404
2408
|
* @param payer Fee payer
|
|
2405
2409
|
* @param accounts Delegated compressed token accounts to revoke
|
|
2410
|
+
* (must all be from the same tree type)
|
|
2406
2411
|
* @param owner Owner of the compressed tokens
|
|
2407
2412
|
* @param confirmOptions Options for confirming the transaction
|
|
2408
2413
|
*
|
|
@@ -2411,7 +2416,10 @@ declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: Publ
|
|
|
2411
2416
|
declare function revoke(rpc: Rpc, payer: Signer, accounts: ParsedTokenAccount[], owner: Signer, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2412
2417
|
|
|
2413
2418
|
/**
|
|
2414
|
-
* Transfer compressed tokens from one owner to another
|
|
2419
|
+
* Transfer compressed tokens from one owner to another.
|
|
2420
|
+
*
|
|
2421
|
+
* Supports automatic V1 -> V2 migration: when running in V2 mode,
|
|
2422
|
+
* V1 token inputs will produce V2 token outputs.
|
|
2415
2423
|
*
|
|
2416
2424
|
* @param rpc Rpc connection to use
|
|
2417
2425
|
* @param payer Fee payer
|
|
@@ -2459,12 +2467,54 @@ declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amo
|
|
|
2459
2467
|
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2460
2468
|
|
|
2461
2469
|
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
|
|
2470
|
+
declare const ERROR_MIXED_TREE_TYPES = "Cannot select accounts from different tree types (V1/V2) in the same batch. Filter accounts by tree type first.";
|
|
2471
|
+
/**
|
|
2472
|
+
* Options for input account selection
|
|
2473
|
+
*/
|
|
2474
|
+
interface SelectInputAccountsOptions {
|
|
2475
|
+
/**
|
|
2476
|
+
* Filter accounts by tree type. If provided, only accounts in trees of
|
|
2477
|
+
* this type will be selected. This prevents mixed V1/V2 batches which
|
|
2478
|
+
* fail at proof generation.
|
|
2479
|
+
*/
|
|
2480
|
+
treeType?: TreeType;
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* Groups accounts by tree type for separate processing
|
|
2484
|
+
*/
|
|
2485
|
+
declare function groupAccountsByTreeType(accounts: ParsedTokenAccount[]): Map<TreeType, ParsedTokenAccount[]>;
|
|
2486
|
+
/**
|
|
2487
|
+
* Result of selectAccountsByPreferredTreeType
|
|
2488
|
+
*/
|
|
2489
|
+
interface SelectedAccountsResult {
|
|
2490
|
+
/** The selected accounts (all from the same tree type) */
|
|
2491
|
+
accounts: ParsedTokenAccount[];
|
|
2492
|
+
/** The tree type of the selected accounts */
|
|
2493
|
+
treeType: TreeType;
|
|
2494
|
+
/** Total balance of selected accounts */
|
|
2495
|
+
totalBalance: BN;
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2498
|
+
* Selects accounts by preferred tree type with automatic fallback.
|
|
2499
|
+
*
|
|
2500
|
+
* In V2 mode, prefers StateV2 accounts. Falls back to StateV1 if V2
|
|
2501
|
+
* has insufficient balance.
|
|
2502
|
+
*
|
|
2503
|
+
* This ensures all returned accounts are from the same tree type,
|
|
2504
|
+
* preventing mixed V1/V2 batch proof failures.
|
|
2505
|
+
*
|
|
2506
|
+
* @param accounts All available accounts (can be mixed V1/V2)
|
|
2507
|
+
* @param requiredAmount Minimum amount needed (optional - if not provided, returns all from preferred type)
|
|
2508
|
+
* @returns Selected accounts from a single tree type
|
|
2509
|
+
*/
|
|
2510
|
+
declare function selectAccountsByPreferredTreeType(accounts: ParsedTokenAccount[], requiredAmount?: BN): SelectedAccountsResult;
|
|
2462
2511
|
/**
|
|
2463
2512
|
* Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
|
|
2464
2513
|
*
|
|
2465
2514
|
* @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
|
|
2466
2515
|
* @param {BN} approveAmount - Amount to approve.
|
|
2467
2516
|
* @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
|
|
2517
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2468
2518
|
* @returns {[
|
|
2469
2519
|
* selectedAccounts: ParsedTokenAccount[],
|
|
2470
2520
|
* total: BN,
|
|
@@ -2476,7 +2526,7 @@ declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for t
|
|
|
2476
2526
|
* - totalLamports: Total lamports from selected accounts.
|
|
2477
2527
|
* - maxPossibleAmount: Max approvable amount given maxInputs.
|
|
2478
2528
|
*/
|
|
2479
|
-
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number): [
|
|
2529
|
+
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2480
2530
|
selectedAccounts: ParsedTokenAccount[],
|
|
2481
2531
|
total: BN,
|
|
2482
2532
|
totalLamports: BN | null,
|
|
@@ -2490,10 +2540,11 @@ declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], a
|
|
|
2490
2540
|
* @param {BN} amount Amount to decompress.
|
|
2491
2541
|
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
2492
2542
|
* is 4.
|
|
2543
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2493
2544
|
*
|
|
2494
2545
|
* @returns Returns selected accounts and their totals.
|
|
2495
2546
|
*/
|
|
2496
|
-
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number): {
|
|
2547
|
+
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): {
|
|
2497
2548
|
selectedAccounts: ParsedTokenAccount[];
|
|
2498
2549
|
total: BN;
|
|
2499
2550
|
totalLamports: BN | null;
|
|
@@ -2507,6 +2558,8 @@ declare function selectMinCompressedTokenAccountsForDecompression(accounts: Pars
|
|
|
2507
2558
|
* @param {BN} transferAmount Amount to transfer or decompress.
|
|
2508
2559
|
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
2509
2560
|
* is 4.
|
|
2561
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2562
|
+
* Use treeType to filter by V1/V2.
|
|
2510
2563
|
*
|
|
2511
2564
|
* @returns Returns selected accounts and their totals. [
|
|
2512
2565
|
* selectedAccounts: ParsedTokenAccount[],
|
|
@@ -2515,7 +2568,7 @@ declare function selectMinCompressedTokenAccountsForDecompression(accounts: Pars
|
|
|
2515
2568
|
* maxPossibleAmount: BN
|
|
2516
2569
|
* ]
|
|
2517
2570
|
*/
|
|
2518
|
-
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
2571
|
+
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2519
2572
|
selectedAccounts: ParsedTokenAccount[],
|
|
2520
2573
|
total: BN,
|
|
2521
2574
|
totalLamports: BN | null,
|
|
@@ -2543,6 +2596,8 @@ declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts:
|
|
|
2543
2596
|
* @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
|
|
2544
2597
|
* @param {BN} transferAmount - The token amount to be transferred.
|
|
2545
2598
|
* @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
|
|
2599
|
+
* @param {SelectInputAccountsOptions} [options] - Optional selection options.
|
|
2600
|
+
* Use treeType to filter by V1/V2.
|
|
2546
2601
|
* @returns {[
|
|
2547
2602
|
* selectedAccounts: ParsedTokenAccount[],
|
|
2548
2603
|
* total: BN,
|
|
@@ -2571,7 +2626,7 @@ declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts:
|
|
|
2571
2626
|
* console.log(totalLamports!.toString()); // '15'
|
|
2572
2627
|
* console.log(maxPossibleAmount.toString()); // '150'
|
|
2573
2628
|
*/
|
|
2574
|
-
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
2629
|
+
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number, options?: SelectInputAccountsOptions): [
|
|
2575
2630
|
selectedAccounts: ParsedTokenAccount[],
|
|
2576
2631
|
total: BN,
|
|
2577
2632
|
totalLamports: BN | null,
|
|
@@ -2753,9 +2808,9 @@ type PackCompressedTokenAccountsParams = {
|
|
|
2753
2808
|
/** Input state to be consumed */
|
|
2754
2809
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2755
2810
|
/**
|
|
2756
|
-
*
|
|
2757
|
-
*
|
|
2758
|
-
*
|
|
2811
|
+
* Output state tree. Required for mint/compress (no inputs).
|
|
2812
|
+
* For transfer/merge with V1 inputs: pass a V2 tree for migration.
|
|
2813
|
+
* If not provided with inputs, uses input tree.
|
|
2759
2814
|
*/
|
|
2760
2815
|
outputStateTreeInfo?: TreeInfo;
|
|
2761
2816
|
/** Optional remaining accounts to append to */
|
|
@@ -5225,7 +5280,9 @@ declare class CompressedTokenProgram {
|
|
|
5225
5280
|
*/
|
|
5226
5281
|
static approveAndMintTo({ feePayer, mint, authority, authorityTokenAccount, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
|
|
5227
5282
|
/**
|
|
5228
|
-
* Construct transfer instruction for compressed tokens
|
|
5283
|
+
* Construct transfer instruction for compressed tokens.
|
|
5284
|
+
*
|
|
5285
|
+
* V1 inputs automatically migrate to V2 outputs when in V2 mode.
|
|
5229
5286
|
*
|
|
5230
5287
|
* @param payer Fee payer.
|
|
5231
5288
|
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
@@ -5284,7 +5341,7 @@ declare class CompressedTokenProgram {
|
|
|
5284
5341
|
*/
|
|
5285
5342
|
static decompress({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, tokenPoolInfos, }: DecompressParams): Promise<TransactionInstruction>;
|
|
5286
5343
|
/**
|
|
5287
|
-
* Create `mergeTokenAccounts` instruction
|
|
5344
|
+
* Create `mergeTokenAccounts` instruction.
|
|
5288
5345
|
*
|
|
5289
5346
|
* @param payer Fee payer.
|
|
5290
5347
|
* @param owner Owner of the compressed token
|
|
@@ -5293,7 +5350,6 @@ declare class CompressedTokenProgram {
|
|
|
5293
5350
|
* @param mint SPL Token mint address.
|
|
5294
5351
|
* @param recentValidityProof Recent validity proof.
|
|
5295
5352
|
* @param recentInputStateRootIndices Recent state root indices.
|
|
5296
|
-
*
|
|
5297
5353
|
* @returns instruction
|
|
5298
5354
|
*/
|
|
5299
5355
|
static mergeTokenAccounts({ payer, owner, inputCompressedTokenAccounts, mint, recentValidityProof, recentInputStateRootIndices, }: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
|
|
@@ -5449,4 +5505,4 @@ declare function transferInterface(rpc: Rpc, payer: Signer, source: PublicKey, m
|
|
|
5449
5505
|
*/
|
|
5450
5506
|
declare function getOrCreateAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey | Signer, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions): Promise<AccountInterface>;
|
|
5451
5507
|
|
|
5452
|
-
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_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 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, 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, 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 };
|
|
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 };
|