From 1e3e8f35bc84661d637f4911265c5dd4536af695 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 31 Aug 2022 19:15:40 -0400 Subject: [PATCH] *Update StreamingRpcQuery result to handle connectModule properly --- src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/index.ts b/src/index.ts index 596debd..7fbb6a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,7 @@ import { StreamingRpcQueryOptions, } from "@lumeweb/dht-rpc-client"; import { Buffer } from "buffer"; +import { DataFn } from "libskynet/dist"; const RPC_MODULE = "AQDaEPIo_lpdvz7AKbeafERBHR331RiyvweJ6OrFTplzyg"; @@ -267,6 +268,19 @@ export class StreamingRpcQuery extends SimpleRpcQuery { return this; } + + get result(): Promise { + return (this._promise as Promise) + .then( + (result): [sendUpdate: DataFn, response: Promise] => result[1] + ) + .then((response: any) => { + if (response[1]) { + return { error: response[1] }; + } + return response[0]; + }); + } } export class WisdomRpcQuery extends RpcQueryBase {