import { ethers } from 'ethers'; import { VAA, VeridexPayload } from './types.mjs'; /** * Veridex Protocol SDK - Wormhole Utilities * * Functions for fetching VAAs, parsing messages, and interacting with Wormhole * * This module integrates with the official @wormhole-foundation/sdk patterns for * better chain abstraction and reliability, while providing Veridex-specific * utilities for payload handling and VAA management. */ /** * Wormhole Consistency Levels * @see https://docs.wormhole.com/wormhole/reference/glossary#consistency-level */ declare const CONSISTENCY_LEVELS: { /** Finalized - Wait for block finality (most secure) */ readonly FINALIZED: 200; /** Instant - No wait for finality (fastest, less secure) */ readonly INSTANT: 201; /** Safe - Standard finality (deprecated, use FINALIZED) */ readonly SAFE: 200; }; /** * Guardian network configuration */ declare const GUARDIAN_CONFIG: { /** Total number of guardians in mainnet */ readonly MAINNET_GUARDIAN_COUNT: 19; /** Required signatures for mainnet quorum (13/19) */ readonly MAINNET_QUORUM: 13; /** Total number of guardians in testnet */ readonly TESTNET_GUARDIAN_COUNT: 1; /** Required signatures for testnet quorum */ readonly TESTNET_QUORUM: 1; }; interface FetchVAAOptions { testnet?: boolean; maxRetries?: number; retryDelayMs?: number; onRetry?: (attempt: number, maxRetries: number) => void; } interface WaitForSignaturesOptions { testnet?: boolean; requiredSignatures?: number; maxWaitMs?: number; checkIntervalMs?: number; onProgress?: (currentSignatures: number, required: number) => void; } /** * Fetch a VAA from Wormhole guardians by sequence number * * @example * ```ts * const vaa = await fetchVAA( * WORMHOLE_CHAIN_IDS.TESTNET.BASE_SEPOLIA, * '0x000...hubAddress', * 97n, * { testnet: true } * ); * ``` */ declare function fetchVAA(emitterChain: number, emitterAddress: string, sequence: bigint, options?: FetchVAAOptions): Promise; /** * Fetch VAA by transaction hash using operations API * This is more reliable than the transactions API when sequence numbers don't match */ declare function fetchVAAByTxHash(txHash: string, options?: { testnet?: boolean; maxRetries?: number; retryDelayMs?: number; onRetry?: (attempt: number, maxRetries: number) => void; }): Promise; /** * Fetch VAA by transaction hash using transactions API (fallback) */ declare function fetchVAAByTxHashFallback(txHash: string, options?: { testnet?: boolean; maxRetries?: number; retryDelayMs?: number; onRetry?: (attempt: number, maxRetries: number) => void; }): Promise; /** * Parse a base64-encoded VAA into its components */ declare function parseVAA(vaaBase64: string): VAA; /** * Parse raw VAA bytes into its components */ declare function parseVAABytes(vaaBytes: Buffer): VAA; /** * Parse a Veridex-specific payload from a VAA */ declare function parseVeridexPayload(payloadHex: string): VeridexPayload; /** * Encode a VAA back to bytes for on-chain submission */ declare function encodeVAAToBytes(vaaBase64: string): string; /** * Encode VAA to bytes for Solana (returns Uint8Array) */ declare function encodeVAAForSolana(vaaBase64: string): Uint8Array; /** * Normalize an address to a 32-byte Wormhole emitter address format */ declare function normalizeEmitterAddress(address: string): string; /** * Convert a 32-byte emitter address back to a 20-byte EVM address */ declare function emitterToEvmAddress(emitterHex: string): string; /** * Extract the VAA sequence from a transaction receipt */ declare function getSequenceFromTxReceipt(provider: ethers.Provider, txHash: string, wormholeCoreBridge: string): Promise; /** * Wait for a Wormhole message to be signed by guardians * * @example * ```ts * const vaa = await waitForGuardianSignatures( * WORMHOLE_CHAIN_IDS.TESTNET.BASE_SEPOLIA, * hubEmitter, * 97n, * { * testnet: true, * onProgress: (current, required) => console.log(`${current}/${required} signatures`) * } * ); * ``` */ declare function waitForGuardianSignatures(emitterChain: number, emitterAddress: string, sequence: bigint, options?: WaitForSignaturesOptions): Promise; /** * Get the Wormhole Core Bridge contract address for a chain */ declare function getWormholeCoreBridge(wormholeChainId: number, testnet?: boolean): string; /** * Get the Wormhole Token Bridge contract address for a chain */ declare function getWormholeTokenBridge(wormholeChainId: number, testnet?: boolean): string; /** * Get the Wormhole Relayer contract address for a chain */ declare function getWormholeRelayer(wormholeChainId: number, testnet?: boolean): string; /** * Check if a chain supports Wormhole Relayer */ declare function supportsRelayer(wormholeChainId: number, testnet?: boolean): boolean; /** * Get chain name from Wormhole chain ID */ declare function getChainName(wormholeChainId: number): string; /** * Validate that a VAA has sufficient signatures for the given network */ declare function hasQuorum(vaa: VAA, testnet?: boolean): boolean; /** * Validate VAA emitter matches expected source */ declare function validateEmitter(vaa: VAA, expectedChain: number, expectedAddress: string): boolean; /** * Convert an EVM address to bytes32 format (for Wormhole) */ declare function evmAddressToBytes32(address: string): string; export { CONSISTENCY_LEVELS, type FetchVAAOptions, GUARDIAN_CONFIG, type WaitForSignaturesOptions, emitterToEvmAddress, encodeVAAForSolana, encodeVAAToBytes, evmAddressToBytes32, fetchVAA, fetchVAAByTxHash, fetchVAAByTxHashFallback, getChainName, getSequenceFromTxReceipt, getWormholeCoreBridge, getWormholeRelayer, getWormholeTokenBridge, hasQuorum, normalizeEmitterAddress, parseVAA, parseVAABytes, parseVeridexPayload, supportsRelayer, validateEmitter, waitForGuardianSignatures };