UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

24 lines (23 loc) 618 B
import { AbstractRpcProvider } from './AbstractRpcProvider.js'; export class WebSocketRpcProvider extends AbstractRpcProvider { wsUrl; constructor(url, network) { super(network); this.wsUrl = this.providerUrl(url); } _send(payload) { throw new Error('Method not implemented.'); } providerUrl(url) { url = url.trim(); if (url.endsWith('/')) { return url.slice(0, -1); } if (url.includes('api/v1/json-rpc-ws')) { return url; } else { return `${url}/api/v1/json-rpc-ws`; } } }