// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.3.0
//   protoc               unknown
// source: feeabstraction/feeabs/v1beta1/query.proto

/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { Coin } from "../../../cosmos/base/v1beta1/coin.js";
import { HostChainFeeAbsConfig } from "./proposal.js";

/** QueryHostChainConfigRequest */
export interface QueryHostChainConfigRequest {
  ibcDenom: string;
}

/** QueryHostChainConfigResponse */
export interface QueryHostChainConfigResponse {
  hostChainConfig: HostChainFeeAbsConfig | undefined;
}

/**
 * QueryOsmosisArithmeticTwapRequest is the request type for the Query/Feeabs
 * RPC method.
 */
export interface QueryOsmosisArithmeticTwapRequest {
  ibcDenom: string;
}

/** QueryOsmosisArithmeticTwapResponse */
export interface QueryOsmosisArithmeticTwapResponse {
  arithmeticTwap: string;
}

/**
 * QueryFeeabsModuleBalacesRequest is the request type for the Query/Feeabs RPC
 * method.
 */
export interface QueryFeeabsModuleBalacesRequest {
}

/** QueryFeeabsModuleBalacesResponse */
export interface QueryFeeabsModuleBalacesResponse {
  balances: Coin[];
  address: string;
}

/** AllQueryHostChainConfigRequest */
export interface AllQueryHostChainConfigRequest {
}

/** AllQueryHostChainConfigResponse */
export interface AllQueryHostChainConfigResponse {
  allHostChainConfig: HostChainFeeAbsConfig[];
}

function createBaseQueryHostChainConfigRequest(): QueryHostChainConfigRequest {
  return { ibcDenom: "" };
}

export const QueryHostChainConfigRequest: MessageFns<QueryHostChainConfigRequest> = {
  encode(message: QueryHostChainConfigRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.ibcDenom !== "") {
      writer.uint32(10).string(message.ibcDenom);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryHostChainConfigRequest {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryHostChainConfigRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.ibcDenom = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): QueryHostChainConfigRequest {
    return { ibcDenom: isSet(object.ibcDenom) ? globalThis.String(object.ibcDenom) : "" };
  },

  toJSON(message: QueryHostChainConfigRequest): unknown {
    const obj: any = {};
    if (message.ibcDenom !== "") {
      obj.ibcDenom = message.ibcDenom;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryHostChainConfigRequest>, I>>(base?: I): QueryHostChainConfigRequest {
    return QueryHostChainConfigRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryHostChainConfigRequest>, I>>(object: I): QueryHostChainConfigRequest {
    const message = createBaseQueryHostChainConfigRequest();
    message.ibcDenom = object.ibcDenom ?? "";
    return message;
  },
};

function createBaseQueryHostChainConfigResponse(): QueryHostChainConfigResponse {
  return { hostChainConfig: undefined };
}

export const QueryHostChainConfigResponse: MessageFns<QueryHostChainConfigResponse> = {
  encode(message: QueryHostChainConfigResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.hostChainConfig !== undefined) {
      HostChainFeeAbsConfig.encode(message.hostChainConfig, writer.uint32(10).fork()).join();
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryHostChainConfigResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryHostChainConfigResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.hostChainConfig = HostChainFeeAbsConfig.decode(reader, reader.uint32());
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): QueryHostChainConfigResponse {
    return {
      hostChainConfig: isSet(object.hostChainConfig)
        ? HostChainFeeAbsConfig.fromJSON(object.hostChainConfig)
        : undefined,
    };
  },

  toJSON(message: QueryHostChainConfigResponse): unknown {
    const obj: any = {};
    if (message.hostChainConfig !== undefined) {
      obj.hostChainConfig = HostChainFeeAbsConfig.toJSON(message.hostChainConfig);
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryHostChainConfigResponse>, I>>(base?: I): QueryHostChainConfigResponse {
    return QueryHostChainConfigResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryHostChainConfigResponse>, I>>(object: I): QueryHostChainConfigResponse {
    const message = createBaseQueryHostChainConfigResponse();
    message.hostChainConfig = (object.hostChainConfig !== undefined && object.hostChainConfig !== null)
      ? HostChainFeeAbsConfig.fromPartial(object.hostChainConfig)
      : undefined;
    return message;
  },
};

function createBaseQueryOsmosisArithmeticTwapRequest(): QueryOsmosisArithmeticTwapRequest {
  return { ibcDenom: "" };
}

export const QueryOsmosisArithmeticTwapRequest: MessageFns<QueryOsmosisArithmeticTwapRequest> = {
  encode(message: QueryOsmosisArithmeticTwapRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.ibcDenom !== "") {
      writer.uint32(10).string(message.ibcDenom);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryOsmosisArithmeticTwapRequest {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryOsmosisArithmeticTwapRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.ibcDenom = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): QueryOsmosisArithmeticTwapRequest {
    return { ibcDenom: isSet(object.ibcDenom) ? globalThis.String(object.ibcDenom) : "" };
  },

  toJSON(message: QueryOsmosisArithmeticTwapRequest): unknown {
    const obj: any = {};
    if (message.ibcDenom !== "") {
      obj.ibcDenom = message.ibcDenom;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryOsmosisArithmeticTwapRequest>, I>>(
    base?: I,
  ): QueryOsmosisArithmeticTwapRequest {
    return QueryOsmosisArithmeticTwapRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryOsmosisArithmeticTwapRequest>, I>>(
    object: I,
  ): QueryOsmosisArithmeticTwapRequest {
    const message = createBaseQueryOsmosisArithmeticTwapRequest();
    message.ibcDenom = object.ibcDenom ?? "";
    return message;
  },
};

function createBaseQueryOsmosisArithmeticTwapResponse(): QueryOsmosisArithmeticTwapResponse {
  return { arithmeticTwap: "" };
}

export const QueryOsmosisArithmeticTwapResponse: MessageFns<QueryOsmosisArithmeticTwapResponse> = {
  encode(message: QueryOsmosisArithmeticTwapResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    if (message.arithmeticTwap !== "") {
      writer.uint32(10).string(message.arithmeticTwap);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryOsmosisArithmeticTwapResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryOsmosisArithmeticTwapResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.arithmeticTwap = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): QueryOsmosisArithmeticTwapResponse {
    return { arithmeticTwap: isSet(object.arithmeticTwap) ? globalThis.String(object.arithmeticTwap) : "" };
  },

  toJSON(message: QueryOsmosisArithmeticTwapResponse): unknown {
    const obj: any = {};
    if (message.arithmeticTwap !== "") {
      obj.arithmeticTwap = message.arithmeticTwap;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryOsmosisArithmeticTwapResponse>, I>>(
    base?: I,
  ): QueryOsmosisArithmeticTwapResponse {
    return QueryOsmosisArithmeticTwapResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryOsmosisArithmeticTwapResponse>, I>>(
    object: I,
  ): QueryOsmosisArithmeticTwapResponse {
    const message = createBaseQueryOsmosisArithmeticTwapResponse();
    message.arithmeticTwap = object.arithmeticTwap ?? "";
    return message;
  },
};

function createBaseQueryFeeabsModuleBalacesRequest(): QueryFeeabsModuleBalacesRequest {
  return {};
}

export const QueryFeeabsModuleBalacesRequest: MessageFns<QueryFeeabsModuleBalacesRequest> = {
  encode(_: QueryFeeabsModuleBalacesRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryFeeabsModuleBalacesRequest {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryFeeabsModuleBalacesRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(_: any): QueryFeeabsModuleBalacesRequest {
    return {};
  },

  toJSON(_: QueryFeeabsModuleBalacesRequest): unknown {
    const obj: any = {};
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryFeeabsModuleBalacesRequest>, I>>(base?: I): QueryFeeabsModuleBalacesRequest {
    return QueryFeeabsModuleBalacesRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryFeeabsModuleBalacesRequest>, I>>(_: I): QueryFeeabsModuleBalacesRequest {
    const message = createBaseQueryFeeabsModuleBalacesRequest();
    return message;
  },
};

function createBaseQueryFeeabsModuleBalacesResponse(): QueryFeeabsModuleBalacesResponse {
  return { balances: [], address: "" };
}

export const QueryFeeabsModuleBalacesResponse: MessageFns<QueryFeeabsModuleBalacesResponse> = {
  encode(message: QueryFeeabsModuleBalacesResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    for (const v of message.balances) {
      Coin.encode(v!, writer.uint32(10).fork()).join();
    }
    if (message.address !== "") {
      writer.uint32(18).string(message.address);
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): QueryFeeabsModuleBalacesResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseQueryFeeabsModuleBalacesResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.balances.push(Coin.decode(reader, reader.uint32()));
          continue;
        }
        case 2: {
          if (tag !== 18) {
            break;
          }

          message.address = reader.string();
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): QueryFeeabsModuleBalacesResponse {
    return {
      balances: globalThis.Array.isArray(object?.balances) ? object.balances.map((e: any) => Coin.fromJSON(e)) : [],
      address: isSet(object.address) ? globalThis.String(object.address) : "",
    };
  },

  toJSON(message: QueryFeeabsModuleBalacesResponse): unknown {
    const obj: any = {};
    if (message.balances?.length) {
      obj.balances = message.balances.map((e) => Coin.toJSON(e));
    }
    if (message.address !== "") {
      obj.address = message.address;
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<QueryFeeabsModuleBalacesResponse>, I>>(
    base?: I,
  ): QueryFeeabsModuleBalacesResponse {
    return QueryFeeabsModuleBalacesResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<QueryFeeabsModuleBalacesResponse>, I>>(
    object: I,
  ): QueryFeeabsModuleBalacesResponse {
    const message = createBaseQueryFeeabsModuleBalacesResponse();
    message.balances = object.balances?.map((e) => Coin.fromPartial(e)) || [];
    message.address = object.address ?? "";
    return message;
  },
};

function createBaseAllQueryHostChainConfigRequest(): AllQueryHostChainConfigRequest {
  return {};
}

export const AllQueryHostChainConfigRequest: MessageFns<AllQueryHostChainConfigRequest> = {
  encode(_: AllQueryHostChainConfigRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): AllQueryHostChainConfigRequest {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseAllQueryHostChainConfigRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(_: any): AllQueryHostChainConfigRequest {
    return {};
  },

  toJSON(_: AllQueryHostChainConfigRequest): unknown {
    const obj: any = {};
    return obj;
  },

  create<I extends Exact<DeepPartial<AllQueryHostChainConfigRequest>, I>>(base?: I): AllQueryHostChainConfigRequest {
    return AllQueryHostChainConfigRequest.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<AllQueryHostChainConfigRequest>, I>>(_: I): AllQueryHostChainConfigRequest {
    const message = createBaseAllQueryHostChainConfigRequest();
    return message;
  },
};

function createBaseAllQueryHostChainConfigResponse(): AllQueryHostChainConfigResponse {
  return { allHostChainConfig: [] };
}

export const AllQueryHostChainConfigResponse: MessageFns<AllQueryHostChainConfigResponse> = {
  encode(message: AllQueryHostChainConfigResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
    for (const v of message.allHostChainConfig) {
      HostChainFeeAbsConfig.encode(v!, writer.uint32(10).fork()).join();
    }
    return writer;
  },

  decode(input: BinaryReader | Uint8Array, length?: number): AllQueryHostChainConfigResponse {
    const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseAllQueryHostChainConfigResponse();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1: {
          if (tag !== 10) {
            break;
          }

          message.allHostChainConfig.push(HostChainFeeAbsConfig.decode(reader, reader.uint32()));
          continue;
        }
      }
      if ((tag & 7) === 4 || tag === 0) {
        break;
      }
      reader.skip(tag & 7);
    }
    return message;
  },

  fromJSON(object: any): AllQueryHostChainConfigResponse {
    return {
      allHostChainConfig: globalThis.Array.isArray(object?.allHostChainConfig)
        ? object.allHostChainConfig.map((e: any) => HostChainFeeAbsConfig.fromJSON(e))
        : [],
    };
  },

  toJSON(message: AllQueryHostChainConfigResponse): unknown {
    const obj: any = {};
    if (message.allHostChainConfig?.length) {
      obj.allHostChainConfig = message.allHostChainConfig.map((e) => HostChainFeeAbsConfig.toJSON(e));
    }
    return obj;
  },

  create<I extends Exact<DeepPartial<AllQueryHostChainConfigResponse>, I>>(base?: I): AllQueryHostChainConfigResponse {
    return AllQueryHostChainConfigResponse.fromPartial(base ?? ({} as any));
  },
  fromPartial<I extends Exact<DeepPartial<AllQueryHostChainConfigResponse>, I>>(
    object: I,
  ): AllQueryHostChainConfigResponse {
    const message = createBaseAllQueryHostChainConfigResponse();
    message.allHostChainConfig = object.allHostChainConfig?.map((e) => HostChainFeeAbsConfig.fromPartial(e)) || [];
    return message;
  },
};

/** Query defines the gRPC querier service. */
export interface Query {
  /** OsmosisArithmeticTwap return spot price of pair Osmo/nativeToken */
  OsmosisArithmeticTwap(request: QueryOsmosisArithmeticTwapRequest): Promise<QueryOsmosisArithmeticTwapResponse>;
  /** FeeabsModuleBalances return total balances of feeabs module */
  FeeabsModuleBalances(request: QueryFeeabsModuleBalacesRequest): Promise<QueryFeeabsModuleBalacesResponse>;
  /** HostChainConfig */
  HostChainConfig(request: QueryHostChainConfigRequest): Promise<QueryHostChainConfigResponse>;
  /** AllHostChainConfig */
  AllHostChainConfig(request: AllQueryHostChainConfigRequest): Promise<AllQueryHostChainConfigResponse>;
}

export const QueryServiceName = "feeabstraction.feeabs.v1beta1.Query";
export class QueryClientImpl implements Query {
  private readonly rpc: Rpc;
  private readonly service: string;
  constructor(rpc: Rpc, opts?: { service?: string }) {
    this.service = opts?.service || QueryServiceName;
    this.rpc = rpc;
    this.OsmosisArithmeticTwap = this.OsmosisArithmeticTwap.bind(this);
    this.FeeabsModuleBalances = this.FeeabsModuleBalances.bind(this);
    this.HostChainConfig = this.HostChainConfig.bind(this);
    this.AllHostChainConfig = this.AllHostChainConfig.bind(this);
  }
  OsmosisArithmeticTwap(request: QueryOsmosisArithmeticTwapRequest): Promise<QueryOsmosisArithmeticTwapResponse> {
    const data = QueryOsmosisArithmeticTwapRequest.encode(request).finish();
    const promise = this.rpc.request(this.service, "OsmosisArithmeticTwap", data);
    return promise.then((data) => QueryOsmosisArithmeticTwapResponse.decode(new BinaryReader(data)));
  }

  FeeabsModuleBalances(request: QueryFeeabsModuleBalacesRequest): Promise<QueryFeeabsModuleBalacesResponse> {
    const data = QueryFeeabsModuleBalacesRequest.encode(request).finish();
    const promise = this.rpc.request(this.service, "FeeabsModuleBalances", data);
    return promise.then((data) => QueryFeeabsModuleBalacesResponse.decode(new BinaryReader(data)));
  }

  HostChainConfig(request: QueryHostChainConfigRequest): Promise<QueryHostChainConfigResponse> {
    const data = QueryHostChainConfigRequest.encode(request).finish();
    const promise = this.rpc.request(this.service, "HostChainConfig", data);
    return promise.then((data) => QueryHostChainConfigResponse.decode(new BinaryReader(data)));
  }

  AllHostChainConfig(request: AllQueryHostChainConfigRequest): Promise<AllQueryHostChainConfigResponse> {
    const data = AllQueryHostChainConfigRequest.encode(request).finish();
    const promise = this.rpc.request(this.service, "AllHostChainConfig", data);
    return promise.then((data) => AllQueryHostChainConfigResponse.decode(new BinaryReader(data)));
  }
}

interface Rpc {
  request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
}

type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;

type DeepPartial<T> = T extends Builtin ? T
  : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
  : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
  : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
  : Partial<T>;

type KeysOfUnion<T> = T extends T ? keyof T : never;
type Exact<P, I extends P> = P extends Builtin ? P
  : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };

function isSet(value: any): boolean {
  return value !== null && value !== undefined;
}

interface MessageFns<T> {
  encode(message: T, writer?: BinaryWriter): BinaryWriter;
  decode(input: BinaryReader | Uint8Array, length?: number): T;
  fromJSON(object: any): T;
  toJSON(message: T): unknown;
  create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
  fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
}
