"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createRpcQueryExtension = exports.QueryClientImpl = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _stargate = require("@cosmjs/stargate");
var _query = require("./query");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
//@ts-nocheck
/** Query provides defines the gRPC querier service */
var QueryClientImpl = exports.QueryClientImpl = /*#__PURE__*/function () {
  function QueryClientImpl(rpc) {
    (0, _classCallCheck2["default"])(this, QueryClientImpl);
    (0, _defineProperty2["default"])(this, "rpc", void 0);
    this.rpc = rpc;
    this.clientState = this.clientState.bind(this);
    this.clientStates = this.clientStates.bind(this);
    this.consensusState = this.consensusState.bind(this);
    this.consensusStates = this.consensusStates.bind(this);
    this.consensusStateHeights = this.consensusStateHeights.bind(this);
    this.clientStatus = this.clientStatus.bind(this);
    this.clientParams = this.clientParams.bind(this);
    this.upgradedClientState = this.upgradedClientState.bind(this);
    this.upgradedConsensusState = this.upgradedConsensusState.bind(this);
    this.verifyMembership = this.verifyMembership.bind(this);
  }
  return (0, _createClass2["default"])(QueryClientImpl, [{
    key: "clientState",
    value: function clientState(request) {
      var data = _query.QueryClientStateRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ClientState", data);
      return promise.then(function (data) {
        return _query.QueryClientStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "clientStates",
    value: function clientStates() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
        pagination: undefined
      };
      var data = _query.QueryClientStatesRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ClientStates", data);
      return promise.then(function (data) {
        return _query.QueryClientStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "consensusState",
    value: function consensusState(request) {
      var data = _query.QueryConsensusStateRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusState", data);
      return promise.then(function (data) {
        return _query.QueryConsensusStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "consensusStates",
    value: function consensusStates(request) {
      var data = _query.QueryConsensusStatesRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusStates", data);
      return promise.then(function (data) {
        return _query.QueryConsensusStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "consensusStateHeights",
    value: function consensusStateHeights(request) {
      var data = _query.QueryConsensusStateHeightsRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ConsensusStateHeights", data);
      return promise.then(function (data) {
        return _query.QueryConsensusStateHeightsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "clientStatus",
    value: function clientStatus(request) {
      var data = _query.QueryClientStatusRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ClientStatus", data);
      return promise.then(function (data) {
        return _query.QueryClientStatusResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "clientParams",
    value: function clientParams() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryClientParamsRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "ClientParams", data);
      return promise.then(function (data) {
        return _query.QueryClientParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "upgradedClientState",
    value: function upgradedClientState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryUpgradedClientStateRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "UpgradedClientState", data);
      return promise.then(function (data) {
        return _query.QueryUpgradedClientStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "upgradedConsensusState",
    value: function upgradedConsensusState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryUpgradedConsensusStateRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "UpgradedConsensusState", data);
      return promise.then(function (data) {
        return _query.QueryUpgradedConsensusStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "verifyMembership",
    value: function verifyMembership(request) {
      var data = _query.QueryVerifyMembershipRequest.encode(request).finish();
      var promise = this.rpc.request("ibc.core.client.v1.Query", "VerifyMembership", data);
      return promise.then(function (data) {
        return _query.QueryVerifyMembershipResponse.decode(new _m0.Reader(data));
      });
    }
  }]);
}();
var createRpcQueryExtension = exports.createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new QueryClientImpl(rpc);
  return {
    clientState: function clientState(request) {
      return queryService.clientState(request);
    },
    clientStates: function clientStates(request) {
      return queryService.clientStates(request);
    },
    consensusState: function consensusState(request) {
      return queryService.consensusState(request);
    },
    consensusStates: function consensusStates(request) {
      return queryService.consensusStates(request);
    },
    consensusStateHeights: function consensusStateHeights(request) {
      return queryService.consensusStateHeights(request);
    },
    clientStatus: function clientStatus(request) {
      return queryService.clientStatus(request);
    },
    clientParams: function clientParams(request) {
      return queryService.clientParams(request);
    },
    upgradedClientState: function upgradedClientState(request) {
      return queryService.upgradedClientState(request);
    },
    upgradedConsensusState: function upgradedConsensusState(request) {
      return queryService.upgradedConsensusState(request);
    },
    verifyMembership: function verifyMembership(request) {
      return queryService.verifyMembership(request);
    }
  };
};