1-
21import { IEthereumRpcError } from 'eth-rpc-errors/@types'
32
43/**
54 * A String specifying the version of the JSON-RPC protocol.
65 * MUST be exactly "2.0".
76 */
8- export type JsonRpcVersion = " 2.0" ;
7+ export type JsonRpcVersion = ' 2.0' ;
98
109/** Method names that begin with the word rpc followed by a period character
1110 * (U+002E or ASCII 46) are reserved for rpc-internal methods and extensions
@@ -52,17 +51,32 @@ export interface JsonRpcFailure<T> extends JsonRpcResponseBase {
5251export type JsonRpcResponse < T > = JsonRpcSuccess < T > | JsonRpcFailure < T >
5352
5453export type JsonRpcEngineEndCallback = ( error ?: JsonRpcError < unknown > ) => void ;
54+
55+ type ReturnHandlerCallback = ( done : ( error ?: Error ) => void ) => void
56+
5557export type JsonRpcEngineNextCallback = (
56- returnFlightCallback ?: ( done : ( ) => void ) => void ,
58+ returnHandlerCallback ?: ReturnHandlerCallback ,
5759) => void ;
5860
61+ export type AsyncJsonRpcEngineNextCallback = (
62+ returnHandlerCallback ?: ReturnHandlerCallback ,
63+ ) => Promise < void > ;
64+
5965export interface JsonRpcMiddleware {
6066 (
6167 req : JsonRpcRequest < unknown > ,
6268 res : JsonRpcResponse < unknown > ,
6369 next : JsonRpcEngineNextCallback ,
6470 end : JsonRpcEngineEndCallback ,
65- ) : void ;
71+ ) : void ;
72+ }
73+
74+ export interface AsyncJsonrpcMiddleware {
75+ (
76+ req : JsonRpcRequest < unknown > ,
77+ res : JsonRpcResponse < unknown > ,
78+ next : AsyncJsonRpcEngineNextCallback ,
79+ ) : Promise < void > ;
6680}
6781
6882export interface JsonRpcEngine {
@@ -75,3 +89,30 @@ export interface JsonRpcEngine {
7589 ) => void ,
7690 ) => void ;
7791}
92+
93+ export interface asMiddleware {
94+ ( engine : JsonRpcEngine ) : JsonRpcMiddleware ;
95+ }
96+
97+ export interface createAsyncMiddleware {
98+ ( asyncMiddleware : AsyncJsonrpcMiddleware ) : JsonRpcMiddleware ;
99+ }
100+
101+ type Serializable = boolean | number | string | Record < string , unknown > | unknown [ ] | null | undefined ;
102+ type ScaffoldMiddlewareHandler < T > = T extends Function ? JsonRpcMiddleware : Serializable ;
103+
104+ export interface createScaffoldMiddleware < T > {
105+ ( handlers : { [ methodName : string ] : ScaffoldMiddlewareHandler < T > } ) : JsonRpcMiddleware ;
106+ }
107+
108+ export interface createIdRemapMiddleware {
109+ ( ) : JsonRpcMiddleware ;
110+ }
111+
112+ export interface mergeMiddleware {
113+ ( middlewares : JsonRpcMiddleware [ ] ) : JsonRpcMiddleware ;
114+ }
115+
116+ export interface getUniqueId {
117+ ( ) : number ;
118+ }
0 commit comments