import { RpcResponse } from "../types/rpc.js";
import { MaybePromise } from "../types/utils.js";
//#region src/transports/getHttpRpcClient.d.ts
type RpcRequest = {
jsonrpc?: "2.0";
method: string;
params?: any;
id?: number;
};
type HttpRequestReturnType
= body extends RpcRequest[] ? RpcResponse[] : RpcResponse;
type HttpRpcClientOptions = {
/** Request configuration to pass to `fetch`. */fetchOptions?: Omit | undefined; /** A callback to handle the request. */
onRequest?: ((request: Request, init: RequestInit) => MaybePromise) | undefined; /** A callback to handle the response. */
onResponse?: ((response: Response) => Promise | void) | undefined; /** The timeout (in ms) for the request. */
timeout?: number | undefined;
};
type HttpRequestParameters = {
url?: string; /** The RPC request body. */
body?: body; /** Request configuration to pass to `fetch`. */
fetchOptions?: HttpRpcClientOptions["fetchOptions"] | undefined; /** A callback to handle the response. */
onRequest?: ((request: Request) => Promise | void) | undefined; /** A callback to handle the response. */
onResponse?: ((response: Response) => Promise | void) | undefined; /** The timeout (in ms) for the request. */
timeout?: HttpRpcClientOptions["timeout"] | undefined;
};
type HttpRpcClient = {
request(params: HttpRequestParameters): Promise>;
};
declare function getHttpRpcClient(url: string, options?: HttpRpcClientOptions): HttpRpcClient;
//#endregion
export { HttpRequestParameters, HttpRequestReturnType, HttpRpcClient, HttpRpcClientOptions, RpcRequest, getHttpRpcClient };
//# sourceMappingURL=getHttpRpcClient.d.ts.map