UNPKG

@node-dlc/messaging

Version:
108 lines (107 loc) 3.85 kB
/// <reference types="node" /> import { MessageType } from '../MessageType'; import { IDlcMessage } from './DlcMessage'; export declare abstract class EventDescriptor { static deserialize(buf: Buffer): EnumEventDescriptor | DigitDecompositionEventDescriptor; /** * Creates an EventDescriptor from JSON data * @param json JSON object representing event descriptor */ static fromJSON(json: any): EventDescriptor; abstract type: number; abstract length: bigint; abstract toJSON(): IEnumEventDescriptorJSON | IDigitDecompositionEventDescriptorJSON; abstract serialize(): Buffer; } /** * EnumEventDescriptor message contains the event outcomes for enumerated events. * Simplified class name (removed V0 suffix). */ export declare class EnumEventDescriptor extends EventDescriptor implements IDlcMessage { static type: MessageType; /** * Creates an EnumEventDescriptor from JSON data * @param json JSON object representing an enum event descriptor */ static fromJSON(json: any): EnumEventDescriptor; /** * Deserializes an enum_event_descriptor_v0 message * @param buf */ static deserialize(buf: Buffer): EnumEventDescriptor; /** * The type for enum_event_descriptor_v0 message. enum_event_descriptor_v0 = 55302 */ type: MessageType; length: bigint; outcomes: string[]; /** * Converts enum_event_descriptor to JSON */ toJSON(): IEnumEventDescriptorJSON; /** * Serializes the enum_event_descriptor_v0 message into a Buffer */ serialize(): Buffer; } export declare const EnumEventDescriptorV0: typeof EnumEventDescriptor; export type EnumEventDescriptorV0 = EnumEventDescriptor; /** * DigitDecompositionEventDescriptor is a simple enumeration of outcomes. * Simplified class name (removed V0 suffix). */ export declare class DigitDecompositionEventDescriptor extends EventDescriptor implements IDlcMessage { static type: MessageType; /** * Creates a DigitDecompositionEventDescriptor from JSON data * @param json JSON object representing digit decomposition event descriptor */ static fromJSON(json: any): DigitDecompositionEventDescriptor; /** * Deserializes an digit_decomposition_event_descriptor message * @param buf */ static deserialize(buf: Buffer): DigitDecompositionEventDescriptor; /** * The type for digit_decomposition_event_descriptor message. digit_decomposition_event_descriptor = 55306 */ type: MessageType; length: bigint; base: number; isSigned: boolean; unit: string; precision: number; nbDigits: number; /** * Validates correctness of all fields in the message * https://github.com/discreetlogcontracts/dlcspecs/blob/master/Oracle.md * @throws Will throw an error if validation fails */ validate(): void; /** * Converts digit_decomposition_event_descriptor to JSON (canonical rust-dlc format) */ toJSON(): IDigitDecompositionEventDescriptorJSON; /** * Serializes the digit_decomposition_event_descriptor message into a Buffer */ serialize(): Buffer; } export declare const DigitDecompositionEventDescriptorV0: typeof DigitDecompositionEventDescriptor; export type DigitDecompositionEventDescriptorV0 = DigitDecompositionEventDescriptor; export interface IEnumEventDescriptorJSON { enumEvent: { outcomes: string[]; }; } export interface IDigitDecompositionEventDescriptorJSON { digitDecompositionEvent: { base: number; isSigned: boolean; unit: string; precision: number; nbDigits: number; }; } export type IEnumEventDescriptorV0JSON = IEnumEventDescriptorJSON; export type IDigitDecompositionEventDescriptorV0JSON = IDigitDecompositionEventDescriptorJSON;