@lightprotocol/compressed-token 0.23.0-beta.1 → 0.23.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-C1QDyKdh.cjs +2 -0
- package/dist/cjs/browser/types-C1QDyKdh.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +1 -1
- package/dist/cjs/browser/unified/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-DPJ16IsW.cjs +2 -0
- package/dist/cjs/node/types-DPJ16IsW.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +1 -1
- package/dist/cjs/node/unified/index.cjs.map +1 -1
- package/dist/es/browser/index.js +1 -1
- package/dist/es/browser/index.js.map +1 -1
- package/dist/es/browser/types-CicHpkHU.js +2 -0
- package/dist/es/browser/types-CicHpkHU.js.map +1 -0
- package/dist/es/browser/unified/index.js +1 -1
- package/dist/es/browser/unified/index.js.map +1 -1
- package/dist/types/index.d.ts +619 -456
- package/dist/types/unified/index.d.ts +792 -630
- package/package.json +17 -11
- package/dist/cjs/browser/types-BYVvBJS4.cjs +0 -2
- package/dist/cjs/browser/types-BYVvBJS4.cjs.map +0 -1
- package/dist/cjs/node/types-C6bFjLLI.cjs +0 -2
- package/dist/cjs/node/types-C6bFjLLI.cjs.map +0 -1
- package/dist/es/browser/types-Z2gqWJ9V.js +0 -2
- package/dist/es/browser/types-Z2gqWJ9V.js.map +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { PublicKey, TransactionInstruction, Commitment, AccountInfo, Signer, ConfirmOptions, TransactionSignature,
|
|
3
|
-
import { ValidityProofWithContext, AddressTreeInfo, TreeInfo, MerkleContext, Rpc,
|
|
2
|
+
import { PublicKey, TransactionInstruction, Commitment, AccountInfo, Signer, ConfirmOptions, TransactionSignature, Keypair, AccountMeta, Connection } from '@solana/web3.js';
|
|
3
|
+
import { ValidityProofWithContext, AddressTreeInfo, TreeInfo, MerkleContext, Rpc, CompressedAccountWithMerkleContext, ParsedTokenAccount, TreeType, PackedMerkleContextLegacy, CompressedCpiContext, ValidityProof, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
4
4
|
export { ParsedTokenAccount as ParsedTokenAccountInterface } from '@lightprotocol/stateless.js';
|
|
5
5
|
import { Mint, Account } from '@solana/spl-token';
|
|
6
6
|
export { Account, AccountState } from '@solana/spl-token';
|
|
@@ -339,7 +339,7 @@ interface AdditionalMetadata {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
/**
|
|
342
|
-
* Token metadata for creating a
|
|
342
|
+
* Token metadata for creating a light-token mint.
|
|
343
343
|
*/
|
|
344
344
|
interface TokenMetadataInstructionData {
|
|
345
345
|
name: string;
|
|
@@ -350,7 +350,7 @@ interface TokenMetadataInstructionData {
|
|
|
350
350
|
}
|
|
351
351
|
declare function createTokenMetadata(name: string, symbol: string, uri: string, updateAuthority?: PublicKey | null, additionalMetadata?: AdditionalMetadata[] | null): TokenMetadataInstructionData;
|
|
352
352
|
/**
|
|
353
|
-
* Create instruction for initializing a
|
|
353
|
+
* Create instruction for initializing a light-token mint.
|
|
354
354
|
*
|
|
355
355
|
* @param mintSigner Mint signer keypair public key.
|
|
356
356
|
* @param decimals Number of decimals for the mint.
|
|
@@ -361,8 +361,9 @@ declare function createTokenMetadata(name: string, symbol: string, uri: string,
|
|
|
361
361
|
* @param addressTreeInfo Address tree info for the mint.
|
|
362
362
|
* @param outputStateTreeInfo Output state tree info.
|
|
363
363
|
* @param metadata Optional token metadata.
|
|
364
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
364
365
|
*/
|
|
365
|
-
declare function createMintInstruction(mintSigner: PublicKey, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext, addressTreeInfo: AddressTreeInfo, outputStateTreeInfo: TreeInfo, metadata?: TokenMetadataInstructionData): TransactionInstruction;
|
|
366
|
+
declare function createMintInstruction(mintSigner: PublicKey, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext, addressTreeInfo: AddressTreeInfo, outputStateTreeInfo: TreeInfo, metadata?: TokenMetadataInstructionData, maxTopUp?: number): TransactionInstruction;
|
|
366
367
|
|
|
367
368
|
/**
|
|
368
369
|
* SPL-compatible base mint structure
|
|
@@ -380,12 +381,12 @@ interface BaseMint {
|
|
|
380
381
|
freezeAuthority: PublicKey | null;
|
|
381
382
|
}
|
|
382
383
|
/**
|
|
383
|
-
*
|
|
384
|
+
* Light mint context (protocol version, SPL mint reference)
|
|
384
385
|
*/
|
|
385
386
|
interface MintContext {
|
|
386
387
|
/** Protocol version for upgradability */
|
|
387
388
|
version: number;
|
|
388
|
-
/** Whether the compressed mint
|
|
389
|
+
/** Whether the compressed light mint has been decompressed to a light mint account */
|
|
389
390
|
cmintDecompressed: boolean;
|
|
390
391
|
/** PDA of the associated SPL mint */
|
|
391
392
|
splMint: PublicKey;
|
|
@@ -423,7 +424,7 @@ interface TokenMetadata {
|
|
|
423
424
|
}[];
|
|
424
425
|
}
|
|
425
426
|
/**
|
|
426
|
-
* Complete
|
|
427
|
+
* Complete light mint structure (raw format)
|
|
427
428
|
*/
|
|
428
429
|
interface CompressedMint {
|
|
429
430
|
base: BaseMint;
|
|
@@ -452,7 +453,7 @@ interface RentConfig {
|
|
|
452
453
|
maxTopUp: number;
|
|
453
454
|
}
|
|
454
455
|
/**
|
|
455
|
-
* Compression info embedded in
|
|
456
|
+
* Compression info embedded in light mint
|
|
456
457
|
*/
|
|
457
458
|
interface CompressionInfo {
|
|
458
459
|
/** Config account version (0 = uninitialized) */
|
|
@@ -477,18 +478,18 @@ interface CompressionInfo {
|
|
|
477
478
|
rentConfig: RentConfig;
|
|
478
479
|
}
|
|
479
480
|
/**
|
|
480
|
-
* Deserialize a
|
|
481
|
+
* Deserialize a light mint from buffer
|
|
481
482
|
* Uses SPL's MintLayout for BaseMint and buffer-layout struct for context
|
|
482
483
|
*
|
|
483
484
|
* @param data - The raw account data buffer
|
|
484
|
-
* @returns The deserialized
|
|
485
|
+
* @returns The deserialized light mint
|
|
485
486
|
*/
|
|
486
487
|
declare function deserializeMint(data: Buffer$1 | Uint8Array): CompressedMint;
|
|
487
488
|
/**
|
|
488
|
-
* Serialize a
|
|
489
|
+
* Serialize a light mint to buffer
|
|
489
490
|
* Uses SPL's MintLayout for BaseMint, helper functions for context/metadata
|
|
490
491
|
*
|
|
491
|
-
* @param mint - The
|
|
492
|
+
* @param mint - The light mint to serialize
|
|
492
493
|
* @returns The serialized buffer
|
|
493
494
|
*/
|
|
494
495
|
declare function serializeMint(mint: CompressedMint): Buffer$1;
|
|
@@ -551,11 +552,11 @@ interface MintInterface {
|
|
|
551
552
|
mintContext?: MintContext;
|
|
552
553
|
tokenMetadata?: TokenMetadata;
|
|
553
554
|
extensions?: MintExtension[];
|
|
554
|
-
/** Compression info for
|
|
555
|
+
/** Compression info for light-token mints */
|
|
555
556
|
compression?: CompressionInfo;
|
|
556
557
|
}
|
|
557
558
|
/**
|
|
558
|
-
* Get unified mint info for SPL/T22/
|
|
559
|
+
* Get unified mint info for SPL/T22/light-token mints.
|
|
559
560
|
*
|
|
560
561
|
* @param rpc RPC connection
|
|
561
562
|
* @param address The mint address
|
|
@@ -567,16 +568,16 @@ interface MintInterface {
|
|
|
567
568
|
*/
|
|
568
569
|
declare function getMintInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<MintInterface>;
|
|
569
570
|
/**
|
|
570
|
-
* Unpack mint info from raw account data for SPL/T22/
|
|
571
|
+
* Unpack mint info from raw account data for SPL/T22/light-token.
|
|
571
572
|
*
|
|
572
573
|
* @param address The mint pubkey
|
|
573
574
|
* @param data The raw account data or AccountInfo
|
|
574
|
-
* @param programId Token program ID. Default
|
|
575
|
+
* @param programId Token program ID. Default light-token.
|
|
575
576
|
* @returns Object with mint, optional mintContext and tokenMetadata.
|
|
576
577
|
*/
|
|
577
578
|
declare function unpackMintInterface(address: PublicKey, data: Buffer$1 | Uint8Array | AccountInfo<Buffer$1>, programId?: PublicKey): Omit<MintInterface, 'merkleContext'>;
|
|
578
579
|
/**
|
|
579
|
-
* Unpack
|
|
580
|
+
* Unpack light-token mint context and metadata from raw account data
|
|
580
581
|
*
|
|
581
582
|
* @param data The raw account data
|
|
582
583
|
* @returns Object with mintContext, tokenMetadata, and extensions
|
|
@@ -588,17 +589,20 @@ declare function unpackMintData(data: Buffer$1 | Uint8Array): {
|
|
|
588
589
|
};
|
|
589
590
|
|
|
590
591
|
/**
|
|
591
|
-
* Create instruction for updating a
|
|
592
|
+
* Create instruction for updating a light mint's mint authority.
|
|
593
|
+
* Works for both compressed and decompressed light mints.
|
|
592
594
|
*
|
|
593
595
|
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext
|
|
594
596
|
* @param currentMintAuthority Current mint authority public key (must sign)
|
|
595
597
|
* @param newMintAuthority New mint authority (or null to revoke)
|
|
596
598
|
* @param payer Fee payer public key
|
|
597
|
-
* @param validityProof Validity proof for the compressed mint
|
|
599
|
+
* @param validityProof Validity proof for the compressed light mint (null for decompressed light mints)
|
|
600
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
598
601
|
*/
|
|
599
|
-
declare function createUpdateMintAuthorityInstruction(mintInterface: MintInterface, currentMintAuthority: PublicKey, newMintAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext): TransactionInstruction;
|
|
602
|
+
declare function createUpdateMintAuthorityInstruction(mintInterface: MintInterface, currentMintAuthority: PublicKey, newMintAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext | null, maxTopUp?: number): TransactionInstruction;
|
|
600
603
|
/**
|
|
601
|
-
* Create instruction for updating a
|
|
604
|
+
* Create instruction for updating a light mint's freeze authority.
|
|
605
|
+
* Works for both compressed and decompressed light mints.
|
|
602
606
|
*
|
|
603
607
|
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
604
608
|
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
@@ -607,12 +611,13 @@ declare function createUpdateMintAuthorityInstruction(mintInterface: MintInterfa
|
|
|
607
611
|
* @param currentFreezeAuthority Current freeze authority public key (must sign)
|
|
608
612
|
* @param newFreezeAuthority New freeze authority (or null to revoke)
|
|
609
613
|
* @param payer Fee payer public key
|
|
610
|
-
* @param validityProof Validity proof for the compressed mint
|
|
614
|
+
* @param validityProof Validity proof for the compressed light mint (null for decompressed light mints)
|
|
615
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
611
616
|
*/
|
|
612
|
-
declare function createUpdateFreezeAuthorityInstruction(mintInterface: MintInterface, currentFreezeAuthority: PublicKey, newFreezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext): TransactionInstruction;
|
|
617
|
+
declare function createUpdateFreezeAuthorityInstruction(mintInterface: MintInterface, currentFreezeAuthority: PublicKey, newFreezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext | null, maxTopUp?: number): TransactionInstruction;
|
|
613
618
|
|
|
614
619
|
/**
|
|
615
|
-
* Create instruction for updating a
|
|
620
|
+
* Create instruction for updating a light mint's metadata field.
|
|
616
621
|
*
|
|
617
622
|
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
618
623
|
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
@@ -620,15 +625,16 @@ declare function createUpdateFreezeAuthorityInstruction(mintInterface: MintInter
|
|
|
620
625
|
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
|
|
621
626
|
* @param authority Metadata update authority public key (must sign)
|
|
622
627
|
* @param payer Fee payer public key
|
|
623
|
-
* @param validityProof Validity proof for the
|
|
628
|
+
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
|
|
624
629
|
* @param fieldType Field to update: 'name', 'symbol', 'uri', or 'custom'
|
|
625
630
|
* @param value New value for the field
|
|
626
631
|
* @param customKey Custom key name (required if fieldType is 'custom')
|
|
627
632
|
* @param extensionIndex Extension index (default: 0)
|
|
633
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
628
634
|
*/
|
|
629
|
-
declare function createUpdateMetadataFieldInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number): TransactionInstruction;
|
|
635
|
+
declare function createUpdateMetadataFieldInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
|
|
630
636
|
/**
|
|
631
|
-
* Create instruction for updating a
|
|
637
|
+
* Create instruction for updating a light mint's metadata authority.
|
|
632
638
|
*
|
|
633
639
|
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
634
640
|
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
@@ -637,12 +643,13 @@ declare function createUpdateMetadataFieldInstruction(mintInterface: MintInterfa
|
|
|
637
643
|
* @param currentAuthority Current metadata update authority public key (must sign)
|
|
638
644
|
* @param newAuthority New metadata update authority public key
|
|
639
645
|
* @param payer Fee payer public key
|
|
640
|
-
* @param validityProof Validity proof for the
|
|
646
|
+
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
|
|
641
647
|
* @param extensionIndex Extension index (default: 0)
|
|
648
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
642
649
|
*/
|
|
643
|
-
declare function createUpdateMetadataAuthorityInstruction(mintInterface: MintInterface, currentAuthority: PublicKey, newAuthority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, extensionIndex?: number): TransactionInstruction;
|
|
650
|
+
declare function createUpdateMetadataAuthorityInstruction(mintInterface: MintInterface, currentAuthority: PublicKey, newAuthority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
|
|
644
651
|
/**
|
|
645
|
-
* Create instruction for removing a metadata key from a
|
|
652
|
+
* Create instruction for removing a metadata key from a light mint.
|
|
646
653
|
*
|
|
647
654
|
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
648
655
|
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
@@ -650,12 +657,13 @@ declare function createUpdateMetadataAuthorityInstruction(mintInterface: MintInt
|
|
|
650
657
|
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
|
|
651
658
|
* @param authority Metadata update authority public key (must sign)
|
|
652
659
|
* @param payer Fee payer public key
|
|
653
|
-
* @param validityProof Validity proof for the
|
|
660
|
+
* @param validityProof Validity proof for the light mint (null for decompressed light mints)
|
|
654
661
|
* @param key Metadata key to remove
|
|
655
662
|
* @param idempotent If true, don't error if key doesn't exist (default: false)
|
|
656
663
|
* @param extensionIndex Extension index (default: 0)
|
|
664
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
657
665
|
*/
|
|
658
|
-
declare function createRemoveMetadataKeyInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, key: string, idempotent?: boolean, extensionIndex?: number): TransactionInstruction;
|
|
666
|
+
declare function createRemoveMetadataKeyInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext | null, key: string, idempotent?: boolean, extensionIndex?: number, maxTopUp?: number): TransactionInstruction;
|
|
659
667
|
|
|
660
668
|
interface CompressToPubkey {
|
|
661
669
|
bump: number;
|
|
@@ -665,49 +673,81 @@ interface CompressToPubkey {
|
|
|
665
673
|
interface CompressibleConfig {
|
|
666
674
|
tokenAccountVersion: number;
|
|
667
675
|
rentPayment: number;
|
|
668
|
-
hasTopUp: number;
|
|
669
676
|
compressionOnly: number;
|
|
670
677
|
writeTopUp: number;
|
|
671
678
|
compressToAccountPubkey?: CompressToPubkey | null;
|
|
672
679
|
}
|
|
673
|
-
interface
|
|
674
|
-
|
|
675
|
-
compressibleConfig?: CompressibleConfig;
|
|
680
|
+
interface CreateAssociatedLightTokenAccountParams {
|
|
681
|
+
compressibleConfig?: CompressibleConfig | null;
|
|
676
682
|
}
|
|
677
683
|
/**
|
|
678
|
-
*
|
|
684
|
+
* Default compressible config for light-token ATAs - matches Rust SDK defaults.
|
|
685
|
+
*
|
|
686
|
+
* - tokenAccountVersion: 3 (ShaFlat) - latest hashing scheme
|
|
687
|
+
* - rentPayment: 16 - prepay 16 epochs (~24 hours rent)
|
|
688
|
+
* - compressionOnly: 1 - required for ATAs
|
|
689
|
+
* - writeTopUp: 766 - per-write top-up (~2 epochs rent) when rent < 2 epochs
|
|
690
|
+
* - compressToAccountPubkey: null - required for ATAs
|
|
691
|
+
*
|
|
692
|
+
* Cost breakdown at associated token account creation:
|
|
693
|
+
* - Rent sponsor PDA (LIGHT_TOKEN_RENT_SPONSOR) pays: rent exemption (~890,880 lamports)
|
|
694
|
+
* - Fee payer pays: compression_cost (11K) + 16 epochs rent (~6,400) = ~17,400 lamports + tx fees
|
|
695
|
+
*
|
|
696
|
+
* Per-write top-up (transfers):
|
|
697
|
+
* - When account rent is below 2 epochs, fee payer pays 766 lamports top-up
|
|
698
|
+
* - This keeps the account perpetually funded when actively used
|
|
699
|
+
*
|
|
700
|
+
* Rent calculation (272-byte compressible lightToken account):
|
|
701
|
+
* - rent_per_epoch = base_rent (128) + bytes * rent_per_byte (272 * 1) = 400 lamports
|
|
702
|
+
* - 16 epochs = 16 * 400 = 6,400 lamports (24 hours)
|
|
703
|
+
* - 2 epochs = 2 * 400 = 800 lamports (~3 hours, writeTopUp = 766 is conservative)
|
|
704
|
+
*
|
|
705
|
+
* Account size breakdown (272 bytes):
|
|
706
|
+
* - 165 bytes: SPL token base layout
|
|
707
|
+
* - 1 byte: account_type discriminator
|
|
708
|
+
* - 1 byte: Option discriminator for extensions
|
|
709
|
+
* - 4 bytes: Vec length prefix
|
|
710
|
+
* - 1 byte: extension type discriminant
|
|
711
|
+
* - 4 bytes: CompressibleExtension header (decimals_option, decimals, compression_only, is_ata)
|
|
712
|
+
* - 96 bytes: CompressionInfo struct
|
|
713
|
+
*/
|
|
714
|
+
declare const DEFAULT_COMPRESSIBLE_CONFIG: CompressibleConfig;
|
|
715
|
+
/**
|
|
716
|
+
* Create instruction for creating an associated light-token account.
|
|
717
|
+
* Uses the default rent sponsor PDA by default.
|
|
679
718
|
*
|
|
680
719
|
* @param feePayer Fee payer public key.
|
|
681
720
|
* @param owner Owner of the associated token account.
|
|
682
721
|
* @param mint Mint address.
|
|
683
|
-
* @param compressibleConfig
|
|
684
|
-
* @param configAccount
|
|
685
|
-
* @param rentPayerPda
|
|
722
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
723
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
724
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
686
725
|
*/
|
|
687
|
-
declare function
|
|
726
|
+
declare function createAssociatedLightTokenAccountInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig | null, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
688
727
|
/**
|
|
689
|
-
* Create idempotent instruction for creating an associated
|
|
728
|
+
* Create idempotent instruction for creating an associated light-token account.
|
|
729
|
+
* Uses the default rent sponsor PDA by default.
|
|
690
730
|
*
|
|
691
731
|
* @param feePayer Fee payer public key.
|
|
692
732
|
* @param owner Owner of the associated token account.
|
|
693
733
|
* @param mint Mint address.
|
|
694
|
-
* @param compressibleConfig
|
|
695
|
-
* @param configAccount
|
|
696
|
-
* @param rentPayerPda
|
|
734
|
+
* @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
|
|
735
|
+
* @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
|
|
736
|
+
* @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
|
|
697
737
|
*/
|
|
698
|
-
declare function
|
|
738
|
+
declare function createAssociatedLightTokenAccountIdempotentInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig | null, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
699
739
|
|
|
700
740
|
/**
|
|
701
|
-
*
|
|
741
|
+
* light-token-specific config for createAssociatedTokenAccountInterfaceInstruction
|
|
702
742
|
*/
|
|
703
|
-
interface
|
|
704
|
-
compressibleConfig?: CompressibleConfig;
|
|
743
|
+
interface LightTokenConfig {
|
|
744
|
+
compressibleConfig?: CompressibleConfig | null;
|
|
705
745
|
configAccount?: PublicKey;
|
|
706
746
|
rentPayerPda?: PublicKey;
|
|
707
747
|
}
|
|
708
748
|
/**
|
|
709
749
|
* Create instruction for creating an associated token account (SPL, Token-2022,
|
|
710
|
-
* or
|
|
750
|
+
* or light-token). Follows SPL Token API signature with optional light-token config at the
|
|
711
751
|
* end.
|
|
712
752
|
*
|
|
713
753
|
* @param payer Fee payer public key.
|
|
@@ -716,12 +756,12 @@ interface CTokenConfig {
|
|
|
716
756
|
* @param mint Mint address.
|
|
717
757
|
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
|
|
718
758
|
* @param associatedTokenProgramId Associated token program ID.
|
|
719
|
-
* @param
|
|
759
|
+
* @param lightTokenConfig Optional light-token-specific configuration.
|
|
720
760
|
*/
|
|
721
|
-
declare function createAssociatedTokenAccountInterfaceInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey,
|
|
761
|
+
declare function createAssociatedTokenAccountInterfaceInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): TransactionInstruction;
|
|
722
762
|
/**
|
|
723
763
|
* Create idempotent instruction for creating an associated token account (SPL,
|
|
724
|
-
* Token-2022, or
|
|
764
|
+
* Token-2022, or light-token). Follows SPL Token API signature with optional light-token
|
|
725
765
|
* config at the end.
|
|
726
766
|
*
|
|
727
767
|
* @param payer Fee payer public key.
|
|
@@ -730,110 +770,14 @@ declare function createAssociatedTokenAccountInterfaceInstruction(payer: PublicK
|
|
|
730
770
|
* @param mint Mint address.
|
|
731
771
|
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
|
|
732
772
|
* @param associatedTokenProgramId Associated token program ID.
|
|
733
|
-
* @param
|
|
773
|
+
* @param lightTokenConfig Optional light-token-specific configuration.
|
|
734
774
|
*/
|
|
735
|
-
declare function createAssociatedTokenAccountInterfaceIdempotentInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey,
|
|
775
|
+
declare function createAssociatedTokenAccountInterfaceIdempotentInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): TransactionInstruction;
|
|
736
776
|
/**
|
|
737
777
|
* Short alias for createAssociatedTokenAccountInterfaceIdempotentInstruction.
|
|
738
778
|
*/
|
|
739
779
|
declare const createAtaInterfaceIdempotentInstruction: typeof createAssociatedTokenAccountInterfaceIdempotentInstruction;
|
|
740
780
|
|
|
741
|
-
/**
|
|
742
|
-
* Create instruction for minting compressed tokens to an onchain token account.
|
|
743
|
-
*
|
|
744
|
-
* @param authority Mint authority public key.
|
|
745
|
-
* @param payer Fee payer public key.
|
|
746
|
-
* @param validityProof Validity proof for the compressed mint.
|
|
747
|
-
* @param merkleContext Merkle context of the compressed mint.
|
|
748
|
-
* @param mintData Mint instruction data.
|
|
749
|
-
* @param outputStateTreeInfo Output state tree info.
|
|
750
|
-
* @param recipientAccount Recipient onchain token account address.
|
|
751
|
-
* @param amount Amount to mint.
|
|
752
|
-
*/
|
|
753
|
-
declare function createMintToInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, outputStateTreeInfo: TreeInfo, recipientAccount: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
754
|
-
|
|
755
|
-
/**
|
|
756
|
-
* Token data version enum - mirrors Rust TokenDataVersion
|
|
757
|
-
* Used for compressed token account hashing strategy
|
|
758
|
-
*/
|
|
759
|
-
declare enum TokenDataVersion {
|
|
760
|
-
/** V1: Poseidon hash with little-endian amount, discriminator [2,0,0,0,0,0,0,0] */
|
|
761
|
-
V1 = 1,
|
|
762
|
-
/** V2: Poseidon hash with big-endian amount, discriminator [0,0,0,0,0,0,0,3] */
|
|
763
|
-
V2 = 2,
|
|
764
|
-
/** ShaFlat: SHA256 hash of borsh-serialized data, discriminator [0,0,0,0,0,0,0,4] */
|
|
765
|
-
ShaFlat = 3
|
|
766
|
-
}
|
|
767
|
-
declare const POOL_SEED: Buffer$1<ArrayBuffer>;
|
|
768
|
-
declare const CPI_AUTHORITY_SEED: Buffer$1<ArrayBuffer>;
|
|
769
|
-
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
770
|
-
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
771
|
-
declare const MINT_TO_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
772
|
-
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
773
|
-
declare const TRANSFER_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
774
|
-
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
775
|
-
declare const APPROVE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
776
|
-
declare const REVOKE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
777
|
-
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
778
|
-
declare const DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
779
|
-
|
|
780
|
-
/**
|
|
781
|
-
* Create instruction for minting tokens from a c-mint to compressed accounts.
|
|
782
|
-
* To mint to onchain token accounts across SPL/T22/c-mints, use
|
|
783
|
-
* {@link createMintToInterfaceInstruction} instead.
|
|
784
|
-
*
|
|
785
|
-
* @param authority Mint authority public key.
|
|
786
|
-
* @param payer Fee payer public key.
|
|
787
|
-
* @param validityProof Validity proof for the compressed mint.
|
|
788
|
-
* @param merkleContext Merkle context of the compressed mint.
|
|
789
|
-
* @param mintData Mint instruction data.
|
|
790
|
-
* @param recipients Array of recipients with amounts.
|
|
791
|
-
* @param outputStateTreeInfo Optional output state tree info. Uses merkle
|
|
792
|
-
* context queue if not provided.
|
|
793
|
-
* @param tokenAccountVersion Token account version (default:
|
|
794
|
-
* TokenDataVersion.ShaFlat).
|
|
795
|
-
*/
|
|
796
|
-
declare function createMintToCompressedInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, recipients: Array<{
|
|
797
|
-
recipient: PublicKey;
|
|
798
|
-
amount: number | bigint;
|
|
799
|
-
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: TokenDataVersion): TransactionInstruction;
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Create mint-to instruction for SPL, Token-2022, or compressed token mints.
|
|
803
|
-
* This instruction ONLY mints to decompressed/onchain token accounts.
|
|
804
|
-
*
|
|
805
|
-
* @param mintInterface Mint interface (SPL, Token-2022, or compressed).
|
|
806
|
-
* @param destination Destination onchain token account address.
|
|
807
|
-
* @param authority Mint authority public key.
|
|
808
|
-
* @param payer Fee payer public key.
|
|
809
|
-
* @param amount Amount to mint.
|
|
810
|
-
* @param validityProof Validity proof (required for compressed mints).
|
|
811
|
-
* @param multiSigners Multi-signature signer public keys.
|
|
812
|
-
*/
|
|
813
|
-
declare function createMintToInterfaceInstruction(mintInterface: MintInterface, destination: PublicKey, authority: PublicKey, payer: PublicKey, amount: number | bigint, validityProof?: ValidityProofWithContext, multiSigners?: PublicKey[]): TransactionInstruction;
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* Create a c-token transfer instruction.
|
|
817
|
-
*
|
|
818
|
-
* @param source Source c-token account
|
|
819
|
-
* @param destination Destination c-token account
|
|
820
|
-
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
821
|
-
* @param amount Amount to transfer
|
|
822
|
-
* @returns Transaction instruction for c-token transfer
|
|
823
|
-
*/
|
|
824
|
-
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
825
|
-
/**
|
|
826
|
-
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
827
|
-
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
828
|
-
*
|
|
829
|
-
* @param source Source token account
|
|
830
|
-
* @param destination Destination token account
|
|
831
|
-
* @param owner Owner of the source account (signer)
|
|
832
|
-
* @param amount Amount to transfer
|
|
833
|
-
* @returns instruction for c-token transfer
|
|
834
|
-
*/
|
|
835
|
-
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey): TransactionInstruction;
|
|
836
|
-
|
|
837
781
|
declare namespace BN {
|
|
838
782
|
type Endianness = "le" | "be";
|
|
839
783
|
type IPrimeName = "k256" | "p224" | "p192" | "p25519";
|
|
@@ -1427,6 +1371,77 @@ declare class RedBN extends BN {
|
|
|
1427
1371
|
redPow(b: BN): RedBN;
|
|
1428
1372
|
}
|
|
1429
1373
|
|
|
1374
|
+
declare const TokenAccountSourceType: {
|
|
1375
|
+
readonly Spl: "spl";
|
|
1376
|
+
readonly Token2022: "token2022";
|
|
1377
|
+
readonly SplCold: "spl-cold";
|
|
1378
|
+
readonly Token2022Cold: "token2022-cold";
|
|
1379
|
+
readonly LightTokenHot: "light-token-hot";
|
|
1380
|
+
readonly LightTokenCold: "light-token-cold";
|
|
1381
|
+
};
|
|
1382
|
+
type TokenAccountSourceTypeValue = (typeof TokenAccountSourceType)[keyof typeof TokenAccountSourceType];
|
|
1383
|
+
/** @internal */
|
|
1384
|
+
interface TokenAccountSource {
|
|
1385
|
+
type: TokenAccountSourceTypeValue;
|
|
1386
|
+
address: PublicKey;
|
|
1387
|
+
amount: bigint;
|
|
1388
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1389
|
+
loadContext?: MerkleContext;
|
|
1390
|
+
parsed: Account;
|
|
1391
|
+
}
|
|
1392
|
+
interface AccountInterface {
|
|
1393
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1394
|
+
parsed: Account;
|
|
1395
|
+
isCold: boolean;
|
|
1396
|
+
loadContext?: MerkleContext;
|
|
1397
|
+
_sources?: TokenAccountSource[];
|
|
1398
|
+
_needsConsolidation?: boolean;
|
|
1399
|
+
_hasDelegate?: boolean;
|
|
1400
|
+
_anyFrozen?: boolean;
|
|
1401
|
+
/** True when fetched via getAtaInterface */
|
|
1402
|
+
_isAta?: boolean;
|
|
1403
|
+
/** Associated token account owner - set by getAtaInterface */
|
|
1404
|
+
_owner?: PublicKey;
|
|
1405
|
+
/** Associated token account mint - set by getAtaInterface */
|
|
1406
|
+
_mint?: PublicKey;
|
|
1407
|
+
}
|
|
1408
|
+
/** @internal */
|
|
1409
|
+
declare function convertTokenDataToAccount(address: PublicKey, tokenData: {
|
|
1410
|
+
mint: PublicKey;
|
|
1411
|
+
owner: PublicKey;
|
|
1412
|
+
amount: BN;
|
|
1413
|
+
delegate: PublicKey | null;
|
|
1414
|
+
state: number;
|
|
1415
|
+
tlv: Buffer$1 | null;
|
|
1416
|
+
}): Account;
|
|
1417
|
+
/** Convert compressed account to AccountInfo */
|
|
1418
|
+
declare function toAccountInfo(compressedAccount: CompressedAccountWithMerkleContext): AccountInfo<Buffer$1>;
|
|
1419
|
+
/** @internal */
|
|
1420
|
+
declare function parseLightTokenHot(address: PublicKey, accountInfo: AccountInfo<Buffer$1>): {
|
|
1421
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1422
|
+
loadContext: undefined;
|
|
1423
|
+
parsed: Account;
|
|
1424
|
+
isCold: false;
|
|
1425
|
+
};
|
|
1426
|
+
/** @internal */
|
|
1427
|
+
declare function parseLightTokenCold(address: PublicKey, compressedAccount: CompressedAccountWithMerkleContext): {
|
|
1428
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1429
|
+
loadContext: MerkleContext;
|
|
1430
|
+
parsed: Account;
|
|
1431
|
+
isCold: true;
|
|
1432
|
+
};
|
|
1433
|
+
/**
|
|
1434
|
+
* Retrieve information about a token account of SPL/T22/light-token.
|
|
1435
|
+
*
|
|
1436
|
+
* @param rpc RPC connection to use
|
|
1437
|
+
* @param address Token account address
|
|
1438
|
+
* @param commitment Desired level of commitment for querying the state
|
|
1439
|
+
* @param programId Token program ID. If not provided, tries all programs concurrently.
|
|
1440
|
+
*
|
|
1441
|
+
* @return Token account information with compression context if applicable
|
|
1442
|
+
*/
|
|
1443
|
+
declare function getAccountInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<AccountInterface>;
|
|
1444
|
+
|
|
1430
1445
|
/**
|
|
1431
1446
|
* SPL interface PDA info.
|
|
1432
1447
|
*/
|
|
@@ -1611,277 +1626,357 @@ declare function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo;
|
|
|
1611
1626
|
*/
|
|
1612
1627
|
declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], decompressAmount: number | BN): TokenPoolInfo[];
|
|
1613
1628
|
|
|
1629
|
+
declare function sliceLast<T>(items: T[]): {
|
|
1630
|
+
rest: T[];
|
|
1631
|
+
last: T;
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1614
1634
|
/**
|
|
1615
|
-
* Create
|
|
1635
|
+
* Create a light-token transfer instruction.
|
|
1616
1636
|
*
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1619
|
-
* - For SPL destinations: Provide splInterfaceInfo (token pool info) and decimals
|
|
1637
|
+
* For light-token accounts with compressible extension, the program needs
|
|
1638
|
+
* system_program and fee_payer to handle rent top-ups.
|
|
1620
1639
|
*
|
|
1621
|
-
* @param
|
|
1622
|
-
* @param
|
|
1623
|
-
* @param
|
|
1624
|
-
* @param amount
|
|
1625
|
-
* @param
|
|
1626
|
-
* @
|
|
1627
|
-
|
|
1628
|
-
|
|
1640
|
+
* @param source Source light-token account
|
|
1641
|
+
* @param destination Destination light-token account
|
|
1642
|
+
* @param owner Owner of the source account (signer, also pays for compressible extension top-ups)
|
|
1643
|
+
* @param amount Amount to transfer
|
|
1644
|
+
* @param feePayer Optional fee payer for top-ups (defaults to owner)
|
|
1645
|
+
* @returns Transaction instruction for light-token transfer
|
|
1646
|
+
*/
|
|
1647
|
+
declare function createLightTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
|
|
1648
|
+
/**
|
|
1649
|
+
* Create a light-token transfer_checked instruction. Same semantics as SPL
|
|
1650
|
+
* TransferChecked.
|
|
1629
1651
|
*/
|
|
1630
|
-
declare function
|
|
1652
|
+
declare function createLightTokenTransferCheckedInstruction(source: PublicKey, destination: PublicKey, mint: PublicKey, owner: PublicKey, amount: number | bigint, decimals: number, payer: PublicKey): TransactionInstruction;
|
|
1653
|
+
declare function createTransferToAccountInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, amount: number | bigint | BN, sender: PublicKey, destination: PublicKey, decimals: number, options?: TransferOptions): Promise<TransactionInstruction[][]>;
|
|
1631
1654
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
};
|
|
1640
|
-
type TokenAccountSourceTypeValue = (typeof TokenAccountSourceType)[keyof typeof TokenAccountSourceType];
|
|
1641
|
-
/** @internal */
|
|
1642
|
-
interface TokenAccountSource {
|
|
1643
|
-
type: TokenAccountSourceTypeValue;
|
|
1644
|
-
address: PublicKey;
|
|
1645
|
-
amount: bigint;
|
|
1646
|
-
accountInfo: AccountInfo<Buffer$1>;
|
|
1647
|
-
loadContext?: MerkleContext;
|
|
1648
|
-
parsed: Account;
|
|
1655
|
+
interface InterfaceOptions {
|
|
1656
|
+
splInterfaceInfos?: SplInterfaceInfo[];
|
|
1657
|
+
/**
|
|
1658
|
+
* ATA owner (authority owner) used to derive the ATA when the signer is a
|
|
1659
|
+
* delegate. For owner-signed flows, omit this field.
|
|
1660
|
+
*/
|
|
1661
|
+
owner?: PublicKey;
|
|
1649
1662
|
}
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
_sources?: TokenAccountSource[];
|
|
1656
|
-
_needsConsolidation?: boolean;
|
|
1657
|
-
_hasDelegate?: boolean;
|
|
1658
|
-
_anyFrozen?: boolean;
|
|
1659
|
-
/** True when fetched via getAtaInterface */
|
|
1660
|
-
_isAta?: boolean;
|
|
1661
|
-
/** ATA owner - set by getAtaInterface */
|
|
1662
|
-
_owner?: PublicKey;
|
|
1663
|
-
/** ATA mint - set by getAtaInterface */
|
|
1664
|
-
_mint?: PublicKey;
|
|
1663
|
+
declare function transferToAccountInterface(rpc: Rpc, payer: Signer, source: PublicKey, mint: PublicKey, destination: PublicKey, owner: Signer, amount: number | bigint | BN, programId?: PublicKey, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, wrap?: boolean, decimals?: number): Promise<TransactionSignature>;
|
|
1664
|
+
declare function transferInterface(rpc: Rpc, payer: Signer, source: PublicKey, mint: PublicKey, recipient: PublicKey, owner: Signer, amount: number | bigint | BN, programId?: PublicKey, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, wrap?: boolean, decimals?: number): Promise<TransactionSignature>;
|
|
1665
|
+
interface TransferOptions extends InterfaceOptions {
|
|
1666
|
+
wrap?: boolean;
|
|
1667
|
+
programId?: PublicKey;
|
|
1665
1668
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1669
|
+
declare function createTransferInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, amount: number | bigint | BN, sender: PublicKey, recipient: PublicKey, decimals: number, options?: TransferOptions): Promise<TransactionInstruction[][]>;
|
|
1670
|
+
|
|
1671
|
+
declare function selectInputsForAmount(accounts: ParsedTokenAccount[], neededAmount: bigint): ParsedTokenAccount[];
|
|
1672
|
+
|
|
1673
|
+
/**
|
|
1674
|
+
* Parameters for creating a MintTo instruction.
|
|
1675
|
+
*/
|
|
1676
|
+
interface CreateMintToInstructionParams {
|
|
1677
|
+
/** Light mint account (decompressed from compressed light mint) */
|
|
1668
1678
|
mint: PublicKey;
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
/**
|
|
1676
|
-
|
|
1677
|
-
/**
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
loadContext: undefined;
|
|
1681
|
-
parsed: Account;
|
|
1682
|
-
isCold: false;
|
|
1683
|
-
};
|
|
1684
|
-
/** @internal */
|
|
1685
|
-
declare function parseCTokenCold(address: PublicKey, compressedAccount: CompressedAccountWithMerkleContext): {
|
|
1686
|
-
accountInfo: AccountInfo<Buffer$1>;
|
|
1687
|
-
loadContext: MerkleContext;
|
|
1688
|
-
parsed: Account;
|
|
1689
|
-
isCold: true;
|
|
1690
|
-
};
|
|
1679
|
+
/** Destination light-token account to mint to */
|
|
1680
|
+
destination: PublicKey;
|
|
1681
|
+
/** Amount of tokens to mint */
|
|
1682
|
+
amount: number | bigint;
|
|
1683
|
+
/** Mint authority (must be signer) */
|
|
1684
|
+
authority: PublicKey;
|
|
1685
|
+
/** Maximum lamports for rent and top-up combined. Transaction fails if exceeded. (u16::MAX = no limit, 0 = no top-ups allowed) */
|
|
1686
|
+
maxTopUp?: number;
|
|
1687
|
+
/** Optional fee payer for rent top-ups. If not provided, authority pays. */
|
|
1688
|
+
feePayer?: PublicKey;
|
|
1689
|
+
}
|
|
1691
1690
|
/**
|
|
1692
|
-
*
|
|
1691
|
+
* Create instruction for minting tokens to a light-token account.
|
|
1693
1692
|
*
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
1696
|
-
* @param commitment Desired level of commitment for querying the state
|
|
1697
|
-
* @param programId Token program ID. If not provided, tries all programs concurrently.
|
|
1693
|
+
* This is a simple 3-4 account instruction for minting to light-token associated token accounts (hot).
|
|
1694
|
+
* Uses discriminator 7 (LightTokenMintTo).
|
|
1698
1695
|
*
|
|
1699
|
-
* @
|
|
1696
|
+
* @param params - Mint instruction parameters
|
|
1697
|
+
* @returns TransactionInstruction for minting tokens
|
|
1700
1698
|
*/
|
|
1701
|
-
declare function
|
|
1699
|
+
declare function createMintToInstruction(params: CreateMintToInstructionParams): TransactionInstruction;
|
|
1702
1700
|
|
|
1701
|
+
/** Default compressible config PDA (V1) */
|
|
1702
|
+
declare const LIGHT_TOKEN_CONFIG: PublicKey;
|
|
1703
|
+
/** Default rent sponsor PDA (V1) */
|
|
1704
|
+
declare const LIGHT_TOKEN_RENT_SPONSOR: PublicKey;
|
|
1703
1705
|
/**
|
|
1704
|
-
*
|
|
1706
|
+
* Token data version enum - mirrors Rust TokenDataVersion
|
|
1707
|
+
* Used for compressed token account hashing strategy
|
|
1705
1708
|
*/
|
|
1706
|
-
|
|
1707
|
-
/**
|
|
1708
|
-
|
|
1709
|
+
declare enum TokenDataVersion {
|
|
1710
|
+
/** V1: Poseidon hash with little-endian amount, discriminator [2,0,0,0,0,0,0,0] */
|
|
1711
|
+
V1 = 1,
|
|
1712
|
+
/** V2: Poseidon hash with big-endian amount, discriminator [0,0,0,0,0,0,0,3] */
|
|
1713
|
+
V2 = 2,
|
|
1714
|
+
/** ShaFlat: SHA256 hash of borsh-serialized data, discriminator [0,0,0,0,0,0,0,4] */
|
|
1715
|
+
ShaFlat = 3
|
|
1709
1716
|
}
|
|
1717
|
+
declare const POOL_SEED: Buffer$1<ArrayBuffer>;
|
|
1718
|
+
declare const CPI_AUTHORITY_SEED: Buffer$1<ArrayBuffer>;
|
|
1719
|
+
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
1720
|
+
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1721
|
+
declare const MINT_TO_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1722
|
+
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1723
|
+
declare const TRANSFER_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1724
|
+
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1725
|
+
declare const APPROVE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1726
|
+
declare const REVOKE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1727
|
+
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
1710
1728
|
/**
|
|
1711
|
-
*
|
|
1712
|
-
*
|
|
1713
|
-
* Matches
|
|
1714
|
-
*
|
|
1715
|
-
* @param rpc RPC connection
|
|
1716
|
-
* @param payer Fee payer (signer)
|
|
1717
|
-
* @param source Source c-token ATA address
|
|
1718
|
-
* @param mint Mint address
|
|
1719
|
-
* @param destination Destination c-token ATA address (must exist)
|
|
1720
|
-
* @param owner Source owner (signer)
|
|
1721
|
-
* @param amount Amount to transfer
|
|
1722
|
-
* @param programId Token program ID (default: CTOKEN_PROGRAM_ID)
|
|
1723
|
-
* @param confirmOptions Optional confirm options
|
|
1724
|
-
* @param options Optional interface options
|
|
1725
|
-
* @param wrap Include SPL/T22 wrapping (default: false)
|
|
1726
|
-
* @returns Transaction signature
|
|
1729
|
+
* Maximum lamports for rent top-up in a single instruction.
|
|
1730
|
+
* u16::MAX = no limit; 0 = no top-ups allowed.
|
|
1731
|
+
* Matches Rust SDK (e.g. token-sdk create_mints uses u16::MAX for "no limit").
|
|
1727
1732
|
*/
|
|
1728
|
-
declare
|
|
1729
|
-
|
|
1733
|
+
declare const MAX_TOP_UP = 65535;
|
|
1730
1734
|
/**
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1734
|
-
* Integrating programs provide their own fetch/parse - this is just the data shape.
|
|
1735
|
+
* Rent configuration constants for compressible light token accounts.
|
|
1736
|
+
* These match the Rust SDK defaults in program-libs/compressible/src/rent/config.rs
|
|
1735
1737
|
*/
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1738
|
+
/** Base rent per epoch (lamports) */
|
|
1739
|
+
declare const BASE_RENT_PER_EPOCH = 128;
|
|
1740
|
+
/** Rent per byte per epoch (lamports) */
|
|
1741
|
+
declare const RENT_PER_BYTE_PER_EPOCH = 1;
|
|
1742
|
+
/** Slots per rent epoch (1.5 hours) */
|
|
1743
|
+
declare const SLOTS_PER_RENT_EPOCH = 13500;
|
|
1744
|
+
/** Compression cost (lamports) - paid at account creation */
|
|
1745
|
+
declare const COMPRESSION_COST = 10000;
|
|
1746
|
+
/** Compression incentive (lamports) - paid at account creation */
|
|
1747
|
+
declare const COMPRESSION_INCENTIVE = 1000;
|
|
1748
|
+
/** Total compression cost (COMPRESSION_COST + COMPRESSION_INCENTIVE) */
|
|
1749
|
+
declare const TOTAL_COMPRESSION_COST: number;
|
|
1742
1750
|
/**
|
|
1743
|
-
*
|
|
1744
|
-
*
|
|
1745
|
-
*
|
|
1746
|
-
* The integrating program is responsible for fetching and parsing their accounts.
|
|
1747
|
-
* This helper just packs them for the decompressAccountsIdempotent instruction.
|
|
1751
|
+
* Compressible light token account size in bytes.
|
|
1752
|
+
* = 165 (base SPL token) + 1 (account_type) + 1 (Option) + 4 (Vec len) + 1 (ext disc) + 4 (ext header) + 96 (CompressionInfo) = 272
|
|
1753
|
+
* Source: program-libs/token-interface/src/state/token/top_up.rs MIN_SIZE_WITH_COMPRESSIBLE
|
|
1748
1754
|
*/
|
|
1749
|
-
|
|
1750
|
-
/** Account address */
|
|
1751
|
-
address: PublicKey;
|
|
1752
|
-
/**
|
|
1753
|
-
* Account type key for packing:
|
|
1754
|
-
* - For PDAs: program-specific type name (e.g., "poolState", "observationState")
|
|
1755
|
-
* - For c-token vaults: "cTokenData"
|
|
1756
|
-
*/
|
|
1757
|
-
accountType: string;
|
|
1758
|
-
/**
|
|
1759
|
-
* Token variant - required when accountType is "cTokenData".
|
|
1760
|
-
* Examples: "lpVault", "token0Vault", "token1Vault"
|
|
1761
|
-
*/
|
|
1762
|
-
tokenVariant?: string;
|
|
1763
|
-
/** Parsed account info (from program-specific fetch) */
|
|
1764
|
-
info: ParsedAccountInfoInterface<T>;
|
|
1765
|
-
}
|
|
1755
|
+
declare const COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE = 272;
|
|
1766
1756
|
/**
|
|
1767
|
-
*
|
|
1757
|
+
* Calculate rent per epoch for a given account size.
|
|
1758
|
+
* Formula: base_rent + (bytes * lamports_per_byte_per_epoch)
|
|
1768
1759
|
*/
|
|
1769
|
-
|
|
1770
|
-
[key: string]: unknown;
|
|
1771
|
-
merkleContext: {
|
|
1772
|
-
merkleTreePubkeyIndex: number;
|
|
1773
|
-
queuePubkeyIndex: number;
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1760
|
+
declare function rentPerEpoch(bytes: number): number;
|
|
1776
1761
|
/**
|
|
1777
|
-
*
|
|
1762
|
+
* Default rent per epoch for a compressible light token account (272 bytes).
|
|
1763
|
+
* = 128 + 272 = 400 lamports
|
|
1778
1764
|
*/
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
/** Packed compressed accounts data for instruction */
|
|
1785
|
-
compressedAccounts: PackedCompressedAccount[];
|
|
1786
|
-
/** Offset to system accounts in remainingAccounts */
|
|
1787
|
-
systemAccountsOffset: number;
|
|
1788
|
-
/** Account metas for remaining accounts */
|
|
1789
|
-
remainingAccounts: AccountMeta[];
|
|
1790
|
-
}
|
|
1765
|
+
declare const COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH: number;
|
|
1766
|
+
/** Default prepaid epochs (24 hours = 16 epochs * 1.5h) */
|
|
1767
|
+
declare const DEFAULT_PREPAY_EPOCHS = 16;
|
|
1768
|
+
/** Default write top-up (lamports) - ~2 epochs rent */
|
|
1769
|
+
declare const DEFAULT_WRITE_TOP_UP = 766;
|
|
1791
1770
|
/**
|
|
1792
|
-
*
|
|
1771
|
+
* Calculate fee payer cost at ATA creation.
|
|
1772
|
+
* = compression_cost (11K) + (prepay_epochs * rent_per_epoch)
|
|
1793
1773
|
*/
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
decompressParams: CompressibleLoadParams | null;
|
|
1797
|
-
/** Instructions to load ATAs (create ATA, wrap SPL/T22, decompressInterface) */
|
|
1798
|
-
ataInstructions: TransactionInstruction[];
|
|
1799
|
-
}
|
|
1774
|
+
declare function calculateFeePayerCostAtCreation(prepayEpochs?: number, accountBytes?: number): number;
|
|
1775
|
+
|
|
1800
1776
|
/**
|
|
1801
|
-
* Create
|
|
1802
|
-
*
|
|
1803
|
-
*
|
|
1804
|
-
* - decompressParams: for a caller program's standardized
|
|
1805
|
-
* decompressAccountsIdempotent instruction
|
|
1806
|
-
* - ataInstructions: for loading user ATAs
|
|
1807
|
-
*
|
|
1808
|
-
* @param rpc RPC connection
|
|
1809
|
-
* @param payer Fee payer (needed for ATA instructions)
|
|
1810
|
-
* @param programId Program ID for decompressAccountsIdempotent
|
|
1811
|
-
* @param programAccounts PDAs and vaults (caller pre-fetches)
|
|
1812
|
-
* @param atas User ATAs (fetched via getAtaInterface)
|
|
1813
|
-
* @param options Optional load options
|
|
1814
|
-
* @returns LoadResult with decompressParams and ataInstructions
|
|
1815
|
-
*
|
|
1816
|
-
* @example
|
|
1817
|
-
* ```typescript
|
|
1818
|
-
* const poolInfo = await myProgram.fetchPoolState(rpc, poolAddress);
|
|
1819
|
-
* const vault0Ata = getAssociatedTokenAddressInterface(token0Mint, poolAddress);
|
|
1820
|
-
* const vault0Info = await getAtaInterface(rpc, vault0Ata, poolAddress, token0Mint, undefined, CTOKEN_PROGRAM_ID);
|
|
1821
|
-
* const userAta = getAssociatedTokenAddressInterface(tokenMint, userWallet);
|
|
1822
|
-
* const userAtaInfo = await getAtaInterface(rpc, userAta, userWallet, tokenMint);
|
|
1823
|
-
*
|
|
1824
|
-
* const result = await createLoadAccountsParams(
|
|
1825
|
-
* rpc,
|
|
1826
|
-
* payer.publicKey,
|
|
1827
|
-
* programId,
|
|
1828
|
-
* [
|
|
1829
|
-
* { address: poolAddress, accountType: 'poolState', info: poolInfo },
|
|
1830
|
-
* { address: vault0, accountType: 'cTokenData', tokenVariant: 'token0Vault', info: vault0Info },
|
|
1831
|
-
* ],
|
|
1832
|
-
* [userAta],
|
|
1833
|
-
* );
|
|
1777
|
+
* Create instruction for minting tokens from a light mint to compressed accounts.
|
|
1778
|
+
* To mint to light-token associated token accounts across SPL/T22/light mints, use
|
|
1779
|
+
* {@link createMintToInterfaceInstruction} instead.
|
|
1834
1780
|
*
|
|
1835
|
-
*
|
|
1836
|
-
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1840
|
-
*
|
|
1841
|
-
*
|
|
1842
|
-
*
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1846
|
-
* }
|
|
1847
|
-
* ```
|
|
1781
|
+
* @param authority Mint authority public key.
|
|
1782
|
+
* @param payer Fee payer public key.
|
|
1783
|
+
* @param validityProof Validity proof for the light mint.
|
|
1784
|
+
* @param merkleContext Merkle context of the light mint.
|
|
1785
|
+
* @param mintData Mint instruction data.
|
|
1786
|
+
* @param recipients Array of recipients with amounts.
|
|
1787
|
+
* @param outputStateTreeInfo Optional output state tree info. Uses merkle
|
|
1788
|
+
* context queue if not provided.
|
|
1789
|
+
* @param tokenAccountVersion Token account version (default:
|
|
1790
|
+
* TokenDataVersion.ShaFlat).
|
|
1791
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
1848
1792
|
*/
|
|
1849
|
-
declare function
|
|
1793
|
+
declare function createMintToCompressedInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, recipients: Array<{
|
|
1794
|
+
recipient: PublicKey;
|
|
1795
|
+
amount: number | bigint;
|
|
1796
|
+
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: TokenDataVersion, maxTopUp?: number): TransactionInstruction;
|
|
1797
|
+
|
|
1850
1798
|
/**
|
|
1851
|
-
*
|
|
1799
|
+
* Create mint-to instruction for SPL, Token-2022, or light-token mints.
|
|
1800
|
+
* This instruction ONLY mints to light-token associated token accounts (hot).
|
|
1801
|
+
*
|
|
1802
|
+
* For light-token mints, the light mint account must exist (mint must be decompressed first).
|
|
1803
|
+
*
|
|
1804
|
+
* @param mintInterface Mint interface (SPL, Token-2022, or light-token).
|
|
1805
|
+
* @param destination Destination onchain token account address.
|
|
1806
|
+
* @param authority Mint authority public key.
|
|
1807
|
+
* @param payer Fee payer public key.
|
|
1808
|
+
* @param amount Amount to mint.
|
|
1809
|
+
* @param validityProof Not used (legacy parameter, kept for compatibility).
|
|
1810
|
+
* @param multiSigners Multi-signature signer public keys (SPL/T22 only).
|
|
1852
1811
|
*/
|
|
1853
|
-
declare function
|
|
1812
|
+
declare function createMintToInterfaceInstruction(mintInterface: MintInterface, destination: PublicKey, authority: PublicKey, payer: PublicKey, amount: number | bigint, validityProof?: ValidityProofWithContext, multiSigners?: PublicKey[]): TransactionInstruction;
|
|
1854
1813
|
|
|
1855
1814
|
/**
|
|
1856
1815
|
* Create a wrap instruction that moves tokens from an SPL/T22 account to a
|
|
1857
|
-
*
|
|
1816
|
+
* light-token account.
|
|
1858
1817
|
*
|
|
1859
1818
|
* @param source Source SPL/T22 token account
|
|
1860
|
-
* @param destination Destination
|
|
1819
|
+
* @param destination Destination light-token account
|
|
1861
1820
|
* @param owner Owner of the source account (signer)
|
|
1862
1821
|
* @param mint Mint address
|
|
1863
1822
|
* @param amount Amount to wrap,
|
|
1864
1823
|
* @param splInterfaceInfo SPL interface info for the compression
|
|
1865
1824
|
* @param decimals Mint decimals (required for transfer_checked)
|
|
1866
1825
|
* @param payer Fee payer (defaults to owner)
|
|
1826
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
1867
1827
|
* @returns Instruction to wrap tokens
|
|
1868
1828
|
*/
|
|
1869
|
-
declare function createWrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, decimals: number, payer?: PublicKey): TransactionInstruction;
|
|
1829
|
+
declare function createWrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, decimals: number, payer?: PublicKey, maxTopUp?: number): TransactionInstruction;
|
|
1830
|
+
|
|
1831
|
+
/**
|
|
1832
|
+
* Create an unwrap instruction that moves tokens from a light-token account to an
|
|
1833
|
+
* SPL/T22 account.
|
|
1834
|
+
*
|
|
1835
|
+
* @param source Source light-token account
|
|
1836
|
+
* @param destination Destination SPL/T22 token account
|
|
1837
|
+
* @param owner Owner of the source account (signer)
|
|
1838
|
+
* @param mint Mint address
|
|
1839
|
+
* @param amount Amount to unwrap,
|
|
1840
|
+
* @param splInterfaceInfo SPL interface info for the decompression
|
|
1841
|
+
* @param decimals Mint decimals (required for transfer_checked)
|
|
1842
|
+
* @param payer Fee payer (defaults to owner if not provided)
|
|
1843
|
+
* @param maxTopUp Optional cap on rent top-up (units of 1k lamports; default no cap)
|
|
1844
|
+
* @returns TransactionInstruction to unwrap tokens
|
|
1845
|
+
*/
|
|
1846
|
+
declare function createUnwrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, decimals: number, payer?: PublicKey, maxTopUp?: number): TransactionInstruction;
|
|
1847
|
+
declare function createUnwrapInstructions(rpc: Rpc, destination: PublicKey, owner: PublicKey, mint: PublicKey, decimals: number, amount?: number | bigint | BN, payer?: PublicKey, splInterfaceInfo?: SplInterfaceInfo, maxTopUp?: number, interfaceOptions?: InterfaceOptions, wrap?: boolean): Promise<TransactionInstruction[][]>;
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* Create an instruction to freeze a decompressed light-token account.
|
|
1851
|
+
*
|
|
1852
|
+
* Freezing sets the account state to AccountState::Frozen, preventing
|
|
1853
|
+
* transfers and other token operations. Only the mint's freeze_authority
|
|
1854
|
+
* can freeze accounts.
|
|
1855
|
+
*
|
|
1856
|
+
* Account order per program:
|
|
1857
|
+
* 0. token_account (mutable) - the light-token account to freeze
|
|
1858
|
+
* 1. mint (readonly) - the mint associated with the token account
|
|
1859
|
+
* 2. freeze_authority - must match mint.freeze_authority (signer)
|
|
1860
|
+
*
|
|
1861
|
+
* @param tokenAccount The light-token account to freeze (must be Initialized)
|
|
1862
|
+
* @param mint The mint of the light-token account
|
|
1863
|
+
* @param freezeAuthority The freeze authority of the mint (signer)
|
|
1864
|
+
* @returns TransactionInstruction
|
|
1865
|
+
*/
|
|
1866
|
+
declare function createLightTokenFreezeAccountInstruction(tokenAccount: PublicKey, mint: PublicKey, freezeAuthority: PublicKey): TransactionInstruction;
|
|
1867
|
+
/**
|
|
1868
|
+
* Create an instruction to thaw (unfreeze) a frozen light-token account.
|
|
1869
|
+
*
|
|
1870
|
+
* Thawing restores the account state from AccountState::Frozen to
|
|
1871
|
+
* AccountState::Initialized, re-enabling token operations. Only the
|
|
1872
|
+
* mint's freeze_authority can thaw accounts.
|
|
1873
|
+
*
|
|
1874
|
+
* Account order per program:
|
|
1875
|
+
* 0. token_account (mutable) - the frozen light-token account to thaw
|
|
1876
|
+
* 1. mint (readonly) - the mint associated with the token account
|
|
1877
|
+
* 2. freeze_authority - must match mint.freeze_authority (signer)
|
|
1878
|
+
*
|
|
1879
|
+
* @param tokenAccount The frozen light-token account to thaw
|
|
1880
|
+
* @param mint The mint of the light-token account
|
|
1881
|
+
* @param freezeAuthority The freeze authority of the mint (signer)
|
|
1882
|
+
* @returns TransactionInstruction
|
|
1883
|
+
*/
|
|
1884
|
+
declare function createLightTokenThawAccountInstruction(tokenAccount: PublicKey, mint: PublicKey, freezeAuthority: PublicKey): TransactionInstruction;
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* Create an instruction to approve a delegate for a light-token account.
|
|
1888
|
+
*
|
|
1889
|
+
* Account order per program:
|
|
1890
|
+
* 0. token_account (mutable) - the light-token account
|
|
1891
|
+
* 1. delegate (readonly) - the delegate to approve
|
|
1892
|
+
* 2. owner (signer) - owner of the token account
|
|
1893
|
+
* 3. system_program (readonly) - for rent top-ups via CPI
|
|
1894
|
+
* 4. fee_payer (mutable, signer) - pays for rent top-ups
|
|
1895
|
+
*
|
|
1896
|
+
* @param tokenAccount The light-token account to set delegation on
|
|
1897
|
+
* @param delegate The delegate to approve
|
|
1898
|
+
* @param owner Owner of the token account (signer)
|
|
1899
|
+
* @param amount Amount of tokens to delegate
|
|
1900
|
+
* @param feePayer Optional fee payer for rent top-ups (defaults to owner)
|
|
1901
|
+
* @returns TransactionInstruction
|
|
1902
|
+
*/
|
|
1903
|
+
declare function createLightTokenApproveInstruction(tokenAccount: PublicKey, delegate: PublicKey, owner: PublicKey, amount: number | bigint, feePayer?: PublicKey): TransactionInstruction;
|
|
1904
|
+
/**
|
|
1905
|
+
* Create an instruction to revoke delegation for a light-token account.
|
|
1906
|
+
*
|
|
1907
|
+
* Account order per program:
|
|
1908
|
+
* 0. token_account (mutable) - the light-token account
|
|
1909
|
+
* 1. owner (signer) - owner of the token account
|
|
1910
|
+
* 2. system_program (readonly) - for rent top-ups via CPI
|
|
1911
|
+
* 3. fee_payer (mutable, signer) - pays for rent top-ups
|
|
1912
|
+
*
|
|
1913
|
+
* @param tokenAccount The light-token account to revoke delegation on
|
|
1914
|
+
* @param owner Owner of the token account (signer)
|
|
1915
|
+
* @param feePayer Optional fee payer for rent top-ups (defaults to owner)
|
|
1916
|
+
* @returns TransactionInstruction
|
|
1917
|
+
*/
|
|
1918
|
+
declare function createLightTokenRevokeInstruction(tokenAccount: PublicKey, owner: PublicKey, feePayer?: PublicKey): TransactionInstruction;
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* Build instruction batches for approving a delegate on an ATA.
|
|
1922
|
+
*
|
|
1923
|
+
* Supports light-token, SPL, and Token-2022 mints.
|
|
1924
|
+
* Returns `TransactionInstruction[][]`. Send [0..n-2] in parallel, then [n-1].
|
|
1925
|
+
*
|
|
1926
|
+
* @remarks For light-token mints, all cold (compressed) balances are loaded
|
|
1927
|
+
* into the hot ATA before the approve instruction. The `amount` parameter
|
|
1928
|
+
* only controls the delegate's spending limit, not the number of accounts
|
|
1929
|
+
* loaded. Users with many cold accounts may see additional load transactions.
|
|
1930
|
+
*
|
|
1931
|
+
* @param rpc RPC connection
|
|
1932
|
+
* @param payer Fee payer public key
|
|
1933
|
+
* @param mint Mint address
|
|
1934
|
+
* @param tokenAccount ATA address
|
|
1935
|
+
* @param delegate Delegate to approve
|
|
1936
|
+
* @param amount Amount to delegate
|
|
1937
|
+
* @param owner Owner public key
|
|
1938
|
+
* @param decimals Token decimals
|
|
1939
|
+
* @param programId Token program ID (default: LIGHT_TOKEN_PROGRAM_ID)
|
|
1940
|
+
* @param wrap When true and mint is SPL/T22, wrap into light-token then approve
|
|
1941
|
+
* @returns Instruction batches
|
|
1942
|
+
*/
|
|
1943
|
+
declare function createApproveInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, tokenAccount: PublicKey, delegate: PublicKey, amount: number | bigint | BN, owner: PublicKey, decimals: number, programId?: PublicKey, wrap?: boolean, options?: InterfaceOptions): Promise<TransactionInstruction[][]>;
|
|
1944
|
+
/**
|
|
1945
|
+
* Build instruction batches for revoking delegation on an ATA.
|
|
1946
|
+
*
|
|
1947
|
+
* Supports light-token, SPL, and Token-2022 mints.
|
|
1948
|
+
* Returns `TransactionInstruction[][]`. Send [0..n-2] in parallel, then [n-1].
|
|
1949
|
+
*
|
|
1950
|
+
* @remarks For light-token mints, all cold (compressed) balances are loaded
|
|
1951
|
+
* into the hot ATA before the revoke instruction. Users with many cold
|
|
1952
|
+
* accounts may see additional load transactions.
|
|
1953
|
+
*
|
|
1954
|
+
* @param rpc RPC connection
|
|
1955
|
+
* @param payer Fee payer public key
|
|
1956
|
+
* @param mint Mint address
|
|
1957
|
+
* @param tokenAccount ATA address
|
|
1958
|
+
* @param owner Owner public key
|
|
1959
|
+
* @param decimals Token decimals
|
|
1960
|
+
* @param programId Token program ID (default: LIGHT_TOKEN_PROGRAM_ID)
|
|
1961
|
+
* @param wrap When true and mint is SPL/T22, wrap into light-token then revoke
|
|
1962
|
+
* @returns Instruction batches
|
|
1963
|
+
*/
|
|
1964
|
+
declare function createRevokeInterfaceInstructions(rpc: Rpc, payer: PublicKey, mint: PublicKey, tokenAccount: PublicKey, owner: PublicKey, decimals: number, programId?: PublicKey, wrap?: boolean, options?: InterfaceOptions): Promise<TransactionInstruction[][]>;
|
|
1870
1965
|
|
|
1871
1966
|
/**
|
|
1872
|
-
* Create and initialize a new mint for SPL/T22/
|
|
1967
|
+
* Create and initialize a new mint for SPL/T22/light-token.
|
|
1873
1968
|
*
|
|
1874
1969
|
* @param rpc RPC connection to use
|
|
1875
1970
|
* @param payer Fee payer
|
|
1876
|
-
* @param mintAuthority Account that will control minting (signer for
|
|
1971
|
+
* @param mintAuthority Account that will control minting (signer for light-token mints)
|
|
1877
1972
|
* @param freezeAuthority Account that will control freeze and thaw (optional)
|
|
1878
1973
|
* @param decimals Location of the decimal place
|
|
1879
1974
|
* @param keypair Mint keypair (defaults to a random keypair)
|
|
1880
1975
|
* @param confirmOptions Confirm options
|
|
1881
|
-
* @param programId Token program ID (defaults to
|
|
1882
|
-
* @param tokenMetadata Optional token metadata (
|
|
1883
|
-
* @param outputStateTreeInfo Optional output state tree info (
|
|
1884
|
-
* @param addressTreeInfo Optional address tree info (
|
|
1976
|
+
* @param programId Token program ID (defaults to LIGHT_TOKEN_PROGRAM_ID)
|
|
1977
|
+
* @param tokenMetadata Optional token metadata (light-token mints only)
|
|
1978
|
+
* @param outputStateTreeInfo Optional output state tree info (light-token mints only)
|
|
1979
|
+
* @param addressTreeInfo Optional address tree info (light-token mints only)
|
|
1885
1980
|
*
|
|
1886
1981
|
* @returns Object with mint address and transaction signature
|
|
1887
1982
|
*/
|
|
@@ -1891,7 +1986,8 @@ declare function createMintInterface(rpc: Rpc, payer: Signer, mintAuthority: Pub
|
|
|
1891
1986
|
}>;
|
|
1892
1987
|
|
|
1893
1988
|
/**
|
|
1894
|
-
* Update the mint authority of a
|
|
1989
|
+
* Update the mint authority of a light-token mint.
|
|
1990
|
+
* Works for both compressed and decompressed light mints.
|
|
1895
1991
|
*
|
|
1896
1992
|
* @param rpc RPC connection
|
|
1897
1993
|
* @param payer Fee payer (signer)
|
|
@@ -1902,7 +1998,8 @@ declare function createMintInterface(rpc: Rpc, payer: Signer, mintAuthority: Pub
|
|
|
1902
1998
|
*/
|
|
1903
1999
|
declare function updateMintAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentMintAuthority: Signer, newMintAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1904
2000
|
/**
|
|
1905
|
-
* Update the freeze authority of a
|
|
2001
|
+
* Update the freeze authority of a light-token mint.
|
|
2002
|
+
* Works for both compressed and decompressed light mints.
|
|
1906
2003
|
*
|
|
1907
2004
|
* @param rpc RPC connection
|
|
1908
2005
|
* @param payer Fee payer (signer)
|
|
@@ -1914,7 +2011,8 @@ declare function updateMintAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, c
|
|
|
1914
2011
|
declare function updateFreezeAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentFreezeAuthority: Signer, newFreezeAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1915
2012
|
|
|
1916
2013
|
/**
|
|
1917
|
-
* Update a metadata field on a
|
|
2014
|
+
* Update a metadata field on a light-token mint.
|
|
2015
|
+
* Works for both compressed and decompressed light mints.
|
|
1918
2016
|
*
|
|
1919
2017
|
* @param rpc RPC connection
|
|
1920
2018
|
* @param payer Fee payer (signer)
|
|
@@ -1928,7 +2026,8 @@ declare function updateFreezeAuthority(rpc: Rpc, payer: Signer, mint: PublicKey,
|
|
|
1928
2026
|
*/
|
|
1929
2027
|
declare function updateMetadataField(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1930
2028
|
/**
|
|
1931
|
-
* Update the metadata authority of a
|
|
2029
|
+
* Update the metadata authority of a light-token mint.
|
|
2030
|
+
* Works for both compressed and decompressed light mints.
|
|
1932
2031
|
*
|
|
1933
2032
|
* @param rpc RPC connection
|
|
1934
2033
|
* @param payer Fee payer (signer)
|
|
@@ -1940,7 +2039,8 @@ declare function updateMetadataField(rpc: Rpc, payer: Signer, mint: PublicKey, a
|
|
|
1940
2039
|
*/
|
|
1941
2040
|
declare function updateMetadataAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentAuthority: Signer, newAuthority: PublicKey, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1942
2041
|
/**
|
|
1943
|
-
* Remove a metadata key from a
|
|
2042
|
+
* Remove a metadata key from a light-token mint.
|
|
2043
|
+
* Works for both compressed and decompressed light mints.
|
|
1944
2044
|
*
|
|
1945
2045
|
* @param rpc RPC connection
|
|
1946
2046
|
* @param payer Fee payer (signer)
|
|
@@ -1954,8 +2054,8 @@ declare function updateMetadataAuthority(rpc: Rpc, payer: Signer, mint: PublicKe
|
|
|
1954
2054
|
declare function removeMetadataKey(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, key: string, idempotent?: boolean, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1955
2055
|
|
|
1956
2056
|
/**
|
|
1957
|
-
* Create an associated token account for SPL/T22/
|
|
1958
|
-
* program.
|
|
2057
|
+
* Create an associated token account for SPL/T22/light-token. Defaults to
|
|
2058
|
+
* light-token program.
|
|
1959
2059
|
*
|
|
1960
2060
|
* @param rpc RPC connection
|
|
1961
2061
|
* @param payer Fee payer and transaction signer
|
|
@@ -1964,16 +2064,16 @@ declare function removeMetadataKey(rpc: Rpc, payer: Signer, mint: PublicKey, aut
|
|
|
1964
2064
|
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
|
|
1965
2065
|
* @param confirmOptions Options for confirming the transaction
|
|
1966
2066
|
* @param programId Token program ID (default:
|
|
1967
|
-
*
|
|
1968
|
-
* @param associatedTokenProgramId
|
|
1969
|
-
* provided)
|
|
1970
|
-
* @param
|
|
2067
|
+
* LIGHT_TOKEN_PROGRAM_ID)
|
|
2068
|
+
* @param associatedTokenProgramId associated token account program ID
|
|
2069
|
+
* (auto-derived if not provided)
|
|
2070
|
+
* @param lightTokenConfig Optional rent config
|
|
1971
2071
|
* @returns Address of the new associated token account
|
|
1972
2072
|
*/
|
|
1973
|
-
declare function createAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey,
|
|
2073
|
+
declare function createAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): Promise<PublicKey>;
|
|
1974
2074
|
/**
|
|
1975
|
-
* Create an associated token account idempotently for SPL/T22/
|
|
1976
|
-
* to
|
|
2075
|
+
* Create an associated token account idempotently for SPL/T22/light-token.
|
|
2076
|
+
* Defaults to light-token program.
|
|
1977
2077
|
*
|
|
1978
2078
|
* If the account already exists, the instruction succeeds without error.
|
|
1979
2079
|
*
|
|
@@ -1984,19 +2084,35 @@ declare function createAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, ow
|
|
|
1984
2084
|
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
|
|
1985
2085
|
* @param confirmOptions Options for confirming the transaction
|
|
1986
2086
|
* @param programId Token program ID (default:
|
|
1987
|
-
*
|
|
1988
|
-
* @param associatedTokenProgramId
|
|
1989
|
-
* provided)
|
|
1990
|
-
* @param
|
|
2087
|
+
* LIGHT_TOKEN_PROGRAM_ID)
|
|
2088
|
+
* @param associatedTokenProgramId associated token account program ID
|
|
2089
|
+
* (auto-derived if not provided)
|
|
2090
|
+
* @param lightTokenConfig Optional light-token-specific configuration
|
|
1991
2091
|
*
|
|
1992
2092
|
* @returns Address of the associated token account
|
|
1993
2093
|
*/
|
|
1994
|
-
declare function createAtaInterfaceIdempotent(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey,
|
|
2094
|
+
declare function createAtaInterfaceIdempotent(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, lightTokenConfig?: LightTokenConfig): Promise<PublicKey>;
|
|
1995
2095
|
|
|
1996
|
-
|
|
2096
|
+
/**
|
|
2097
|
+
* Mint tokens to a light-token account.
|
|
2098
|
+
*
|
|
2099
|
+
* This is a simple mint instruction for minting to light-token associated token accounts (hot).
|
|
2100
|
+
* The light mint account must exist (mint must be decompressed first).
|
|
2101
|
+
*
|
|
2102
|
+
* @param rpc - RPC connection
|
|
2103
|
+
* @param payer - Fee payer (signer)
|
|
2104
|
+
* @param mint - Mint address (light mint account)
|
|
2105
|
+
* @param destination - Destination light-token account
|
|
2106
|
+
* @param authority - Mint authority (signer)
|
|
2107
|
+
* @param amount - Amount to mint
|
|
2108
|
+
* @param maxTopUp - Optional maximum lamports for rent top-up
|
|
2109
|
+
* @param confirmOptions - Optional confirm options
|
|
2110
|
+
* @returns Transaction signature
|
|
2111
|
+
*/
|
|
2112
|
+
declare function mintTo$1(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer, amount: number | bigint, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1997
2113
|
|
|
1998
2114
|
/**
|
|
1999
|
-
* Mint
|
|
2115
|
+
* Mint light-tokens directly to compressed accounts.
|
|
2000
2116
|
*
|
|
2001
2117
|
* @param rpc RPC connection
|
|
2002
2118
|
* @param payer Fee payer
|
|
@@ -2005,29 +2121,32 @@ declare function mintTo$1(rpc: Rpc, payer: Signer, mint: PublicKey, recipientAcc
|
|
|
2005
2121
|
* @param recipients Array of recipients with amounts
|
|
2006
2122
|
* @param outputStateTreeInfo Optional output state tree info (auto-fetched if not provided)
|
|
2007
2123
|
* @param tokenAccountVersion Token account version (default: 3)
|
|
2124
|
+
* @param maxTopUp Optional: cap on rent top-up (units of 1k lamports; default no cap)
|
|
2008
2125
|
* @param confirmOptions Optional confirm options
|
|
2009
2126
|
*/
|
|
2010
2127
|
declare function mintToCompressed(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, recipients: Array<{
|
|
2011
2128
|
recipient: PublicKey;
|
|
2012
2129
|
amount: number | bigint;
|
|
2013
|
-
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2130
|
+
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: number, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2014
2131
|
|
|
2015
2132
|
/**
|
|
2016
2133
|
* Mint tokens to a decompressed/onchain token account.
|
|
2017
|
-
* Works with SPL, Token-2022, and
|
|
2134
|
+
* Works with SPL, Token-2022, and light-token mints.
|
|
2135
|
+
*
|
|
2136
|
+
* This function ONLY mints to light-token associated token accounts (hot), never to compressed light-token accounts (cold).
|
|
2137
|
+
* For light-token mints, the light mint account must exist (mint must be decompressed first).
|
|
2018
2138
|
*
|
|
2019
|
-
* This function ONLY mints to decompressed onchain token accounts, never to compressed accounts.
|
|
2020
2139
|
* The signature matches the standard SPL mintTo for simplicity and consistency.
|
|
2021
2140
|
*
|
|
2022
2141
|
* @param rpc - RPC connection to use
|
|
2023
2142
|
* @param payer - Transaction fee payer
|
|
2024
|
-
* @param mint - Mint address (SPL, Token-2022, or
|
|
2143
|
+
* @param mint - Mint address (SPL, Token-2022, or light-token mint)
|
|
2025
2144
|
* @param destination - Destination token account address (must be an existing onchain token account)
|
|
2026
2145
|
* @param authority - Mint authority (can be Signer or PublicKey if multiSigners provided)
|
|
2027
2146
|
* @param amount - Amount to mint
|
|
2028
2147
|
* @param multiSigners - Optional: Multi-signature signers (default: [])
|
|
2029
2148
|
* @param confirmOptions - Optional: Transaction confirmation options
|
|
2030
|
-
* @param programId - Optional: Token program ID
|
|
2149
|
+
* @param programId - Optional: Token program ID. If undefined, auto-detects.
|
|
2031
2150
|
*
|
|
2032
2151
|
* @returns Transaction signature
|
|
2033
2152
|
*/
|
|
@@ -2042,7 +2161,7 @@ declare function mintToInterface(rpc: Rpc, payer: Signer, mint: PublicKey, desti
|
|
|
2042
2161
|
* @param mint Mint associated with the account to set or
|
|
2043
2162
|
* verify.
|
|
2044
2163
|
* @param owner Owner of the account. Pass Signer to
|
|
2045
|
-
* auto-load cold
|
|
2164
|
+
* auto-load compressed light-tokens (cold balance), or
|
|
2046
2165
|
* PublicKey for read-only.
|
|
2047
2166
|
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program
|
|
2048
2167
|
* Derived Address).
|
|
@@ -2050,7 +2169,7 @@ declare function mintToInterface(rpc: Rpc, payer: Signer, mint: PublicKey, desti
|
|
|
2050
2169
|
* state.
|
|
2051
2170
|
* @param confirmOptions Options for confirming the transaction
|
|
2052
2171
|
* @param programId Token program ID (defaults to
|
|
2053
|
-
*
|
|
2172
|
+
* LIGHT_TOKEN_PROGRAM_ID)
|
|
2054
2173
|
* @param associatedTokenProgramId Associated token program ID (auto-derived if
|
|
2055
2174
|
* not provided)
|
|
2056
2175
|
*
|
|
@@ -2059,48 +2178,31 @@ declare function mintToInterface(rpc: Rpc, payer: Signer, mint: PublicKey, desti
|
|
|
2059
2178
|
declare function getOrCreateAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey | Signer, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey): Promise<AccountInterface>;
|
|
2060
2179
|
|
|
2061
2180
|
/**
|
|
2062
|
-
*
|
|
2063
|
-
*
|
|
2064
|
-
* For unified loading, use {@link loadAta} instead.
|
|
2065
|
-
*
|
|
2066
|
-
* @param rpc RPC connection
|
|
2067
|
-
* @param payer Fee payer (signer)
|
|
2068
|
-
* @param owner Owner of the compressed tokens (signer)
|
|
2069
|
-
* @param mint Mint address
|
|
2070
|
-
* @param amount Amount to decompress (defaults to all)
|
|
2071
|
-
* @param destinationAta Destination token account address
|
|
2072
|
-
* @param destinationOwner Owner of the destination ATA
|
|
2073
|
-
* @param splInterfaceInfo SPL interface info for SPL/T22 destinations
|
|
2074
|
-
* @param confirmOptions Confirm options
|
|
2075
|
-
* @returns Transaction signature, null if nothing to load.
|
|
2076
|
-
*/
|
|
2077
|
-
declare function decompressInterface(rpc: Rpc, payer: Signer, owner: Signer, mint: PublicKey, amount?: number | bigint | BN, destinationAta?: PublicKey, destinationOwner?: PublicKey, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature | null>;
|
|
2078
|
-
|
|
2079
|
-
/**
|
|
2080
|
-
* Wrap tokens from an SPL/T22 account to a c-token account.
|
|
2181
|
+
* Wrap tokens from an SPL/T22 account to a light-token account.
|
|
2081
2182
|
*
|
|
2082
2183
|
* This is an agnostic action that takes explicit account addresses (spl-token style).
|
|
2083
|
-
* Use getAssociatedTokenAddressSync() to derive
|
|
2184
|
+
* Use getAssociatedTokenAddressSync() to derive associated token account addresses if needed.
|
|
2084
2185
|
*
|
|
2085
2186
|
* @param rpc RPC connection
|
|
2086
2187
|
* @param payer Fee payer
|
|
2087
|
-
* @param source Source SPL/T22 token account (any token account, not just
|
|
2088
|
-
* @param destination Destination
|
|
2188
|
+
* @param source Source SPL/T22 token account (any token account, not just associated token account)
|
|
2189
|
+
* @param destination Destination light-token account
|
|
2089
2190
|
* @param owner Owner/authority of the source account (must sign)
|
|
2090
2191
|
* @param mint Mint address
|
|
2091
2192
|
* @param amount Amount to wrap
|
|
2092
2193
|
* @param splInterfaceInfo Optional: SPL interface info (will be fetched if not provided)
|
|
2194
|
+
* @param maxTopUp Optional: cap on rent top-up (units of 1k lamports; default no cap)
|
|
2093
2195
|
* @param confirmOptions Optional: Confirm options
|
|
2094
2196
|
*
|
|
2095
2197
|
* @example
|
|
2096
2198
|
* const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey, false, TOKEN_PROGRAM_ID);
|
|
2097
|
-
* const
|
|
2199
|
+
* const lightTokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); // defaults to light-token
|
|
2098
2200
|
*
|
|
2099
2201
|
* await wrap(
|
|
2100
2202
|
* rpc,
|
|
2101
2203
|
* payer,
|
|
2102
2204
|
* splAta,
|
|
2103
|
-
*
|
|
2205
|
+
* lightTokenAta,
|
|
2104
2206
|
* owner,
|
|
2105
2207
|
* mint,
|
|
2106
2208
|
* 1000n,
|
|
@@ -2108,34 +2210,60 @@ declare function decompressInterface(rpc: Rpc, payer: Signer, owner: Signer, min
|
|
|
2108
2210
|
*
|
|
2109
2211
|
* @returns Transaction signature
|
|
2110
2212
|
*/
|
|
2111
|
-
declare function wrap(rpc: Rpc, payer: Signer, source: PublicKey, destination: PublicKey, owner: Signer, mint: PublicKey, amount: bigint, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2213
|
+
declare function wrap(rpc: Rpc, payer: Signer, source: PublicKey, destination: PublicKey, owner: Signer, mint: PublicKey, amount: bigint, splInterfaceInfo?: SplInterfaceInfo, maxTopUp?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2112
2214
|
|
|
2113
2215
|
/**
|
|
2114
|
-
*
|
|
2216
|
+
* Approve a delegate for an associated token account.
|
|
2115
2217
|
*
|
|
2116
|
-
*
|
|
2117
|
-
*
|
|
2118
|
-
* (SPL ATA via pool, T22 ATA via pool, or c-token ATA direct)
|
|
2119
|
-
* - wrap=true (unified): Wrap SPL/T22 + decompress all to c-token ATA
|
|
2218
|
+
* Supports light-token, SPL, and Token-2022 mints. For light-token mints,
|
|
2219
|
+
* loads cold accounts if needed before sending the approve instruction.
|
|
2120
2220
|
*
|
|
2121
|
-
* @
|
|
2122
|
-
*
|
|
2123
|
-
*
|
|
2124
|
-
*
|
|
2125
|
-
* @param
|
|
2126
|
-
* @param
|
|
2127
|
-
* @
|
|
2221
|
+
* @remarks For light-token mints, all cold (compressed) balances are loaded
|
|
2222
|
+
* into the hot ATA, not just the delegation amount. The `amount` parameter
|
|
2223
|
+
* only controls the delegate's spending limit.
|
|
2224
|
+
*
|
|
2225
|
+
* @param rpc RPC connection
|
|
2226
|
+
* @param payer Fee payer (signer)
|
|
2227
|
+
* @param tokenAccount ATA address
|
|
2228
|
+
* @param mint Mint address
|
|
2229
|
+
* @param delegate Delegate to approve
|
|
2230
|
+
* @param amount Amount to delegate
|
|
2231
|
+
* @param owner Owner of the token account (signer)
|
|
2232
|
+
* @param confirmOptions Optional confirm options
|
|
2233
|
+
* @param programId Token program ID (default: LIGHT_TOKEN_PROGRAM_ID)
|
|
2234
|
+
* @param wrap When true and mint is SPL/T22, wrap into light-token then approve
|
|
2235
|
+
* @returns Transaction signature
|
|
2128
2236
|
*/
|
|
2129
|
-
declare function
|
|
2237
|
+
declare function approveInterface(rpc: Rpc, payer: Signer, tokenAccount: PublicKey, mint: PublicKey, delegate: PublicKey, amount: number | bigint | BN, owner: Signer, confirmOptions?: ConfirmOptions, programId?: PublicKey, wrap?: boolean, options?: InterfaceOptions, decimals?: number): Promise<TransactionSignature>;
|
|
2238
|
+
/**
|
|
2239
|
+
* Revoke delegation for an associated token account.
|
|
2240
|
+
*
|
|
2241
|
+
* Supports light-token, SPL, and Token-2022 mints. For light-token mints,
|
|
2242
|
+
* loads cold accounts if needed before sending the revoke instruction.
|
|
2243
|
+
*
|
|
2244
|
+
* @remarks For light-token mints, all cold (compressed) balances are loaded
|
|
2245
|
+
* into the hot ATA before the revoke instruction.
|
|
2246
|
+
*
|
|
2247
|
+
* @param rpc RPC connection
|
|
2248
|
+
* @param payer Fee payer (signer)
|
|
2249
|
+
* @param tokenAccount ATA address
|
|
2250
|
+
* @param mint Mint address
|
|
2251
|
+
* @param owner Owner of the token account (signer)
|
|
2252
|
+
* @param confirmOptions Optional confirm options
|
|
2253
|
+
* @param programId Token program ID (default: LIGHT_TOKEN_PROGRAM_ID)
|
|
2254
|
+
* @param wrap When true and mint is SPL/T22, wrap into light-token then revoke
|
|
2255
|
+
* @returns Transaction signature
|
|
2256
|
+
*/
|
|
2257
|
+
declare function revokeInterface(rpc: Rpc, payer: Signer, tokenAccount: PublicKey, mint: PublicKey, owner: Signer, confirmOptions?: ConfirmOptions, programId?: PublicKey, wrap?: boolean, options?: InterfaceOptions, decimals?: number): Promise<TransactionSignature>;
|
|
2130
2258
|
|
|
2131
2259
|
/**
|
|
2132
|
-
* Derive the canonical associated token address for any of SPL/T22/
|
|
2133
|
-
* Defaults to using
|
|
2260
|
+
* Derive the canonical associated token address for any of SPL/T22/light-token.
|
|
2261
|
+
* Defaults to using light-token as the canonical associated token account.
|
|
2134
2262
|
*
|
|
2135
2263
|
* @param mint Mint public key
|
|
2136
2264
|
* @param owner Owner public key
|
|
2137
2265
|
* @param allowOwnerOffCurve Allow owner to be a PDA. Default false.
|
|
2138
|
-
* @param programId Token program ID. Default
|
|
2266
|
+
* @param programId Token program ID. Default light-token.
|
|
2139
2267
|
*
|
|
2140
2268
|
* @param associatedTokenProgramId Associated token program ID. Default
|
|
2141
2269
|
* auto-detected.
|
|
@@ -2191,7 +2319,7 @@ interface OffChainTokenMetadataJson {
|
|
|
2191
2319
|
* const metadataJson = toOffChainMetadataJson({
|
|
2192
2320
|
* name: 'My Token',
|
|
2193
2321
|
* symbol: 'MTK',
|
|
2194
|
-
* description: 'A
|
|
2322
|
+
* description: 'A light-token',
|
|
2195
2323
|
* image: 'https://example.com/image.png',
|
|
2196
2324
|
* });
|
|
2197
2325
|
* const uri = await umi.uploader.uploadJson(metadataJson);
|
|
@@ -5230,14 +5358,14 @@ declare class CompressedTokenProgram {
|
|
|
5230
5358
|
* @param mintSize Optional: mint size. Default: MINT_SIZE
|
|
5231
5359
|
*
|
|
5232
5360
|
* @returns [createMintAccountInstruction, initializeMintInstruction,
|
|
5233
|
-
*
|
|
5361
|
+
* createSplInterfaceInstruction]
|
|
5234
5362
|
*
|
|
5235
|
-
* Note that `
|
|
5363
|
+
* Note that `createSplInterfaceInstruction` must be executed after
|
|
5236
5364
|
* `initializeMintInstruction`.
|
|
5237
5365
|
*/
|
|
5238
5366
|
static createMint({ feePayer, mint, authority, freezeAuthority, decimals, rentExemptBalance, tokenProgramId, mintSize, }: CreateMintParams): Promise<TransactionInstruction[]>;
|
|
5239
5367
|
/**
|
|
5240
|
-
*
|
|
5368
|
+
* Create SPL interface (omnibus account) for an existing SPL mint.
|
|
5241
5369
|
* For new mints, use `CompressedTokenProgram.createMint`.
|
|
5242
5370
|
*
|
|
5243
5371
|
* @param feePayer Fee payer.
|
|
@@ -5245,12 +5373,16 @@ declare class CompressedTokenProgram {
|
|
|
5245
5373
|
* @param tokenProgramId Optional: Token program ID. Default: SPL
|
|
5246
5374
|
* Token Program ID
|
|
5247
5375
|
*
|
|
5248
|
-
* @returns The
|
|
5376
|
+
* @returns The createSplInterface instruction
|
|
5249
5377
|
*/
|
|
5250
|
-
static
|
|
5378
|
+
static createSplInterface({ feePayer, mint, tokenProgramId, }: CreateSplInterfaceParams): Promise<TransactionInstruction>;
|
|
5379
|
+
/**
|
|
5380
|
+
* @deprecated Use {@link createSplInterface} instead.
|
|
5381
|
+
*/
|
|
5382
|
+
static createTokenPool(params: CreateSplInterfaceParams): Promise<TransactionInstruction>;
|
|
5251
5383
|
/**
|
|
5252
5384
|
* Add a token pool to an existing SPL mint. For new mints, use
|
|
5253
|
-
* {@link
|
|
5385
|
+
* {@link createSplInterface}.
|
|
5254
5386
|
*
|
|
5255
5387
|
* @param feePayer Fee payer.
|
|
5256
5388
|
* @param mint SPL Mint address.
|
|
@@ -5414,6 +5546,36 @@ declare class CompressedTokenProgram {
|
|
|
5414
5546
|
static revoke({ payer, inputCompressedTokenAccounts, recentValidityProof, recentInputStateRootIndices, }: RevokeParams): Promise<TransactionInstruction>;
|
|
5415
5547
|
}
|
|
5416
5548
|
|
|
5549
|
+
/** Solana maximum transaction size in bytes. */
|
|
5550
|
+
declare const MAX_TRANSACTION_SIZE = 1232;
|
|
5551
|
+
/**
|
|
5552
|
+
* Conservative size budget for a combined batch (load + transfer + ATA).
|
|
5553
|
+
* Leaves headroom below MAX_TRANSACTION_SIZE for edge-case key counts.
|
|
5554
|
+
*/
|
|
5555
|
+
declare const MAX_COMBINED_BATCH_BYTES = 900;
|
|
5556
|
+
/**
|
|
5557
|
+
* Conservative size budget for a load-only or setup-only batch.
|
|
5558
|
+
*/
|
|
5559
|
+
declare const MAX_LOAD_ONLY_BATCH_BYTES = 1000;
|
|
5560
|
+
/**
|
|
5561
|
+
* Estimate the serialized byte size of a V0 VersionedTransaction built from
|
|
5562
|
+
* the given instructions and signer count.
|
|
5563
|
+
*
|
|
5564
|
+
* The estimate accounts for Solana's account-key deduplication: all unique
|
|
5565
|
+
* pubkeys across every instruction (keys + programIds) are collected into a
|
|
5566
|
+
* single set, matching the behaviour of
|
|
5567
|
+
* `TransactionMessage.compileToV0Message`.
|
|
5568
|
+
*
|
|
5569
|
+
* This intentionally does NOT use address lookup tables, so the result is an
|
|
5570
|
+
* upper bound. If lookup tables are used at send time the actual size will be
|
|
5571
|
+
* smaller.
|
|
5572
|
+
*
|
|
5573
|
+
* @param instructions The instructions that will be included in the tx.
|
|
5574
|
+
* @param numSigners Number of signers (determines signature count).
|
|
5575
|
+
* @returns Estimated byte size of the serialized transaction.
|
|
5576
|
+
*/
|
|
5577
|
+
declare function estimateTransactionSize(instructions: TransactionInstruction[], numSigners: number): number;
|
|
5578
|
+
|
|
5417
5579
|
/**
|
|
5418
5580
|
* Retrieve associated token account for a given owner and mint.
|
|
5419
5581
|
*
|
|
@@ -5427,19 +5589,20 @@ declare class CompressedTokenProgram {
|
|
|
5427
5589
|
*/
|
|
5428
5590
|
declare function getAtaInterface(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<AccountInterface>;
|
|
5429
5591
|
/**
|
|
5430
|
-
* Create
|
|
5592
|
+
* Create instruction batches for loading token balances into an ATA.
|
|
5593
|
+
* Returns batches of instructions, each batch is one transaction.
|
|
5431
5594
|
*
|
|
5432
|
-
* @param rpc
|
|
5433
|
-
* @param ata
|
|
5434
|
-
* @param owner
|
|
5435
|
-
* @param mint
|
|
5436
|
-
* @param payer
|
|
5437
|
-
* @param options
|
|
5438
|
-
* @returns
|
|
5595
|
+
* @param rpc RPC connection
|
|
5596
|
+
* @param ata Associated token address
|
|
5597
|
+
* @param owner Owner public key
|
|
5598
|
+
* @param mint Mint public key
|
|
5599
|
+
* @param payer Fee payer (defaults to owner)
|
|
5600
|
+
* @param options Optional load options
|
|
5601
|
+
* @returns Instruction batches - each inner array is one transaction
|
|
5439
5602
|
*/
|
|
5440
|
-
declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, payer?: PublicKey, options?: InterfaceOptions): Promise<TransactionInstruction[]>;
|
|
5603
|
+
declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, payer?: PublicKey, options?: InterfaceOptions): Promise<TransactionInstruction[][]>;
|
|
5441
5604
|
/**
|
|
5442
|
-
* Load token balances into a
|
|
5605
|
+
* Load token balances into a light-token ATA.
|
|
5443
5606
|
*
|
|
5444
5607
|
* @param rpc RPC connection
|
|
5445
5608
|
* @param ata Associated token address
|
|
@@ -5450,6 +5613,6 @@ declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: Publ
|
|
|
5450
5613
|
* @param interfaceOptions Optional interface options
|
|
5451
5614
|
* @returns Transaction signature, or null if nothing to load
|
|
5452
5615
|
*/
|
|
5453
|
-
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions): Promise<TransactionSignature | null>;
|
|
5616
|
+
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions, decimals?: number): Promise<TransactionSignature | null>;
|
|
5454
5617
|
|
|
5455
|
-
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type
|
|
5618
|
+
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BASE_RENT_PER_EPOCH, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESSIBLE_LIGHT_TOKEN_ACCOUNT_SIZE, COMPRESSIBLE_LIGHT_TOKEN_RENT_PER_EPOCH, COMPRESSION_COST, COMPRESSION_INCENTIVE, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleConfig, CpiContextLayout, type CreateAssociatedLightTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DEFAULT_COMPRESSIBLE_CONFIG, DEFAULT_PREPAY_EPOCHS, DEFAULT_WRITE_TOP_UP, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_MIXED_TREE_TYPES, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, LIGHT_TOKEN_CONFIG, LIGHT_TOKEN_RENT_SPONSOR, type LightCompressedToken, type LightTokenConfig, CompressedTokenProgram as LightTokenProgram, MAX_COMBINED_BATCH_BYTES, MAX_LOAD_ONLY_BATCH_BYTES, MAX_TOP_UP, MAX_TRANSACTION_SIZE, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, RENT_PER_BYTE_PER_EPOCH, REVOKE_DISCRIMINATOR, type RevokeParams, SLOTS_PER_RENT_EPOCH, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SelectInputAccountsOptions, type SelectedAccountsResult, type SplInterfaceActivity, type SplInterfaceInfo, TOTAL_COMPRESSION_COST, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, approveInterface, batchCompressLayout, calculateFeePayerCostAtCreation, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createApproveInterfaceInstructions, createAssociatedLightTokenAccountIdempotentInstruction, createAssociatedLightTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createDecompressOutputState, createLightTokenApproveInstruction, createLightTokenFreezeAccountInstruction, createLightTokenRevokeInstruction, createLightTokenThawAccountInstruction, createLightTokenTransferCheckedInstruction, createLightTokenTransferInstruction, createLoadAtaInstructions, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createRevokeInterfaceInstructions, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstructions, createTransferOutputState, createTransferToAccountInterfaceInstructions, createUnwrapInstruction, createUnwrapInstructions, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, estimateTransactionSize, extractTokenMetadata, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, groupAccountsByTreeType, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToCompressed, mintToInterface, mintToLayout, mintTo$1 as mintToLightToken, packCompressedTokenAccounts, parseLightTokenCold, parseLightTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, rentPerEpoch, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, revokeInterface, selectAccountsByPreferredTreeType, selectInputsForAmount, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sliceLast, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, transferToAccountInterface, unpackMintData, unpackMintInterface, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|