Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (providerOrRpc?: Rpc | ProviderInterface) {
this._api = providerOrRpc instanceof Rpc
? providerOrRpc
: new Rpc(providerOrRpc);
this._eventemitter = new EventEmitter();
this._isConnected = new BehaviorSubject(this._api._provider.isConnected());
this.initEmitters(this._api._provider);
this.author = this.createInterface(this._api.author);
this.chain = this.createInterface(this._api.chain);
this.state = this.createInterface(this._api.state);
this.system = this.createInterface(this._api.system);
}
constructor (options: ApiOptions, type: ApiTypes, decorateMethod: DecorateMethod) {
super();
this.registry = options.registry || new TypeRegistry();
const thisProvider = options.source
? options.source._rpcCore.provider.clone()
: (options.provider || new WsProvider());
this.decorateMethod = decorateMethod;
this._options = options;
this._type = type;
this._rpcCore = new RpcCore(this.registry, thisProvider, this._options.rpc);
this._isConnected = new BehaviorSubject(this._rpcCore.provider.isConnected());
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
this._rx.registry = this.registry;
}