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 {