import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; import { type Json, type JsonRpcParams } from '@metamask/utils'; import type { AbstractRpcServiceLike, InfuraJsonRpcSupportedNetwork } from './types'; /** * A simplified version of the `HeadersInit` type from the Fetch API. * * We purposefully do not use that type because we don't want to accidentally * rely on browser-only APIs in this package. */ declare type Headers = Record; export declare type CreateInfuraMiddlewareOptions = { network?: InfuraJsonRpcSupportedNetwork; maxAttempts?: number; source?: string; projectId: string; headers?: Headers; }; /** * Creates middleware for sending a JSON-RPC request through the given RPC * service. * @param args - The arguments to this function. * @param args.rpcService - The RPC service to use. * @param args.options - Options. * @param args.options.source - A descriptor for the entity making the request; * tracked by Infura for analytics purposes. * @param args.options.headers - Extra headers to include in the request. * @returns The fetch middleware. */ export declare function createInfuraMiddleware(args: { rpcService: AbstractRpcServiceLike; options?: { source?: string; headers?: Headers; }; }): JsonRpcMiddleware; /** * Builds [`@metamask/json-rpc-engine`](https://github.com/MetaMask/@metamask/json-rpc-engine)-compatible middleware designed * for interfacing with Infura's JSON-RPC endpoints. * @deprecated This overload is deprecated — please pass an `RpcService` * instance from `@metamask/network-controller` instead. * @param args - The arguments to this function. * @param args.network - A network that Infura supports; plugs into * `https://${network}.infura.io` (default: 'mainnet'). * @param args.maxAttempts - The number of times a request to Infura should be * retried in the case of failure (default: 5). * @param args.source - A descriptor for the entity making the request; tracked * by Infura for analytics purposes. * @param args.projectId - The Infura project id. * @param args.headers - Extra headers that will be used to make the request. * @returns The `@metamask/json-rpc-engine`-compatible middleware. */ export declare function createInfuraMiddleware(args: CreateInfuraMiddlewareOptions): JsonRpcMiddleware; /** * Builds [`@metamask/json-rpc-engine`](https://github.com/MetaMask/@metamask/json-rpc-engine)-compatible middleware designed * for interfacing with Infura's JSON-RPC endpoints. * @param opts - The options. * @param opts.network - A network that Infura supports; plugs into * `https://${network}.infura.io` (default: 'mainnet'). * @param opts.maxAttempts - The number of times a request to Infura should be * retried in the case of failure (default: 5). * @param opts.source - A descriptor for the entity making the request; tracked * by Infura for analytics purposes. * @param opts.projectId - The Infura project id. * @param opts.headers - Extra headers that will be used to make the request. * @returns The `@metamask/json-rpc-engine`-compatible middleware. */ export declare function createInfuraMiddlewareWithoutRpcService({ network, maxAttempts, source, projectId, headers, }: CreateInfuraMiddlewareOptions): JsonRpcMiddleware; export {};