"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Block = void 0;
var _types = require("./types");
var _evidence = require("./evidence");
var _binary = require("../../binary");
var _helpers = require("../../helpers");
function createBaseBlock() {
  return {
    header: _types.Header.fromPartial({}),
    data: _types.Data.fromPartial({}),
    evidence: _evidence.EvidenceList.fromPartial({}),
    lastCommit: undefined
  };
}
var Block = exports.Block = {
  typeUrl: "/tendermint.types.Block",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.header !== undefined) {
      _types.Header.encode(message.header, writer.uint32(10).fork()).ldelim();
    }
    if (message.data !== undefined) {
      _types.Data.encode(message.data, writer.uint32(18).fork()).ldelim();
    }
    if (message.evidence !== undefined) {
      _evidence.EvidenceList.encode(message.evidence, writer.uint32(26).fork()).ldelim();
    }
    if (message.lastCommit !== undefined) {
      _types.Commit.encode(message.lastCommit, writer.uint32(34).fork()).ldelim();
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      header: (0, _helpers.isSet)(object.header) ? _types.Header.fromJSON(object.header) : undefined,
      data: (0, _helpers.isSet)(object.data) ? _types.Data.fromJSON(object.data) : undefined,
      evidence: (0, _helpers.isSet)(object.evidence) ? _evidence.EvidenceList.fromJSON(object.evidence) : undefined,
      lastCommit: (0, _helpers.isSet)(object.lastCommit) ? _types.Commit.fromJSON(object.lastCommit) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseBlock();
    message.header = object.header !== undefined && object.header !== null ? _types.Header.fromPartial(object.header) : undefined;
    message.data = object.data !== undefined && object.data !== null ? _types.Data.fromPartial(object.data) : undefined;
    message.evidence = object.evidence !== undefined && object.evidence !== null ? _evidence.EvidenceList.fromPartial(object.evidence) : undefined;
    message.lastCommit = object.lastCommit !== undefined && object.lastCommit !== null ? _types.Commit.fromPartial(object.lastCommit) : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseBlock();
    if (object.header !== undefined && object.header !== null) {
      message.header = _types.Header.fromAmino(object.header);
    }
    if (object.data !== undefined && object.data !== null) {
      message.data = _types.Data.fromAmino(object.data);
    }
    if (object.evidence !== undefined && object.evidence !== null) {
      message.evidence = _evidence.EvidenceList.fromAmino(object.evidence);
    }
    if (object.last_commit !== undefined && object.last_commit !== null) {
      message.lastCommit = _types.Commit.fromAmino(object.last_commit);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.header = message.header ? _types.Header.toAmino(message.header) : undefined;
    obj.data = message.data ? _types.Data.toAmino(message.data) : undefined;
    obj.evidence = message.evidence ? _evidence.EvidenceList.toAmino(message.evidence) : undefined;
    obj.last_commit = message.lastCommit ? _types.Commit.toAmino(message.lastCommit) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Block.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Block.decode(message.value);
  },
  toProto: function toProto(message) {
    return Block.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/tendermint.types.Block",
      value: Block.encode(message).finish()
    };
  }
};