"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
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 _binary = require("../binary");
var _stargate = require("@cosmjs/stargate");
var _query = require("./query");
/** Query 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.params = this.params.bind(this);
    this.tasks = this.tasks.bind(this);
    this.reward = this.reward.bind(this);
    this.rewardsAll = this.rewardsAll.bind(this);
  }
  return (0, _createClass2["default"])(QueryClientImpl, [{
    key: "params",
    value: function params() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryParamsRequest.encode(request).finish();
      var promise = this.rpc.request("gitopia.gitopia.rewards.Query", "Params", data);
      return promise.then(function (data) {
        return _query.QueryParamsResponse.decode(new _binary.BinaryReader(data));
      });
    }
  }, {
    key: "tasks",
    value: function tasks(request) {
      var data = _query.QueryTasksRequest.encode(request).finish();
      var promise = this.rpc.request("gitopia.gitopia.rewards.Query", "Tasks", data);
      return promise.then(function (data) {
        return _query.QueryTasksResponse.decode(new _binary.BinaryReader(data));
      });
    }
  }, {
    key: "reward",
    value: function reward(request) {
      var data = _query.QueryGetRewardRequest.encode(request).finish();
      var promise = this.rpc.request("gitopia.gitopia.rewards.Query", "Reward", data);
      return promise.then(function (data) {
        return _query.QueryGetRewardResponse.decode(new _binary.BinaryReader(data));
      });
    }
  }, {
    key: "rewardsAll",
    value: function rewardsAll() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
        pagination: undefined
      };
      var data = _query.QueryAllRewardsRequest.encode(request).finish();
      var promise = this.rpc.request("gitopia.gitopia.rewards.Query", "RewardsAll", data);
      return promise.then(function (data) {
        return _query.QueryAllRewardsResponse.decode(new _binary.BinaryReader(data));
      });
    }
  }]);
}();
var createRpcQueryExtension = exports.createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new QueryClientImpl(rpc);
  return {
    params: function params(request) {
      return queryService.params(request);
    },
    tasks: function tasks(request) {
      return queryService.tasks(request);
    },
    reward: function reward(request) {
      return queryService.reward(request);
    },
    rewardsAll: function rewardsAll(request) {
      return queryService.rewardsAll(request);
    }
  };
};