@lightprotocol/compressed-token 0.22.1-alpha.3 → 0.22.1-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/types-CJcjpvYl.cjs +2 -0
- package/dist/cjs/browser/types-CJcjpvYl.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/types-BPweZlnn.cjs +2 -0
- package/dist/cjs/node/types-BPweZlnn.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/types-CUGXWKP-.js +2 -0
- package/dist/es/browser/types-CUGXWKP-.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 +10 -10
- package/dist/types/unified/index.d.ts +10 -10
- package/package.json +8 -7
- package/dist/cjs/browser/types-DZs1jl_2.cjs +0 -2
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +0 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +0 -2
- package/dist/cjs/node/types-CxnYquyR.cjs.map +0 -1
- package/dist/es/browser/types-Drp6Yu8A.js +0 -2
- package/dist/es/browser/types-Drp6Yu8A.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{CTOKEN_PROGRAM_ID as c,dedupeSigner as l,buildAndSignTx as C,sendAndConfirmTx as D}from"@lightprotocol/stateless.js";import{br as
|
|
1
|
+
import{CTOKEN_PROGRAM_ID as c,dedupeSigner as l,buildAndSignTx as C,sendAndConfirmTx as D}from"@lightprotocol/stateless.js";import{TokenAccountNotFoundError as g}from"@solana/spl-token";export{AccountState}from"@solana/spl-token";import{br as E,bs as ea,bt as ta,bo as sa,am as oa,C as na,l as ra,g as ca,c as ia,E as ua,bu as pa,bv as Ia}from"../types-CUGXWKP-.js";export{aP as ADD_TOKEN_POOL_DISCRIMINATOR,aN as APPROVE_DISCRIMINATOR,an as Action,aK as BATCH_COMPRESS_DISCRIMINATOR,bx as COMPRESSED_MINT_SEED,aM as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aG as CPI_AUTHORITY_SEED,aI as CREATE_TOKEN_POOL_DISCRIMINATOR,bc as CompressedTokenInstructionDataApproveLayout,bd as CompressedTokenInstructionDataRevokeLayout,aU as CompressedTokenInstructionDataTransferLayout,aT as CpiContextLayout,aQ as DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,aS as DelegatedTransferLayout,av as ERROR_NO_ACCOUNTS_FOUND,a0 as ExtensionType,aR as IDL,aJ as MINT_TO_DISCRIMINATOR,aF as POOL_SEED,aO as REVOKE_DISCRIMINATOR,aH as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,aL as TRANSFER_DISCRIMINATOR,aE as TokenDataVersion,a9 as addSplInterfaces,b5 as addTokenPoolAccountsLayout,aa as addTokenPools,a2 as approve,b8 as approveAccountsLayout,a3 as approveAndMintTo,aW as batchCompressLayout,d as calculateCompressibleLoadComputeUnits,aD as checkMint,al as checkSplInterfaceInfo,ar as checkTokenPoolInfo,a4 as compress,a5 as compressSplTokenAccount,aX as compressSplTokenAccountInstructionDataLayout,W as convertTokenDataToAccount,i as createAssociatedCTokenAccountIdempotentInstruction,h as createAssociatedCTokenAccountInstruction,k as createAssociatedTokenAccountInterfaceIdempotentInstruction,j as createAssociatedTokenAccountInterfaceInstruction,A as createAtaInterface,B as createAtaInterfaceIdempotent,m as createAtaInterfaceIdempotentInstruction,y as createCTokenTransferInstruction,w as createDecompressInterfaceInstruction,bn as createDecompressOutputState,a as createLoadAccountsParams,b as createLoadAtaInstructionsFromInterface,a6 as createMint,e as createMintInstruction,z as createMintInterface,o as createMintToCompressedInstruction,n as createMintToInstruction,p as createMintToInterfaceInstruction,u as createRemoveMetadataKeyInstruction,a7 as createSplInterface,f as createTokenMetadata,a8 as createTokenPool,b4 as createTokenPoolAccountsLayout,ab as createTokenProgramLookupTable,x as createTransferInterfaceInstruction,bm as createTransferOutputState,r as createUpdateFreezeAuthorityInstruction,t as createUpdateMetadataAuthorityInstruction,s as createUpdateMetadataFieldInstruction,q as createUpdateMintAuthorityInstruction,v as createWrapInstruction,bf as decodeApproveInstructionData,a$ as decodeBatchCompressInstructionData,b1 as decodeCompressSplTokenAccountInstructionData,aZ as decodeMintToInstructionData,bh as decodeRevokeInstructionData,Z as decodeTokenMetadata,b3 as decodeTransferInstructionData,ac as decompress,ai as decompressDelegated,F as decompressInterface,bw as deriveCMintAddress,ak as deriveSplInterfaceInfo,aq as deriveTokenPoolInfo,X as deserializeMint,be as encodeApproveInstructionData,a_ as encodeBatchCompressInstructionData,b0 as encodeCompressSplTokenAccountInstructionData,aY as encodeMintToInstructionData,bg as encodeRevokeInstructionData,_ as encodeTokenMetadata,b2 as encodeTransferInstructionData,$ as extractTokenMetadata,by as findMintAddress,ba as freezeAccountsLayout,S as getAccountInterface,bA as getAssociatedCTokenAddress,bz as getAssociatedCTokenAddressAndBump,P as getMintInterface,as as getTokenPoolInfos,bp as isSingleSplInterfaceInfo,bq as isSingleTokenPoolInfo,ad as mergeTokenAccounts,ae as mintTo,b6 as mintToAccountsLayout,H as mintToCToken,I as mintToCompressed,J as mintToInterface,aV as mintToLayout,aC as packCompressedTokenAccounts,U as parseCTokenCold,T as parseCTokenHot,bl as parseMaybeDelegatedTransfer,bk as parseTokenData,O as removeMetadataKey,af as revoke,b9 as revokeAccountsLayout,ax as selectMinCompressedTokenAccountsForDecompression,ay as selectMinCompressedTokenAccountsForTransfer,az as selectMinCompressedTokenAccountsForTransferOrPartial,aA as selectSmartCompressedTokenAccountsForTransfer,aB as selectSmartCompressedTokenAccountsForTransferOrPartial,ao as selectSplInterfaceInfo,ap as selectSplInterfaceInfosForDecompression,aw as selectTokenAccountsForApprove,at as selectTokenPoolInfo,au as selectTokenPoolInfosForDecompression,Y as serializeMint,bi as sumUpTokenAmount,bb as thawAccountsLayout,V as toAccountInfo,a1 as toOffChainMetadataJson,aj as toTokenPoolInfo,ag as transfer,b7 as transferAccountsLayout,ah as transferDelegated,R as unpackMintData,Q as unpackMintInterface,L as updateFreezeAuthority,N as updateMetadataAuthority,M as updateMetadataField,K as updateMintAuthority,bj as validateSameTokenOwner,G as wrap}from"../types-CUGXWKP-.js";import{TransactionInstruction as da,ComputeBudgetProgram as Ta}from"@solana/web3.js";import"@coral-xyz/borsh";function la(a,e,t,s,o,n,r=t){const i=[E(o,0,2,1,6),ea(o,0,3,4,n.poolIndex,n.bump)],u=ta({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:i,proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),p=[{pubkey:sa.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:s,isSigner:0,isWritable:0},{pubkey:t,isSigner:1,isWritable:0},{pubkey:a,isSigner:0,isWritable:1},{pubkey:e,isSigner:0,isWritable:1},{pubkey:n.splInterfacePda,isSigner:0,isWritable:1},{pubkey:n.tokenProgram,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0}];return new da({programId:sa.programId,keys:p,data:u})}async function Aa(a,e,t,s,o,n,r,c){let i=r;if(!i&&(i=(await oa(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=na(o,s.publicKey);await ra(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 I=p.data.readBigUInt64LE(64);if(I===BigInt(0))throw new Error("No c-token balance to unwrap");const d=n?BigInt(n.toString()):I;if(d>I)throw new Error(`Insufficient c-token balance. Requested: ${d}, Available: ${I}`);const T=la(u,t,s.publicKey,o,d,i,e.publicKey),{blockhash:A}=await a.getLatestBlockhash(),f=l(e,[s]),k=C([Ta.setComputeUnitLimit({units:2e5}),T],e,A,f);return await D(a,k,c)}async function fa(a,e,t,s,o,n){return ca(a,e,t,s,o,n,1)}function ka(a,e,t=0,s=c,o){if(!s.equals(c))throw new Error("Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.");return na(a,e,t,s,o)}async function ma(a,e,t,s,o,n){return ia(a,e,t,s,o,n,1)}async function Ca(a,e,t,s,o,n,r){const c=await ra(a,e,t,s,o,n,r,1);if(null===c&&!await a.getAccountInfo(e))throw new g;return c}async function Sa(a,e,t,s,o,n,r,i=c,u,p){return ua(a,e,t,s,o,n,r,i,u,p,1)}async function Ma(a,e,t,s,o=0,n,r){return pa(a,e,t,s,o,n,r,c,Ia(c),1)}export{sa as CompressedTokenProgram,ma as createLoadAtaInstructions,la as createUnwrapInstruction,ka as getAssociatedTokenAddressInterface,fa as getAtaInterface,Ma as getOrCreateAtaInterface,oa as getSplInterfaceInfos,Ca as loadAta,Sa as transferInterface,Aa 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 payer Fee payer (defaults to owner if not provided)\n * @returns TransactionInstruction to unwrap tokens\n */\nexport function createUnwrapInstruction(\n source: PublicKey,\n destination: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n amount: bigint,\n splInterfaceInfo: SplInterfaceInfo,\n payer: PublicKey = owner,\n): TransactionInstruction {\n const MINT_INDEX = 0;\n const OWNER_INDEX = 1;\n const SOURCE_INDEX = 2;\n const DESTINATION_INDEX = 3;\n const POOL_INDEX = 4;\n const _SPL_TOKEN_PROGRAM_INDEX = 5;\n const CTOKEN_PROGRAM_INDEX = 6;\n\n // Unwrap flow: compress from c-token, decompress to SPL\n const compressions: Compression[] = [\n createCompressCtoken(\n amount,\n MINT_INDEX,\n SOURCE_INDEX,\n OWNER_INDEX,\n CTOKEN_PROGRAM_INDEX,\n ),\n createDecompressSpl(\n amount,\n MINT_INDEX,\n DESTINATION_INDEX,\n POOL_INDEX,\n splInterfaceInfo.poolIndex,\n splInterfaceInfo.bump,\n ),\n ];\n\n const instructionData: Transfer2InstructionData = {\n withTransactionHash: false,\n withLamportsChangeAccountMerkleTreeIndex: false,\n lamportsChangeAccountMerkleTreeIndex: 0,\n lamportsChangeAccountOwnerIndex: 0,\n outputQueue: 0,\n maxTopUp: 0,\n cpiContext: null,\n compressions,\n proof: null,\n inTokenData: [],\n outTokenData: [],\n inLamports: null,\n outLamports: null,\n inTlv: null,\n outTlv: null,\n };\n\n const data = encodeTransfer2InstructionData(instructionData);\n\n // Account order matches wrap instruction for consistency\n const keys = [\n {\n pubkey: CompressedTokenProgram.deriveCpiAuthorityPda,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: owner, isSigner: true, isWritable: false },\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: splInterfaceInfo.splInterfacePda,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: splInterfaceInfo.tokenProgram,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: CTOKEN_PROGRAM_ID,\n isSigner: false,\n isWritable: false,\n },\n ];\n\n return new TransactionInstruction({\n programId: CompressedTokenProgram.programId,\n keys,\n data,\n });\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { createUnwrapInstruction } from '../instructions/unwrap';\nimport {\n getSplInterfaceInfos,\n SplInterfaceInfo,\n} from '../../utils/get-token-pool-infos';\nimport { getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport { loadAta as _loadAta } from './load-ata';\n\n/**\n * Unwrap c-tokens to SPL tokens.\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the c-token (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap (defaults to all)\n * @param splInterfaceInfo SPL interface info\n * @param confirmOptions Confirm options\n *\n * @returns Transaction signature\n */\nexport async function unwrap(\n rpc: Rpc,\n payer: Signer,\n destination: PublicKey,\n owner: Signer,\n mint: PublicKey,\n amount?: number | bigint | BN,\n splInterfaceInfo?: SplInterfaceInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n // 1. Get SPL interface info if not provided\n let resolvedSplInterfaceInfo = splInterfaceInfo;\n if (!resolvedSplInterfaceInfo) {\n const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint);\n resolvedSplInterfaceInfo = splInterfaceInfos.find(\n info => info.isInitialized,\n );\n\n if (!resolvedSplInterfaceInfo) {\n throw new Error(\n `No initialized SPL interface found for mint: ${mint.toBase58()}. ` +\n `Please create an SPL interface via createSplInterface().`,\n );\n }\n }\n\n const destAtaInfo = await rpc.getAccountInfo(destination);\n if (!destAtaInfo) {\n throw new Error(\n `Destination account does not exist: ${destination.toBase58()}. ` +\n `Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`,\n );\n }\n\n // Load all tokens to c-token hot ATA\n const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);\n await _loadAta(rpc, ctokenAta, owner, mint, payer, confirmOptions);\n\n // Check c-token hot balance\n const ctokenAccountInfo = await rpc.getAccountInfo(ctokenAta);\n if (!ctokenAccountInfo) {\n throw new Error('No c-token ATA found after loading');\n }\n\n // Parse c-token account balance\n const data = ctokenAccountInfo.data;\n const ctokenBalance = data.readBigUInt64LE(64);\n\n if (ctokenBalance === BigInt(0)) {\n throw new Error('No c-token balance to unwrap');\n }\n\n const unwrapAmount = amount ? BigInt(amount.toString()) : ctokenBalance;\n\n if (unwrapAmount > ctokenBalance) {\n throw new Error(\n `Insufficient c-token balance. Requested: ${unwrapAmount}, Available: ${ctokenBalance}`,\n );\n }\n\n // Build unwrap instruction\n const ix = createUnwrapInstruction(\n ctokenAta,\n destination,\n owner.publicKey,\n mint,\n unwrapAmount,\n resolvedSplInterfaceInfo,\n payer.publicKey,\n );\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n","/**\n * Exports for @lightprotocol/compressed-token/unified\n *\n * Import from `/unified` to get a single unified ATA for SPL/T22 and c-token\n * mints.\n */\nimport { PublicKey, Signer, ConfirmOptions, Commitment } from '@solana/web3.js';\nimport { Rpc, CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\n\nimport {\n getAtaInterface as _getAtaInterface,\n AccountInterface,\n} from '../get-account-interface';\nimport { getAssociatedTokenAddressInterface as _getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport {\n createLoadAtaInstructions as _createLoadAtaInstructions,\n loadAta as _loadAta,\n} from '../actions/load-ata';\nimport { transferInterface as _transferInterface } from '../actions/transfer-interface';\nimport { _getOrCreateAtaInterface } from '../actions/get-or-create-ata-interface';\nimport { getAtaProgramId } from '../ata-utils';\nimport { InterfaceOptions } from '..';\n\n/**\n * Get associated token account with unified balance\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param commitment Optional commitment level\n * @param programId Optional program ID (omit for unified behavior)\n * @returns AccountInterface with aggregated balance from all sources\n */\nexport async function getAtaInterface(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n commitment?: Commitment,\n programId?: PublicKey,\n): Promise<AccountInterface> {\n return _getAtaInterface(rpc, ata, owner, mint, commitment, programId, true);\n}\n\n/**\n * Derive the canonical token ATA for SPL/T22/c-token in the unified path.\n *\n * Enforces CTOKEN_PROGRAM_ID.\n *\n * @param mint Mint public key\n * @param owner Owner public key\n * @param allowOwnerOffCurve Allow owner to be a PDA. Default false.\n * @param programId Token program ID. Default c-token.\n * @param associatedTokenProgramId Associated token program ID. Default\n * auto-detected.\n * @returns Associated token address.\n */\nexport function getAssociatedTokenAddressInterface(\n mint: PublicKey,\n owner: PublicKey,\n allowOwnerOffCurve = false,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n associatedTokenProgramId?: PublicKey,\n): PublicKey {\n if (!programId.equals(CTOKEN_PROGRAM_ID)) {\n throw new Error(\n 'Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.',\n );\n }\n\n return _getAssociatedTokenAddressInterface(\n mint,\n owner,\n allowOwnerOffCurve,\n programId,\n associatedTokenProgramId,\n );\n}\n\n/**\n * Create instructions to load ALL token balances into a c-token ATA.\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param payer Fee payer (defaults to owner)\n * @param options Optional interface options\n * @returns Array of instructions (empty if nothing to load)\n */\nexport async function createLoadAtaInstructions(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n payer?: PublicKey,\n options?: InterfaceOptions,\n) {\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n payer,\n options,\n true,\n );\n}\n\n/**\n * Load all token balances into the c-token ATA.\n *\n * Wraps SPL/Token-2022 balances and decompresses compressed c-tokens\n * into the on-chain c-token ATA. Idempotent: returns null if nothing to load.\n *\n * @param rpc RPC connection\n * @param ata Associated token address (c-token)\n * @param owner Owner of the tokens (signer)\n * @param mint Mint public key\n * @param payer Fee payer (signer, defaults to owner)\n * @param confirmOptions Optional confirm options\n * @param interfaceOptions Optional interface options\n * @returns Transaction signature, or null if nothing to load\n */\nexport async function loadAta(\n rpc: Rpc,\n ata: PublicKey,\n owner: Signer,\n mint: PublicKey,\n payer?: Signer,\n confirmOptions?: ConfirmOptions,\n interfaceOptions?: InterfaceOptions,\n) {\n return _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n true,\n );\n}\n\n/**\n * Transfer tokens using the unified ata interface.\n *\n * Matches SPL Token's transferChecked signature order. Destination must exist.\n *\n * @param rpc RPC connection\n * @param payer Fee payer (signer)\n * @param source Source c-token ATA address\n * @param mint Mint address\n * @param destination Destination c-token ATA address (must exist)\n * @param owner Source owner (signer)\n * @param amount Amount to transfer\n * @param programId Token program ID (default: CTOKEN_PROGRAM_ID)\n * @param confirmOptions Optional confirm options\n * @param options Optional interface options\n * @returns Transaction signature\n */\nexport async function transferInterface(\n rpc: Rpc,\n payer: Signer,\n source: PublicKey,\n mint: PublicKey,\n destination: PublicKey,\n owner: Signer,\n amount: number | bigint | BN,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n confirmOptions?: ConfirmOptions,\n options?: InterfaceOptions,\n) {\n return _transferInterface(\n rpc,\n payer,\n source,\n mint,\n destination,\n owner,\n amount,\n programId,\n confirmOptions,\n options,\n true,\n );\n}\n\n/**\n * Get or create c-token ATA with unified balance detection and auto-loading.\n *\n * Enforces CTOKEN_PROGRAM_ID. Aggregates balances from:\n * - c-token hot (on-chain) account\n * - c-token cold (compressed) accounts\n * - SPL token accounts (for unified wrapping)\n * - Token-2022 accounts (for unified wrapping)\n *\n * When owner is a Signer:\n * - Creates hot ATA if it doesn't exist\n * - Loads cold (compressed) tokens into hot ATA\n * - Wraps SPL/T22 tokens into c-token ATA\n * - Returns account with all tokens ready to use\n *\n * When owner is a PublicKey:\n * - Creates hot ATA if it doesn't exist\n * - Returns aggregated balance but does NOT auto-load (can't sign)\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param mint Mint address\n * @param owner Owner (Signer for auto-load, PublicKey for read-only)\n * @param allowOwnerOffCurve Allow PDA owners (default: false)\n * @param commitment Optional commitment level\n * @param confirmOptions Optional confirm options\n * @returns AccountInterface with unified balance and source breakdown\n */\nexport async function getOrCreateAtaInterface(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: PublicKey | Signer,\n allowOwnerOffCurve = false,\n commitment?: Commitment,\n confirmOptions?: ConfirmOptions,\n): Promise<AccountInterface> {\n return _getOrCreateAtaInterface(\n rpc,\n payer,\n mint,\n owner,\n allowOwnerOffCurve,\n commitment,\n confirmOptions,\n CTOKEN_PROGRAM_ID,\n getAtaProgramId(CTOKEN_PROGRAM_ID),\n true, // wrap=true for unified path\n );\n}\n\nexport {\n getAccountInterface,\n AccountInterface,\n TokenAccountSource,\n // Note: Account is already exported from @solana/spl-token via get-account-interface\n AccountState,\n ParsedTokenAccount,\n parseCTokenHot,\n parseCTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n} from '../get-account-interface';\n\nexport {\n createLoadAccountsParams,\n createLoadAtaInstructionsFromInterface,\n calculateCompressibleLoadComputeUnits,\n CompressibleAccountInput,\n ParsedAccountInfoInterface,\n CompressibleLoadParams,\n PackedCompressedAccount,\n LoadResult,\n} from '../actions/load-ata';\n\nexport { InterfaceOptions } from '../actions/transfer-interface';\n\nexport * from '../../actions';\nexport * from '../../utils';\nexport * from '../../constants';\nexport * from '../../idl';\nexport * from '../../layout';\nexport * from '../../program';\nexport * from '../../types';\nexport * from '../derivation';\n\nexport {\n // Instructions\n createMintInstruction,\n createTokenMetadata,\n createAssociatedCTokenAccountInstruction,\n createAssociatedCTokenAccountIdempotentInstruction,\n createAssociatedTokenAccountInterfaceInstruction,\n createAssociatedTokenAccountInterfaceIdempotentInstruction,\n createAtaInterfaceIdempotentInstruction,\n createMintToInstruction,\n createMintToCompressedInstruction,\n createMintToInterfaceInstruction,\n createUpdateMintAuthorityInstruction,\n createUpdateFreezeAuthorityInstruction,\n createUpdateMetadataFieldInstruction,\n createUpdateMetadataAuthorityInstruction,\n createRemoveMetadataKeyInstruction,\n createWrapInstruction,\n createUnwrapInstruction,\n createDecompressInterfaceInstruction,\n createTransferInterfaceInstruction,\n createCTokenTransferInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n CTokenConfig,\n CreateAssociatedCTokenAccountParams,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n // getOrCreateAtaInterface is defined locally with unified behavior\n decompressInterface,\n wrap,\n unwrap,\n mintTo as mintToCToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n // Serde\n BaseMint,\n MintContext,\n MintExtension,\n TokenMetadata,\n CompressedMint,\n deserializeMint,\n serializeMint,\n decodeTokenMetadata,\n encodeTokenMetadata,\n extractTokenMetadata,\n ExtensionType,\n // Metadata formatting\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from '..';\n"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","payer","compressions","createCompressCtoken","createDecompressSpl","poolIndex","bump","data","encodeTransfer2InstructionData","withTransactionHash","withLamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountOwnerIndex","outputQueue","maxTopUp","cpiContext","proof","inTokenData","outTokenData","inLamports","outLamports","inTlv","outTlv","keys","pubkey","CompressedTokenProgram","deriveCpiAuthorityPda","isSigner","isWritable","splInterfacePda","tokenProgram","CTOKEN_PROGRAM_ID","TransactionInstruction","programId","async","unwrap","rpc","confirmOptions","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","Error","toBase58","getAccountInfo","ctokenAta","getAssociatedTokenAddressInterface","publicKey","_loadAta","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","getAtaInterface","ata","commitment","_getAtaInterface","allowOwnerOffCurve","associatedTokenProgramId","equals","_getAssociatedTokenAddressInterface","createLoadAtaInstructions","options","_createLoadAtaInstructions","loadAta","interfaceOptions","transferInterface","_transferInterface","getOrCreateAtaInterface","_getOrCreateAtaInterface","getAtaProgramId"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/v3/instructions/unwrap.ts","../../../../../../src/v3/actions/unwrap.ts","../../../../../../src/v3/unified/index.ts"],"sourcesContent":["import { PublicKey, TransactionInstruction } from '@solana/web3.js';\nimport { CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../../program';\nimport { SplInterfaceInfo } from '../../utils/get-token-pool-infos';\nimport {\n encodeTransfer2InstructionData,\n createCompressCtoken,\n createDecompressSpl,\n Transfer2InstructionData,\n Compression,\n} from '../layout/layout-transfer2';\n\n/**\n * Create an unwrap instruction that moves tokens from a c-token account to an\n * SPL/T22 account.\n *\n * @param source Source c-token account\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the source account (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap,\n * @param splInterfaceInfo SPL interface info for the decompression\n * @param payer Fee payer (defaults to owner if not provided)\n * @returns TransactionInstruction to unwrap tokens\n */\nexport function createUnwrapInstruction(\n source: PublicKey,\n destination: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n amount: bigint,\n splInterfaceInfo: SplInterfaceInfo,\n payer: PublicKey = owner,\n): TransactionInstruction {\n const MINT_INDEX = 0;\n const OWNER_INDEX = 1;\n const SOURCE_INDEX = 2;\n const DESTINATION_INDEX = 3;\n const POOL_INDEX = 4;\n const _SPL_TOKEN_PROGRAM_INDEX = 5;\n const CTOKEN_PROGRAM_INDEX = 6;\n\n // Unwrap flow: compress from c-token, decompress to SPL\n const compressions: Compression[] = [\n createCompressCtoken(\n amount,\n MINT_INDEX,\n SOURCE_INDEX,\n OWNER_INDEX,\n CTOKEN_PROGRAM_INDEX,\n ),\n createDecompressSpl(\n amount,\n MINT_INDEX,\n DESTINATION_INDEX,\n POOL_INDEX,\n splInterfaceInfo.poolIndex,\n splInterfaceInfo.bump,\n ),\n ];\n\n const instructionData: Transfer2InstructionData = {\n withTransactionHash: false,\n withLamportsChangeAccountMerkleTreeIndex: false,\n lamportsChangeAccountMerkleTreeIndex: 0,\n lamportsChangeAccountOwnerIndex: 0,\n outputQueue: 0,\n maxTopUp: 0,\n cpiContext: null,\n compressions,\n proof: null,\n inTokenData: [],\n outTokenData: [],\n inLamports: null,\n outLamports: null,\n inTlv: null,\n outTlv: null,\n };\n\n const data = encodeTransfer2InstructionData(instructionData);\n\n // Account order matches wrap instruction for consistency\n const keys = [\n {\n pubkey: CompressedTokenProgram.deriveCpiAuthorityPda,\n isSigner: false,\n isWritable: false,\n },\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: owner, isSigner: true, isWritable: false },\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: splInterfaceInfo.splInterfacePda,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: splInterfaceInfo.tokenProgram,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: CTOKEN_PROGRAM_ID,\n isSigner: false,\n isWritable: false,\n },\n ];\n\n return new TransactionInstruction({\n programId: CompressedTokenProgram.programId,\n keys,\n data,\n });\n}\n","import {\n ComputeBudgetProgram,\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n dedupeSigner,\n} from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { createUnwrapInstruction } from '../instructions/unwrap';\nimport {\n getSplInterfaceInfos,\n SplInterfaceInfo,\n} from '../../utils/get-token-pool-infos';\nimport { getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport { loadAta as _loadAta } from './load-ata';\n\n/**\n * Unwrap c-tokens to SPL tokens.\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the c-token (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap (defaults to all)\n * @param splInterfaceInfo SPL interface info\n * @param confirmOptions Confirm options\n *\n * @returns Transaction signature\n */\nexport async function unwrap(\n rpc: Rpc,\n payer: Signer,\n destination: PublicKey,\n owner: Signer,\n mint: PublicKey,\n amount?: number | bigint | BN,\n splInterfaceInfo?: SplInterfaceInfo,\n confirmOptions?: ConfirmOptions,\n): Promise<TransactionSignature> {\n // 1. Get SPL interface info if not provided\n let resolvedSplInterfaceInfo = splInterfaceInfo;\n if (!resolvedSplInterfaceInfo) {\n const splInterfaceInfos = await getSplInterfaceInfos(rpc, mint);\n resolvedSplInterfaceInfo = splInterfaceInfos.find(\n info => info.isInitialized,\n );\n\n if (!resolvedSplInterfaceInfo) {\n throw new Error(\n `No initialized SPL interface found for mint: ${mint.toBase58()}. ` +\n `Please create an SPL interface via createSplInterface().`,\n );\n }\n }\n\n const destAtaInfo = await rpc.getAccountInfo(destination);\n if (!destAtaInfo) {\n throw new Error(\n `Destination account does not exist: ${destination.toBase58()}. ` +\n `Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`,\n );\n }\n\n // Load all tokens to c-token hot ATA\n const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);\n await _loadAta(rpc, ctokenAta, owner, mint, payer, confirmOptions);\n\n // Check c-token hot balance\n const ctokenAccountInfo = await rpc.getAccountInfo(ctokenAta);\n if (!ctokenAccountInfo) {\n throw new Error('No c-token ATA found after loading');\n }\n\n // Parse c-token account balance\n const data = ctokenAccountInfo.data;\n const ctokenBalance = data.readBigUInt64LE(64);\n\n if (ctokenBalance === BigInt(0)) {\n throw new Error('No c-token balance to unwrap');\n }\n\n const unwrapAmount = amount ? BigInt(amount.toString()) : ctokenBalance;\n\n if (unwrapAmount > ctokenBalance) {\n throw new Error(\n `Insufficient c-token balance. Requested: ${unwrapAmount}, Available: ${ctokenBalance}`,\n );\n }\n\n // Build unwrap instruction\n const ix = createUnwrapInstruction(\n ctokenAta,\n destination,\n owner.publicKey,\n mint,\n unwrapAmount,\n resolvedSplInterfaceInfo,\n payer.publicKey,\n );\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const additionalSigners = dedupeSigner(payer, [owner]);\n\n const tx = buildAndSignTx(\n [ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), ix],\n payer,\n blockhash,\n additionalSigners,\n );\n\n const txId = await sendAndConfirmTx(rpc, tx, confirmOptions);\n\n return txId;\n}\n","/**\n * Exports for @lightprotocol/compressed-token/unified\n *\n * Import from `/unified` to get a single unified ATA for SPL/T22 and c-token\n * mints.\n */\nimport { PublicKey, Signer, ConfirmOptions, Commitment } from '@solana/web3.js';\nimport { Rpc, CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport BN from 'bn.js';\nimport { TokenAccountNotFoundError } from '@solana/spl-token';\n\nimport {\n getAtaInterface as _getAtaInterface,\n AccountInterface,\n} from '../get-account-interface';\nimport { getAssociatedTokenAddressInterface as _getAssociatedTokenAddressInterface } from '../get-associated-token-address-interface';\nimport {\n createLoadAtaInstructions as _createLoadAtaInstructions,\n loadAta as _loadAta,\n} from '../actions/load-ata';\nimport { transferInterface as _transferInterface } from '../actions/transfer-interface';\nimport { _getOrCreateAtaInterface } from '../actions/get-or-create-ata-interface';\nimport { getAtaProgramId } from '../ata-utils';\nimport { InterfaceOptions } from '..';\n\n/**\n * Get associated token account with unified balance\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param commitment Optional commitment level\n * @param programId Optional program ID (omit for unified behavior)\n * @returns AccountInterface with aggregated balance from all sources\n */\nexport async function getAtaInterface(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n commitment?: Commitment,\n programId?: PublicKey,\n): Promise<AccountInterface> {\n return _getAtaInterface(rpc, ata, owner, mint, commitment, programId, true);\n}\n\n/**\n * Derive the canonical token ATA for SPL/T22/c-token in the unified path.\n *\n * Enforces CTOKEN_PROGRAM_ID.\n *\n * @param mint Mint public key\n * @param owner Owner public key\n * @param allowOwnerOffCurve Allow owner to be a PDA. Default false.\n * @param programId Token program ID. Default c-token.\n * @param associatedTokenProgramId Associated token program ID. Default\n * auto-detected.\n * @returns Associated token address.\n */\nexport function getAssociatedTokenAddressInterface(\n mint: PublicKey,\n owner: PublicKey,\n allowOwnerOffCurve = false,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n associatedTokenProgramId?: PublicKey,\n): PublicKey {\n if (!programId.equals(CTOKEN_PROGRAM_ID)) {\n throw new Error(\n 'Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.',\n );\n }\n\n return _getAssociatedTokenAddressInterface(\n mint,\n owner,\n allowOwnerOffCurve,\n programId,\n associatedTokenProgramId,\n );\n}\n\n/**\n * Create instructions to load ALL token balances into a c-token ATA.\n *\n * @param rpc RPC connection\n * @param ata Associated token address\n * @param owner Owner public key\n * @param mint Mint public key\n * @param payer Fee payer (defaults to owner)\n * @param options Optional interface options\n * @returns Array of instructions (empty if nothing to load)\n */\nexport async function createLoadAtaInstructions(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n payer?: PublicKey,\n options?: InterfaceOptions,\n) {\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n payer,\n options,\n true,\n );\n}\n\n/**\n * Load all token balances into the c-token ATA.\n *\n * Wraps SPL/Token-2022 balances and decompresses compressed c-tokens\n * into the on-chain c-token ATA. Idempotent: returns null if nothing to load.\n *\n * @param rpc RPC connection\n * @param ata Associated token address (c-token)\n * @param owner Owner of the tokens (signer)\n * @param mint Mint public key\n * @param payer Fee payer (signer, defaults to owner)\n * @param confirmOptions Optional confirm options\n * @param interfaceOptions Optional interface options\n * @returns Transaction signature, or null if nothing to load\n */\nexport async function loadAta(\n rpc: Rpc,\n ata: PublicKey,\n owner: Signer,\n mint: PublicKey,\n payer?: Signer,\n confirmOptions?: ConfirmOptions,\n interfaceOptions?: InterfaceOptions,\n) {\n const signature = await _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n true,\n );\n\n // Unified semantics: if the canonical c-token ATA does not exist at all,\n // treat this as an error (caller has no balances to load and no ATA).\n if (signature === null) {\n const accountInfo = await rpc.getAccountInfo(ata);\n if (!accountInfo) {\n throw new TokenAccountNotFoundError();\n }\n }\n\n return signature;\n}\n\n/**\n * Transfer tokens using the unified ata interface.\n *\n * Matches SPL Token's transferChecked signature order. Destination must exist.\n *\n * @param rpc RPC connection\n * @param payer Fee payer (signer)\n * @param source Source c-token ATA address\n * @param mint Mint address\n * @param destination Destination c-token ATA address (must exist)\n * @param owner Source owner (signer)\n * @param amount Amount to transfer\n * @param programId Token program ID (default: CTOKEN_PROGRAM_ID)\n * @param confirmOptions Optional confirm options\n * @param options Optional interface options\n * @returns Transaction signature\n */\nexport async function transferInterface(\n rpc: Rpc,\n payer: Signer,\n source: PublicKey,\n mint: PublicKey,\n destination: PublicKey,\n owner: Signer,\n amount: number | bigint | BN,\n programId: PublicKey = CTOKEN_PROGRAM_ID,\n confirmOptions?: ConfirmOptions,\n options?: InterfaceOptions,\n) {\n return _transferInterface(\n rpc,\n payer,\n source,\n mint,\n destination,\n owner,\n amount,\n programId,\n confirmOptions,\n options,\n true,\n );\n}\n\n/**\n * Get or create c-token ATA with unified balance detection and auto-loading.\n *\n * Enforces CTOKEN_PROGRAM_ID. Aggregates balances from:\n * - c-token hot (on-chain) account\n * - c-token cold (compressed) accounts\n * - SPL token accounts (for unified wrapping)\n * - Token-2022 accounts (for unified wrapping)\n *\n * When owner is a Signer:\n * - Creates hot ATA if it doesn't exist\n * - Loads cold (compressed) tokens into hot ATA\n * - Wraps SPL/T22 tokens into c-token ATA\n * - Returns account with all tokens ready to use\n *\n * When owner is a PublicKey:\n * - Creates hot ATA if it doesn't exist\n * - Returns aggregated balance but does NOT auto-load (can't sign)\n *\n * @param rpc RPC connection\n * @param payer Fee payer\n * @param mint Mint address\n * @param owner Owner (Signer for auto-load, PublicKey for read-only)\n * @param allowOwnerOffCurve Allow PDA owners (default: false)\n * @param commitment Optional commitment level\n * @param confirmOptions Optional confirm options\n * @returns AccountInterface with unified balance and source breakdown\n */\nexport async function getOrCreateAtaInterface(\n rpc: Rpc,\n payer: Signer,\n mint: PublicKey,\n owner: PublicKey | Signer,\n allowOwnerOffCurve = false,\n commitment?: Commitment,\n confirmOptions?: ConfirmOptions,\n): Promise<AccountInterface> {\n return _getOrCreateAtaInterface(\n rpc,\n payer,\n mint,\n owner,\n allowOwnerOffCurve,\n commitment,\n confirmOptions,\n CTOKEN_PROGRAM_ID,\n getAtaProgramId(CTOKEN_PROGRAM_ID),\n true, // wrap=true for unified path\n );\n}\n\nexport {\n getAccountInterface,\n AccountInterface,\n TokenAccountSource,\n // Note: Account is already exported from @solana/spl-token via get-account-interface\n AccountState,\n ParsedTokenAccount,\n parseCTokenHot,\n parseCTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n} from '../get-account-interface';\n\nexport {\n createLoadAccountsParams,\n createLoadAtaInstructionsFromInterface,\n calculateCompressibleLoadComputeUnits,\n CompressibleAccountInput,\n ParsedAccountInfoInterface,\n CompressibleLoadParams,\n PackedCompressedAccount,\n LoadResult,\n} from '../actions/load-ata';\n\nexport { InterfaceOptions } from '../actions/transfer-interface';\n\nexport * from '../../actions';\nexport * from '../../utils';\nexport * from '../../constants';\nexport * from '../../idl';\nexport * from '../../layout';\nexport * from '../../program';\nexport * from '../../types';\nexport * from '../derivation';\n\nexport {\n // Instructions\n createMintInstruction,\n createTokenMetadata,\n createAssociatedCTokenAccountInstruction,\n createAssociatedCTokenAccountIdempotentInstruction,\n createAssociatedTokenAccountInterfaceInstruction,\n createAssociatedTokenAccountInterfaceIdempotentInstruction,\n createAtaInterfaceIdempotentInstruction,\n createMintToInstruction,\n createMintToCompressedInstruction,\n createMintToInterfaceInstruction,\n createUpdateMintAuthorityInstruction,\n createUpdateFreezeAuthorityInstruction,\n createUpdateMetadataFieldInstruction,\n createUpdateMetadataAuthorityInstruction,\n createRemoveMetadataKeyInstruction,\n createWrapInstruction,\n createUnwrapInstruction,\n createDecompressInterfaceInstruction,\n createTransferInterfaceInstruction,\n createCTokenTransferInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n CTokenConfig,\n CreateAssociatedCTokenAccountParams,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n // getOrCreateAtaInterface is defined locally with unified behavior\n decompressInterface,\n wrap,\n unwrap,\n mintTo as mintToCToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n // Serde\n BaseMint,\n MintContext,\n MintExtension,\n TokenMetadata,\n CompressedMint,\n deserializeMint,\n serializeMint,\n decodeTokenMetadata,\n encodeTokenMetadata,\n extractTokenMetadata,\n ExtensionType,\n // Metadata formatting\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from '..';\n"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","payer","compressions","createCompressCtoken","createDecompressSpl","poolIndex","bump","data","encodeTransfer2InstructionData","withTransactionHash","withLamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountOwnerIndex","outputQueue","maxTopUp","cpiContext","proof","inTokenData","outTokenData","inLamports","outLamports","inTlv","outTlv","keys","pubkey","CompressedTokenProgram","deriveCpiAuthorityPda","isSigner","isWritable","splInterfacePda","tokenProgram","CTOKEN_PROGRAM_ID","TransactionInstruction","programId","async","unwrap","rpc","confirmOptions","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","Error","toBase58","getAccountInfo","ctokenAta","getAssociatedTokenAddressInterface","publicKey","_loadAta","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","ix","blockhash","getLatestBlockhash","additionalSigners","dedupeSigner","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","getAtaInterface","ata","commitment","_getAtaInterface","allowOwnerOffCurve","associatedTokenProgramId","equals","_getAssociatedTokenAddressInterface","createLoadAtaInstructions","options","_createLoadAtaInstructions","loadAta","interfaceOptions","signature","TokenAccountNotFoundError","transferInterface","_transferInterface","getOrCreateAtaInterface","_getOrCreateAtaInterface","getAtaProgramId"],"mappings":"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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -385,8 +385,8 @@ interface BaseMint {
|
|
|
385
385
|
interface MintContext {
|
|
386
386
|
/** Protocol version for upgradability */
|
|
387
387
|
version: number;
|
|
388
|
-
/** Whether the
|
|
389
|
-
|
|
388
|
+
/** Whether the compressed mint is decompressed to a CMint Solana account */
|
|
389
|
+
cmintDecompressed: boolean;
|
|
390
390
|
/** PDA of the associated SPL mint */
|
|
391
391
|
splMint: PublicKey;
|
|
392
392
|
}
|
|
@@ -485,7 +485,7 @@ interface MintInstructionData {
|
|
|
485
485
|
mintAuthority: PublicKey | null;
|
|
486
486
|
freezeAuthority: PublicKey | null;
|
|
487
487
|
splMint: PublicKey;
|
|
488
|
-
|
|
488
|
+
cmintDecompressed: boolean;
|
|
489
489
|
version: number;
|
|
490
490
|
metadata?: MintMetadataField;
|
|
491
491
|
}
|
|
@@ -761,12 +761,11 @@ declare function createMintToInterfaceInstruction(mintInterface: MintInterface,
|
|
|
761
761
|
*
|
|
762
762
|
* @param source Source c-token account
|
|
763
763
|
* @param destination Destination c-token account
|
|
764
|
-
* @param owner Owner of the source account (signer)
|
|
764
|
+
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
765
765
|
* @param amount Amount to transfer
|
|
766
|
-
* @param payer Payer for compressible extension top-up (optional)
|
|
767
766
|
* @returns Transaction instruction for c-token transfer
|
|
768
767
|
*/
|
|
769
|
-
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint
|
|
768
|
+
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
770
769
|
/**
|
|
771
770
|
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
772
771
|
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
@@ -775,10 +774,9 @@ declare function createCTokenTransferInstruction(source: PublicKey, destination:
|
|
|
775
774
|
* @param destination Destination token account
|
|
776
775
|
* @param owner Owner of the source account (signer)
|
|
777
776
|
* @param amount Amount to transfer
|
|
778
|
-
* @param payer Payer for compressible top-up (optional)
|
|
779
777
|
* @returns instruction for c-token transfer
|
|
780
778
|
*/
|
|
781
|
-
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey
|
|
779
|
+
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
|
|
782
780
|
|
|
783
781
|
declare namespace BN {
|
|
784
782
|
type Endianness = "le" | "be";
|
|
@@ -2316,8 +2314,10 @@ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authorit
|
|
|
2316
2314
|
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2317
2315
|
|
|
2318
2316
|
/**
|
|
2319
|
-
* Merge multiple compressed token accounts for a given mint into
|
|
2320
|
-
*
|
|
2317
|
+
* Merge multiple compressed token accounts for a given mint into fewer
|
|
2318
|
+
* accounts. Each call merges up to 4 accounts (V1) or 8 accounts (V2) at a
|
|
2319
|
+
* time. Call repeatedly until only 1 account remains if full consolidation
|
|
2320
|
+
* is needed.
|
|
2321
2321
|
*
|
|
2322
2322
|
* @param rpc RPC connection to use
|
|
2323
2323
|
* @param payer Fee payer
|
|
@@ -1050,8 +1050,8 @@ interface BaseMint {
|
|
|
1050
1050
|
interface MintContext {
|
|
1051
1051
|
/** Protocol version for upgradability */
|
|
1052
1052
|
version: number;
|
|
1053
|
-
/** Whether the
|
|
1054
|
-
|
|
1053
|
+
/** Whether the compressed mint is decompressed to a CMint Solana account */
|
|
1054
|
+
cmintDecompressed: boolean;
|
|
1055
1055
|
/** PDA of the associated SPL mint */
|
|
1056
1056
|
splMint: PublicKey;
|
|
1057
1057
|
}
|
|
@@ -1150,7 +1150,7 @@ interface MintInstructionData {
|
|
|
1150
1150
|
mintAuthority: PublicKey | null;
|
|
1151
1151
|
freezeAuthority: PublicKey | null;
|
|
1152
1152
|
splMint: PublicKey;
|
|
1153
|
-
|
|
1153
|
+
cmintDecompressed: boolean;
|
|
1154
1154
|
version: number;
|
|
1155
1155
|
metadata?: MintMetadataField;
|
|
1156
1156
|
}
|
|
@@ -1426,12 +1426,11 @@ declare function createMintToInterfaceInstruction(mintInterface: MintInterface,
|
|
|
1426
1426
|
*
|
|
1427
1427
|
* @param source Source c-token account
|
|
1428
1428
|
* @param destination Destination c-token account
|
|
1429
|
-
* @param owner Owner of the source account (signer)
|
|
1429
|
+
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
1430
1430
|
* @param amount Amount to transfer
|
|
1431
|
-
* @param payer Payer for compressible extension top-up (optional)
|
|
1432
1431
|
* @returns Transaction instruction for c-token transfer
|
|
1433
1432
|
*/
|
|
1434
|
-
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint
|
|
1433
|
+
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
1435
1434
|
/**
|
|
1436
1435
|
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
1437
1436
|
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
@@ -1440,10 +1439,9 @@ declare function createCTokenTransferInstruction(source: PublicKey, destination:
|
|
|
1440
1439
|
* @param destination Destination token account
|
|
1441
1440
|
* @param owner Owner of the source account (signer)
|
|
1442
1441
|
* @param amount Amount to transfer
|
|
1443
|
-
* @param payer Payer for compressible top-up (optional)
|
|
1444
1442
|
* @returns instruction for c-token transfer
|
|
1445
1443
|
*/
|
|
1446
|
-
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey
|
|
1444
|
+
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
|
|
1447
1445
|
|
|
1448
1446
|
/**
|
|
1449
1447
|
* SPL interface PDA info.
|
|
@@ -2303,8 +2301,10 @@ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authorit
|
|
|
2303
2301
|
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2304
2302
|
|
|
2305
2303
|
/**
|
|
2306
|
-
* Merge multiple compressed token accounts for a given mint into
|
|
2307
|
-
*
|
|
2304
|
+
* Merge multiple compressed token accounts for a given mint into fewer
|
|
2305
|
+
* accounts. Each call merges up to 4 accounts (V1) or 8 accounts (V2) at a
|
|
2306
|
+
* time. Call repeatedly until only 1 account remains if full consolidation
|
|
2307
|
+
* is needed.
|
|
2308
2308
|
*
|
|
2309
2309
|
* @param rpc RPC connection to use
|
|
2310
2310
|
* @param payer Fee payer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightprotocol/compressed-token",
|
|
3
|
-
"version": "0.22.1-alpha.
|
|
3
|
+
"version": "0.22.1-alpha.5",
|
|
4
4
|
"description": "JS client to interact with the compressed-token program",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/node/index.cjs",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@coral-xyz/borsh": "^0.29.0",
|
|
43
43
|
"@solana/spl-token": ">=0.3.9",
|
|
44
44
|
"@solana/web3.js": ">=1.73.5",
|
|
45
|
-
"@lightprotocol/stateless.js": "0.22.1-alpha.
|
|
45
|
+
"@lightprotocol/stateless.js": "0.22.1-alpha.4"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@solana/buffer-layout": "^4.0.1",
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
|
-
"test": "pnpm test:e2e:legacy:all",
|
|
121
|
-
"test-ci": "pnpm test:v1 && pnpm test:v2
|
|
120
|
+
"test": "vitest run tests/unit && if [ \"$LIGHT_PROTOCOL_VERSION\" = \"V1\" ]; then pnpm test:e2e:legacy:all; else pnpm test:e2e:ctoken:all; fi",
|
|
121
|
+
"test-ci": "pnpm test:v1 && pnpm test:v2",
|
|
122
122
|
"test:v1": "pnpm build:v1 && LIGHT_PROTOCOL_VERSION=V1 vitest run tests/unit && LIGHT_PROTOCOL_VERSION=V1 pnpm test:e2e:legacy:all",
|
|
123
|
-
"test:v2": "pnpm build:v2 && LIGHT_PROTOCOL_VERSION=V2 vitest run tests/unit && LIGHT_PROTOCOL_VERSION=V2 pnpm test:e2e:
|
|
123
|
+
"test:v2": "pnpm build:v2 && LIGHT_PROTOCOL_VERSION=V2 vitest run tests/unit && LIGHT_PROTOCOL_VERSION=V2 pnpm test:e2e:ctoken:all",
|
|
124
124
|
"test:v2:ctoken": "pnpm build:v2 && LIGHT_PROTOCOL_VERSION=V2 pnpm test:e2e:ctoken:all",
|
|
125
125
|
"test-all": "vitest run",
|
|
126
126
|
"test:unit:all": "EXCLUDE_E2E=true vitest run",
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
"test:e2e:rpc-token-interop": "pnpm test-validator && vitest run tests/e2e/rpc-token-interop.test.ts --reporter=verbose",
|
|
156
156
|
"test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts --reporter=verbose",
|
|
157
157
|
"test:e2e:multi-pool": "pnpm test-validator && vitest run tests/e2e/multi-pool.test.ts --reporter=verbose",
|
|
158
|
-
"test:e2e:legacy:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/delegate.test.ts && vitest run tests/e2e/transfer-delegated.test.ts && vitest run tests/e2e/multi-pool.test.ts && vitest run tests/e2e/decompress-delegated.test.ts && pnpm test-validator-skip-prover && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/compress-spl-token-account.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/create-token-pool.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/select-accounts.test.ts",
|
|
158
|
+
"test:e2e:legacy:all": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts && vitest run tests/e2e/mint-to.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/delegate.test.ts && vitest run tests/e2e/transfer-delegated.test.ts && vitest run tests/e2e/multi-pool.test.ts && vitest run tests/e2e/decompress-delegated.test.ts && vitest run tests/e2e/merge-token-accounts.test.ts && pnpm test-validator-skip-prover && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/compress-spl-token-account.test.ts && vitest run tests/e2e/decompress.test.ts && vitest run tests/e2e/create-token-pool.test.ts && vitest run tests/e2e/approve-and-mint-to.test.ts && vitest run tests/e2e/rpc-token-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts && vitest run tests/e2e/select-accounts.test.ts",
|
|
159
159
|
"test:e2e:wrap": "pnpm test-validator && vitest run tests/e2e/wrap.test.ts --reporter=verbose",
|
|
160
160
|
"test:e2e:get-mint-interface": "pnpm test-validator && vitest run tests/e2e/get-mint-interface.test.ts --reporter=verbose",
|
|
161
161
|
"test:e2e:get-or-create-ata-interface": "pnpm test-validator && vitest run tests/e2e/get-or-create-ata-interface.test.ts --reporter=verbose",
|
|
@@ -165,7 +165,8 @@
|
|
|
165
165
|
"test:e2e:load-ata-combined": "pnpm test-validator && vitest run tests/e2e/load-ata-combined.test.ts --reporter=verbose",
|
|
166
166
|
"test:e2e:load-ata-spl-t22": "pnpm test-validator && vitest run tests/e2e/load-ata-spl-t22.test.ts --reporter=verbose",
|
|
167
167
|
"test:e2e:load-ata:all": "pnpm test-validator && vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
168
|
-
"test:e2e:ctoken:all": "pnpm test-validator && vitest run tests/e2e/create-compressed-mint.test.ts --bail=1 && vitest run tests/e2e/create-associated-ctoken.test.ts --bail=1 && vitest run tests/e2e/mint-to-ctoken.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/mint-to-compressed.test.ts --bail=1 && vitest run tests/e2e/mint-to-interface.test.ts --bail=1 && vitest run tests/e2e/mint-workflow.test.ts --bail=1 && vitest run tests/e2e/update-mint.test.ts --bail=1 && vitest run tests/e2e/update-metadata.test.ts --bail=1 && vitest run tests/e2e/compressible-load.test.ts --bail=1 && vitest run tests/e2e/wrap.test.ts --bail=1 && vitest run tests/e2e/get-mint-interface.test.ts --bail=1 && vitest run tests/e2e/get-account-interface.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
168
|
+
"test:e2e:ctoken:all": "pnpm test-validator && vitest run tests/e2e/create-compressed-mint.test.ts --bail=1 && vitest run tests/e2e/create-associated-ctoken.test.ts --bail=1 && vitest run tests/e2e/mint-to-ctoken.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/mint-to-compressed.test.ts --bail=1 && vitest run tests/e2e/mint-to-interface.test.ts --bail=1 && vitest run tests/e2e/mint-workflow.test.ts --bail=1 && vitest run tests/e2e/update-mint.test.ts --bail=1 && vitest run tests/e2e/update-metadata.test.ts --bail=1 && vitest run tests/e2e/compressible-load.test.ts --bail=1 && vitest run tests/e2e/wrap.test.ts --bail=1 && vitest run tests/e2e/get-mint-interface.test.ts --bail=1 && vitest run tests/e2e/get-account-interface.test.ts --bail=1 && vitest run tests/e2e/create-mint-interface.test.ts --bail=1 && vitest run tests/e2e/create-ata-interface.test.ts --bail=1 && vitest run tests/e2e/get-or-create-ata-interface.test.ts --bail=1 && vitest run tests/e2e/transfer-interface.test.ts --bail=1 && vitest run tests/e2e/unwrap.test.ts --bail=1 && vitest run tests/e2e/decompress2.test.ts --bail=1 && vitest run tests/e2e/payment-flows.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-standard.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-unified.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-combined.test.ts --bail=1 && pnpm test-validator && vitest run tests/e2e/load-ata-spl-t22.test.ts --bail=1",
|
|
169
|
+
"test:e2e:all": "pnpm test:e2e:legacy:all && pnpm test:e2e:ctoken:all",
|
|
169
170
|
"pull-idl": "../../scripts/push-compressed-token-idl.sh",
|
|
170
171
|
"build": "if [ \"$LIGHT_PROTOCOL_VERSION\" = \"V2\" ]; then LIGHT_PROTOCOL_VERSION=V2 pnpm build:bundle; else LIGHT_PROTOCOL_VERSION=V1 pnpm build:bundle; fi",
|
|
171
172
|
"build:bundle": "rimraf dist && rollup -c",
|