"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Equivocation = void 0;
var _timestamp = require("../../../google/protobuf/timestamp");
var _binary = require("../../../binary");
var _helpers = require("../../../helpers");
/**
 * Equivocation implements the Evidence interface and defines evidence of double
 * signing misbehavior.
 */

/**
 * Equivocation implements the Evidence interface and defines evidence of double
 * signing misbehavior.
 */

/**
 * Equivocation implements the Evidence interface and defines evidence of double
 * signing misbehavior.
 */

function createBaseEquivocation() {
  return {
    height: BigInt(0),
    time: _timestamp.Timestamp.fromPartial({}),
    power: BigInt(0),
    consensusAddress: ""
  };
}
var Equivocation = exports.Equivocation = {
  typeUrl: "/cosmos.evidence.v1beta1.Equivocation",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.height !== BigInt(0)) {
      writer.uint32(8).int64(message.height);
    }
    if (message.time !== undefined) {
      _timestamp.Timestamp.encode(message.time, writer.uint32(18).fork()).ldelim();
    }
    if (message.power !== BigInt(0)) {
      writer.uint32(24).int64(message.power);
    }
    if (message.consensusAddress !== "") {
      writer.uint32(34).string(message.consensusAddress);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      height: (0, _helpers.isSet)(object.height) ? BigInt(object.height.toString()) : BigInt(0),
      time: (0, _helpers.isSet)(object.time) ? (0, _helpers.fromJsonTimestamp)(object.time) : undefined,
      power: (0, _helpers.isSet)(object.power) ? BigInt(object.power.toString()) : BigInt(0),
      consensusAddress: (0, _helpers.isSet)(object.consensusAddress) ? String(object.consensusAddress) : ""
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$consensusAddr;
    var message = createBaseEquivocation();
    message.height = object.height !== undefined && object.height !== null ? BigInt(object.height.toString()) : BigInt(0);
    message.time = object.time !== undefined && object.time !== null ? _timestamp.Timestamp.fromPartial(object.time) : undefined;
    message.power = object.power !== undefined && object.power !== null ? BigInt(object.power.toString()) : BigInt(0);
    message.consensusAddress = (_object$consensusAddr = object.consensusAddress) !== null && _object$consensusAddr !== void 0 ? _object$consensusAddr : "";
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBaseEquivocation();
    if (object.height !== undefined && object.height !== null) {
      message.height = BigInt(object.height);
    }
    if (object.time !== undefined && object.time !== null) {
      message.time = _timestamp.Timestamp.fromAmino(object.time);
    }
    if (object.power !== undefined && object.power !== null) {
      message.power = BigInt(object.power);
    }
    if (object.consensus_address !== undefined && object.consensus_address !== null) {
      message.consensusAddress = object.consensus_address;
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.height = message.height !== BigInt(0) ? message.height.toString() : undefined;
    obj.time = message.time ? _timestamp.Timestamp.toAmino(message.time) : undefined;
    obj.power = message.power !== BigInt(0) ? message.power.toString() : undefined;
    obj.consensus_address = message.consensusAddress === "" ? undefined : message.consensusAddress;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return Equivocation.fromAmino(object.value);
  },
  toAminoMsg: function toAminoMsg(message) {
    return {
      type: "cosmos-sdk/Equivocation",
      value: Equivocation.toAmino(message)
    };
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return Equivocation.decode(message.value);
  },
  toProto: function toProto(message) {
    return Equivocation.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.evidence.v1beta1.Equivocation",
      value: Equivocation.encode(message).finish()
    };
  }
};