import type { Connection } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js"; import { MerkleTree } from "../merkle.js"; import type { CommitmentEvent } from "./types.js"; /** * Historical leaves repaired manually in the relayer. * * The deployed `open_position` instruction appended these commitments without * emitting CommitmentEvent. They must be retained when rebuilding history. * Values are copied byte-for-byte from relayer-server/src/db/service.ts. */ export declare const PROTECTED_COMMITMENT_EVENTS: readonly [{ readonly leafIndex: 3738; readonly commitmentHex: "0c7850c9360e041ceeba27297e0fd49fa6a224a651c2fff8c56b22c70a319a94"; }, { readonly leafIndex: 4; readonly commitmentHex: "15e182d12e044ef2a469ccda88d903304a4e3e69f72765a29e4e6df9c206b0bf"; readonly mintAddressHex: "e272b88fb18eaf1994acb885bdba76820c567c3467300f0cd320a0c15ebf9d2f"; readonly onChainTreeId: 0; }]; /** @deprecated Use PROTECTED_COMMITMENT_EVENTS. */ export declare const PROTECTED_COMMITMENT_EVENT: { readonly leafIndex: 3738; readonly commitmentHex: "0c7850c9360e041ceeba27297e0fd49fa6a224a651c2fff8c56b22c70a319a94"; }; /** Return protected records as normal SDK events for a particular tree. */ export declare function getProtectedCommitmentEvents(params: { mintAddress: PublicKey; treeId?: number; }): CommitmentEvent[]; /** Return every protected leaf, including the global position-tree repair. */ export declare function getAllProtectedCommitmentEvents(): CommitmentEvent[]; /** * Add the protected historical leaves without duplicating records already read * from an indexer. A conflicting commitment at a protected index is rejected. */ export declare function mergeProtectedCommitmentEvents(events: readonly CommitmentEvent[], params: { mintAddress: PublicKey; treeId?: number; }): CommitmentEvent[]; /** * Insert expected commitments and prefer authoritative emitted metadata when it * exists. Missing events are computed from the local tree exactly like the * relayer's `insertAndPersistCommitments` fallback. * * This function mutates `tree`. */ export declare function resolveCommitmentEvents(params: { commitments: readonly Uint8Array[]; tree: MerkleTree; logMessages?: readonly string[] | null; programId: PublicKey; mintAddress: PublicKey; treeId: number; txSignature: string; slot: number; timestamp?: number; requireAllInLogs?: boolean; }): CommitmentEvent[]; export type EventlessOpenPositionCommitments = { sourceMint: PublicKey; sourceTreeId: number; sourceCommitment: Uint8Array; positionMint: PublicKey; positionTreeId: number; positionCommitment: Uint8Array; positionPdaKey: Uint8Array; }; /** Decode the two commitments hidden in a current `open_position` instruction. */ export declare function decodeEventlessOpenPositionCommitments(instructionData: Uint8Array): EventlessOpenPositionCommitments | null; export declare function getPositionPda(programId: PublicKey, positionPdaKey: Uint8Array): PublicKey; /** Read PositionPDA.leaf_index at the same byte offset used by the relayer. */ export declare function readPositionLeafIndex(accountData: Uint8Array): number; /** * Recover the two events omitted by the deployed `open_position` instruction. * The source tree must already contain every earlier source-mint commitment. * This function inserts the source commitment into that tree. */ export declare function recoverEventlessOpenPositionEvents(params: { instructionData: Uint8Array; sourceTree: MerkleTree; connection: Pick; programId: PublicKey; txSignature: string; slot: number; timestamp?: number; }): Promise;