import { WebSocketProvider } from './ws' ; import { NewBlockQuery , NewEventQuery , QueryParam , SubscriptionOption , } from './types' ; export class Subscription extends WebSocketProvider { subject : NewBlockQuery | NewEventQuery ; constructor ( subject , url , options ? ) { super ( url , options ) ; this . subject = subject ; } async start ( ) { return super . subscribe ( this . subject ) ; } async stop ( ) { const event = this . subject . query === QueryParam . NEW_BLOCK ? { query : QueryParam . UNSUBSCRIBE , type : QueryParam . NEW_BLOCK , } : { query : QueryParam . UNSUBSCRIBE , type : QueryParam . EVENT_LOG } ; return super . unsubscribe ( event ) ; } }