/* eslint-disable */ import * as Long from 'long'; import { Timestamp } from '../../../google/protobuf/timestamp'; import { Writer, Reader, util, configure } from 'protobufjs/minimal'; /** * Equivocation implements the Evidence interface and defines evidence of double * signing misbehavior. */ export interface Equivocation { height: Long; time?: Date; power: Long; consensusAddress: string; } const baseEquivocation: object = { height: Long.ZERO, power: Long.ZERO, consensusAddress: "", }; function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); } } function toTimestamp(date: Date): Timestamp { const seconds = numberToLong(date.getTime() / 1_000); const nanos = (date.getTime() % 1_000) * 1_000_000; return { seconds, nanos }; } function fromTimestamp(t: Timestamp): Date { let millis = t.seconds.toNumber() * 1_000; millis += t.nanos / 1_000_000; return new Date(millis); } function numberToLong(number: number) { return Long.fromNumber(number); } export const protobufPackage = 'cosmos.evidence.v1beta1' export const Equivocation = { encode(message: Equivocation, writer: Writer = Writer.create()): Writer { writer.uint32(8).int64(message.height); if (message.time !== undefined && message.time !== undefined) { Timestamp.encode(toTimestamp(message.time), writer.uint32(18).fork()).ldelim(); } writer.uint32(24).int64(message.power); writer.uint32(34).string(message.consensusAddress); return writer; }, decode(input: Uint8Array | Reader, length?: number): Equivocation { const reader = input instanceof Uint8Array ? new Reader(input) : input; let end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseEquivocation } as Equivocation; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.height = reader.int64() as Long; break; case 2: message.time = fromTimestamp(Timestamp.decode(reader, reader.uint32())); break; case 3: message.power = reader.int64() as Long; break; case 4: message.consensusAddress = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): Equivocation { const message = { ...baseEquivocation } as Equivocation; if (object.height !== undefined && object.height !== null) { message.height = Long.fromString(object.height); } else { message.height = Long.ZERO; } if (object.time !== undefined && object.time !== null) { message.time = fromJsonTimestamp(object.time); } else { message.time = undefined; } if (object.power !== undefined && object.power !== null) { message.power = Long.fromString(object.power); } else { message.power = Long.ZERO; } if (object.consensusAddress !== undefined && object.consensusAddress !== null) { message.consensusAddress = String(object.consensusAddress); } else { message.consensusAddress = ""; } return message; }, fromPartial(object: DeepPartial): Equivocation { const message = { ...baseEquivocation } as Equivocation; if (object.height !== undefined && object.height !== null) { message.height = object.height as Long; } else { message.height = Long.ZERO; } if (object.time !== undefined && object.time !== null) { message.time = object.time; } else { message.time = undefined; } if (object.power !== undefined && object.power !== null) { message.power = object.power as Long; } else { message.power = Long.ZERO; } if (object.consensusAddress !== undefined && object.consensusAddress !== null) { message.consensusAddress = object.consensusAddress; } else { message.consensusAddress = ""; } return message; }, toJSON(message: Equivocation): unknown { const obj: any = {}; message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); message.time !== undefined && (obj.time = message.time !== undefined ? message.time.toISOString() : null); message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); message.consensusAddress !== undefined && (obj.consensusAddress = message.consensusAddress); return obj; }, }; if (util.Long !== Long as any) { util.Long = Long as any; configure(); } type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial;