/* eslint-disable */ import Long from 'long'; import _m0 from 'protobufjs/minimal'; import { Timestamp } from '../../../google/protobuf/timestamp'; export const protobufPackage = 'cosmos.evidence.v1beta1'; /** * 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: '' }; export const Equivocation = { encode(message: Equivocation, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.height.isZero()) { writer.uint32(8).int64(message.height); } if (message.time !== undefined) { Timestamp.encode(toTimestamp(message.time), writer.uint32(18).fork()).ldelim(); } if (!message.power.isZero()) { writer.uint32(24).int64(message.power); } if (message.consensusAddress !== '') { writer.uint32(34).string(message.consensusAddress); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): Equivocation { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(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; }, toJSON(message: Equivocation): unknown { const obj: any = {}; message.height !== undefined && (obj.height = (message.height || Long.ZERO).toString()); message.time !== undefined && (obj.time = message.time.toISOString()); message.power !== undefined && (obj.power = (message.power || Long.ZERO).toString()); message.consensusAddress !== undefined && (obj.consensusAddress = message.consensusAddress); return obj; }, 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; }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined | Long; export type DeepPartial = T extends Builtin ? T : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; 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 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 numberToLong(number: number) { return Long.fromNumber(number); } if (_m0.util.Long !== Long) { _m0.util.Long = Long as any; _m0.configure(); }