"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ListenFinalizeBlockResponse = exports.ListenFinalizeBlockRequest = exports.ListenCommitResponse = exports.ListenCommitRequest = void 0;
var _types = require("../../../../tendermint/abci/types");
var _listening = require("../../v1beta1/listening");
var _helpers = require("../../../../helpers");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
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); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
/** ListenEndBlockRequest is the request type for the ListenEndBlock RPC method */

/** ListenEndBlockRequest is the request type for the ListenEndBlock RPC method */

/** ListenEndBlockResponse is the response type for the ListenEndBlock RPC method */

/** ListenEndBlockResponse is the response type for the ListenEndBlock RPC method */

/** ListenCommitRequest is the request type for the ListenCommit RPC method */

/** ListenCommitRequest is the request type for the ListenCommit RPC method */

/** ListenCommitResponse is the response type for the ListenCommit RPC method */

/** ListenCommitResponse is the response type for the ListenCommit RPC method */

function createBaseListenFinalizeBlockRequest() {
  return {
    req: undefined,
    res: undefined
  };
}
var ListenFinalizeBlockRequest = exports.ListenFinalizeBlockRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.req !== undefined) {
      _types.RequestFinalizeBlock.encode(message.req, writer.uint32(10).fork()).ldelim();
    }
    if (message.res !== undefined) {
      _types.ResponseFinalizeBlock.encode(message.res, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListenFinalizeBlockRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.req = _types.RequestFinalizeBlock.decode(reader, reader.uint32());
          break;
        case 2:
          message.res = _types.ResponseFinalizeBlock.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      req: (0, _helpers.isSet)(object.req) ? _types.RequestFinalizeBlock.fromJSON(object.req) : undefined,
      res: (0, _helpers.isSet)(object.res) ? _types.ResponseFinalizeBlock.fromJSON(object.res) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.req !== undefined && (obj.req = message.req ? _types.RequestFinalizeBlock.toJSON(message.req) : undefined);
    message.res !== undefined && (obj.res = message.res ? _types.ResponseFinalizeBlock.toJSON(message.res) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseListenFinalizeBlockRequest();
    message.req = object.req !== undefined && object.req !== null ? _types.RequestFinalizeBlock.fromPartial(object.req) : undefined;
    message.res = object.res !== undefined && object.res !== null ? _types.ResponseFinalizeBlock.fromPartial(object.res) : undefined;
    return message;
  }
};
function createBaseListenFinalizeBlockResponse() {
  return {};
}
var ListenFinalizeBlockResponse = exports.ListenFinalizeBlockResponse = {
  encode: function encode(_) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListenFinalizeBlockResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(_) {
    return {};
  },
  toJSON: function toJSON(_) {
    var obj = {};
    return obj;
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseListenFinalizeBlockResponse();
    return message;
  }
};
function createBaseListenCommitRequest() {
  return {
    blockHeight: _helpers.Long.ZERO,
    res: undefined,
    changeSet: []
  };
}
var ListenCommitRequest = exports.ListenCommitRequest = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (!message.blockHeight.isZero()) {
      writer.uint32(8).int64(message.blockHeight);
    }
    if (message.res !== undefined) {
      _types.ResponseCommit.encode(message.res, writer.uint32(18).fork()).ldelim();
    }
    var _iterator = _createForOfIteratorHelper(message.changeSet),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _listening.StoreKVPair.encode(v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListenCommitRequest();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.blockHeight = reader.int64();
          break;
        case 2:
          message.res = _types.ResponseCommit.decode(reader, reader.uint32());
          break;
        case 3:
          message.changeSet.push(_listening.StoreKVPair.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      blockHeight: (0, _helpers.isSet)(object.blockHeight) ? _helpers.Long.fromValue(object.blockHeight) : _helpers.Long.ZERO,
      res: (0, _helpers.isSet)(object.res) ? _types.ResponseCommit.fromJSON(object.res) : undefined,
      changeSet: Array.isArray(object === null || object === void 0 ? void 0 : object.changeSet) ? object.changeSet.map(function (e) {
        return _listening.StoreKVPair.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.blockHeight !== undefined && (obj.blockHeight = (message.blockHeight || _helpers.Long.ZERO).toString());
    message.res !== undefined && (obj.res = message.res ? _types.ResponseCommit.toJSON(message.res) : undefined);
    if (message.changeSet) {
      obj.changeSet = message.changeSet.map(function (e) {
        return e ? _listening.StoreKVPair.toJSON(e) : undefined;
      });
    } else {
      obj.changeSet = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$changeSet;
    var message = createBaseListenCommitRequest();
    message.blockHeight = object.blockHeight !== undefined && object.blockHeight !== null ? _helpers.Long.fromValue(object.blockHeight) : _helpers.Long.ZERO;
    message.res = object.res !== undefined && object.res !== null ? _types.ResponseCommit.fromPartial(object.res) : undefined;
    message.changeSet = ((_object$changeSet = object.changeSet) === null || _object$changeSet === void 0 ? void 0 : _object$changeSet.map(function (e) {
      return _listening.StoreKVPair.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseListenCommitResponse() {
  return {};
}
var ListenCommitResponse = exports.ListenCommitResponse = {
  encode: function encode(_) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseListenCommitResponse();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(_) {
    return {};
  },
  toJSON: function toJSON(_) {
    var obj = {};
    return obj;
  },
  fromPartial: function fromPartial(_) {
    var message = createBaseListenCommitResponse();
    return message;
  }
};