import { Timestamp, TimestampSDKType } from "../../../google/protobuf/timestamp"; import { Duration, DurationAmino, DurationSDKType } from "../../../google/protobuf/duration"; import { BinaryWriter } from "../../../binary"; import { isSet, fromJsonTimestamp, bytesFromBase64, base64FromBytes } from "../../../helpers"; /** * ValidatorSigningInfo defines a validator's signing info for monitoring their * liveness activity. */ export interface ValidatorSigningInfo { address: string; /** Height at which validator was first a candidate OR was unjailed */ startHeight: bigint; /** * Index which is incremented each time the validator was a bonded * in a block and may have signed a precommit or not. This in conjunction with the * `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. */ indexOffset: bigint; /** Timestamp until which the validator is jailed due to liveness downtime. */ jailedUntil: Timestamp; /** * Whether or not a validator has been tombstoned (killed out of validator set). It is set * once the validator commits an equivocation or for any other configured misbehiavor. */ tombstoned: boolean; /** * A counter kept to avoid unnecessary array reads. * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. */ missedBlocksCounter: bigint; } export interface ValidatorSigningInfoProtoMsg { typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo"; value: Uint8Array; } /** * ValidatorSigningInfo defines a validator's signing info for monitoring their * liveness activity. */ export interface ValidatorSigningInfoAmino { address?: string; /** Height at which validator was first a candidate OR was unjailed */ start_height?: string; /** * Index which is incremented each time the validator was a bonded * in a block and may have signed a precommit or not. This in conjunction with the * `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. */ index_offset?: string; /** Timestamp until which the validator is jailed due to liveness downtime. */ jailed_until?: string; /** * Whether or not a validator has been tombstoned (killed out of validator set). It is set * once the validator commits an equivocation or for any other configured misbehiavor. */ tombstoned?: boolean; /** * A counter kept to avoid unnecessary array reads. * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. */ missed_blocks_counter?: string; } export interface ValidatorSigningInfoAminoMsg { type: "cosmos-sdk/ValidatorSigningInfo"; value: ValidatorSigningInfoAmino; } /** * ValidatorSigningInfo defines a validator's signing info for monitoring their * liveness activity. */ export interface ValidatorSigningInfoSDKType { address: string; start_height: bigint; index_offset: bigint; jailed_until: TimestampSDKType; tombstoned: boolean; missed_blocks_counter: bigint; } /** Params represents the parameters used for by the slashing module. */ export interface Params { signedBlocksWindow: bigint; minSignedPerWindow: Uint8Array; downtimeJailDuration: Duration; slashFractionDoubleSign: Uint8Array; slashFractionDowntime: Uint8Array; } export interface ParamsProtoMsg { typeUrl: "/cosmos.slashing.v1beta1.Params"; value: Uint8Array; } /** Params represents the parameters used for by the slashing module. */ export interface ParamsAmino { signed_blocks_window?: string; min_signed_per_window?: string; downtime_jail_duration?: DurationAmino; slash_fraction_double_sign?: string; slash_fraction_downtime?: string; } export interface ParamsAminoMsg { type: "cosmos-sdk/Params"; value: ParamsAmino; } /** Params represents the parameters used for by the slashing module. */ export interface ParamsSDKType { signed_blocks_window: bigint; min_signed_per_window: Uint8Array; downtime_jail_duration: DurationSDKType; slash_fraction_double_sign: Uint8Array; slash_fraction_downtime: Uint8Array; } function createBaseValidatorSigningInfo(): ValidatorSigningInfo { return { address: "", startHeight: BigInt(0), indexOffset: BigInt(0), jailedUntil: Timestamp.fromPartial({}), tombstoned: false, missedBlocksCounter: BigInt(0) }; } export const ValidatorSigningInfo = { typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo", encode(message: ValidatorSigningInfo, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.address !== "") { writer.uint32(10).string(message.address); } if (message.startHeight !== BigInt(0)) { writer.uint32(16).int64(message.startHeight); } if (message.indexOffset !== BigInt(0)) { writer.uint32(24).int64(message.indexOffset); } if (message.jailedUntil !== undefined) { Timestamp.encode(message.jailedUntil, writer.uint32(34).fork()).ldelim(); } if (message.tombstoned === true) { writer.uint32(40).bool(message.tombstoned); } if (message.missedBlocksCounter !== BigInt(0)) { writer.uint32(48).int64(message.missedBlocksCounter); } return writer; }, fromJSON(object: any): ValidatorSigningInfo { return { address: isSet(object.address) ? String(object.address) : "", startHeight: isSet(object.startHeight) ? BigInt(object.startHeight.toString()) : BigInt(0), indexOffset: isSet(object.indexOffset) ? BigInt(object.indexOffset.toString()) : BigInt(0), jailedUntil: isSet(object.jailedUntil) ? fromJsonTimestamp(object.jailedUntil) : undefined, tombstoned: isSet(object.tombstoned) ? Boolean(object.tombstoned) : false, missedBlocksCounter: isSet(object.missedBlocksCounter) ? BigInt(object.missedBlocksCounter.toString()) : BigInt(0) }; }, fromPartial(object: Partial): ValidatorSigningInfo { const message = createBaseValidatorSigningInfo(); message.address = object.address ?? ""; message.startHeight = object.startHeight !== undefined && object.startHeight !== null ? BigInt(object.startHeight.toString()) : BigInt(0); message.indexOffset = object.indexOffset !== undefined && object.indexOffset !== null ? BigInt(object.indexOffset.toString()) : BigInt(0); message.jailedUntil = object.jailedUntil !== undefined && object.jailedUntil !== null ? Timestamp.fromPartial(object.jailedUntil) : undefined; message.tombstoned = object.tombstoned ?? false; message.missedBlocksCounter = object.missedBlocksCounter !== undefined && object.missedBlocksCounter !== null ? BigInt(object.missedBlocksCounter.toString()) : BigInt(0); return message; }, fromAmino(object: ValidatorSigningInfoAmino): ValidatorSigningInfo { const message = createBaseValidatorSigningInfo(); if (object.address !== undefined && object.address !== null) { message.address = object.address; } if (object.start_height !== undefined && object.start_height !== null) { message.startHeight = BigInt(object.start_height); } if (object.index_offset !== undefined && object.index_offset !== null) { message.indexOffset = BigInt(object.index_offset); } if (object.jailed_until !== undefined && object.jailed_until !== null) { message.jailedUntil = Timestamp.fromAmino(object.jailed_until); } if (object.tombstoned !== undefined && object.tombstoned !== null) { message.tombstoned = object.tombstoned; } if (object.missed_blocks_counter !== undefined && object.missed_blocks_counter !== null) { message.missedBlocksCounter = BigInt(object.missed_blocks_counter); } return message; }, toAmino(message: ValidatorSigningInfo): ValidatorSigningInfoAmino { const obj: any = {}; obj.address = message.address === "" ? undefined : message.address; obj.start_height = message.startHeight !== BigInt(0) ? message.startHeight.toString() : undefined; obj.index_offset = message.indexOffset !== BigInt(0) ? message.indexOffset.toString() : undefined; obj.jailed_until = message.jailedUntil ? Timestamp.toAmino(message.jailedUntil) : undefined; obj.tombstoned = message.tombstoned === false ? undefined : message.tombstoned; obj.missed_blocks_counter = message.missedBlocksCounter !== BigInt(0) ? message.missedBlocksCounter.toString() : undefined; return obj; }, fromAminoMsg(object: ValidatorSigningInfoAminoMsg): ValidatorSigningInfo { return ValidatorSigningInfo.fromAmino(object.value); }, toAminoMsg(message: ValidatorSigningInfo): ValidatorSigningInfoAminoMsg { return { type: "cosmos-sdk/ValidatorSigningInfo", value: ValidatorSigningInfo.toAmino(message) }; }, fromProtoMsg(message: ValidatorSigningInfoProtoMsg): ValidatorSigningInfo { return ValidatorSigningInfo.decode(message.value); }, toProto(message: ValidatorSigningInfo): Uint8Array { return ValidatorSigningInfo.encode(message).finish(); }, toProtoMsg(message: ValidatorSigningInfo): ValidatorSigningInfoProtoMsg { return { typeUrl: "/cosmos.slashing.v1beta1.ValidatorSigningInfo", value: ValidatorSigningInfo.encode(message).finish() }; } }; function createBaseParams(): Params { return { signedBlocksWindow: BigInt(0), minSignedPerWindow: new Uint8Array(), downtimeJailDuration: Duration.fromPartial({}), slashFractionDoubleSign: new Uint8Array(), slashFractionDowntime: new Uint8Array() }; } export const Params = { typeUrl: "/cosmos.slashing.v1beta1.Params", encode(message: Params, writer: BinaryWriter = BinaryWriter.create()): BinaryWriter { if (message.signedBlocksWindow !== BigInt(0)) { writer.uint32(8).int64(message.signedBlocksWindow); } if (message.minSignedPerWindow.length !== 0) { writer.uint32(18).bytes(message.minSignedPerWindow); } if (message.downtimeJailDuration !== undefined) { Duration.encode(message.downtimeJailDuration, writer.uint32(26).fork()).ldelim(); } if (message.slashFractionDoubleSign.length !== 0) { writer.uint32(34).bytes(message.slashFractionDoubleSign); } if (message.slashFractionDowntime.length !== 0) { writer.uint32(42).bytes(message.slashFractionDowntime); } return writer; }, fromJSON(object: any): Params { return { signedBlocksWindow: isSet(object.signedBlocksWindow) ? BigInt(object.signedBlocksWindow.toString()) : BigInt(0), minSignedPerWindow: isSet(object.minSignedPerWindow) ? bytesFromBase64(object.minSignedPerWindow) : new Uint8Array(), downtimeJailDuration: isSet(object.downtimeJailDuration) ? Duration.fromJSON(object.downtimeJailDuration) : undefined, slashFractionDoubleSign: isSet(object.slashFractionDoubleSign) ? bytesFromBase64(object.slashFractionDoubleSign) : new Uint8Array(), slashFractionDowntime: isSet(object.slashFractionDowntime) ? bytesFromBase64(object.slashFractionDowntime) : new Uint8Array() }; }, fromPartial(object: Partial): Params { const message = createBaseParams(); message.signedBlocksWindow = object.signedBlocksWindow !== undefined && object.signedBlocksWindow !== null ? BigInt(object.signedBlocksWindow.toString()) : BigInt(0); message.minSignedPerWindow = object.minSignedPerWindow ?? new Uint8Array(); message.downtimeJailDuration = object.downtimeJailDuration !== undefined && object.downtimeJailDuration !== null ? Duration.fromPartial(object.downtimeJailDuration) : undefined; message.slashFractionDoubleSign = object.slashFractionDoubleSign ?? new Uint8Array(); message.slashFractionDowntime = object.slashFractionDowntime ?? new Uint8Array(); return message; }, fromAmino(object: ParamsAmino): Params { const message = createBaseParams(); if (object.signed_blocks_window !== undefined && object.signed_blocks_window !== null) { message.signedBlocksWindow = BigInt(object.signed_blocks_window); } if (object.min_signed_per_window !== undefined && object.min_signed_per_window !== null) { message.minSignedPerWindow = bytesFromBase64(object.min_signed_per_window); } if (object.downtime_jail_duration !== undefined && object.downtime_jail_duration !== null) { message.downtimeJailDuration = Duration.fromAmino(object.downtime_jail_duration); } if (object.slash_fraction_double_sign !== undefined && object.slash_fraction_double_sign !== null) { message.slashFractionDoubleSign = bytesFromBase64(object.slash_fraction_double_sign); } if (object.slash_fraction_downtime !== undefined && object.slash_fraction_downtime !== null) { message.slashFractionDowntime = bytesFromBase64(object.slash_fraction_downtime); } return message; }, toAmino(message: Params): ParamsAmino { const obj: any = {}; obj.signed_blocks_window = message.signedBlocksWindow !== BigInt(0) ? message.signedBlocksWindow.toString() : undefined; obj.min_signed_per_window = message.minSignedPerWindow ? base64FromBytes(message.minSignedPerWindow) : undefined; obj.downtime_jail_duration = message.downtimeJailDuration ? Duration.toAmino(message.downtimeJailDuration) : undefined; obj.slash_fraction_double_sign = message.slashFractionDoubleSign ? base64FromBytes(message.slashFractionDoubleSign) : undefined; obj.slash_fraction_downtime = message.slashFractionDowntime ? base64FromBytes(message.slashFractionDowntime) : undefined; return obj; }, fromAminoMsg(object: ParamsAminoMsg): Params { return Params.fromAmino(object.value); }, toAminoMsg(message: Params): ParamsAminoMsg { return { type: "cosmos-sdk/Params", value: Params.toAmino(message) }; }, fromProtoMsg(message: ParamsProtoMsg): Params { return Params.decode(message.value); }, toProto(message: Params): Uint8Array { return Params.encode(message).finish(); }, toProtoMsg(message: Params): ParamsProtoMsg { return { typeUrl: "/cosmos.slashing.v1beta1.Params", value: Params.encode(message).finish() }; } };