"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.bandRelayers = this.bandRelayers.bind(this);
    this.bandPriceStates = this.bandPriceStates.bind(this);
    this.bandIBCPriceStates = this.bandIBCPriceStates.bind(this);
    this.priceFeedPriceStates = this.priceFeedPriceStates.bind(this);
    this.coinbasePriceStates = this.coinbasePriceStates.bind(this);
    this.providerPriceState = this.providerPriceState.bind(this);
    this.oracleModuleState = this.oracleModuleState.bind(this);
    this.historicalPriceRecords = this.historicalPriceRecords.bind(this);
    this.oracleVolatility = this.oracleVolatility.bind(this);
    this.oracleProvidersInfo = this.oracleProvidersInfo.bind(this);
    this.oracleProviderPrices = this.oracleProviderPrices.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.oracle.v1beta1.Query", "Params", data);
      return promise.then(function (data) {
        return _query.QueryParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "bandRelayers",
    value: function bandRelayers() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryBandRelayersRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "BandRelayers", data);
      return promise.then(function (data) {
        return _query.QueryBandRelayersResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "bandPriceStates",
    value: function bandPriceStates() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryBandPriceStatesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "BandPriceStates", data);
      return promise.then(function (data) {
        return _query.QueryBandPriceStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "bandIBCPriceStates",
    value: function bandIBCPriceStates() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryBandIBCPriceStatesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "BandIBCPriceStates", data);
      return promise.then(function (data) {
        return _query.QueryBandIBCPriceStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "priceFeedPriceStates",
    value: function priceFeedPriceStates() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryPriceFeedPriceStatesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "PriceFeedPriceStates", data);
      return promise.then(function (data) {
        return _query.QueryPriceFeedPriceStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "coinbasePriceStates",
    value: function coinbasePriceStates() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryCoinbasePriceStatesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "CoinbasePriceStates", data);
      return promise.then(function (data) {
        return _query.QueryCoinbasePriceStatesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "providerPriceState",
    value: function providerPriceState(request) {
      var data = _query.QueryProviderPriceStateRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "ProviderPriceState", data);
      return promise.then(function (data) {
        return _query.QueryProviderPriceStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "oracleModuleState",
    value: function oracleModuleState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryModuleStateRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "OracleModuleState", data);
      return promise.then(function (data) {
        return _query.QueryModuleStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "historicalPriceRecords",
    value: function historicalPriceRecords(request) {
      var data = _query.QueryHistoricalPriceRecordsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "HistoricalPriceRecords", data);
      return promise.then(function (data) {
        return _query.QueryHistoricalPriceRecordsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "oracleVolatility",
    value: function oracleVolatility(request) {
      var data = _query.QueryOracleVolatilityRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "OracleVolatility", data);
      return promise.then(function (data) {
        return _query.QueryOracleVolatilityResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "oracleProvidersInfo",
    value: function oracleProvidersInfo() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryOracleProvidersInfoRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "OracleProvidersInfo", data);
      return promise.then(function (data) {
        return _query.QueryOracleProvidersInfoResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "oracleProviderPrices",
    value: function oracleProviderPrices(request) {
      var data = _query.QueryOracleProviderPricesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.oracle.v1beta1.Query", "OracleProviderPrices", data);
      return promise.then(function (data) {
        return _query.QueryOracleProviderPricesResponse.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);
    },
    bandRelayers: function bandRelayers(request) {
      return queryService.bandRelayers(request);
    },
    bandPriceStates: function bandPriceStates(request) {
      return queryService.bandPriceStates(request);
    },
    bandIBCPriceStates: function bandIBCPriceStates(request) {
      return queryService.bandIBCPriceStates(request);
    },
    priceFeedPriceStates: function priceFeedPriceStates(request) {
      return queryService.priceFeedPriceStates(request);
    },
    coinbasePriceStates: function coinbasePriceStates(request) {
      return queryService.coinbasePriceStates(request);
    },
    providerPriceState: function providerPriceState(request) {
      return queryService.providerPriceState(request);
    },
    oracleModuleState: function oracleModuleState(request) {
      return queryService.oracleModuleState(request);
    },
    historicalPriceRecords: function historicalPriceRecords(request) {
      return queryService.historicalPriceRecords(request);
    },
    oracleVolatility: function oracleVolatility(request) {
      return queryService.oracleVolatility(request);
    },
    oracleProvidersInfo: function oracleProvidersInfo(request) {
      return queryService.oracleProvidersInfo(request);
    },
    oracleProviderPrices: function oracleProviderPrices(request) {
      return queryService.oracleProviderPrices(request);
    }
  };
};
exports.createRpcQueryExtension = createRpcQueryExtension;