import { RpcRequest } from 'ox'; import { type Address, type Client } from 'viem'; import type { LocalAccount } from 'viem/accounts'; import { type Handler, from } from '../Handler.js'; import * as Store from '../internal/Store.js'; import * as Multisig from './internal/multisig.js'; import * as Sponsorship from './internal/sponsorship.js'; /** * Instantiates a relay handler that proxies `eth_fillTransaction` * with wallet-aware enrichment (fee token resolution, simulation, * sponsorship, AMM resolution). * * @example * ```ts * import { Handler } from 'tapimo' * * const handler = Handler.relay({ apiKey: process.env.TEMPO_API_KEY }) * * // Plug handler into your server framework of choice: * createServer(handler.listener) // Node.js * Bun.serve(handler) // Bun * Deno.serve(handler) // Deno * app.use(handler.listener) // Express * app.all('*', c => handler.fetch(c.req.raw)) // Hono * export const GET = handler.fetch // Next.js * export const POST = handler.fetch // Next.js * ``` * * @example * With sponsorship * * ```ts * import { privateKeyToAccount } from 'viem/accounts' * import { Handler } from 'tapimo' * * const handler = Handler.relay({ * feePayer: { * account: privateKeyToAccount('0x...'), * }, * }) * ``` * * @param options - Options. * @returns Request handler. */ export declare function relay(options?: relay.Options): Handler; export declare namespace relay { type Options = from.Options & { /** * Tempo API key used by the default RPC clients and token resolver. When * omitted, RPC clients use each chain's default transport. */ apiKey?: string | undefined; /** * Auto-swap options. */ autoSwap?: false | { /** Slippage tolerance (e.g. 0.05 = 5%). @default 0.05 */ slippage?: number | undefined; } | undefined; /** * Resolves a viem client for a chain id. The handler resolves the client * from the `chainId` in the incoming transaction (falling back to the * client's default chain). Defaults to Tempo mainnet and testnet clients. */ getClient?: ((chainId?: number) => Client) | undefined; /** * Fee payer / sponsor configuration. When provided, the relay will * sign `feePayerSignature` on the filled transaction. */ feePayer?: { /** Account to use as the fee payer. */ account: LocalAccount; /** Preferred fee token the sponsor wants to pay fees in. */ feeToken?: Address | undefined; /** * Called once the fee payer has signed a raw transaction. */ onSponsored?: Sponsorship.handleRawTransaction.Options['onSponsored']; /** * Validates whether to sponsor the transaction. When omitted, all * transactions are sponsored. Return `false` to reject sponsorship. */ validate?: Sponsorship.Validate | undefined; /** Sponsor display name returned from `eth_fillTransaction`. */ name?: string | undefined; /** Sponsor URL returned from `eth_fillTransaction`. */ url?: string | undefined; } | undefined; /** * Native multisig configuration. When provided, the relay collects owner * approvals from multisig raw transaction submissions and broadcasts once * collected owner weight meets the configured threshold. */ multisig?: Multisig.Options | undefined; /** * Relay features. * * - `'all'` — enables fee token resolution, auto-swap, * fee payer, and simulation (balance diffs + fee breakdown). * - `undefined` (default) — only fee payers. */ features?: 'all' | undefined; /** * Allows app-provided external fee payer URLs to use non-HTTPS protocols * or local/private hosts. Intended only for trusted development setups. * @default false */ internal_allowUnsafeUrls?: boolean | undefined; /** * In-process cache backing TIP-20 metadata and user fee-token preference * memoization. Omit to read upstream on every fill. */ cache?: Store.Store | undefined; /** Function to call before handling the request. */ onRequest?: ((request: RpcRequest.RpcRequest) => Promise) | undefined; /** Path to use for the handler. @default "/" */ path?: string | undefined; /** * Resolves the known fee-token candidates for a chain. Defaults to the * Tempo API verified token list for mainnet and testnet. */ resolveTokens?: ((chainId: number) => readonly Address[] | Promise) | undefined; }; } //# sourceMappingURL=relay.d.ts.map