Provider based on WS JSON-RPC requests.
Creates a new instance of the WebSocket Provider
baseURL
string the WS URL of the noderequestTimeout
number the timeout for the WS request (in MS)
new WSProvider('ws://test3.gno.land:36657/ws');
// provider with WS connection is created
Closes the WS connection. Required when done working with the WS provider
const wsProvider = new WSProvider('ws://test3.gno.land:36657/ws');
wsProvider.closeConnection();
// WS connection is now closed
Sends a request to the WS connection, and resolves upon receiving the response
request
RPCRequest the RPC request
Returns Promise<RPCResponse<Result>>
const request: RPCRequest = // ...
const wsProvider = new WSProvider('ws://test3.gno.land:36657/ws');
wsProvider.sendRequest<Result>(request);
// request is sent over the open WS connection
Parses the result from the response
response
RPCResponse<Result> the response to be parsed
Returns Result
const response: RPCResponse = // ...
const wsProvider = new WSProvider('ws://test3.gno.land:36657/ws');
wsProvider.parseResponse<Result>(response);
// response is parsed
Waits for the WS connection to be established
Returns Promise<null>
const wsProvider = new WSProvider('ws://test3.gno.land:36657/ws');
await wsProvider.waitForOpenConnection()
// status of the connection is: CONNECTED