@lightprotocol/compressed-token 0.22.1-alpha.9 → 0.23.0-beta.10

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.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@solana/web3.js"),t=require("@lightprotocol/stateless.js"),o=require("../types-DaJDA3il.cjs"),r=require("@solana/spl-token");function n(r,n,s,a,c,p,i,u=s){const I={withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[o.createCompressCtoken(c,0,2,1,6),o.createDecompressSpl(c,0,3,4,p.poolIndex,p.bump,i)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null},d=o.encodeTransfer2InstructionData(I),T=[{pubkey:o.CompressedTokenProgram.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:u,isSigner:1,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:s,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:p.splInterfacePda,isSigner:0,isWritable:1},{pubkey:p.tokenProgram,isSigner:0,isWritable:0},{pubkey:t.CTOKEN_PROGRAM_ID,isSigner:0,isWritable:0}];return new e.TransactionInstruction({programId:o.CompressedTokenProgram.programId,keys:T,data:d})}require("buffer"),require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=o.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=o.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return o.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=o.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESSED_MINT_SEED=o.COMPRESSED_MINT_SEED,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=o.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=o.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=o.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=o.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=o.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=o.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=o.CompressedTokenProgram,exports.CpiContextLayout=o.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=o.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=o.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=o.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return o.ExtensionType}}),exports.IDL=o.IDL,exports.MINT_TO_DISCRIMINATOR=o.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=o.POOL_SEED,exports.REVOKE_DISCRIMINATOR=o.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=o.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=o.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return o.TokenDataVersion}}),exports.addSplInterfaces=o.addSplInterfaces,exports.addTokenPoolAccountsLayout=o.addTokenPoolAccountsLayout,exports.addTokenPools=o.addTokenPools,exports.approve=o.approve,exports.approveAccountsLayout=o.approveAccountsLayout,exports.approveAndMintTo=o.approveAndMintTo,exports.batchCompressLayout=o.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=o.calculateCompressibleLoadComputeUnits,exports.checkMint=o.checkMint,exports.checkSplInterfaceInfo=o.checkSplInterfaceInfo,exports.checkTokenPoolInfo=o.checkTokenPoolInfo,exports.compress=o.compress,exports.compressSplTokenAccount=o.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=o.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=o.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=o.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=o.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=o.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=o.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=o.createAtaInterface,exports.createAtaInterfaceIdempotent=o.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=o.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=o.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=o.createDecompressInterfaceInstruction,exports.createDecompressOutputState=o.createDecompressOutputState,exports.createLoadAccountsParams=o.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=o.createLoadAtaInstructionsFromInterface,exports.createMint=o.createMint,exports.createMintInstruction=o.createMintInstruction,exports.createMintInterface=o.createMintInterface,exports.createMintToCompressedInstruction=o.createMintToCompressedInstruction,exports.createMintToInstruction=o.createMintToInstruction,exports.createMintToInterfaceInstruction=o.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=o.createRemoveMetadataKeyInstruction,exports.createSplInterface=o.createSplInterface,exports.createTokenMetadata=o.createTokenMetadata,exports.createTokenPool=o.createTokenPool,exports.createTokenPoolAccountsLayout=o.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=o.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=o.createTransferInterfaceInstruction,exports.createTransferOutputState=o.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=o.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=o.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=o.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=o.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=o.createWrapInstruction,exports.decodeApproveInstructionData=o.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=o.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=o.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=o.decodeMintToInstructionData,exports.decodeRevokeInstructionData=o.decodeRevokeInstructionData,exports.decodeTokenMetadata=o.decodeTokenMetadata,exports.decodeTransferInstructionData=o.decodeTransferInstructionData,exports.decompress=o.decompress,exports.decompressDelegated=o.decompressDelegated,exports.decompressInterface=o.decompressInterface,exports.deriveCMintAddress=o.deriveCMintAddress,exports.deriveSplInterfaceInfo=o.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=o.deriveTokenPoolInfo,exports.deserializeMint=o.deserializeMint,exports.encodeApproveInstructionData=o.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=o.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=o.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=o.encodeMintToInstructionData,exports.encodeRevokeInstructionData=o.encodeRevokeInstructionData,exports.encodeTokenMetadata=o.encodeTokenMetadata,exports.encodeTransferInstructionData=o.encodeTransferInstructionData,exports.extractTokenMetadata=o.extractTokenMetadata,exports.findMintAddress=o.findMintAddress,exports.freezeAccountsLayout=o.freezeAccountsLayout,exports.getAccountInterface=o.getAccountInterface,exports.getAssociatedCTokenAddress=o.getAssociatedCTokenAddress,exports.getAssociatedCTokenAddressAndBump=o.getAssociatedCTokenAddressAndBump,exports.getMintInterface=o.getMintInterface,exports.getSplInterfaceInfos=o.getSplInterfaceInfos,exports.getTokenPoolInfos=o.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=o.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=o.isSingleTokenPoolInfo,exports.mergeTokenAccounts=o.mergeTokenAccounts,exports.mintTo=o.mintTo$1,exports.mintToAccountsLayout=o.mintToAccountsLayout,exports.mintToCToken=o.mintTo,exports.mintToCompressed=o.mintToCompressed,exports.mintToInterface=o.mintToInterface,exports.mintToLayout=o.mintToLayout,exports.packCompressedTokenAccounts=o.packCompressedTokenAccounts,exports.parseCTokenCold=o.parseCTokenCold,exports.parseCTokenHot=o.parseCTokenHot,exports.parseMaybeDelegatedTransfer=o.parseMaybeDelegatedTransfer,exports.parseTokenData=o.parseTokenData,exports.removeMetadataKey=o.removeMetadataKey,exports.revoke=o.revoke,exports.revokeAccountsLayout=o.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=o.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=o.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=o.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=o.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=o.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=o.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=o.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=o.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=o.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=o.selectTokenPoolInfosForDecompression,exports.serializeMint=o.serializeMint,exports.sumUpTokenAmount=o.sumUpTokenAmount,exports.thawAccountsLayout=o.thawAccountsLayout,exports.toAccountInfo=o.toAccountInfo,exports.toOffChainMetadataJson=o.toOffChainMetadataJson,exports.toTokenPoolInfo=o.toTokenPoolInfo,exports.transfer=o.transfer,exports.transferAccountsLayout=o.transferAccountsLayout,exports.transferDelegated=o.transferDelegated,exports.unpackMintData=o.unpackMintData,exports.unpackMintInterface=o.unpackMintInterface,exports.updateFreezeAuthority=o.updateFreezeAuthority,exports.updateMetadataAuthority=o.updateMetadataAuthority,exports.updateMetadataField=o.updateMetadataField,exports.updateMintAuthority=o.updateMintAuthority,exports.validateSameTokenOwner=o.validateSameTokenOwner,exports.wrap=o.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return r.AccountState}}),exports.createLoadAtaInstructions=async function(e,t,r,n,s,a){return o.createLoadAtaInstructions(e,t,r,n,s,a,1)},exports.createUnwrapInstruction=n,exports.getAssociatedTokenAddressInterface=function(e,r,n=0,s=t.CTOKEN_PROGRAM_ID,a){if(!s.equals(t.CTOKEN_PROGRAM_ID))throw new Error("Please derive the unified ATA from the c-token program; balances across SPL, T22, and c-token are unified under the canonical c-token ATA.");return o.getAssociatedTokenAddressInterface(e,r,n,s,a)},exports.getAtaInterface=async function(e,t,r,n,s,a){return o.getAtaInterface(e,t,r,n,s,a,1)},exports.getOrCreateAtaInterface=async function(e,r,n,s,a=0,c,p){return o._getOrCreateAtaInterface(e,r,n,s,a,c,p,t.CTOKEN_PROGRAM_ID,o.getAtaProgramId(t.CTOKEN_PROGRAM_ID),1)},exports.loadAta=async function(r,n,s,a,c,p,i){null!=c||(c=s);const u=await o.loadAta(r,n,s,a,c,p,i,1);if(null===u&&!await r.getAccountInfo(n)){const i=o.createAssociatedTokenAccountInterfaceIdempotentInstruction(c.publicKey,n,s.publicKey,a,t.CTOKEN_PROGRAM_ID),{blockhash:u}=await r.getLatestBlockhash(),I=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:3e4}),i],c,u,c.publicKey.equals(s.publicKey)?[]:[s]);return t.sendAndConfirmTx(r,I,p)}return u},exports.transferInterface=async function(e,r,n,s,a,c,p,i=t.CTOKEN_PROGRAM_ID,u,I){return o.transferInterface(e,r,n,s,a,c,p,i,u,I,1)},exports.unwrap=async function(s,a,c,p,i,u,I,d){let T=I;if(!T&&(T=(await o.getSplInterfaceInfos(s,i)).find((e=>e.isInitialized)),!T))throw new Error(`No initialized SPL interface found for mint: ${i.toBase58()}. Please create an SPL interface via createSplInterface().`);if(!await s.getAccountInfo(c))throw new Error(`Destination account does not exist: ${c.toBase58()}. Create it first using getOrCreateAssociatedTokenAccount or createAssociatedTokenAccountIdempotentInstruction.`);const A=o.getAssociatedTokenAddressInterface(i,p.publicKey);await o.loadAta(s,A,p,i,a,d);const l=await s.getAccountInfo(A);if(!l)throw new Error("No c-token ATA found after loading");const f=l.data.readBigUInt64LE(64);if(f===BigInt(0))throw new Error("No c-token balance to unwrap");const x=u?BigInt(u.toString()):f;if(x>f)throw new Error(`Insufficient c-token balance. Requested: ${x}, Available: ${f}`);const k=await r.getMint(s,i,void 0,T.tokenProgram),m=n(A,c,p.publicKey,i,x,T,k.decimals,a.publicKey),{blockhash:C}=await s.getLatestBlockhash(),M=t.dedupeSigner(a,[p]),S=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:2e5}),m],a,C,M);return await t.sendAndConfirmTx(s,S,d)};
1
+ "use strict";var e=require("@solana/web3.js"),t=require("@lightprotocol/stateless.js"),o=require("../types-DgmOPYyc.cjs"),r=require("@solana/spl-token");require("buffer"),require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=o.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=o.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return o.Action}}),exports.BASE_RENT_PER_EPOCH=o.BASE_RENT_PER_EPOCH,exports.BATCH_COMPRESS_DISCRIMINATOR=o.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESSED_MINT_SEED=o.COMPRESSED_MINT_SEED,exports.COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE=o.COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE,exports.COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH=o.COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH,exports.COMPRESSION_COST=o.COMPRESSION_COST,exports.COMPRESSION_INCENTIVE=o.COMPRESSION_INCENTIVE,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=o.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=o.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=o.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=o.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=o.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=o.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=o.CompressedTokenProgram,exports.CpiContextLayout=o.CpiContextLayout,exports.DEFAULT_COMPRESSIBLE_CONFIG=o.DEFAULT_COMPRESSIBLE_CONFIG,exports.DEFAULT_PREPAY_EPOCHS=o.DEFAULT_PREPAY_EPOCHS,exports.DEFAULT_WRITE_TOP_UP=o.DEFAULT_WRITE_TOP_UP,exports.DelegatedTransferLayout=o.DelegatedTransferLayout,exports.ERROR_MIXED_TREE_TYPES=o.ERROR_MIXED_TREE_TYPES,exports.ERROR_NO_ACCOUNTS_FOUND=o.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return o.ExtensionType}}),exports.IDL=o.IDL,exports.LIGHT_TOKEN_CONFIG=o.LIGHT_TOKEN_CONFIG,exports.LIGHT_TOKEN_RENT_SPONSOR=o.LIGHT_TOKEN_RENT_SPONSOR,exports.MAX_TOP_UP=o.MAX_TOP_UP,exports.MINT_TO_DISCRIMINATOR=o.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=o.POOL_SEED,exports.RENT_PER_BYTE_PER_EPOCH=o.RENT_PER_BYTE_PER_EPOCH,exports.REVOKE_DISCRIMINATOR=o.REVOKE_DISCRIMINATOR,exports.SLOTS_PER_RENT_EPOCH=o.SLOTS_PER_RENT_EPOCH,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=o.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TOTAL_COMPRESSION_COST=o.TOTAL_COMPRESSION_COST,exports.TRANSFER_DISCRIMINATOR=o.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return o.TokenDataVersion}}),exports.addSplInterfaces=o.addSplInterfaces,exports.addTokenPoolAccountsLayout=o.addTokenPoolAccountsLayout,exports.addTokenPools=o.addTokenPools,exports.approve=o.approve,exports.approveAccountsLayout=o.approveAccountsLayout,exports.approveAndMintTo=o.approveAndMintTo,exports.batchCompressLayout=o.batchCompressLayout,exports.calculateFeePayerCostAtCreation=o.calculateFeePayerCostAtCreation,exports.checkMint=o.checkMint,exports.checkSplInterfaceInfo=o.checkSplInterfaceInfo,exports.checkTokenPoolInfo=o.checkTokenPoolInfo,exports.compress=o.compress,exports.compressSplTokenAccount=o.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=o.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=o.convertTokenDataToAccount,exports.createAssociatedLightTokenAccountIdempotentInstruction=o.createAssociatedLightTokenAccountIdempotentInstruction,exports.createAssociatedLightTokenAccountInstruction=o.createAssociatedLightTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=o.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=o.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=o.createAtaInterface,exports.createAtaInterfaceIdempotent=o.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=o.createAtaInterfaceIdempotentInstruction,exports.createDecompressOutputState=o.createDecompressOutputState,exports.createLightTokenFreezeAccountInstruction=o.createLightTokenFreezeAccountInstruction,exports.createLightTokenThawAccountInstruction=o.createLightTokenThawAccountInstruction,exports.createLightTokenTransferCheckedInstruction=o.createLightTokenTransferCheckedInstruction,exports.createLightTokenTransferInstruction=o.createLightTokenTransferInstruction,exports.createMint=o.createMint,exports.createMintInstruction=o.createMintInstruction,exports.createMintInterface=o.createMintInterface,exports.createMintToCompressedInstruction=o.createMintToCompressedInstruction,exports.createMintToInstruction=o.createMintToInstruction,exports.createMintToInterfaceInstruction=o.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=o.createRemoveMetadataKeyInstruction,exports.createSplInterface=o.createSplInterface,exports.createTokenMetadata=o.createTokenMetadata,exports.createTokenPool=o.createTokenPool,exports.createTokenPoolAccountsLayout=o.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=o.createTokenProgramLookupTable,exports.createTransferOutputState=o.createTransferOutputState,exports.createUnwrapInstruction=o.createUnwrapInstruction,exports.createUpdateFreezeAuthorityInstruction=o.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=o.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=o.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=o.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=o.createWrapInstruction,exports.decodeApproveInstructionData=o.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=o.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=o.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=o.decodeMintToInstructionData,exports.decodeRevokeInstructionData=o.decodeRevokeInstructionData,exports.decodeTokenMetadata=o.decodeTokenMetadata,exports.decodeTransferInstructionData=o.decodeTransferInstructionData,exports.decompress=o.decompress,exports.decompressDelegated=o.decompressDelegated,exports.deriveCMintAddress=o.deriveCMintAddress,exports.deriveSplInterfaceInfo=o.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=o.deriveTokenPoolInfo,exports.deserializeMint=o.deserializeMint,exports.encodeApproveInstructionData=o.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=o.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=o.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=o.encodeMintToInstructionData,exports.encodeRevokeInstructionData=o.encodeRevokeInstructionData,exports.encodeTokenMetadata=o.encodeTokenMetadata,exports.encodeTransferInstructionData=o.encodeTransferInstructionData,exports.extractTokenMetadata=o.extractTokenMetadata,exports.findMintAddress=o.findMintAddress,exports.freezeAccountsLayout=o.freezeAccountsLayout,exports.getAccountInterface=o.getAccountInterface,exports.getAssociatedLightTokenAddress=o.getAssociatedLightTokenAddress,exports.getAssociatedLightTokenAddressAndBump=o.getAssociatedLightTokenAddressAndBump,exports.getMintInterface=o.getMintInterface,exports.getSplInterfaceInfos=o.getSplInterfaceInfos,exports.getTokenPoolInfos=o.getTokenPoolInfos,exports.groupAccountsByTreeType=o.groupAccountsByTreeType,exports.isSingleSplInterfaceInfo=o.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=o.isSingleTokenPoolInfo,exports.mergeTokenAccounts=o.mergeTokenAccounts,exports.mintTo=o.mintTo$1,exports.mintToAccountsLayout=o.mintToAccountsLayout,exports.mintToCompressed=o.mintToCompressed,exports.mintToInterface=o.mintToInterface,exports.mintToLayout=o.mintToLayout,exports.mintToLightToken=o.mintTo,exports.packCompressedTokenAccounts=o.packCompressedTokenAccounts,exports.parseLightTokenCold=o.parseLightTokenCold,exports.parseLightTokenHot=o.parseLightTokenHot,exports.parseMaybeDelegatedTransfer=o.parseMaybeDelegatedTransfer,exports.parseTokenData=o.parseTokenData,exports.removeMetadataKey=o.removeMetadataKey,exports.rentPerEpoch=o.rentPerEpoch,exports.revoke=o.revoke,exports.revokeAccountsLayout=o.revokeAccountsLayout,exports.selectAccountsByPreferredTreeType=o.selectAccountsByPreferredTreeType,exports.selectMinCompressedTokenAccountsForDecompression=o.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=o.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=o.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=o.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=o.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=o.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=o.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=o.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=o.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=o.selectTokenPoolInfosForDecompression,exports.serializeMint=o.serializeMint,exports.sliceLast=o.sliceLast,exports.sumUpTokenAmount=o.sumUpTokenAmount,exports.thawAccountsLayout=o.thawAccountsLayout,exports.toAccountInfo=o.toAccountInfo,exports.toOffChainMetadataJson=o.toOffChainMetadataJson,exports.toTokenPoolInfo=o.toTokenPoolInfo,exports.transfer=o.transfer,exports.transferAccountsLayout=o.transferAccountsLayout,exports.transferDelegated=o.transferDelegated,exports.unpackMintData=o.unpackMintData,exports.unpackMintInterface=o.unpackMintInterface,exports.updateFreezeAuthority=o.updateFreezeAuthority,exports.updateMetadataAuthority=o.updateMetadataAuthority,exports.updateMetadataField=o.updateMetadataField,exports.updateMintAuthority=o.updateMintAuthority,exports.validateSameTokenOwner=o.validateSameTokenOwner,exports.wrap=o.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return r.AccountState}}),exports.createLoadAtaInstructions=async function(e,t,r,n,s,a){const c=await o.getMintInterface(e,n);return o.createLoadAtaInstructions(e,t,r,n,c.mint.decimals,s,a,1)},exports.createTransferInterfaceInstructions=async function(e,t,r,n,s,a,c){const p=await o.getMintInterface(e,r);return o.createTransferInterfaceInstructions(e,t,r,n,s,a,p.mint.decimals,Object.assign(Object.assign({},c),{wrap:1}))},exports.createUnwrapInstructions=async function(e,t,r,n,s,a,c,p){const i=await o.getMintInterface(e,n);return o.createUnwrapInstructions(e,t,r,n,i.mint.decimals,s,a,c,void 0,p,0)},exports.getAssociatedTokenAddressInterface=function(e,r,n=0,s=t.LIGHT_TOKEN_PROGRAM_ID,a){if(!s.equals(t.LIGHT_TOKEN_PROGRAM_ID))throw new Error("Please derive the unified ATA from the light-token program; balances across SPL, T22, and light-token are unified under the canonical light-token ATA.");return o.getAssociatedTokenAddressInterface(e,r,n,s,a)},exports.getAtaInterface=async function(e,t,r,n,s,a){return o.getAtaInterface(e,t,r,n,s,a,1)},exports.getOrCreateAtaInterface=async function(e,r,n,s,a=0,c,p){return o._getOrCreateAtaInterface(e,r,n,s,a,c,p,t.LIGHT_TOKEN_PROGRAM_ID,o.getAtaProgramId(t.LIGHT_TOKEN_PROGRAM_ID),1)},exports.loadAta=async function(r,n,s,a,c,p,i,T){null!=c||(c=s);const u=await o.loadAta(r,n,s,a,c,p,i,1,T);if(null===u&&!await r.getAccountInfo(n)){const i=o.createAssociatedTokenAccountInterfaceIdempotentInstruction(c.publicKey,n,s.publicKey,a,t.LIGHT_TOKEN_PROGRAM_ID),{blockhash:T}=await r.getLatestBlockhash(),u=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:3e4}),i],c,T,c.publicKey.equals(s.publicKey)?[]:[s]);return t.sendAndConfirmTx(r,u,p)}return u},exports.transferInterface=async function(e,t,r,n,s,a,c,p,i,T){return o.transferInterface(e,t,r,n,s,a,c,void 0,p,i,1,T)},exports.unwrap=async function(e,r,n,s,a,c,p,i,T){return async function(e,r,n,s,a,c,p,i,T,u,I=0){t.assertBetaEnabled();const d=null!=u?u:(await o.getMintInterface(e,a)).mint.decimals,A=await o.createUnwrapInstructions(e,n,s.publicKey,a,d,c,r.publicKey,p,i,void 0,I),x=t.dedupeSigner(r,[s]),{rest:_,last:l}=o.sliceLast(A);await Promise.all(_.map((async o=>{const{blockhash:n}=await e.getLatestBlockhash(),s=t.buildAndSignTx(o,r,n,x);return t.sendAndConfirmTx(e,s,T)})));const{blockhash:f}=await e.getLatestBlockhash(),O=t.buildAndSignTx(l,r,f,x);return t.sendAndConfirmTx(e,O,T)}(e,r,n,s,a,c,p,void 0,i,T,0)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../../../src/v3/instructions/unwrap.ts","../../../../../../src/v3/unified/index.ts","../../../../../../src/v3/actions/unwrap.ts"],"sourcesContent":["import { PublicKey, TransactionInstruction } from '@solana/web3.js';\nimport { CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';\nimport { CompressedTokenProgram } from '../../program';\nimport { SplInterfaceInfo } from '../../utils/get-token-pool-infos';\nimport {\n encodeTransfer2InstructionData,\n createCompressCtoken,\n createDecompressSpl,\n Transfer2InstructionData,\n Compression,\n} from '../layout/layout-transfer2';\n\n/**\n * Create an unwrap instruction that moves tokens from a c-token account to an\n * SPL/T22 account.\n *\n * @param source Source c-token account\n * @param destination Destination SPL/T22 token account\n * @param owner Owner of the source account (signer)\n * @param mint Mint address\n * @param amount Amount to unwrap,\n * @param splInterfaceInfo SPL interface info for the decompression\n * @param 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","/**\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","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"],"names":["createUnwrapInstruction","source","destination","owner","mint","amount","splInterfaceInfo","decimals","payer","instructionData","withTransactionHash","withLamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountMerkleTreeIndex","lamportsChangeAccountOwnerIndex","outputQueue","maxTopUp","cpiContext","compressions","createCompressCtoken","createDecompressSpl","poolIndex","bump","proof","inTokenData","outTokenData","inLamports","outLamports","inTlv","outTlv","data","encodeTransfer2InstructionData","keys","pubkey","CompressedTokenProgram","deriveCpiAuthorityPda","isSigner","isWritable","splInterfacePda","tokenProgram","CTOKEN_PROGRAM_ID","TransactionInstruction","programId","async","rpc","ata","options","_createLoadAtaInstructions","createLoadAtaInstructions","allowOwnerOffCurve","associatedTokenProgramId","equals","Error","_getAssociatedTokenAddressInterface","commitment","_getAtaInterface","getAtaInterface","confirmOptions","_getOrCreateAtaInterface","getAtaProgramId","interfaceOptions","signature","_loadAta","getAccountInfo","ix","createAssociatedTokenAccountInterfaceIdempotentInstruction","publicKey","blockhash","getLatestBlockhash","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","_transferInterface","transferInterface","resolvedSplInterfaceInfo","getSplInterfaceInfos","find","info","isInitialized","toBase58","ctokenAta","getAssociatedTokenAddressInterface","ctokenAccountInfo","ctokenBalance","readBigUInt64LE","BigInt","unwrapAmount","toString","mintInfo","getMint","undefined","additionalSigners","dedupeSigner"],"mappings":"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"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../../../src/v3/unified/index.ts","../../../../../../src/v3/actions/unwrap.ts"],"sourcesContent":["/**\n * Exports for @lightprotocol/compressed-token/unified\n *\n * Import from `/unified` to get a single unified associated token account for SPL/T22 and light-token\n * mints.\n */\nimport {\n PublicKey,\n Signer,\n ConfirmOptions,\n Commitment,\n ComputeBudgetProgram,\n TransactionInstruction,\n} from '@solana/web3.js';\nimport {\n Rpc,\n LIGHT_TOKEN_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 {\n transferInterface as _transferInterface,\n createTransferInterfaceInstructions as _createTransferInterfaceInstructions,\n} from '../actions/transfer-interface';\nimport type { TransferOptions as _TransferOptions } from '../actions/transfer-interface';\nimport { _getOrCreateAtaInterface } from '../actions/get-or-create-ata-interface';\nimport {\n createUnwrapInstructions as _createUnwrapInstructions,\n unwrap as _unwrap,\n} from '../actions/unwrap';\nimport { SplInterfaceInfo } from '../../utils/get-token-pool-infos';\nimport { getAtaProgramId } from '../ata-utils';\nimport { InterfaceOptions } from '..';\nimport { getMintInterface } from '../get-mint-interface';\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 associated token account for SPL/T22/light-token in the unified path.\n *\n * Enforces LIGHT_TOKEN_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 light-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 = LIGHT_TOKEN_PROGRAM_ID,\n associatedTokenProgramId?: PublicKey,\n): PublicKey {\n if (!programId.equals(LIGHT_TOKEN_PROGRAM_ID)) {\n throw new Error(\n 'Please derive the unified ATA from the light-token program; balances across SPL, T22, and light-token are unified under the canonical light-token ATA.',\n );\n }\n\n return _getAssociatedTokenAddressInterface(\n mint,\n owner,\n allowOwnerOffCurve,\n programId,\n associatedTokenProgramId,\n );\n}\n\n/**\n * Create instruction batches for loading ALL token balances into a light-token associated token account.\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 Instruction batches - each inner array is one transaction\n */\nexport async function createLoadAtaInstructions(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n payer?: PublicKey,\n options?: InterfaceOptions,\n): Promise<TransactionInstruction[][]> {\n const mintInterface = await getMintInterface(rpc, mint);\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n mintInterface.mint.decimals,\n payer,\n options,\n true,\n );\n}\n\n/**\n * Load all token balances into the light-token associated token account.\n *\n * Wraps SPL/Token-2022 balances and decompresses compressed light-tokens\n * into the on-chain light-token associated token account. If no balances exist and the associated token account doesn't\n * exist, creates an empty ATA (idempotent).\n *\n * @param rpc RPC connection\n * @param ata Associated token address (light-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 decimals?: number,\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 decimals,\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 LIGHT_TOKEN_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 * Destination associated token account must exist. Automatically wraps SPL/T22 to light-token associated token account.\n *\n * @param rpc RPC connection\n * @param payer Fee payer (signer)\n * @param source Source light-token associated token account address\n * @param mint Mint address\n * @param destination Destination token account address (must exist; derive via getAssociatedTokenAddressInterface)\n * @param owner Source owner (signer)\n * @param amount Amount to transfer\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 confirmOptions?: ConfirmOptions,\n options?: InterfaceOptions,\n decimals?: number,\n) {\n return _transferInterface(\n rpc,\n payer,\n source,\n mint,\n destination,\n owner,\n amount,\n undefined, // programId: use default LIGHT_TOKEN_PROGRAM_ID\n confirmOptions,\n options,\n true, // wrap=true for unified\n decimals,\n );\n}\n\n/**\n * Get or create light-token ATA with unified balance detection and auto-loading.\n *\n * Enforces LIGHT_TOKEN_PROGRAM_ID. Aggregates balances from:\n * - light-token associated token account (hot balance)\n * - compressed light-token accounts (cold balance)\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 light-token associated token account\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 LIGHT_TOKEN_PROGRAM_ID,\n getAtaProgramId(LIGHT_TOKEN_PROGRAM_ID),\n true, // wrap=true for unified path\n );\n}\n\n/**\n * Create transfer instructions for a unified token transfer.\n *\n * Unified variant: always wraps SPL/T22 to light-token associated token account.\n *\n * Returns `TransactionInstruction[][]`. Send [0..n-2] in parallel, then [n-1].\n * Use `sliceLast` to separate the parallel prefix from the final transfer.\n *\n * @see createTransferInterfaceInstructions in v3/actions/transfer-interface.ts\n */\nexport async function createTransferInterfaceInstructions(\n rpc: Rpc,\n payer: PublicKey,\n mint: PublicKey,\n amount: number | bigint | BN,\n sender: PublicKey,\n destination: PublicKey,\n options?: Omit<_TransferOptions, 'wrap'>,\n): Promise<TransactionInstruction[][]> {\n const mintInterface = await getMintInterface(rpc, mint);\n return _createTransferInterfaceInstructions(\n rpc,\n payer,\n mint,\n amount,\n sender,\n destination,\n mintInterface.mint.decimals,\n {\n ...options,\n wrap: true,\n },\n );\n}\n\n/**\n * Build instruction batches for unwrapping light-tokens to SPL/T22.\n *\n * Load batches (cold -> hot) come first if needed; unwrap is bundled into the\n * final batch.\n * SPL/T22 balances are not consolidated; only light ATA (hot + cold) is unwrapped.\n *\n * Returns `TransactionInstruction[][]`. Load-only batches (if any) come first;\n * the last batch contains unwrap.\n *\n * @param rpc RPC connection\n * @param destination Destination SPL/T22 token account (must exist)\n * @param owner Owner of the light-token\n * @param mint Mint address\n * @param amount Amount to unwrap (defaults to full balance)\n * @param payer Fee payer (defaults to owner)\n * @param splInterfaceInfo Optional: SPL interface info\n * @param interfaceOptions Optional: interface options for load\n * @returns Instruction batches - each inner array is one transaction\n */\nexport async function createUnwrapInstructions(\n rpc: Rpc,\n destination: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n amount?: number | bigint | BN,\n payer?: PublicKey,\n splInterfaceInfo?: SplInterfaceInfo,\n interfaceOptions?: InterfaceOptions,\n): Promise<TransactionInstruction[][]> {\n const mintInterface = await getMintInterface(rpc, mint);\n return _createUnwrapInstructions(\n rpc,\n destination,\n owner,\n mint,\n mintInterface.mint.decimals,\n amount,\n payer,\n splInterfaceInfo,\n undefined, // maxTopUp - use default\n interfaceOptions,\n false, // always no wrap on unwrap.\n );\n}\n\n/**\n * Unwrap light-tokens to SPL tokens.\n *\n * Loads cold into hot if needed, then unwraps from light ATA to destination SPL/T22.\n * SPL/T22 balances are not consolidated; only light ATA balance is unwrapped.\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 light-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 * @returns Transaction signature of the unwrap transaction\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 decimals?: number,\n): Promise<string> {\n return _unwrap(\n rpc,\n payer,\n destination,\n owner,\n mint,\n amount,\n splInterfaceInfo,\n undefined, // maxTopUp - use default\n confirmOptions,\n decimals,\n false, // always no wrap on unwrap.\n );\n}\n\nexport type { _TransferOptions as TransferOptions };\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 parseLightTokenHot,\n parseLightTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n} from '../get-account-interface';\n\nexport { InterfaceOptions, sliceLast } 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 createAssociatedLightTokenAccountInstruction,\n createAssociatedLightTokenAccountIdempotentInstruction,\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 createLightTokenTransferInstruction,\n createLightTokenTransferCheckedInstruction,\n createLightTokenFreezeAccountInstruction,\n createLightTokenThawAccountInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n LightTokenConfig,\n CreateAssociatedLightTokenAccountParams,\n // Constants for rent sponsor\n DEFAULT_COMPRESSIBLE_CONFIG,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n // getOrCreateAtaInterface is defined locally with unified behavior\n wrap,\n // unwrap and createUnwrapInstructions are defined locally with unified behavior\n mintTo as mintToLightToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n // Serde\n BaseMint,\n MintContext,\n MintExtension,\n TokenMetadata,\n CompressedMint,\n deserializeMint,\n serializeMint,\n decodeTokenMetadata,\n encodeTokenMetadata,\n extractTokenMetadata,\n ExtensionType,\n // Metadata formatting\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from '..';\n","import {\n ConfirmOptions,\n PublicKey,\n Signer,\n TransactionInstruction,\n TransactionSignature,\n} from '@solana/web3.js';\nimport {\n Rpc,\n buildAndSignTx,\n sendAndConfirmTx,\n dedupeSigner,\n assertBetaEnabled,\n} from '@lightprotocol/stateless.js';\nimport { sliceLast } from './transfer-interface';\nimport BN from 'bn.js';\nimport { createUnwrapInstructions } from '../instructions/unwrap';\nimport { getMintInterface } from '../get-mint-interface';\nimport { type SplInterfaceInfo } from '../../utils/get-token-pool-infos';\n\nexport { createUnwrapInstructions } from '../instructions/unwrap';\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 maxTopUp?: number,\n confirmOptions?: ConfirmOptions,\n decimals?: number,\n wrap = false,\n): Promise<TransactionSignature> {\n assertBetaEnabled();\n\n const resolvedDecimals =\n decimals ?? (await getMintInterface(rpc, mint)).mint.decimals;\n const batches = await createUnwrapInstructions(\n rpc,\n destination,\n owner.publicKey,\n mint,\n resolvedDecimals,\n amount,\n payer.publicKey,\n splInterfaceInfo,\n maxTopUp,\n undefined,\n wrap,\n );\n\n const additionalSigners = dedupeSigner(payer, [owner]);\n const { rest: loads, last: unwrapIxs } = sliceLast(batches);\n\n await Promise.all(\n loads.map(async (ixs: TransactionInstruction[]) => {\n const { blockhash } = await rpc.getLatestBlockhash();\n const tx = buildAndSignTx(ixs, payer, blockhash, additionalSigners);\n return sendAndConfirmTx(rpc, tx, confirmOptions);\n }),\n );\n\n const { blockhash } = await rpc.getLatestBlockhash();\n const tx = buildAndSignTx(unwrapIxs, payer, blockhash, additionalSigners);\n return sendAndConfirmTx(rpc, tx, confirmOptions);\n}\n"],"names":["async","rpc","ata","owner","mint","payer","options","mintInterface","getMintInterface","_createLoadAtaInstructions","decimals","amount","sender","destination","_createTransferInterfaceInstructions","createTransferInterfaceInstructions","Object","assign","wrap","splInterfaceInfo","interfaceOptions","_createUnwrapInstructions","undefined","allowOwnerOffCurve","programId","LIGHT_TOKEN_PROGRAM_ID","associatedTokenProgramId","equals","Error","_getAssociatedTokenAddressInterface","commitment","_getAtaInterface","getAtaInterface","confirmOptions","_getOrCreateAtaInterface","getAtaProgramId","signature","_loadAta","getAccountInfo","ix","createAssociatedTokenAccountInterfaceIdempotentInstruction","publicKey","blockhash","getLatestBlockhash","tx","buildAndSignTx","ComputeBudgetProgram","setComputeUnitLimit","units","sendAndConfirmTx","source","_transferInterface","transferInterface","maxTopUp","assertBetaEnabled","resolvedDecimals","batches","createUnwrapInstructions","additionalSigners","dedupeSigner","rest","loads","last","unwrapIxs","sliceLast","Promise","all","map","ixs","_unwrap"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{g as c,c as l,l as g}from"./types-f0sdegvS.js";export{aP as ADD_TOKEN_POOL_DISCRIMINATOR,aN as APPROVE_DISCRIMINATOR,an as Action,aK as BATCH_COMPRESS_DISCRIMINATOR,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,bo as CompressedTokenProgram,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,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,ba as freezeAccountsLayout,S as getAccountInterface,C as getAssociatedTokenAddressInterface,P as getMintInterface,D as getOrCreateAtaInterface,am as getSplInterfaceInfos,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,E as transferInterface,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-f0sdegvS.js";import"@solana/web3.js";import"@lightprotocol/stateless.js";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";async function ea(a,e,t,s,o,n){return c(a,e,t,s,o,n)}async function ta(a,e,t,s,o,n){return l(a,e,t,s,o,n,0)}async function sa(a,e,t,s,o,n,r){return g(a,e,t,s,o,n,r,0)}export{ta as createLoadAtaInstructions,ea as getAtaInterface,sa as loadAta};
1
+ import{g as a,a as c,c as l,l as g}from"./types-e_5LjLhR.js";export{b0 as ADD_TOKEN_POOL_DISCRIMINATOR,a_ as APPROVE_DISCRIMINATOR,av as Action,b2 as BASE_RENT_PER_EPOCH,aX as BATCH_COMPRESS_DISCRIMINATOR,b8 as COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE,ba as COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH,b5 as COMPRESSION_COST,b6 as COMPRESSION_INCENTIVE,aZ as COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,aT as CPI_AUTHORITY_SEED,aV as CREATE_TOKEN_POOL_DISCRIMINATOR,bB as CompressedTokenInstructionDataApproveLayout,bC as CompressedTokenInstructionDataRevokeLayout,bh as CompressedTokenInstructionDataTransferLayout,C as CompressedTokenProgram,bg as CpiContextLayout,F as DEFAULT_COMPRESSIBLE_CONFIG,bb as DEFAULT_PREPAY_EPOCHS,bc as DEFAULT_WRITE_TOP_UP,bf as DelegatedTransferLayout,aE as ERROR_MIXED_TREE_TYPES,aD as ERROR_NO_ACCOUNTS_FOUND,a8 as ExtensionType,be as IDL,aP as LIGHT_TOKEN_CONFIG,aQ as LIGHT_TOKEN_RENT_SPONSOR,C as LightTokenProgram,b as MAX_COMBINED_BATCH_BYTES,d as MAX_LOAD_ONLY_BATCH_BYTES,b1 as MAX_TOP_UP,M as MAX_TRANSACTION_SIZE,aW as MINT_TO_DISCRIMINATOR,aS as POOL_SEED,b3 as RENT_PER_BYTE_PER_EPOCH,a$ as REVOKE_DISCRIMINATOR,b4 as SLOTS_PER_RENT_EPOCH,aU as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,b7 as TOTAL_COMPRESSION_COST,aY as TRANSFER_DISCRIMINATOR,aR as TokenDataVersion,ah as addSplInterfaces,bu as addTokenPoolAccountsLayout,ai as addTokenPools,aa as approve,bx as approveAccountsLayout,ab as approveAndMintTo,bj as batchCompressLayout,bd as calculateFeePayerCostAtCreation,aO as checkMint,at as checkSplInterfaceInfo,az as checkTokenPoolInfo,ac as compress,ad as compressSplTokenAccount,bk as compressSplTokenAccountInstructionDataLayout,a2 as convertTokenDataToAccount,j as createAssociatedLightTokenAccountIdempotentInstruction,i as createAssociatedLightTokenAccountInstruction,m as createAssociatedTokenAccountInterfaceIdempotentInstruction,k as createAssociatedTokenAccountInterfaceInstruction,H as createAtaInterface,I as createAtaInterfaceIdempotent,n as createAtaInterfaceIdempotentInstruction,bM as createDecompressOutputState,A as createLightTokenFreezeAccountInstruction,B as createLightTokenThawAccountInstruction,E as createLightTokenTransferCheckedInstruction,D as createLightTokenTransferInstruction,ae as createMint,f as createMintInstruction,G as createMintInterface,p as createMintToCompressedInstruction,o as createMintToInstruction,q as createMintToInterfaceInstruction,w as createRemoveMetadataKeyInstruction,af as createSplInterface,h as createTokenMetadata,ag as createTokenPool,bt as createTokenPoolAccountsLayout,aj as createTokenProgramLookupTable,N as createTransferInterfaceInstructions,bL as createTransferOutputState,y as createUnwrapInstruction,z as createUnwrapInstructions,t as createUpdateFreezeAuthorityInstruction,v as createUpdateMetadataAuthorityInstruction,u as createUpdateMetadataFieldInstruction,r as createUpdateMintAuthorityInstruction,x as createWrapInstruction,bE as decodeApproveInstructionData,bo as decodeBatchCompressInstructionData,bq as decodeCompressSplTokenAccountInstructionData,bm as decodeMintToInstructionData,bG as decodeRevokeInstructionData,a5 as decodeTokenMetadata,bs as decodeTransferInstructionData,ak as decompress,aq as decompressDelegated,as as deriveSplInterfaceInfo,ay as deriveTokenPoolInfo,a3 as deserializeMint,bD as encodeApproveInstructionData,bn as encodeBatchCompressInstructionData,bp as encodeCompressSplTokenAccountInstructionData,bl as encodeMintToInstructionData,bF as encodeRevokeInstructionData,a6 as encodeTokenMetadata,br as encodeTransferInstructionData,e as estimateTransactionSize,a7 as extractTokenMetadata,bz as freezeAccountsLayout,_ as getAccountInterface,J as getAssociatedTokenAddressInterface,K as getOrCreateAtaInterface,au as getSplInterfaceInfos,aA as getTokenPoolInfos,aF as groupAccountsByTreeType,bN as isSingleSplInterfaceInfo,bO as isSingleTokenPoolInfo,al as mergeTokenAccounts,am as mintTo,bv as mintToAccountsLayout,R as mintToCompressed,S as mintToInterface,bi as mintToLayout,Q as mintToLightToken,aN as packCompressedTokenAccounts,a0 as parseLightTokenCold,$ as parseLightTokenHot,bK as parseMaybeDelegatedTransfer,bJ as parseTokenData,X as removeMetadataKey,b9 as rentPerEpoch,an as revoke,by as revokeAccountsLayout,aG as selectAccountsByPreferredTreeType,s as selectInputsForAmount,aI as selectMinCompressedTokenAccountsForDecompression,aJ as selectMinCompressedTokenAccountsForTransfer,aK as selectMinCompressedTokenAccountsForTransferOrPartial,aL as selectSmartCompressedTokenAccountsForTransfer,aM as selectSmartCompressedTokenAccountsForTransferOrPartial,aw as selectSplInterfaceInfo,ax as selectSplInterfaceInfosForDecompression,aH as selectTokenAccountsForApprove,aB as selectTokenPoolInfo,aC as selectTokenPoolInfosForDecompression,a4 as serializeMint,O as sliceLast,bH as sumUpTokenAmount,bA as thawAccountsLayout,a1 as toAccountInfo,a9 as toOffChainMetadataJson,ar as toTokenPoolInfo,ao as transfer,bw as transferAccountsLayout,ap as transferDelegated,L as transferInterface,Z as unpackMintData,Y as unpackMintInterface,U as updateFreezeAuthority,W as updateMetadataAuthority,V as updateMetadataField,T as updateMintAuthority,bI as validateSameTokenOwner,P as wrap}from"./types-e_5LjLhR.js";import"@solana/web3.js";import"@lightprotocol/stateless.js";export{AccountState}from"@solana/spl-token";import"@coral-xyz/borsh";async function ea(e,t,s,o,n,r){return a(e,t,s,o,n,r)}async function ta(a,e,t,s,o,n){const r=await c(a,s);return l(a,e,t,s,r.mint.decimals,o,n,0)}async function sa(a,e,t,s,o,n,r,c){return g(a,e,t,s,o,n,r,0,c)}export{ta as createLoadAtaInstructions,ea as getAtaInterface,c as getMintInterface,sa as loadAta};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/index.ts"],"sourcesContent":["import type {\n Commitment,\n PublicKey,\n TransactionInstruction,\n Signer,\n ConfirmOptions,\n TransactionSignature,\n} from '@solana/web3.js';\nimport type { Rpc } from '@lightprotocol/stateless.js';\nimport type {\n AccountInterface as MintAccountInterface,\n InterfaceOptions,\n} from './v3';\nimport { getAtaInterface as _mintGetAtaInterface } from './v3';\n\nexport * from './actions';\nexport * from './utils';\nexport * from './constants';\nexport * from './idl';\nexport * from './layout';\nexport * from './program';\nexport * from './types';\nimport {\n createLoadAccountsParams,\n createLoadAtaInstructionsFromInterface,\n createLoadAtaInstructions as _createLoadAtaInstructions,\n loadAta as _loadAta,\n calculateCompressibleLoadComputeUnits,\n CompressibleAccountInput,\n ParsedAccountInfoInterface,\n CompressibleLoadParams,\n PackedCompressedAccount,\n LoadResult,\n} from './v3/actions/load-ata';\n\nexport {\n createLoadAccountsParams,\n createLoadAtaInstructionsFromInterface,\n calculateCompressibleLoadComputeUnits,\n CompressibleAccountInput,\n ParsedAccountInfoInterface,\n CompressibleLoadParams,\n PackedCompressedAccount,\n LoadResult,\n};\n\n// Export mint module with explicit naming to avoid conflicts\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 createDecompressInterfaceInstruction,\n createTransferInterfaceInstruction,\n createCTokenTransferInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n CTokenConfig,\n CreateAssociatedCTokenAccountParams,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n getAssociatedTokenAddressInterface,\n getOrCreateAtaInterface,\n transferInterface,\n decompressInterface,\n wrap,\n mintTo as mintToCToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Action types\n InterfaceOptions,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n getAccountInterface,\n Account,\n AccountState,\n ParsedTokenAccount as ParsedTokenAccountInterface,\n parseCTokenHot,\n parseCTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n // Types\n AccountInterface,\n TokenAccountSource,\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 (for use with any uploader)\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from './v3';\n\n/**\n * Retrieve associated token account for a given owner and mint.\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\n * @returns AccountInterface with ATA metadata\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<MintAccountInterface> {\n return _mintGetAtaInterface(rpc, ata, owner, mint, commitment, programId);\n}\n\n/**\n * Create instructions to load 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 load 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): Promise<TransactionInstruction[]> {\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n payer,\n options,\n false,\n );\n}\n\n/**\n * Load token balances into a c-token ATA.\n *\n * @param rpc RPC connection\n * @param ata Associated token address\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): Promise<TransactionSignature | null> {\n return _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n false,\n );\n}\n"],"names":["async","getAtaInterface","rpc","ata","owner","mint","commitment","programId","_mintGetAtaInterface","createLoadAtaInstructions","payer","options","_createLoadAtaInstructions","loadAta","confirmOptions","interfaceOptions","_loadAta"],"mappings":"giJAyIOA,eAAeC,GAClBC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAqBN,EAAKC,EAAKC,EAAOC,EAAMC,EAAYC,EACnE,CAaOP,eAAeS,GAClBP,EACAC,EACAC,EACAC,EACAK,EACAC,GAEA,OAAOC,EACHV,EACAC,EACAC,EACAC,EACAK,EACAC,EACA,EAER,CAcOX,eAAea,GAClBX,EACAC,EACAC,EACAC,EACAK,EACAI,EACAC,GAEA,OAAOC,EACHd,EACAC,EACAC,EACAC,EACAK,EACAI,EACAC,EACA,EAER"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/index.ts"],"sourcesContent":["import type {\n Commitment,\n PublicKey,\n Signer,\n ConfirmOptions,\n TransactionInstruction,\n TransactionSignature,\n} from '@solana/web3.js';\nimport type { Rpc } from '@lightprotocol/stateless.js';\nimport type {\n AccountInterface as MintAccountInterface,\n InterfaceOptions,\n} from './v3';\nimport { getAtaInterface as _mintGetAtaInterface } from './v3';\n\nexport * from './actions';\nexport * from './utils';\nexport * from './constants';\nexport * from './idl';\nexport * from './layout';\nexport * from './program';\nexport { CompressedTokenProgram as LightTokenProgram } from './program';\nexport * from './types';\nimport {\n createLoadAtaInstructions as _createLoadAtaInstructions,\n loadAta as _loadAta,\n selectInputsForAmount,\n} from './v3/actions/load-ata';\nimport { getMintInterface } from './v3/get-mint-interface';\n\nexport { selectInputsForAmount };\n\nexport {\n estimateTransactionSize,\n MAX_TRANSACTION_SIZE,\n MAX_COMBINED_BATCH_BYTES,\n MAX_LOAD_ONLY_BATCH_BYTES,\n} from './v3/utils/estimate-tx-size';\n\n// Export mint module with explicit naming to avoid conflicts\nexport {\n // Instructions\n createMintInstruction,\n createTokenMetadata,\n createAssociatedLightTokenAccountInstruction,\n createAssociatedLightTokenAccountIdempotentInstruction,\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 createUnwrapInstructions,\n createLightTokenFreezeAccountInstruction,\n createLightTokenThawAccountInstruction,\n createLightTokenTransferInstruction,\n createLightTokenTransferCheckedInstruction,\n // Types\n TokenMetadataInstructionData,\n CompressibleConfig,\n LightTokenConfig,\n CreateAssociatedLightTokenAccountParams,\n // Constants for rent sponsor\n DEFAULT_COMPRESSIBLE_CONFIG,\n // Actions\n createMintInterface,\n createAtaInterface,\n createAtaInterfaceIdempotent,\n getAssociatedTokenAddressInterface,\n getOrCreateAtaInterface,\n transferInterface,\n createTransferInterfaceInstructions,\n sliceLast,\n wrap,\n mintTo as mintToLightToken,\n mintToCompressed,\n mintToInterface,\n updateMintAuthority,\n updateFreezeAuthority,\n updateMetadataField,\n updateMetadataAuthority,\n removeMetadataKey,\n // Action types\n InterfaceOptions,\n // Helpers\n getMintInterface,\n unpackMintInterface,\n unpackMintData,\n MintInterface,\n getAccountInterface,\n Account,\n AccountState,\n ParsedTokenAccount as ParsedTokenAccountInterface,\n parseLightTokenHot,\n parseLightTokenCold,\n toAccountInfo,\n convertTokenDataToAccount,\n // Types\n AccountInterface,\n TokenAccountSource,\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 (for use with any uploader)\n toOffChainMetadataJson,\n OffChainTokenMetadata,\n OffChainTokenMetadataJson,\n} from './v3';\n\n/**\n * Retrieve associated token account for a given owner and mint.\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\n * @returns AccountInterface with ATA metadata\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<MintAccountInterface> {\n return _mintGetAtaInterface(rpc, ata, owner, mint, commitment, programId);\n}\n\n/**\n * Create instruction batches for loading token balances into an ATA.\n * Returns batches of instructions, each batch is one transaction.\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 load options\n * @returns Instruction batches - each inner array is one transaction\n */\nexport async function createLoadAtaInstructions(\n rpc: Rpc,\n ata: PublicKey,\n owner: PublicKey,\n mint: PublicKey,\n payer?: PublicKey,\n options?: InterfaceOptions,\n): Promise<TransactionInstruction[][]> {\n const mintInterface = await getMintInterface(rpc, mint);\n return _createLoadAtaInstructions(\n rpc,\n ata,\n owner,\n mint,\n mintInterface.mint.decimals,\n payer,\n options,\n false,\n );\n}\n\n/**\n * Load token balances into a light-token ATA.\n *\n * @param rpc RPC connection\n * @param ata Associated token address\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 decimals?: number,\n): Promise<TransactionSignature | null> {\n return _loadAta(\n rpc,\n ata,\n owner,\n mint,\n payer,\n confirmOptions,\n interfaceOptions,\n false,\n decimals,\n );\n}\n"],"names":["async","getAtaInterface","rpc","ata","owner","mint","commitment","programId","_mintGetAtaInterface","createLoadAtaInstructions","payer","options","mintInterface","getMintInterface","_createLoadAtaInstructions","decimals","loadAta","confirmOptions","interfaceOptions","_loadAta"],"mappings":"0vKAwIOA,eAAeC,GAClBC,EACAC,EACAC,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAqBN,EAAKC,EAAKC,EAAOC,EAAMC,EAAYC,EACnE,CAcOP,eAAeS,GAClBP,EACAC,EACAC,EACAC,EACAK,EACAC,GAEA,MAAMC,QAAsBC,EAAiBX,EAAKG,GAClD,OAAOS,EACHZ,EACAC,EACAC,EACAC,EACAO,EAAcP,KAAKU,SACnBL,EACAC,EACA,EAER,CAcOX,eAAegB,GAClBd,EACAC,EACAC,EACAC,EACAK,EACAO,EACAC,EACAH,GAEA,OAAOI,EACHjB,EACAC,EACAC,EACAC,EACAK,EACAO,EACAC,EACA,EACAH,EAER"}