"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LCDQueryClient = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
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 LCDQueryClient = /*#__PURE__*/function () {
  function LCDQueryClient(_ref) {
    var requestClient = _ref.requestClient;
    (0, _classCallCheck2["default"])(this, LCDQueryClient);
    (0, _defineProperty2["default"])(this, "req", void 0);
    this.req = requestClient;
    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);
  }
  /* Deployments queries deployments */
  (0, _createClass2["default"])(LCDQueryClient, [{
    key: "params",
    value: function () {
      var _params2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
        var _params,
          endpoint,
          _args = arguments;
        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              _params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
              endpoint = "peggy/v1/params";
              _context.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context.abrupt("return", _context.sent);
            case 5:
            case "end":
              return _context.stop();
          }
        }, _callee, this);
      }));
      function params() {
        return _params2.apply(this, arguments);
      }
      return params;
    }() /* valset */
  }, {
    key: "currentValset",
    value: function () {
      var _currentValset = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
        var _params,
          endpoint,
          _args2 = arguments;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) switch (_context2.prev = _context2.next) {
            case 0:
              _params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
              endpoint = "peggy/v1/valset/current";
              _context2.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context2.abrupt("return", _context2.sent);
            case 5:
            case "end":
              return _context2.stop();
          }
        }, _callee2, this);
      }));
      function currentValset() {
        return _currentValset.apply(this, arguments);
      }
      return currentValset;
    }() /* ValsetRequest */
  }, {
    key: "valsetRequest",
    value: function () {
      var _valsetRequest = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) switch (_context3.prev = _context3.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.nonce) !== "undefined") {
                options.params.nonce = params.nonce;
              }
              endpoint = "peggy/v1/valset";
              _context3.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context3.abrupt("return", _context3.sent);
            case 6:
            case "end":
              return _context3.stop();
          }
        }, _callee3, this);
      }));
      function valsetRequest(_x) {
        return _valsetRequest.apply(this, arguments);
      }
      return valsetRequest;
    }() /* ValsetConfirm */
  }, {
    key: "valsetConfirm",
    value: function () {
      var _valsetConfirm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) switch (_context4.prev = _context4.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.nonce) !== "undefined") {
                options.params.nonce = params.nonce;
              }
              if (typeof (params === null || params === void 0 ? void 0 : params.address) !== "undefined") {
                options.params.address = params.address;
              }
              endpoint = "peggy/v1/valset/confirm";
              _context4.next = 6;
              return this.req.get(endpoint, options);
            case 6:
              return _context4.abrupt("return", _context4.sent);
            case 7:
            case "end":
              return _context4.stop();
          }
        }, _callee4, this);
      }));
      function valsetConfirm(_x2) {
        return _valsetConfirm.apply(this, arguments);
      }
      return valsetConfirm;
    }() /* ValsetConfirmsByNonce */
  }, {
    key: "valsetConfirmsByNonce",
    value: function () {
      var _valsetConfirmsByNonce = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(params) {
        var endpoint;
        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) switch (_context5.prev = _context5.next) {
            case 0:
              endpoint = "peggy/v1/confirms/".concat(params.nonce);
              _context5.next = 3;
              return this.req.get(endpoint);
            case 3:
              return _context5.abrupt("return", _context5.sent);
            case 4:
            case "end":
              return _context5.stop();
          }
        }, _callee5, this);
      }));
      function valsetConfirmsByNonce(_x3) {
        return _valsetConfirmsByNonce.apply(this, arguments);
      }
      return valsetConfirmsByNonce;
    }() /* LastValsetRequests */
  }, {
    key: "lastValsetRequests",
    value: function () {
      var _lastValsetRequests = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
        var _params,
          endpoint,
          _args6 = arguments;
        return _regenerator["default"].wrap(function _callee6$(_context6) {
          while (1) switch (_context6.prev = _context6.next) {
            case 0:
              _params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
              endpoint = "peggy/v1/valset/requests";
              _context6.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context6.abrupt("return", _context6.sent);
            case 5:
            case "end":
              return _context6.stop();
          }
        }, _callee6, this);
      }));
      function lastValsetRequests() {
        return _lastValsetRequests.apply(this, arguments);
      }
      return lastValsetRequests;
    }() /* LastPendingValsetRequestByAddr */
  }, {
    key: "lastPendingValsetRequestByAddr",
    value: function () {
      var _lastPendingValsetRequestByAddr = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee7$(_context7) {
          while (1) switch (_context7.prev = _context7.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.address) !== "undefined") {
                options.params.address = params.address;
              }
              endpoint = "peggy/v1/valset/last";
              _context7.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context7.abrupt("return", _context7.sent);
            case 6:
            case "end":
              return _context7.stop();
          }
        }, _callee7, this);
      }));
      function lastPendingValsetRequestByAddr(_x4) {
        return _lastPendingValsetRequestByAddr.apply(this, arguments);
      }
      return lastPendingValsetRequestByAddr;
    }() /* claim */
  }, {
    key: "lastEventByAddr",
    value: function () {
      var _lastEventByAddr = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(params) {
        var endpoint;
        return _regenerator["default"].wrap(function _callee8$(_context8) {
          while (1) switch (_context8.prev = _context8.next) {
            case 0:
              endpoint = "peggy/v1/oracle/event/".concat(params.address);
              _context8.next = 3;
              return this.req.get(endpoint);
            case 3:
              return _context8.abrupt("return", _context8.sent);
            case 4:
            case "end":
              return _context8.stop();
          }
        }, _callee8, this);
      }));
      function lastEventByAddr(_x5) {
        return _lastEventByAddr.apply(this, arguments);
      }
      return lastEventByAddr;
    }() /* batch */
  }, {
    key: "getPendingSendToEth",
    value: function () {
      var _getPendingSendToEth = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee9$(_context9) {
          while (1) switch (_context9.prev = _context9.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.senderAddress) !== "undefined") {
                options.params.sender_address = params.senderAddress;
              }
              endpoint = "peggy/v1/pending_send_to_eth";
              _context9.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context9.abrupt("return", _context9.sent);
            case 6:
            case "end":
              return _context9.stop();
          }
        }, _callee9, this);
      }));
      function getPendingSendToEth(_x6) {
        return _getPendingSendToEth.apply(this, arguments);
      }
      return getPendingSendToEth;
    }() /* BatchFees */
  }, {
    key: "batchFees",
    value: function () {
      var _batchFees = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
        var _params,
          endpoint,
          _args10 = arguments;
        return _regenerator["default"].wrap(function _callee10$(_context10) {
          while (1) switch (_context10.prev = _context10.next) {
            case 0:
              _params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
              endpoint = "peggy/v1/batchfees";
              _context10.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context10.abrupt("return", _context10.sent);
            case 5:
            case "end":
              return _context10.stop();
          }
        }, _callee10, this);
      }));
      function batchFees() {
        return _batchFees.apply(this, arguments);
      }
      return batchFees;
    }() /* OutgoingTxBatches */
  }, {
    key: "outgoingTxBatches",
    value: function () {
      var _outgoingTxBatches = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
        var _params,
          endpoint,
          _args11 = arguments;
        return _regenerator["default"].wrap(function _callee11$(_context11) {
          while (1) switch (_context11.prev = _context11.next) {
            case 0:
              _params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
              endpoint = "peggy/v1/batch/outgoingtx";
              _context11.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context11.abrupt("return", _context11.sent);
            case 5:
            case "end":
              return _context11.stop();
          }
        }, _callee11, this);
      }));
      function outgoingTxBatches() {
        return _outgoingTxBatches.apply(this, arguments);
      }
      return outgoingTxBatches;
    }() /* LastPendingBatchRequestByAddr */
  }, {
    key: "lastPendingBatchRequestByAddr",
    value: function () {
      var _lastPendingBatchRequestByAddr = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee12$(_context12) {
          while (1) switch (_context12.prev = _context12.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.address) !== "undefined") {
                options.params.address = params.address;
              }
              endpoint = "peggy/v1/batch/last";
              _context12.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context12.abrupt("return", _context12.sent);
            case 6:
            case "end":
              return _context12.stop();
          }
        }, _callee12, this);
      }));
      function lastPendingBatchRequestByAddr(_x7) {
        return _lastPendingBatchRequestByAddr.apply(this, arguments);
      }
      return lastPendingBatchRequestByAddr;
    }() /* BatchRequestByNonce */
  }, {
    key: "batchRequestByNonce",
    value: function () {
      var _batchRequestByNonce = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee13$(_context13) {
          while (1) switch (_context13.prev = _context13.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.nonce) !== "undefined") {
                options.params.nonce = params.nonce;
              }
              if (typeof (params === null || params === void 0 ? void 0 : params.contractAddress) !== "undefined") {
                options.params.contract_address = params.contractAddress;
              }
              endpoint = "peggy/v1/batch";
              _context13.next = 6;
              return this.req.get(endpoint, options);
            case 6:
              return _context13.abrupt("return", _context13.sent);
            case 7:
            case "end":
              return _context13.stop();
          }
        }, _callee13, this);
      }));
      function batchRequestByNonce(_x8) {
        return _batchRequestByNonce.apply(this, arguments);
      }
      return batchRequestByNonce;
    }() /* BatchConfirms */
  }, {
    key: "batchConfirms",
    value: function () {
      var _batchConfirms = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee14$(_context14) {
          while (1) switch (_context14.prev = _context14.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.nonce) !== "undefined") {
                options.params.nonce = params.nonce;
              }
              if (typeof (params === null || params === void 0 ? void 0 : params.contractAddress) !== "undefined") {
                options.params.contract_address = params.contractAddress;
              }
              endpoint = "peggy/v1/batch/confirms";
              _context14.next = 6;
              return this.req.get(endpoint, options);
            case 6:
              return _context14.abrupt("return", _context14.sent);
            case 7:
            case "end":
              return _context14.stop();
          }
        }, _callee14, this);
      }));
      function batchConfirms(_x9) {
        return _batchConfirms.apply(this, arguments);
      }
      return batchConfirms;
    }() /* ERC20ToDenom */
  }, {
    key: "eRC20ToDenom",
    value: function () {
      var _eRC20ToDenom = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee15$(_context15) {
          while (1) switch (_context15.prev = _context15.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.erc20) !== "undefined") {
                options.params.erc20 = params.erc20;
              }
              endpoint = "peggy/v1/cosmos_originated/erc20_to_denom";
              _context15.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context15.abrupt("return", _context15.sent);
            case 6:
            case "end":
              return _context15.stop();
          }
        }, _callee15, this);
      }));
      function eRC20ToDenom(_x10) {
        return _eRC20ToDenom.apply(this, arguments);
      }
      return eRC20ToDenom;
    }() /* DenomToERC20 */
  }, {
    key: "denomToERC20",
    value: function () {
      var _denomToERC = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee16$(_context16) {
          while (1) switch (_context16.prev = _context16.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.denom) !== "undefined") {
                options.params.denom = params.denom;
              }
              endpoint = "peggy/v1/cosmos_originated/denom_to_erc20";
              _context16.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context16.abrupt("return", _context16.sent);
            case 6:
            case "end":
              return _context16.stop();
          }
        }, _callee16, this);
      }));
      function denomToERC20(_x11) {
        return _denomToERC.apply(this, arguments);
      }
      return denomToERC20;
    }() /* GetDelegateKeyByValidator */
  }, {
    key: "getDelegateKeyByValidator",
    value: function () {
      var _getDelegateKeyByValidator = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee17$(_context17) {
          while (1) switch (_context17.prev = _context17.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.validatorAddress) !== "undefined") {
                options.params.validator_address = params.validatorAddress;
              }
              endpoint = "peggy/v1/query_delegate_keys_by_validator";
              _context17.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context17.abrupt("return", _context17.sent);
            case 6:
            case "end":
              return _context17.stop();
          }
        }, _callee17, this);
      }));
      function getDelegateKeyByValidator(_x12) {
        return _getDelegateKeyByValidator.apply(this, arguments);
      }
      return getDelegateKeyByValidator;
    }() /* GetDelegateKeyByEth */
  }, {
    key: "getDelegateKeyByEth",
    value: function () {
      var _getDelegateKeyByEth = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee18$(_context18) {
          while (1) switch (_context18.prev = _context18.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.ethAddress) !== "undefined") {
                options.params.eth_address = params.ethAddress;
              }
              endpoint = "peggy/v1/query_delegate_keys_by_eth";
              _context18.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context18.abrupt("return", _context18.sent);
            case 6:
            case "end":
              return _context18.stop();
          }
        }, _callee18, this);
      }));
      function getDelegateKeyByEth(_x13) {
        return _getDelegateKeyByEth.apply(this, arguments);
      }
      return getDelegateKeyByEth;
    }() /* GetDelegateKeyByOrchestrator */
  }, {
    key: "getDelegateKeyByOrchestrator",
    value: function () {
      var _getDelegateKeyByOrchestrator = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(params) {
        var options, endpoint;
        return _regenerator["default"].wrap(function _callee19$(_context19) {
          while (1) switch (_context19.prev = _context19.next) {
            case 0:
              options = {
                params: {}
              };
              if (typeof (params === null || params === void 0 ? void 0 : params.orchestratorAddress) !== "undefined") {
                options.params.orchestrator_address = params.orchestratorAddress;
              }
              endpoint = "peggy/v1/query_delegate_keys_by_orchestrator";
              _context19.next = 5;
              return this.req.get(endpoint, options);
            case 5:
              return _context19.abrupt("return", _context19.sent);
            case 6:
            case "end":
              return _context19.stop();
          }
        }, _callee19, this);
      }));
      function getDelegateKeyByOrchestrator(_x14) {
        return _getDelegateKeyByOrchestrator.apply(this, arguments);
      }
      return getDelegateKeyByOrchestrator;
    }() /* Retrieves the entire peggy module's state */
  }, {
    key: "peggyModuleState",
    value: function () {
      var _peggyModuleState = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
        var _params,
          endpoint,
          _args20 = arguments;
        return _regenerator["default"].wrap(function _callee20$(_context20) {
          while (1) switch (_context20.prev = _context20.next) {
            case 0:
              _params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
              endpoint = "peggy/v1/module_state";
              _context20.next = 4;
              return this.req.get(endpoint);
            case 4:
              return _context20.abrupt("return", _context20.sent);
            case 5:
            case "end":
              return _context20.stop();
          }
        }, _callee20, this);
      }));
      function peggyModuleState() {
        return _peggyModuleState.apply(this, arguments);
      }
      return peggyModuleState;
    }()
  }]);
  return LCDQueryClient;
}();
exports.LCDQueryClient = LCDQueryClient;