"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.currentValset = this.currentValset.bind(this);
    this.valsetRequest = this.valsetRequest.bind(this);
    this.valsetConfirm = this.valsetConfirm.bind(this);
    this.valsetConfirmsByNonce = this.valsetConfirmsByNonce.bind(this);
    this.lastValsetRequests = this.lastValsetRequests.bind(this);
    this.lastPendingValsetRequestByAddr = this.lastPendingValsetRequestByAddr.bind(this);
    this.lastEventByAddr = this.lastEventByAddr.bind(this);
    this.getPendingSendToEth = this.getPendingSendToEth.bind(this);
    this.batchFees = this.batchFees.bind(this);
    this.outgoingTxBatches = this.outgoingTxBatches.bind(this);
    this.lastPendingBatchRequestByAddr = this.lastPendingBatchRequestByAddr.bind(this);
    this.batchRequestByNonce = this.batchRequestByNonce.bind(this);
    this.batchConfirms = this.batchConfirms.bind(this);
    this.eRC20ToDenom = this.eRC20ToDenom.bind(this);
    this.denomToERC20 = this.denomToERC20.bind(this);
    this.getDelegateKeyByValidator = this.getDelegateKeyByValidator.bind(this);
    this.getDelegateKeyByEth = this.getDelegateKeyByEth.bind(this);
    this.getDelegateKeyByOrchestrator = this.getDelegateKeyByOrchestrator.bind(this);
    this.peggyModuleState = this.peggyModuleState.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.peggy.v1.Query", "Params", data);
      return promise.then(function (data) {
        return _query.QueryParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "currentValset",
    value: function currentValset() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryCurrentValsetRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "CurrentValset", data);
      return promise.then(function (data) {
        return _query.QueryCurrentValsetResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "valsetRequest",
    value: function valsetRequest(request) {
      var data = _query.QueryValsetRequestRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "ValsetRequest", data);
      return promise.then(function (data) {
        return _query.QueryValsetRequestResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "valsetConfirm",
    value: function valsetConfirm(request) {
      var data = _query.QueryValsetConfirmRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "ValsetConfirm", data);
      return promise.then(function (data) {
        return _query.QueryValsetConfirmResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "valsetConfirmsByNonce",
    value: function valsetConfirmsByNonce(request) {
      var data = _query.QueryValsetConfirmsByNonceRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "ValsetConfirmsByNonce", data);
      return promise.then(function (data) {
        return _query.QueryValsetConfirmsByNonceResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "lastValsetRequests",
    value: function lastValsetRequests() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryLastValsetRequestsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "LastValsetRequests", data);
      return promise.then(function (data) {
        return _query.QueryLastValsetRequestsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "lastPendingValsetRequestByAddr",
    value: function lastPendingValsetRequestByAddr(request) {
      var data = _query.QueryLastPendingValsetRequestByAddrRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "LastPendingValsetRequestByAddr", data);
      return promise.then(function (data) {
        return _query.QueryLastPendingValsetRequestByAddrResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "lastEventByAddr",
    value: function lastEventByAddr(request) {
      var data = _query.QueryLastEventByAddrRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "LastEventByAddr", data);
      return promise.then(function (data) {
        return _query.QueryLastEventByAddrResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "getPendingSendToEth",
    value: function getPendingSendToEth(request) {
      var data = _query.QueryPendingSendToEth.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "GetPendingSendToEth", data);
      return promise.then(function (data) {
        return _query.QueryPendingSendToEthResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "batchFees",
    value: function batchFees() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryBatchFeeRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "BatchFees", data);
      return promise.then(function (data) {
        return _query.QueryBatchFeeResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "outgoingTxBatches",
    value: function outgoingTxBatches() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryOutgoingTxBatchesRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "OutgoingTxBatches", data);
      return promise.then(function (data) {
        return _query.QueryOutgoingTxBatchesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "lastPendingBatchRequestByAddr",
    value: function lastPendingBatchRequestByAddr(request) {
      var data = _query.QueryLastPendingBatchRequestByAddrRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "LastPendingBatchRequestByAddr", data);
      return promise.then(function (data) {
        return _query.QueryLastPendingBatchRequestByAddrResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "batchRequestByNonce",
    value: function batchRequestByNonce(request) {
      var data = _query.QueryBatchRequestByNonceRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "BatchRequestByNonce", data);
      return promise.then(function (data) {
        return _query.QueryBatchRequestByNonceResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "batchConfirms",
    value: function batchConfirms(request) {
      var data = _query.QueryBatchConfirmsRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "BatchConfirms", data);
      return promise.then(function (data) {
        return _query.QueryBatchConfirmsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "eRC20ToDenom",
    value: function eRC20ToDenom(request) {
      var data = _query.QueryERC20ToDenomRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "ERC20ToDenom", data);
      return promise.then(function (data) {
        return _query.QueryERC20ToDenomResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "denomToERC20",
    value: function denomToERC20(request) {
      var data = _query.QueryDenomToERC20Request.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "DenomToERC20", data);
      return promise.then(function (data) {
        return _query.QueryDenomToERC20Response.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "getDelegateKeyByValidator",
    value: function getDelegateKeyByValidator(request) {
      var data = _query.QueryDelegateKeysByValidatorAddress.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "GetDelegateKeyByValidator", data);
      return promise.then(function (data) {
        return _query.QueryDelegateKeysByValidatorAddressResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "getDelegateKeyByEth",
    value: function getDelegateKeyByEth(request) {
      var data = _query.QueryDelegateKeysByEthAddress.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "GetDelegateKeyByEth", data);
      return promise.then(function (data) {
        return _query.QueryDelegateKeysByEthAddressResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "getDelegateKeyByOrchestrator",
    value: function getDelegateKeyByOrchestrator(request) {
      var data = _query.QueryDelegateKeysByOrchestratorAddress.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "GetDelegateKeyByOrchestrator", data);
      return promise.then(function (data) {
        return _query.QueryDelegateKeysByOrchestratorAddressResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "peggyModuleState",
    value: function peggyModuleState() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var data = _query.QueryModuleStateRequest.encode(request).finish();
      var promise = this.rpc.request("injective.peggy.v1.Query", "PeggyModuleState", 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);
    },
    currentValset: function currentValset(request) {
      return queryService.currentValset(request);
    },
    valsetRequest: function valsetRequest(request) {
      return queryService.valsetRequest(request);
    },
    valsetConfirm: function valsetConfirm(request) {
      return queryService.valsetConfirm(request);
    },
    valsetConfirmsByNonce: function valsetConfirmsByNonce(request) {
      return queryService.valsetConfirmsByNonce(request);
    },
    lastValsetRequests: function lastValsetRequests(request) {
      return queryService.lastValsetRequests(request);
    },
    lastPendingValsetRequestByAddr: function lastPendingValsetRequestByAddr(request) {
      return queryService.lastPendingValsetRequestByAddr(request);
    },
    lastEventByAddr: function lastEventByAddr(request) {
      return queryService.lastEventByAddr(request);
    },
    getPendingSendToEth: function getPendingSendToEth(request) {
      return queryService.getPendingSendToEth(request);
    },
    batchFees: function batchFees(request) {
      return queryService.batchFees(request);
    },
    outgoingTxBatches: function outgoingTxBatches(request) {
      return queryService.outgoingTxBatches(request);
    },
    lastPendingBatchRequestByAddr: function lastPendingBatchRequestByAddr(request) {
      return queryService.lastPendingBatchRequestByAddr(request);
    },
    batchRequestByNonce: function batchRequestByNonce(request) {
      return queryService.batchRequestByNonce(request);
    },
    batchConfirms: function batchConfirms(request) {
      return queryService.batchConfirms(request);
    },
    eRC20ToDenom: function eRC20ToDenom(request) {
      return queryService.eRC20ToDenom(request);
    },
    denomToERC20: function denomToERC20(request) {
      return queryService.denomToERC20(request);
    },
    getDelegateKeyByValidator: function getDelegateKeyByValidator(request) {
      return queryService.getDelegateKeyByValidator(request);
    },
    getDelegateKeyByEth: function getDelegateKeyByEth(request) {
      return queryService.getDelegateKeyByEth(request);
    },
    getDelegateKeyByOrchestrator: function getDelegateKeyByOrchestrator(request) {
      return queryService.getDelegateKeyByOrchestrator(request);
    },
    peggyModuleState: function peggyModuleState(request) {
      return queryService.peggyModuleState(request);
    }
  };
};
exports.createRpcQueryExtension = createRpcQueryExtension;