/** * Transaction Formatter * * Formats ZK proof into a transaction for the Railgun contract. * Ported from backend: utils/railgun-core/transaction/formatter.ts */ import type { ProofResult } from './prover'; /** * Commitment ciphertext structure for the contract */ export interface ContractCommitmentCiphertext { ciphertext: [string, string, string, string]; blindedSenderViewingKey: string; blindedReceiverViewingKey: string; annotationData: string; memo: string; } export interface RailgunTransactionStruct { proof: { a: { x: string; y: string; }; b: { x: [string, string]; y: [string, string]; }; c: { x: string; y: string; }; }; merkleRoot: string; nullifiers: string[]; commitments: string[]; boundParams: { treeNumber: number; minGasPrice: string; unshield: number; chainID: string; adaptContract: string; adaptParams: string; commitmentCiphertext: ContractCommitmentCiphertext[]; }; unshieldPreimage: { npk: string; token: { tokenType: number; tokenAddress: string; tokenSubID: number; }; value: string; }; } export interface FormatUnshieldParams { proofResult: ProofResult; treeNumber: number; tokenAddress: string; recipientAddress: string; unshieldAmount: bigint; chainId: number; } /** * Format proof and inputs into Railgun contract transaction struct */ export declare function formatUnshieldTransaction(params: FormatUnshieldParams): RailgunTransactionStruct; /** * Encode transaction for Railgun contract call * Returns to and data only - let wallet estimate gas */ export declare function encodeUnshieldTransaction(transactionStruct: RailgunTransactionStruct, chainId: number): { to: string; data: string; }; /** * Build transaction ready to send * No hardcoded gas - wallet will estimate automatically */ export declare function buildUnshieldTransaction(params: FormatUnshieldParams): { to: string; data: string; }; /** * Parameters for formatting a transact transaction (no unshield) */ export interface FormatTransactParams { proofResult: ProofResult; treeNumber: number; tokenAddress: string; chainId: number; } /** * Format proof and inputs into Railgun transaction struct for transact (no unshield) * * Key difference from unshield: * - unshieldPreimage.npk = 0 (tells contract this is a pure transact) * - Both outputs stay shielded in Railgun */ export declare function formatTransactTransaction(params: FormatTransactParams): RailgunTransactionStruct; /** * Build transact transaction ready to send * No hardcoded gas - wallet will estimate automatically */ export declare function buildTransactTransaction(params: FormatTransactParams): { to: string; data: string; };