"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MsgSignData = exports.ListOfMsgSignData = void 0;
var _binary = require("../binary");
var _helpers = require("../helpers");
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
/** MsgSignData defines an arbitrary, general-purpose, off-chain message */

/** MsgSignData defines an arbitrary, general-purpose, off-chain message */

/** MsgSignData defines an arbitrary, general-purpose, off-chain message */

/** ListOfMsgSignData defines a list of MsgSignData, used to marshal and unmarshal them in a clean way */

/** ListOfMsgSignData defines a list of MsgSignData, used to marshal and unmarshal them in a clean way */

/** ListOfMsgSignData defines a list of MsgSignData, used to marshal and unmarshal them in a clean way */

function createBaseMsgSignData() {
  return {
    signer: "",
    data: new Uint8Array()
  };
}
var MsgSignData = exports.MsgSignData = {
  typeUrl: "/gitopia.gitopia.offchain.MsgSignData",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.signer !== "") {
      writer.uint32(10).string(message.signer);
    }
    if (message.data.length !== 0) {
      writer.uint32(18).bytes(message.data);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      signer: (0, _helpers.isSet)(object.signer) ? String(object.signer) : "",
      data: (0, _helpers.isSet)(object.data) ? (0, _helpers.bytesFromBase64)(object.data) : new Uint8Array()
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$signer, _object$data;
    var message = createBaseMsgSignData();
    message.signer = (_object$signer = object.signer) !== null && _object$signer !== void 0 ? _object$signer : "";
    message.data = (_object$data = object.data) !== null && _object$data !== void 0 ? _object$data : new Uint8Array();
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseMsgSignData();
    if (object.signer !== undefined && object.signer !== null) {
      message.signer = object.signer;
    }
    if (object.data !== undefined && object.data !== null) {
      message.data = (0, _helpers.bytesFromBase64)(object.data);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.signer = message.signer === "" ? undefined : message.signer;
    obj.data = message.data ? (0, _helpers.base64FromBytes)(message.data) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return MsgSignData.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return MsgSignData.decode(message.value);
  },
  toProto: function toProto(message) {
    return MsgSignData.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.offchain.MsgSignData",
      value: MsgSignData.encode(message).finish()
    };
  }
};
function createBaseListOfMsgSignData() {
  return {
    msgs: []
  };
}
var ListOfMsgSignData = exports.ListOfMsgSignData = {
  typeUrl: "/gitopia.gitopia.offchain.ListOfMsgSignData",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    var _iterator = _createForOfIteratorHelper(message.msgs),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        MsgSignData.encode(v, writer.uint32(10).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      msgs: Array.isArray(object === null || object === void 0 ? void 0 : object.msgs) ? object.msgs.map(function (e) {
        return MsgSignData.fromJSON(e);
      }) : []
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$msgs;
    var message = createBaseListOfMsgSignData();
    message.msgs = ((_object$msgs = object.msgs) === null || _object$msgs === void 0 ? void 0 : _object$msgs.map(function (e) {
      return MsgSignData.fromPartial(e);
    })) || [];
    return message;
  },
  fromAmino: function fromAmino(object) {
    var _object$msgs2;
    var message = createBaseListOfMsgSignData();
    message.msgs = ((_object$msgs2 = object.msgs) === null || _object$msgs2 === void 0 ? void 0 : _object$msgs2.map(function (e) {
      return MsgSignData.fromAmino(e);
    })) || [];
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    if (message.msgs) {
      obj.msgs = message.msgs.map(function (e) {
        return e ? MsgSignData.toAmino(e) : undefined;
      });
    } else {
      obj.msgs = message.msgs;
    }
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return ListOfMsgSignData.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return ListOfMsgSignData.decode(message.value);
  },
  toProto: function toProto(message) {
    return ListOfMsgSignData.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.offchain.ListOfMsgSignData",
      value: ListOfMsgSignData.encode(message).finish()
    };
  }
};