"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 _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var 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.feedConfig = this.feedConfig.bind(this);
    this.feedConfigInfo = this.feedConfigInfo.bind(this);
    this.latestRound = this.latestRound.bind(this);
    this.latestTransmissionDetails = this.latestTransmissionDetails.bind(this);
    this.owedAmount = this.owedAmount.bind(this);
    this.ocrModuleState = this.ocrModuleState.bind(this);
  }
  (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("injective.ocr.v1beta1.Query", "Params", data);
      return promise.then(function (data) {
        return _query.QueryParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "feedConfig",
    value: function feedConfig(request) {
      var data = _query.QueryFeedConfigRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "FeedConfig", data);
      return promise.then(function (data) {
        return _query.QueryFeedConfigResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "feedConfigInfo",
    value: function feedConfigInfo(request) {
      var data = _query.QueryFeedConfigInfoRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "FeedConfigInfo", data);
      return promise.then(function (data) {
        return _query.QueryFeedConfigInfoResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "latestRound",
    value: function latestRound(request) {
      var data = _query.QueryLatestRoundRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "LatestRound", data);
      return promise.then(function (data) {
        return _query.QueryLatestRoundResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "latestTransmissionDetails",
    value: function latestTransmissionDetails(request) {
      var data = _query.QueryLatestTransmissionDetailsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "LatestTransmissionDetails", data);
      return promise.then(function (data) {
        return _query.QueryLatestTransmissionDetailsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "owedAmount",
    value: function owedAmount(request) {
      var data = _query.QueryOwedAmountRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "OwedAmount", data);
      return promise.then(function (data) {
        return _query.QueryOwedAmountResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "ocrModuleState",
    value: function ocrModuleState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryModuleStateRequest.encode(request).finish();
      var promise = this.rpc.request("injective.ocr.v1beta1.Query", "OcrModuleState", data);
      return promise.then(function (data) {
        return _query.QueryModuleStateResponse.decode(new _m0.Reader(data));
      });
    }
  }]);
  return QueryClientImpl;
}();
exports.QueryClientImpl = QueryClientImpl;
var createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new QueryClientImpl(rpc);
  return {
    params: function params(request) {
      return queryService.params(request);
    },
    feedConfig: function feedConfig(request) {
      return queryService.feedConfig(request);
    },
    feedConfigInfo: function feedConfigInfo(request) {
      return queryService.feedConfigInfo(request);
    },
    latestRound: function latestRound(request) {
      return queryService.latestRound(request);
    },
    latestTransmissionDetails: function latestTransmissionDetails(request) {
      return queryService.latestTransmissionDetails(request);
    },
    owedAmount: function owedAmount(request) {
      return queryService.owedAmount(request);
    },
    ocrModuleState: function ocrModuleState(request) {
      return queryService.ocrModuleState(request);
    }
  };
};
exports.createRpcQueryExtension = createRpcQueryExtension;