jito-distributor-sdk
Version:
TypeScript SDK for JITO Merkle Distributor with production-ready versioning and double-hashing support
56 lines (55 loc) • 1.8 kB
TypeScript
import { PublicKey } from '@solana/web3.js';
export interface AirdropRecipient {
address: PublicKey;
unlockedAmount: number;
lockedAmount: number;
}
/**
* Production-ready Merkle Tree for JITO Merkle Distributor
* Uses double-hashing to match Solana program expectations exactly
*/
export declare class JitoMerkleTree {
private leaves;
private tree;
private root;
constructor(recipients: AirdropRecipient[]);
private createLeaf;
private hashLeaf;
private hashIntermediate;
private buildTree;
getRoot(): Buffer;
getProof(index: number): Buffer[];
verifyProof(index: number, leafData: Buffer, proof: Buffer[]): boolean;
getRawLeafForRecipient(recipient: AirdropRecipient): Buffer;
findRecipientIndex(recipients: AirdropRecipient[], targetAddress: PublicKey): number;
}
/**
* Creates a JITO-compatible merkle tree with the specified recipients
*/
export declare function createJitoMerkleTree(recipients: AirdropRecipient[]): {
tree: JitoMerkleTree;
root: Uint8Array;
recipients: AirdropRecipient[];
};
/**
* Generates a merkle proof for a specific recipient
*/
export declare function generateProofForRecipient(tree: JitoMerkleTree, recipients: AirdropRecipient[], targetAddress: PublicKey): {
proof: Uint8Array[];
index: number;
recipient: AirdropRecipient;
};
/**
* Validates that a merkle proof is properly formatted
* @param proof Array of hex strings or Uint8Arrays
* @returns boolean
*/
export declare function validateMerkleProof(proof: (string | Uint8Array)[]): boolean;
/**
* Convert hex string to Uint8Array
*/
export declare function hexToUint8Array(hex: string): Uint8Array;
/**
* Convert Uint8Array to hex string
*/
export declare function uint8ArrayToHex(bytes: Uint8Array): string;