UNPKG

@nosana/kit

Version:

Nosana KIT

102 lines (101 loc) 3.46 kB
import { Address, ReadonlyUint8Array, TransactionSigner } from '@solana/kit'; import type { ProgramDeps } from '../../../types.js'; import * as programClient from '../../../generated_clients/merkle_distributor/index.js'; import { ConvertTypesForDb } from '../../../utils/index.js'; /** * Claim target enum for merkle distributor. * Determines which address receives the claimed tokens. */ export declare enum ClaimTarget { YES = "YES", NO = "NO" } /** * Allowed addresses for receiving claimed tokens from merkle distributor. * The `to` account must be the ATA of one of these addresses. */ export declare const ALLOWED_RECEIVE_ADDRESSES: { readonly YES: Address<"YessuvqUauj9yW4B3eERcyRLWmQtWpFc2ERKmaedmCE">; readonly NO: Address<"NopXntmRdXhYNkoZaNTMUMShJ3aVG5RvwpiyPdd4bMh">; }; export type MerkleDistributor = ConvertTypesForDb<programClient.MerkleDistributorArgs> & { address: Address; }; export type ClaimStatus = ConvertTypesForDb<programClient.ClaimStatusArgs> & { address: Address; }; /** * Error thrown when a claim status account is not found */ export declare class ClaimStatusNotFoundError extends Error { constructor(address: Address); } /** * Merkle distributor program interface */ export interface MerkleDistributorProgram { /** * Derive the ClaimStatus PDA address for a given distributor and optional claimant. */ getClaimStatusPda(distributor: Address, claimant?: Address): Promise<Address>; /** * Fetch a merkle distributor account by address */ get(addr: Address): Promise<MerkleDistributor>; /** * Fetch all merkle distributor accounts */ all(): Promise<MerkleDistributor[]>; /** * Fetch a claim status account by address */ getClaimStatus(addr: Address): Promise<ClaimStatus>; /** * Fetch claim status for a specific distributor and optional claimant. */ getClaimStatusForDistributor(distributor: Address, claimant?: Address): Promise<ClaimStatus | null>; /** * Fetch all claim status accounts */ allClaimStatus(): Promise<ClaimStatus[]>; /** * Claim tokens from a merkle distributor. */ claim(params: { distributor: Address; amountUnlocked: number | bigint; amountLocked: number | bigint; proof: Array<ReadonlyUint8Array>; target: ClaimTarget; claimant?: TransactionSigner; }): Promise<ReturnType<typeof programClient.getNewClaimInstruction>>; /** * Clawback tokens from a merkle distributor. */ clawback(params: { distributor: Address; claimant?: TransactionSigner; }): Promise<ReturnType<typeof programClient.getClawbackInstruction>>; } /** * Creates a new MerkleDistributorProgram instance. * * @param deps - Program dependencies (config, logger, solana service, wallet getter) * @returns A MerkleDistributorProgram instance with methods to interact with the merkle distributor program * * @example * ```ts * import { createMerkleDistributorProgram } from '@nosana/kit'; * * const merkleDistributor = createMerkleDistributorProgram({ * config, * logger, * solana, * getWallet, * }); * * const distributor = await merkleDistributor.get('distributor-address'); * ``` */ import type { ProgramConfig } from '../../../config/types.js'; export declare function createMerkleDistributorProgram(deps: ProgramDeps, config: ProgramConfig): MerkleDistributorProgram;