/** * Core bridge utilities — shared between x402 and MPP clients. * * Auto-discovers bridge info from the RelAI API and provides helpers * for executing cross-chain payments transparently. * * Usage (MPP): * ```ts * import { evmChargeWithBridge } from '@relai-fi/x402/mpp/with-bridge' * ``` * * Usage (x402): * ```ts * import { createX402Client } from '@relai-fi/x402' * const client = createX402Client({ ..., bridge: { enabled: true } }) * ``` */ interface BridgeInfo { settleEndpoint: string; supportedSourceChains: string[]; supportedSourceAssets: string[]; payTo: Record; feePayerSvm: string | null; feeBps: number; paymentFacilitator: string; } interface BridgeSettleRequest { /** x402 mode: base64-encoded payment header */ sourcePayment?: string; /** MPP mode: source tx hash */ sourceTxHash?: string; /** MPP mode: wallet address that sent the source tx */ senderAddress?: string; /** MPP mode: signature of (sourceTxHash + JSON(targetAccept)) */ senderSignature?: string; /** CAIP-2 source chain identifier */ sourceChain: string; targetAccept: { scheme: 'exact'; network: string; asset: string; payTo: string; amount: string; }; /** x402 payment requirements (full 402 body) — needed by settle for x402 flow */ requirements?: any; resource?: string; paymentFacilitator?: string | null; } interface BridgeSettleResponse { success?: boolean; targetTxId?: string; sourceTxId?: string; /** x402 payment header (returned by x402-flavored settle) */ xPayment?: string; } /** * Fetch bridge info from the RelAI API (cached per base URL for 5 minutes). */ declare function getBridgeInfo(baseUrl?: string): Promise; /** * Call the bridge settle endpoint. */ declare function settleBridge(settleEndpoint: string, body: BridgeSettleRequest): Promise; /** * Select a source chain from supported chains that matches the available wallet. */ declare function selectSourceChain(supportedChains: string[], hasEvmWallet: boolean, hasSolanaWallet: boolean, preferredSourceChainId?: number): { type: 'evm' | 'solana'; chain: string; } | null; /** * Compute source amount including bridge fee. */ declare function computeSourceAmount(targetAmount: bigint, feeBps: number): bigint; declare const DEFAULT_EVM_RPC: Record; export { type BridgeInfo, type BridgeSettleRequest, type BridgeSettleResponse, DEFAULT_EVM_RPC, computeSourceAmount, getBridgeInfo, selectSourceChain, settleBridge };