"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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
//@ts-nocheck
/** Query provides 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.contractInfo = this.contractInfo.bind(this);
    this.contractHistory = this.contractHistory.bind(this);
    this.contractsByCode = this.contractsByCode.bind(this);
    this.allContractState = this.allContractState.bind(this);
    this.rawContractState = this.rawContractState.bind(this);
    this.smartContractState = this.smartContractState.bind(this);
    this.code = this.code.bind(this);
    this.codes = this.codes.bind(this);
    this.pinnedCodes = this.pinnedCodes.bind(this);
    this.params = this.params.bind(this);
    this.contractsByCreator = this.contractsByCreator.bind(this);
  }
  return (0, _createClass2["default"])(QueryClientImpl, [{
    key: "contractInfo",
    value: function contractInfo(request) {
      var data = _query.QueryContractInfoRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractInfo", data);
      return promise.then(function (data) {
        return _query.QueryContractInfoResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "contractHistory",
    value: function contractHistory(request) {
      var data = _query.QueryContractHistoryRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractHistory", data);
      return promise.then(function (data) {
        return _query.QueryContractHistoryResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "contractsByCode",
    value: function contractsByCode(request) {
      var data = _query.QueryContractsByCodeRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractsByCode", data);
      return promise.then(function (data) {
        return _query.QueryContractsByCodeResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "allContractState",
    value: function allContractState(request) {
      var data = _query.QueryAllContractStateRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "AllContractState", data);
      return promise.then(function (data) {
        return _query.QueryAllContractStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "rawContractState",
    value: function rawContractState(request) {
      var data = _query.QueryRawContractStateRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "RawContractState", data);
      return promise.then(function (data) {
        return _query.QueryRawContractStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "smartContractState",
    value: function smartContractState(request) {
      var data = _query.QuerySmartContractStateRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "SmartContractState", data);
      return promise.then(function (data) {
        return _query.QuerySmartContractStateResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "code",
    value: function code(request) {
      var data = _query.QueryCodeRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "Code", data);
      return promise.then(function (data) {
        return _query.QueryCodeResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "codes",
    value: function codes() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
        pagination: undefined
      };
      var data = _query.QueryCodesRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "Codes", data);
      return promise.then(function (data) {
        return _query.QueryCodesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "pinnedCodes",
    value: function pinnedCodes() {
      var request = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
        pagination: undefined
      };
      var data = _query.QueryPinnedCodesRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "PinnedCodes", data);
      return promise.then(function (data) {
        return _query.QueryPinnedCodesResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    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("cosmwasm.wasm.v1.Query", "Params", data);
      return promise.then(function (data) {
        return _query.QueryParamsResponse.decode(new _m0.Reader(data));
      });
    }
  }, {
    key: "contractsByCreator",
    value: function contractsByCreator(request) {
      var data = _query.QueryContractsByCreatorRequest.encode(request).finish();
      var promise = this.rpc.request("cosmwasm.wasm.v1.Query", "ContractsByCreator", data);
      return promise.then(function (data) {
        return _query.QueryContractsByCreatorResponse.decode(new _m0.Reader(data));
      });
    }
  }]);
}();
var createRpcQueryExtension = exports.createRpcQueryExtension = function createRpcQueryExtension(base) {
  var rpc = (0, _stargate.createProtobufRpcClient)(base);
  var queryService = new QueryClientImpl(rpc);
  return {
    contractInfo: function contractInfo(request) {
      return queryService.contractInfo(request);
    },
    contractHistory: function contractHistory(request) {
      return queryService.contractHistory(request);
    },
    contractsByCode: function contractsByCode(request) {
      return queryService.contractsByCode(request);
    },
    allContractState: function allContractState(request) {
      return queryService.allContractState(request);
    },
    rawContractState: function rawContractState(request) {
      return queryService.rawContractState(request);
    },
    smartContractState: function smartContractState(request) {
      return queryService.smartContractState(request);
    },
    code: function code(request) {
      return queryService.code(request);
    },
    codes: function codes(request) {
      return queryService.codes(request);
    },
    pinnedCodes: function pinnedCodes(request) {
      return queryService.pinnedCodes(request);
    },
    params: function params(request) {
      return queryService.params(request);
    },
    contractsByCreator: function contractsByCreator(request) {
      return queryService.contractsByCreator(request);
    }
  };
};