Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/compressed-token/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export {
createDecompressInterfaceInstruction,
createTransferInterfaceInstruction,
createCTokenTransferInstruction,
createTransferCheckedInterfaceInstruction,
createCTokenTransferCheckedInstruction,
transferCheckedInterface,
// Types
TokenMetadataInstructionData,
CompressibleConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { getAssociatedCTokenAddress } from '../derivation';

/**
* Create an associated c-token account.
* Create an associated light-token account.
*
* @param rpc RPC connection
* @param payer Fee payer
Expand Down
8 changes: 4 additions & 4 deletions js/compressed-token/src/v3/actions/create-ata-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getAssociatedTokenAddressInterface } from '../get-associated-token-addr
export type { CTokenConfig };

/**
* Create an associated token account for SPL/T22/c-token. Defaults to c-token
* Create an associated token account for SPL/T22/light-token. Defaults to light-token
* program.
*
* @param rpc RPC connection
Expand Down Expand Up @@ -98,8 +98,8 @@ export async function createAtaInterface(
}

/**
* Create an associated token account idempotently for SPL/T22/c-token. Defaults
* to c-token program.
* Create an associated token account idempotently for SPL/T22/light-token. Defaults
* to light-token program.
*
* If the account already exists, the instruction succeeds without error.
*
Expand All @@ -113,7 +113,7 @@ export async function createAtaInterface(
* CTOKEN_PROGRAM_ID)
* @param associatedTokenProgramId ATA program ID (auto-derived if not
* provided)
* @param ctokenConfig Optional c-token-specific configuration
* @param ctokenConfig Optional light-token-specific configuration
*
* @returns Address of the associated token account
*/
Expand Down
10 changes: 5 additions & 5 deletions js/compressed-token/src/v3/actions/create-mint-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ import { createMint } from '../../actions/create-mint';
export { TokenMetadataInstructionData };

/**
* Create and initialize a new mint for SPL/T22/c-token.
* Create and initialize a new mint for SPL/T22/light-token.
*
* @param rpc RPC connection to use
* @param payer Fee payer
* @param mintAuthority Account that will control minting (signer for c-token mints)
* @param mintAuthority Account that will control minting (signer for light-token mints)
* @param freezeAuthority Account that will control freeze and thaw (optional)
* @param decimals Location of the decimal place
* @param keypair Mint keypair (defaults to a random keypair)
* @param confirmOptions Confirm options
* @param programId Token program ID (defaults to CTOKEN_PROGRAM_ID)
* @param tokenMetadata Optional token metadata (c-token mints only)
* @param outputStateTreeInfo Optional output state tree info (c-token mints only)
* @param addressTreeInfo Optional address tree info (c-token mints only)
* @param tokenMetadata Optional token metadata (light-token mints only)
* @param outputStateTreeInfo Optional output state tree info (light-token mints only)
* @param addressTreeInfo Optional address tree info (light-token mints only)
*
* @returns Object with mint address and transaction signature
*/
Expand Down
6 changes: 3 additions & 3 deletions js/compressed-token/src/v3/actions/decompress-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function decompressInterface(
): Promise<TransactionSignature | null> {
assertBetaEnabled();

// Determine if this is SPL or c-token destination
// Determine if this is SPL or light-token destination
const isSplDestination = splInterfaceInfo !== undefined;

// Get compressed token accounts
Expand Down Expand Up @@ -119,7 +119,7 @@ export async function decompressInterface(
splInterfaceInfo.tokenProgram,
));
} else {
// c-token destination - use c-token ATA
// light-token destination - use light-token ATA
destinationAtaAddress =
destinationAta ??
getAssociatedTokenAddressInterface(mint, ataOwner);
Expand All @@ -143,7 +143,7 @@ export async function decompressInterface(
),
);
} else {
// Create c-token ATA
// Create light-token ATA
instructions.push(
createAssociatedTokenAccountInterfaceIdempotentInstruction(
payer.publicKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function _getOrCreateAtaInterface(
associatedTokenProgramId,
);

// For c-token, use getAtaInterface which properly aggregates hot+cold balances
// For light-token, use getAtaInterface which properly aggregates hot+cold balances
// When wrap=true (unified path), also includes SPL/T22 balances
if (programId.equals(CTOKEN_PROGRAM_ID)) {
return getOrCreateCTokenAta(
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function _getOrCreateAtaInterface(
}

/**
* Get or create c-token ATA with proper cold balance handling.
* Get or create light-token ATA with proper cold balance handling.
*
* Like SPL's getOrCreateAssociatedTokenAccount, this is a write operation:
* 1. Creates hot ATA if it doesn't exist
Expand Down Expand Up @@ -321,7 +321,7 @@ async function getOrCreateCTokenAta(
}

/**
* Create c-token ATA idempotently.
* Create light-token ATA idempotently.
* @internal
*/
async function createCTokenAtaIdempotent(
Expand Down
1 change: 1 addition & 0 deletions js/compressed-token/src/v3/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './decompress-interface';
export * from './wrap';
export * from './unwrap';
export * from './load-ata';
export * from './transfer-checked';
40 changes: 20 additions & 20 deletions js/compressed-token/src/v3/actions/load-ata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ export {
*
* Behavior depends on `wrap` parameter:
* - wrap=false (standard): Decompress compressed tokens to the target ATA.
* ATA can be SPL (via pool), T22 (via pool), or c-token (direct).
* - wrap=true (unified): Wrap SPL/T22 + decompress all to c-token ATA.
* ATA must be a c-token ATA.
* ATA can be SPL (via pool), T22 (via pool), or light-token (direct).
* - wrap=true (unified): Wrap SPL/T22 + decompress all to light-token ATA.
* ATA must be a light-token ATA.
*
* @param rpc RPC connection
* @param ata Associated token address (SPL, T22, or c-token)
* @param ata Associated token address (SPL, T22, or light-token)
* @param owner Owner public key
* @param mint Mint public key
* @param payer Fee payer (defaults to owner)
* @param options Optional load options
* @param wrap Unified mode: wrap SPL/T22 to c-token (default: false)
* @param wrap Unified mode: wrap SPL/T22 to light-token (default: false)
* @returns Array of instructions (empty if nothing to load)
*/
export async function createLoadAtaInstructions(
Expand All @@ -149,7 +149,7 @@ export async function createLoadAtaInstructions(

// Validation happens inside getAtaInterface via checkAtaAddress helper:
// - Always validates ata matches mint+owner derivation
// - For wrap=true, additionally requires c-token ATA
// - For wrap=true, additionally requires light-token ATA
try {
const ataInterface = await _getAtaInterface(
rpc,
Expand Down Expand Up @@ -185,14 +185,14 @@ export { AtaType } from '../ata-utils';
*
* Behavior depends on `wrap` parameter:
* - wrap=false (standard): Decompress compressed tokens to the target ATA type
* (SPL ATA via pool, T22 ATA via pool, or c-token ATA direct)
* - wrap=true (unified): Wrap SPL/T22 + decompress all to c-token ATA
* (SPL ATA via pool, T22 ATA via pool, or light-token ATA direct)
* - wrap=true (unified): Wrap SPL/T22 + decompress all to light-token ATA
*
* @param rpc RPC connection
* @param payer Fee payer
* @param ata AccountInterface from getAtaInterface (must have _isAta, _owner, _mint)
* @param options Optional load options
* @param wrap Unified mode: wrap SPL/T22 to c-token (default: false)
* @param wrap Unified mode: wrap SPL/T22 to light-token (default: false)
* @param targetAta Target ATA address (used for type detection in standard mode)
* @returns Array of instructions (empty if nothing to load)
*/
Expand Down Expand Up @@ -247,7 +247,7 @@ export async function createLoadAtaInstructionsFromInterface(
const validation = checkAtaAddress(targetAta, mint, owner);
ataType = validation.type;

// For wrap=true, must be c-token ATA
// For wrap=true, must be light-token ATA
if (wrap && ataType !== 'ctoken') {
throw new Error(
`For wrap=true, targetAta must be c-token ATA. Got ${ataType} ATA.`,
Expand Down Expand Up @@ -307,9 +307,9 @@ export async function createLoadAtaInstructionsFromInterface(
}

if (wrap) {
// UNIFIED MODE: Everything goes to c-token ATA
// UNIFIED MODE: Everything goes to light-token ATA

// 1. Create c-token ATA if needed
// 1. Create light-token ATA if needed
if (!ctokenHotSource) {
instructions.push(
createAssociatedTokenAccountInterfaceIdempotentInstruction(
Expand All @@ -322,7 +322,7 @@ export async function createLoadAtaInstructionsFromInterface(
);
}

// 2. Wrap SPL tokens to c-token
// 2. Wrap SPL tokens to light-token
if (splBalance > BigInt(0) && splInterfaceInfo) {
instructions.push(
createWrapInstruction(
Expand All @@ -338,7 +338,7 @@ export async function createLoadAtaInstructionsFromInterface(
);
}

// 3. Wrap T22 tokens to c-token
// 3. Wrap T22 tokens to light-token
if (t22Balance > BigInt(0) && splInterfaceInfo) {
instructions.push(
createWrapInstruction(
Expand All @@ -354,7 +354,7 @@ export async function createLoadAtaInstructionsFromInterface(
);
}

// 4. Decompress compressed tokens to c-token ATA
// 4. Decompress compressed tokens to light-token ATA
// Note: v3 interface only supports V2 trees
if (coldBalance > BigInt(0) && ctokenColdSource) {
const compressedAccounts =
Expand Down Expand Up @@ -403,7 +403,7 @@ export async function createLoadAtaInstructionsFromInterface(
);

if (ataType === 'ctoken') {
// Decompress to c-token ATA (direct)
// Decompress to light-token ATA (direct)
if (!ctokenHotSource) {
instructions.push(
createAssociatedTokenAccountInterfaceIdempotentInstruction(
Expand Down Expand Up @@ -489,19 +489,19 @@ export async function createLoadAtaInstructionsFromInterface(
*
* Behavior depends on `wrap` parameter:
* - wrap=false (standard): Decompress compressed tokens to the target ATA.
* ATA can be SPL (via pool), T22 (via pool), or c-token (direct).
* - wrap=true (unified): Wrap SPL/T22 + decompress all to c-token ATA.
* ATA can be SPL (via pool), T22 (via pool), or light-token (direct).
* - wrap=true (unified): Wrap SPL/T22 + decompress all to light-token ATA.
*
* Idempotent: returns null if nothing to load.
*
* @param rpc RPC connection
* @param ata Associated token address (SPL, T22, or c-token)
* @param ata Associated token address (SPL, T22, or light-token)
* @param owner Owner of the tokens (signer)
* @param mint Mint public key
* @param payer Fee payer (signer, defaults to owner)
* @param confirmOptions Optional confirm options
* @param interfaceOptions Optional interface options
* @param wrap Unified mode: wrap SPL/T22 to c-token (default: false)
* @param wrap Unified mode: wrap SPL/T22 to light-token (default: false)
* @returns Transaction signature, or null if nothing to load
*/
export async function loadAta(
Expand Down
6 changes: 3 additions & 3 deletions js/compressed-token/src/v3/actions/mint-to-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import { getMintInterface } from '../get-mint-interface';

/**
* Mint tokens to a decompressed/onchain token account.
* Works with SPL, Token-2022, and compressed token (c-token) mints.
* Works with SPL, Token-2022, and compressed token (light-token) mints.
*
* This function ONLY mints to decompressed onchain token accounts, never to compressed accounts.
* The signature matches the standard SPL mintTo for simplicity and consistency.
*
* @param rpc - RPC connection to use
* @param payer - Transaction fee payer
* @param mint - Mint address (SPL, Token-2022, or compressed mint)
* @param mint - Mint address (SPL, Token-2022, or light mint)
* @param destination - Destination token account address (must be an existing onchain token account)
* @param authority - Mint authority (can be Signer or PublicKey if multiSigners provided)
* @param amount - Amount to mint
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function mintToInterface(
programId,
);

// Fetch validity proof if this is a compressed mint (has merkleContext)
// Fetch validity proof if this is a light mint (has merkleContext)
let validityProof;
if (mintInterface.merkleContext) {
validityProof = await rpc.getValidityProofV2(
Expand Down
Loading