// package: injective_meta_rpc
// file: injective_meta_rpc.proto

import * as injective_meta_rpc_pb from "./injective_meta_rpc_pb";
import {grpc} from "@improbable-eng/grpc-web";

type InjectiveMetaRPCPing = {
  readonly methodName: string;
  readonly service: typeof InjectiveMetaRPC;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof injective_meta_rpc_pb.PingRequest;
  readonly responseType: typeof injective_meta_rpc_pb.PingResponse;
};

type InjectiveMetaRPCVersion = {
  readonly methodName: string;
  readonly service: typeof InjectiveMetaRPC;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof injective_meta_rpc_pb.VersionRequest;
  readonly responseType: typeof injective_meta_rpc_pb.VersionResponse;
};

type InjectiveMetaRPCInfo = {
  readonly methodName: string;
  readonly service: typeof InjectiveMetaRPC;
  readonly requestStream: false;
  readonly responseStream: false;
  readonly requestType: typeof injective_meta_rpc_pb.InfoRequest;
  readonly responseType: typeof injective_meta_rpc_pb.InfoResponse;
};

type InjectiveMetaRPCStreamKeepalive = {
  readonly methodName: string;
  readonly service: typeof InjectiveMetaRPC;
  readonly requestStream: false;
  readonly responseStream: true;
  readonly requestType: typeof injective_meta_rpc_pb.StreamKeepaliveRequest;
  readonly responseType: typeof injective_meta_rpc_pb.StreamKeepaliveResponse;
};

export class InjectiveMetaRPC {
  static readonly serviceName: string;
  static readonly Ping: InjectiveMetaRPCPing;
  static readonly Version: InjectiveMetaRPCVersion;
  static readonly Info: InjectiveMetaRPCInfo;
  static readonly StreamKeepalive: InjectiveMetaRPCStreamKeepalive;
}

export type ServiceError = { message: string, code: number; metadata: grpc.Metadata }
export type Status = { details: string, code: number; metadata: grpc.Metadata }

interface UnaryResponse {
  cancel(): void;
}
interface ResponseStream<T> {
  cancel(): void;
  on(type: 'data', handler: (message: T) => void): ResponseStream<T>;
  on(type: 'end', handler: (status?: Status) => void): ResponseStream<T>;
  on(type: 'status', handler: (status: Status) => void): ResponseStream<T>;
}
interface RequestStream<T> {
  write(message: T): RequestStream<T>;
  end(): void;
  cancel(): void;
  on(type: 'end', handler: (status?: Status) => void): RequestStream<T>;
  on(type: 'status', handler: (status: Status) => void): RequestStream<T>;
}
interface BidirectionalStream<ReqT, ResT> {
  write(message: ReqT): BidirectionalStream<ReqT, ResT>;
  end(): void;
  cancel(): void;
  on(type: 'data', handler: (message: ResT) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'end', handler: (status?: Status) => void): BidirectionalStream<ReqT, ResT>;
  on(type: 'status', handler: (status: Status) => void): BidirectionalStream<ReqT, ResT>;
}

export class InjectiveMetaRPCClient {
  readonly serviceHost: string;

  constructor(serviceHost: string, options?: grpc.RpcOptions);
  ping(
    requestMessage: injective_meta_rpc_pb.PingRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.PingResponse|null) => void
  ): UnaryResponse;
  ping(
    requestMessage: injective_meta_rpc_pb.PingRequest,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.PingResponse|null) => void
  ): UnaryResponse;
  version(
    requestMessage: injective_meta_rpc_pb.VersionRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.VersionResponse|null) => void
  ): UnaryResponse;
  version(
    requestMessage: injective_meta_rpc_pb.VersionRequest,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.VersionResponse|null) => void
  ): UnaryResponse;
  info(
    requestMessage: injective_meta_rpc_pb.InfoRequest,
    metadata: grpc.Metadata,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.InfoResponse|null) => void
  ): UnaryResponse;
  info(
    requestMessage: injective_meta_rpc_pb.InfoRequest,
    callback: (error: ServiceError|null, responseMessage: injective_meta_rpc_pb.InfoResponse|null) => void
  ): UnaryResponse;
  streamKeepalive(requestMessage: injective_meta_rpc_pb.StreamKeepaliveRequest, metadata?: grpc.Metadata): ResponseStream<injective_meta_rpc_pb.StreamKeepaliveResponse>;
}

