@node-dlc/messaging
Version:
DLC Messaging Protocol
102 lines (101 loc) • 3.35 kB
TypeScript
/// <reference types="node" />
import { MessageType } from '../MessageType';
import { ContractDescriptor, ContractDescriptorV0JSON, ContractDescriptorV1JSON } from './ContractDescriptor';
import { DlcMessage, IDlcMessage } from './DlcMessage';
import { OracleInfoV0, OracleInfoV0JSON } from './OracleInfoV0';
export declare abstract class ContractInfo extends DlcMessage {
static deserialize(buf: Buffer): ContractInfoV0 | ContractInfoV1;
abstract type: number;
abstract length: bigint;
abstract totalCollateral: bigint;
abstract validate(): void;
abstract toJSON(): IContractInfoV0JSON | IContractInfoV1JSON;
abstract serialize(): Buffer;
}
/**
* ContractInfo V0 contains information about a contract's outcomes,
* their corresponding payouts, and the oracles to be used.
*/
export declare class ContractInfoV0 implements IDlcMessage {
static type: MessageType;
/**
* Deserializes an contract_info_v0 message
* @param buf
*/
static deserialize(buf: Buffer): ContractInfoV0;
/**
* The type for contract_info_v0 message. contract_info_v0 = 55342
*/
type: MessageType;
length: bigint;
totalCollateral: bigint;
contractDescriptor: ContractDescriptor;
oracleInfo: OracleInfoV0;
/**
* Validates correctness of all fields in the message
* https://github.com/discreetlogcontracts/dlcspecs/blob/master/Messaging.md#the-contract_info-type
* @throws Will throw an error if validation fails
*/
validate(): void;
/**
* Converts contract_info_v0 to JSON
*/
toJSON(): IContractInfoV0JSON;
/**
* Serializes the contract_info_v0 message into a Buffer
*/
serialize(): Buffer;
}
/**
* ContractInfo V1 contains information about a contract's outcomes,
* their corresponding payouts, and the oracles to be used.
*/
export declare class ContractInfoV1 implements IDlcMessage {
static type: MessageType;
/**
* Deserializes an contract_info_v0 message
* @param buf
*/
static deserialize(buf: Buffer): ContractInfoV1;
/**
* The type for contract_info_v1 message. contract_info_v0 = 55342
*/
type: MessageType;
length: bigint;
totalCollateral: bigint;
contractOraclePairs: IContractOraclePair[];
/**
* Validates correctness of all fields in the message
* https://github.com/discreetlogcontracts/dlcspecs/blob/master/Messaging.md#the-contract_info-type
* @throws Will throw an error if validation fails
*/
validate(): void;
/**
* Converts contract_info_v1 to JSON
*/
toJSON(): IContractInfoV1JSON;
/**
* Serializes the contract_info_v1 message into a Buffer
*/
serialize(): Buffer;
}
interface IContractOraclePair {
contractDescriptor: ContractDescriptor;
oracleInfo: OracleInfoV0;
}
interface IContractOraclePairJSON {
contractDescriptor: ContractDescriptorV0JSON | ContractDescriptorV1JSON;
oracleInfo: OracleInfoV0JSON;
}
export interface IContractInfoV0JSON {
type: number;
totalCollateral: number;
contractDescriptor: ContractDescriptorV0JSON | ContractDescriptorV1JSON;
oracleInfo: OracleInfoV0JSON;
}
export interface IContractInfoV1JSON {
type: number;
totalCollateral: number;
contractOraclePairs: IContractOraclePairJSON[];
}
export {};