From 7f6bd96b3334ebda252163d0e0c7f484e2fdae4e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 31 Aug 2022 17:32:52 -0400 Subject: [PATCH] *Update and bug fix rpc classes --- src/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 87d5c4b..44cc276 100644 --- a/src/index.ts +++ b/src/index.ts @@ -213,6 +213,7 @@ export abstract class RpcQueryBase { } export class SimpleRpcQuery extends RpcQueryBase { + private _relay: string | Buffer; constructor( network: RpcNetwork, relay: string | Buffer, @@ -220,10 +221,23 @@ export class SimpleRpcQuery extends RpcQueryBase { options: RpcQueryOptions ) { super(network, query, options, "simpleQuery"); + this._relay = relay; + } + public run(): this { + this._promise = this._network.processQueue().then(() => + callModule(RPC_MODULE, this._queryType, { + relay: this._relay, + query: this._query, + options: this._options, + network: this._network.networkId, + }) + ); + + return this; } } -export class StreamingRpcQuery extends RpcQueryBase { +export class StreamingRpcQuery extends SimpleRpcQuery { protected _options: StreamingRpcQueryOptions; constructor( @@ -232,8 +246,9 @@ export class StreamingRpcQuery extends RpcQueryBase { query: RPCRequest, options: StreamingRpcQueryOptions ) { - super(network, query, options, "streamingQuery"); + super(network, relay, query, options); this._options = options; + this._queryType = "streamingQuery"; } public run(): this {