import type { Chain as core_Chain, Client as core_Client, FallbackTransport, HttpTransport, PublicActions } from 'viem'; import type { TempoActions } from 'viem/tempo'; import { tempoMainnet } from 'viem/tempo/chains'; import type * as z from 'zod/mini'; import type * as Auth from './Auth.js'; import * as Credential from './Credential.js'; import type * as Schema from './Schema.js'; /** Known Tempo chains keyed by id, for metadata lookups. */ export declare const chains: readonly core_Chain[]; /** Tempo chain ids keyed by network. */ export declare const chainId: { readonly mainnet: 4217; readonly testnet: 42431; }; /** Default Tempo chain id. */ export declare const defaultChainId: 4217; /** Whether a chain id is Tempo mainnet. */ export declare function isMainnet(id: number): boolean; /** Default Tempo RPC URLs keyed by chain id. */ export declare const url: Record; /** Tempo chain id. */ export type ChainId = z.output; /** Tempo chain metadata with a configurable chain id. */ export type Chain = Omit & { id: ChainId; }; /** Gets a Tempo viem client for a chain id. */ export type GetClient = (chainId?: ChainId) => getClient.ReturnType; /** Shared, per-chain, or dynamically resolved RPC URLs. */ export type UrlResolver = string | Record | ((chainId: ChainId) => string | undefined); /** Headers required when connecting to a Zone upstream. */ export type ZoneHeaders = Record; /** Creates a generic EVM client with ordered RPC endpoint fallback. */ export declare function createEvmClient(options: createEvmClient.Options): createEvmClient.ReturnType; export declare namespace createEvmClient { /** Generic EVM RPC client configuration. */ type Options = { /** EIP-155 chain id attached to request failures. */ chainId?: number | undefined; /** Fetch implementation used for RPC requests. */ fetch: typeof globalThis.fetch; /** Optional request cancellation signal. */ signal?: AbortSignal | undefined; /** Ordered RPC endpoint URLs. */ urls: readonly string[]; }; /** Generic EVM client with fallback transport. */ type ReturnType = core_Client; } /** Returns bounded diagnostics for a viem request failure. */ export declare function requestFailure(cause: unknown): requestFailure.Result | undefined; export declare namespace requestFailure { /** Bounded viem request failure details. */ type Result = { /** EIP-155 chain whose RPC request failed. */ chainId?: number | undefined; /** Stable error class and JSON-RPC code. */ code: string; /** Failure boundary inferred from the viem cause chain. */ failure: 'http' | 'network' | 'query' | 'rate_limit' | 'timeout' | 'unknown'; /** Root-cause error message. */ message: string; /** Upstream HTTP status, when a response was received. */ status?: number | undefined; }; } /** Returns chain ids declared by a static chain-id-to-URL map. */ export declare function configuredChainIds(value: UrlResolver | undefined): number[]; /** * Resolves the effective RPC config for a single request. * * Accepts either a static config object or a per-request resolver function. The * resolver receives a {@link resolveRpc.Context} (`chainId` plus the request * `principal`), so callers can route traffic per caller — e.g. send anonymous * (`principal.type === 'public'`) traffic to a separate, no-auth upstream. A * `null` principal denotes a trusted, non-request caller (the scheduled * webhook poller). A missing `url` falls back to the built-in public host map * ({@link url}); missing `auth` means no Authorization header is sent. * * Memoization is keyed on the resolved output (see {@link createGetClient} and * {@link Tidx.createGetClient}), not the context, so a resolver may branch on * any principal field without unbounded client cardinality: callers that * resolve to the same upstream share a client. Pass the result to * {@link getClient} (or let `getClient` resolve for you) to build a client. */ export declare function resolveRpc(rpc: getClient.Rpc | undefined, context: resolveRpc.Context): resolveRpc.Resolved; export declare namespace resolveRpc { /** RPC resolution context. */ type Context = { /** Tempo chain id. */ chainId: ChainId; /** * Request principal, or `null` for a trusted non-request caller (the * scheduled webhook poller). Anonymous and MPP-paid public requests carry a * `type: 'public'` principal; authenticated requests a `type: 'api_key'` one. */ principal: Auth.Principal | null; /** Zone chain selected for this request, when applicable. */ zone?: core_Chain | undefined; }; /** Resolved RPC config for a single request. */ type Resolved = { /** Basic auth credentials, or undefined to send no Basic auth. */ basicAuth?: string | undefined; /** Bearer auth credential, or undefined to send no Bearer auth. */ bearerAuth?: string | undefined; /** Explicit public Zone RPC URL, absent when missing, invalid, or matching the selected Zone's internal endpoints. */ publicZoneUrl?: string | undefined; /** Headers sent to Zone RPC upstreams. */ zoneHeaders?: ZoneHeaders | undefined; /** * Resolved RPC URL, or `undefined` when neither a configured `rpc` nor the * built-in {@link url} map covers the chain (e.g. an unconfigured localnet). * A `undefined` URL falls through to viem's chain default transport. */ url: string | undefined; }; } export declare function getClient(options: getClient.Options): getClient.ReturnType; /** Creates a request-local Tempo client that batches JSON-RPC calls over HTTP. */ export declare function createBatchClient(options: getClient.Options): getClient.ReturnType; /** Builds a memoized Tempo client resolver. */ export declare function createGetClient(options?: createGetClient.Options): createGetClient.ReturnType; export declare namespace createGetClient { /** Options for building a memoized Tempo client resolver. */ type Options = { /** Tempo chain id used when a caller omits one. */ defaultChainId?: ChainId | undefined; /** Tempo RPC options applied to every constructed client. */ rpc?: getClient.Rpc | undefined; /** Zone chains whose internal RPC URLs serve as per-chain defaults. */ zones?: readonly core_Chain[] | undefined; }; /** Memoized Tempo client resolver. */ type ReturnType = (chainId?: ChainId, principal?: Auth.Principal | null) => getClient.ReturnType; } export declare namespace getClient { /** Tempo viem client with public and Tempo action helpers. */ type ReturnType = core_Client, 'token'> & TempoActions>; /** Options for getting a Tempo viem client. */ type Options = { /** Tempo chain id. */ chainId?: ChainId | undefined; /** Request principal, or `null`/omitted for a trusted non-request caller. */ principal?: Auth.Principal | null | undefined; /** Tempo RPC options. */ rpc?: Rpc | undefined; /** Zone chain metadata used for RPC URL resolution. */ zone?: core_Chain | undefined; /** Zone authorization token forwarded to the RPC node. */ zoneToken?: string | undefined; }; /** * Tempo RPC options: either a static config, or a per-request resolver * function that receives a {@link resolveRpc.Context} and returns the config to * use (e.g. routing anonymous callers to a public, no-auth RPC). */ type Rpc = { /** Shared or per-chain RPC credentials. Values containing `:` use Basic auth; others use Bearer auth. */ auth?: Credential.ChainCredential | undefined; /** Explicit token-validating Zone RPC URL. Must have a distinct host or port from the selected Zone's internal endpoints. */ publicZoneUrl?: UrlResolver | undefined; /** Headers sent to Zone RPC upstreams. */ zoneHeaders?: ZoneHeaders | undefined; /** Resolves the RPC URL for a Tempo chain id. */ url?: UrlResolver | undefined; } | ((context: resolveRpc.Context) => { /** Shared or per-chain RPC credentials, or undefined for none. */ auth?: Credential.ChainCredential | undefined; /** Explicit token-validating Zone RPC URL. Must have a distinct host or port from the selected Zone's internal endpoints. */ publicZoneUrl?: string | undefined; /** Headers sent to Zone RPC upstreams. */ zoneHeaders?: ZoneHeaders | undefined; /** RPC URL to use; falls back to the built-in public host when omitted. */ url?: string | undefined; }); } /** Resolves a shared or per-chain URL for one chain id. */ export declare function resolveUrl(value: UrlResolver | undefined, chainId: ChainId): string | undefined; /** A caller-authorized Zone request has no safe public RPC endpoint. */ export declare class PublicZoneRpcUnavailableError extends Error { name: string; constructor(); } //# sourceMappingURL=Viem.d.ts.map