@polkadot/rpc-provider
Advanced tools
Comparing version 0.31.11 to 0.31.12
{ | ||
"name": "@polkadot/rpc-provider", | ||
"version": "0.31.11", | ||
"version": "0.31.12", | ||
"description": "Transport providers for the API", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"@babel/runtime": "^7.0.0", | ||
"@polkadot/storage": "^0.31.11", | ||
"@polkadot/storage": "^0.31.12", | ||
"@polkadot/util": "^0.30.7", | ||
@@ -36,0 +36,0 @@ "@polkadot/util-crypto": "^0.30.7", |
import { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types'; | ||
import './polyfill'; | ||
import E3 from 'eventemitter3'; | ||
declare type SubscriptionHandler = { | ||
@@ -29,3 +28,4 @@ callback: ProviderInterface$Callback; | ||
*/ | ||
export default class WsProvider extends E3.EventEmitter implements WSProviderInterface { | ||
export default class WsProvider implements WSProviderInterface { | ||
private _eventemitter; | ||
private autoConnect; | ||
@@ -60,5 +60,4 @@ private coder; | ||
* @param {ProviderInterface$EmitCb} sub Callback | ||
* @return {this} [description] | ||
*/ | ||
on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): this; | ||
on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void; | ||
/** | ||
@@ -96,2 +95,3 @@ * @summary Send JSON data using WebSockets to configured HTTP Endpoint or queue. | ||
unsubscribe(type: string, method: string, id: number): Promise<boolean>; | ||
private emit; | ||
private onSocketClose; | ||
@@ -98,0 +98,0 @@ private onSocketError; |
@@ -50,3 +50,3 @@ "use strict"; | ||
*/ | ||
class WsProvider extends _eventemitter.default.EventEmitter { | ||
class WsProvider { | ||
/** | ||
@@ -57,3 +57,3 @@ * @param {string} endpoint The endpoint url. Usually `ws://ip:9944` or `wss://ip:9944` | ||
constructor(endpoint, autoConnect = true) { | ||
super(); | ||
this._eventemitter = void 0; | ||
this.autoConnect = void 0; | ||
@@ -157,2 +157,3 @@ this.coder = void 0; | ||
(0, _assert.default)(/^(wss|ws):\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`); | ||
this._eventemitter = new _eventemitter.default(); | ||
this.autoConnect = autoConnect; | ||
@@ -203,3 +204,2 @@ this.coder = (0, _json.default)(); | ||
* @param {ProviderInterface$EmitCb} sub Callback | ||
* @return {this} [description] | ||
*/ | ||
@@ -209,3 +209,3 @@ | ||
on(type, sub) { | ||
return super.on(type, sub); | ||
this._eventemitter.on(type, sub); | ||
} | ||
@@ -294,4 +294,8 @@ /** | ||
emit(type, ...args) { | ||
this._eventemitter.emit(type, ...args); | ||
} | ||
} | ||
exports.default = WsProvider; |
@@ -11,3 +11,3 @@ // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors | ||
import E3 from 'eventemitter3'; | ||
import EventEmitter from 'eventemitter3'; | ||
import assert from '@polkadot/util/assert'; | ||
@@ -59,3 +59,4 @@ import isNull from '@polkadot/util/is/null'; | ||
*/ | ||
export default class WsProvider extends E3.EventEmitter implements WSProviderInterface { | ||
export default class WsProvider implements WSProviderInterface { | ||
private _eventemitter: EventEmitter; | ||
private autoConnect: boolean; | ||
@@ -82,6 +83,5 @@ private coder: RpcCoder; | ||
constructor (endpoint: string, autoConnect: boolean = true) { | ||
super(); | ||
assert(/^(wss|ws):\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`); | ||
this._eventemitter = new EventEmitter(); | ||
this.autoConnect = autoConnect; | ||
@@ -132,6 +132,5 @@ this.coder = coder(); | ||
* @param {ProviderInterface$EmitCb} sub Callback | ||
* @return {this} [description] | ||
*/ | ||
on (type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): this { | ||
return super.on(type, sub); | ||
on (type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void { | ||
this._eventemitter.on(type, sub); | ||
} | ||
@@ -219,2 +218,6 @@ | ||
private emit (type: ProviderInterface$Emitted, ...args: Array<any>): void { | ||
this._eventemitter.emit(type, ...args); | ||
} | ||
private onSocketClose = (): void => { | ||
@@ -221,0 +224,0 @@ this.l.debug(() => ['disconnected from', this.endpoint]); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82802
2280
Updated@polkadot/storage@^0.31.12