Skip to content
Merged
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
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 Expand Up @@ -65,7 +65,7 @@ export async function createAssociatedCTokenAccount(
}

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

/**
* Create an associated token account for SPL/T22/c-token. Defaults to c-token
* program.
* Create an associated token account for SPL/T22/light-token. Defaults to
* light-token program.
*
* @param rpc RPC connection
* @param payer Fee payer and transaction signer
Expand All @@ -36,8 +36,8 @@ export type { CTokenConfig };
* @param confirmOptions Options for confirming the transaction
* @param programId Token program ID (default:
* LIGHT_TOKEN_PROGRAM_ID)
* @param associatedTokenProgramId ATA program ID (auto-derived if not
* provided)
* @param associatedTokenProgramId associated token account program ID
* (auto-derived if not provided)
* @param ctokenConfig Optional rent config
* @returns Address of the new associated token account
*/
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 @@ -111,9 +111,9 @@ export async function createAtaInterface(
* @param confirmOptions Options for confirming the transaction
* @param programId Token program ID (default:
* LIGHT_TOKEN_PROGRAM_ID)
* @param associatedTokenProgramId ATA program ID (auto-derived if not
* provided)
* @param ctokenConfig Optional c-token-specific configuration
* @param associatedTokenProgramId associated token account program ID
* (auto-derived if not provided)
* @param ctokenConfig Optional light-token-specific configuration
*
* @returns Address of the associated token account
*/
Expand Down
14 changes: 7 additions & 7 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 LIGHT_TOKEN_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 Expand Up @@ -79,10 +79,10 @@ export async function createMintInterface(
);
}

// Default: compressed token mint creation
// Default: light-token mint creation
if (!('secretKey' in mintAuthority)) {
throw new Error(
'mintAuthority must be a Signer for compressed token mints',
'mintAuthority must be a Signer for light-token mints',
);
}
if (
Expand Down
22 changes: 11 additions & 11 deletions js/compressed-token/src/v3/actions/decompress-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ import { LIGHT_TOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js';
import { SplInterfaceInfo } from '../../utils/get-token-pool-infos';

/**
* Decompress compressed (cold) tokens to an on-chain token account.
* Decompress compressed light-tokens (cold balance) to a light-token associated token account (hot balance).
*
* For unified loading, use {@link loadAta} instead.
*
* @param rpc RPC connection
* @param payer Fee payer (signer)
* @param owner Owner of the compressed tokens (signer)
* @param owner Owner of the light-tokens (signer)
* @param mint Mint address
* @param amount Amount to decompress (defaults to all)
* @param destinationAta Destination token account address
* @param destinationOwner Owner of the destination ATA
* @param destinationOwner Owner of the destination associated token account
* @param splInterfaceInfo SPL interface info for SPL/T22 destinations
* @param confirmOptions Confirm options
* @returns Transaction signature, null if nothing to load.
Expand All @@ -55,10 +55,10 @@ 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
// Get compressed light-token accounts (cold balance)
const compressedResult = await rpc.getCompressedTokenAccountsByOwner(
owner.publicKey,
{ mint },
Expand Down Expand Up @@ -104,12 +104,12 @@ export async function decompressInterface(
})),
);

// Determine destination ATA based on token program
// Determine destination associated token account based on token program
const ataOwner = destinationOwner ?? owner.publicKey;
let destinationAtaAddress: PublicKey;

if (isSplDestination) {
// SPL destination - use SPL ATA
// SPL destination - use SPL associated token account
destinationAtaAddress =
destinationAta ??
(await getAssociatedTokenAddress(
Expand All @@ -119,7 +119,7 @@ export async function decompressInterface(
splInterfaceInfo.tokenProgram,
));
} else {
// c-token destination - use c-token ATA
// light-token destination - use light-token associated token account
destinationAtaAddress =
destinationAta ??
getAssociatedTokenAddressInterface(mint, ataOwner);
Expand All @@ -128,11 +128,11 @@ export async function decompressInterface(
// Build instructions
const instructions = [];

// Create ATA if needed (idempotent)
// Create associated token account if needed (idempotent)
const ataInfo = await rpc.getAccountInfo(destinationAtaAddress);
if (!ataInfo) {
if (isSplDestination) {
// Create SPL ATA
// Create SPL associated token account
instructions.push(
createAssociatedTokenAccountIdempotentInstruction(
payer.publicKey,
Expand All @@ -143,7 +143,7 @@ export async function decompressInterface(
),
);
} else {
// Create c-token ATA
// Create light-token associated token account
instructions.push(
createAssociatedTokenAccountInterfaceIdempotentInstruction(
payer.publicKey,
Expand Down
6 changes: 3 additions & 3 deletions js/compressed-token/src/v3/actions/decompress-mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export interface DecompressMintParams {
}

/**
* Decompress a compressed mint to create the CMint Solana account.
* Decompress a compressed light mint to create the light mint account.
*
* This makes the mint available on-chain, which is required before creating
* CToken associated token accounts. DecompressMint is **permissionless** -
* This creates the light mint account, which is required before creating
* light-token associated token accounts. DecompressMint is **permissionless** -
* any account can call it.
*
* @param rpc - RPC connection
Expand Down
26 changes: 13 additions & 13 deletions js/compressed-token/src/v3/actions/get-or-create-ata-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { loadAta } from './load-ata';
* @param mint Mint associated with the account to set or
* verify.
* @param owner Owner of the account. Pass Signer to
* auto-load cold (compressed) tokens, or
* auto-load compressed light-tokens (cold balance), or
* PublicKey for read-only.
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program
* Derived Address).
Expand Down 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(LIGHT_TOKEN_PROGRAM_ID)) {
return getOrCreateCTokenAta(
Expand Down Expand Up @@ -162,14 +162,14 @@ export async function _getOrCreateAtaInterface(
}

/**
* Get or create c-token ATA with proper cold balance handling.
* Get or create light-token associated token account with proper compressed balance handling.
*
* Like SPL's getOrCreateAssociatedTokenAccount, this is a write operation:
* 1. Creates hot ATA if it doesn't exist
* 2. If owner is Signer: loads cold (compressed) tokens into hot ATA
* 1. Creates hot associated token account if it doesn't exist
* 2. If owner is Signer: loads compressed light-tokens (cold balance) into light-token associated token account
* 3. When wrap=true and owner is Signer: also wraps SPL/T22 tokens
*
* After this call (with Signer owner), all tokens are in the hot ATA and ready
* After this call (with Signer owner), all tokens are in the hot associated token account and ready
* to use.
*
* @internal
Expand Down Expand Up @@ -215,7 +215,7 @@ async function getOrCreateCTokenAta(
error instanceof TokenAccountNotFoundError ||
error instanceof TokenInvalidAccountOwnerError
) {
// No account found (neither hot nor cold), create hot ATA
// No account found (neither hot nor cold), create hot associated token account
await createCTokenAtaIdempotent(
rpc,
payer,
Expand All @@ -242,7 +242,7 @@ async function getOrCreateCTokenAta(
}
}

// If we only have cold balance (no hot ATA), create the hot ATA first
// If we only have cold balance (no hot associated token account), create the hot associated token account first
if (!hasHotAccount) {
await createCTokenAtaIdempotent(
rpc,
Expand All @@ -257,7 +257,7 @@ async function getOrCreateCTokenAta(
// Only auto-load if owner is a Signer (we can sign the load transaction)
// Use direct type guard in the if condition for proper type narrowing
if (isSigner(owner)) {
// Check if we need to load tokens into the hot ATA
// Check if we need to load tokens into the hot associated token account
// Load if: cold balance exists, or (wrap=true and SPL/T22 balance exists)
const sources = accountInterface._sources ?? [];
const hasCold = sources.some(
Expand Down Expand Up @@ -285,7 +285,7 @@ async function getOrCreateCTokenAta(
);
}

// Load all tokens into hot ATA (decompress cold, wrap SPL/T22 if
// Load all tokens into hot associated token account (decompress cold, wrap SPL/T22 if
// wrap=true)
await loadAta(
rpc,
Expand Down Expand Up @@ -321,7 +321,7 @@ async function getOrCreateCTokenAta(
}

/**
* Create c-token ATA idempotently.
* Create light-token associated token account idempotently.
* @internal
*/
async function createCTokenAtaIdempotent(
Expand Down Expand Up @@ -351,12 +351,12 @@ async function createCTokenAtaIdempotent(

await sendAndConfirmTx(rpc, tx, confirmOptions);
} catch {
// Ignore errors - ATA may already exist
// Ignore errors - associated token account may already exist
}
}

/**
* Get or create SPL/T22 ATA.
* Get or create SPL/T22 associated token account.
* @internal
*/
async function getOrCreateSplAta(
Expand Down
Loading