abstractSocketProvider <MessageEvent, CloseEvent, ErrorEvent, API>
Hierarchy
- Eip1193Provider<API>
- SocketProvider
Index
Constructors
publicconstructor
Type parameters
- MessageEvent
- CloseEvent
- ErrorEvent
- API: unknown = EthExecutionAPI
Parameters
socketPath: string
The path to the socket (e.g. /ipc/path or ws://localhost:8546)
optionalsocketOptions: object
The options for the socket connection
optionalreconnectOptions: object
The options for the socket reconnection ReconnectOptions
Returns SocketProvider<MessageEvent, CloseEvent, ErrorEvent, API>
Accessors
publicSocketConnection
Returns unknown
[symbol]
Returns boolean
Methods
publicconnect
Try to establish a connection to the socket
Returns void
publicdisconnect
Disconnects the socket
Parameters
optionalcode: number
The code to be sent to the server
optionaldata: string
The data to be sent to the server
Returns void
abstractgetStatus
Returns Web3ProviderStatus
publicon
Registers a listener for the specified event type.
Type parameters
- T = JsonRpcResult
Parameters
type: string
The event type to listen for
callback: Web3ProviderEventCallback<T>
The callback to be invoked when the event is emitted
Returns void
publiconce
Registers a listener for the specified event type that will be invoked at most once.
Type parameters
- T = JsonRpcResult
Parameters
type: string
The event type to listen for
callback: Web3ProviderEventCallback<T>
The callback to be invoked when the event is emitted
Returns void
publicremoveAllListeners
Removes all listeners for the specified event type.
Parameters
type: string
The event type to remove the listeners for
Returns void
publicremoveListener
Removes a listener for the specified event type.
Parameters
type: string
The event type to remove the listener for
callback: Web3ProviderEventCallback<JsonRpcResult>
The callback to be executed
Returns void
publicrequest
Creates a request object to be sent to the server
Type parameters
- Method: string
- ResultType = Web3APIReturnType<API, Method>
Parameters
request: Web3APIPayload<API, Method>
Returns Promise<JsonRpcResponseWithResult<ResultType>>
publicreset
Resets the socket, removing all listeners and pending requests
Returns void
send
Type parameters
- ResultType = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
callback: (err?: null | Error, response?: JsonRpcResponse<ResultType, JsonRpcResult>) => void
Returns void
sendAsync
Type parameters
- R = JsonRpcResult
- P = unknown
Parameters
payload: JsonRpcPayload<P>
Returns Promise<JsonRpcResponse<R, JsonRpcResult>>
publicsupportsSubscriptions
Returns boolean
true
if the socket supports subscriptions
staticisWeb3Provider
Parameters
provider: unknown
Returns boolean
This is an abstract class for implementing a socket provider (e.g. WebSocket, IPC). It extends the EIP-1193 provider EIP1193Provider.