import * as Errors from './Errors.js'; import * as promise from './internal/promise.js'; import type * as RpcSchema_internal from './internal/rpcSchema.js'; import * as internal from './internal/rpcTransport.js'; import type { Compute } from './internal/types.js'; import type * as RpcResponse from './RpcResponse.js'; import type * as RpcSchema from './RpcSchema.js'; /** Root type for an RPC Transport. */ export type RpcTransport = {}, schema extends RpcSchema.Generic = RpcSchema.Default> = Compute<{ request: RequestFn; }>; /** HTTP-based RPC Transport. */ export type Http = RpcTransport; export type HttpOptions = { /** Request configuration to pass to `fetch`. */ fetchOptions?: Omit | ((method: RpcSchema.Generic['Request']) => Omit | Promise>) | undefined; /** Function to use to make the request. @default fetch */ fetchFn?: typeof fetch | undefined; /** Timeout for the request in milliseconds. @default 10_000 */ timeout?: number | undefined; }; export type RequestFn = {}, schema extends RpcSchema.Generic = RpcSchema.Default> = (parameters: Compute>, options?: internal.Options) => Promise> : RpcSchema.ExtractReturnType : raw extends true ? RpcResponse.RpcResponse> : RpcSchema.ExtractReturnType>; /** * Creates a HTTP JSON-RPC Transport from a URL. * * @example * ```ts twoslash * import { RpcTransport } from 'ox' * * const transport = RpcTransport.fromHttp( * 'https://1.rpc.thirdweb.com' * ) * * const blockNumber = await transport.request({ * method: 'eth_blockNumber' * }) * // @log: '0x1a2b3c' * ``` * * @param url - URL to perform the JSON-RPC requests to. * @param options - Transport options. * @returns HTTP JSON-RPC Transport. */ export declare function fromHttp(url: string, options?: fromHttp.Options): Http>; export declare namespace fromHttp { type Options = internal.Options; type ErrorType = promise.withTimeout.ErrorType | HttpError | Errors.GlobalErrorType; } /** Thrown when a HTTP request fails. */ export declare class HttpError extends Errors.BaseError { readonly name = "RpcTransport.HttpError"; constructor({ body, details, response, url, }: { body: unknown; details: string; response: Response; url: string; }); } /** Thrown when a HTTP response is malformed. */ export declare class MalformedResponseError extends Errors.BaseError { readonly name = "RpcTransport.MalformedResponseError"; constructor({ response }: { response: string; }); } //# sourceMappingURL=RpcTransport.d.ts.map