import { Rpc } from "../../../helpers"; import * as _m0 from "protobufjs/minimal"; import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; import { ParamsRequest, ParamsResponse, ArithmeticTwapRequest, ArithmeticTwapResponse, ArithmeticTwapToNowRequest, ArithmeticTwapToNowResponse } from "./query"; export interface Query { params(request?: ParamsRequest): Promise; arithmeticTwap(request: ArithmeticTwapRequest): Promise; arithmeticTwapToNow(request: ArithmeticTwapToNowRequest): Promise; } export class QueryClientImpl implements Query { private readonly rpc: Rpc; constructor(rpc: Rpc) { this.rpc = rpc; this.params = this.params.bind(this); this.arithmeticTwap = this.arithmeticTwap.bind(this); this.arithmeticTwapToNow = this.arithmeticTwapToNow.bind(this); } params(request: ParamsRequest = {}): Promise { const data = ParamsRequest.encode(request).finish(); const promise = this.rpc.request("osmosis.twap.v1beta1.Query", "Params", data); return promise.then(data => ParamsResponse.decode(new _m0.Reader(data))); } arithmeticTwap(request: ArithmeticTwapRequest): Promise { const data = ArithmeticTwapRequest.encode(request).finish(); const promise = this.rpc.request("osmosis.twap.v1beta1.Query", "ArithmeticTwap", data); return promise.then(data => ArithmeticTwapResponse.decode(new _m0.Reader(data))); } arithmeticTwapToNow(request: ArithmeticTwapToNowRequest): Promise { const data = ArithmeticTwapToNowRequest.encode(request).finish(); const promise = this.rpc.request("osmosis.twap.v1beta1.Query", "ArithmeticTwapToNow", data); return promise.then(data => ArithmeticTwapToNowResponse.decode(new _m0.Reader(data))); } } export const createRpcQueryExtension = (base: QueryClient) => { const rpc = createProtobufRpcClient(base); const queryService = new QueryClientImpl(rpc); return { params(request?: ParamsRequest): Promise { return queryService.params(request); }, arithmeticTwap(request: ArithmeticTwapRequest): Promise { return queryService.arithmeticTwap(request); }, arithmeticTwapToNow(request: ArithmeticTwapToNowRequest): Promise { return queryService.arithmeticTwapToNow(request); } }; };