import { JsonRpcMiddleware, JsonRpcRequest, PendingJsonRpcResponse } from './JsonRpcEngine'; export declare type AsyncJsonRpcEngineNextCallback = () => Promise; export declare type AsyncJsonrpcMiddleware = (req: JsonRpcRequest, res: PendingJsonRpcResponse, next: AsyncJsonRpcEngineNextCallback) => Promise; /** * JsonRpcEngine only accepts callback-based middleware directly. * createAsyncMiddleware exists to enable consumers to pass in async middleware * functions. * * Async middleware have no "end" function. Instead, they "end" if they return * without calling "next". Rather than passing in explicit return handlers, * async middleware can simply await "next", and perform operations on the * response object when execution resumes. * * To accomplish this, createAsyncMiddleware passes the async middleware a * wrapped "next" function. That function calls the internal JsonRpcEngine * "next" function with a return handler that resolves a promise when called. * * The return handler will always be called. Its resolution of the promise * enables the control flow described above. */ export declare function createAsyncMiddleware(asyncMiddleware: AsyncJsonrpcMiddleware): JsonRpcMiddleware;