chia-agent
Version:
chia rpc/websocket client library
92 lines (91 loc) • 4.9 kB
TypeScript
import { BlockRecord } from "../../chia_rs/chia-protocol/block_record";
import { bool, float, None, str } from "../../chia/types/_python_types_";
import { int, uint128, uint32, uint64, uint8 } from "../../chia_rs/wheel/python/sized_ints";
import { TDaemon } from "../../../daemon/index";
import { GetMessageType, TConnectionGeneral } from "../../types";
import { bytes32 } from "../../chia_rs/wheel/python/sized_bytes";
import { NewSignagePoint } from "../../chia/protocols/farmer_protocol";
import { AddBlockResult } from "../../chia/consensus/blockchain";
import { UnfinishedBlock } from "../../chia_rs/chia-protocol/unfinished_block";
export declare const chia_full_node_service = "chia_full_node";
export type chia_full_node_service = typeof chia_full_node_service;
export type TConnectionFullNode = ({
peak_height: uint32;
peak_weight: uint128;
peak_hash: bytes32;
} | {
peak_height: None;
peak_weight: None;
peak_hash: None;
}) & TConnectionGeneral;
export declare const get_connections_command = "get_connections";
export type get_connections_command = typeof get_connections_command;
export type TGetConnectionsBroadCast = {
connections: TConnectionFullNode[];
};
export type WsGetConnectionFullNodeMessage = GetMessageType<chia_full_node_service, get_connections_command, TGetConnectionsBroadCast>;
export declare function on_get_connections(daemon: TDaemon, callback: (e: WsGetConnectionFullNodeMessage) => unknown): Promise<() => void>;
export declare const get_blockchain_state_command = "get_blockchain_state";
export type get_blockchain_state_command = typeof get_blockchain_state_command;
export type TGetBlockchainStateBroadCast = {
blockchain_state: {
peak: BlockRecord;
genesis_challenge_initialized: bool;
sync: {
sync_mode: bool;
synced: bool;
sync_tip_height: uint32;
sync_progress_height: uint32;
};
difficulty: uint64;
sub_slot_iters: uint64;
space: uint128;
mempool_size: int;
mempool_cost: int;
mempool_min_fees: {
cost_5000000: float;
};
mempool_max_total_cost: int;
block_max_cost: int;
node_id: str;
};
};
export type WsGetBlockchainStateMessage = GetMessageType<chia_full_node_service, get_blockchain_state_command, TGetBlockchainStateBroadCast>;
export declare function on_get_blockchain_state(daemon: TDaemon, callback: (e: WsGetBlockchainStateMessage) => unknown): Promise<() => void>;
export declare const block_command = "block";
export type block_command = typeof block_command;
export type TBlockBroadCast = Record<string, never> | {
transaction_block: bool;
k_size: uint8;
header_hash: bytes32;
height: uint32;
block_cost?: uint64;
block_fees?: uint64;
timestamp?: uint64;
transaction_generator_size_bytes?: int;
transaction_generator_ref_list: uint32[];
receive_block_result?: AddBlockResult;
};
export type WsBlockMessage = GetMessageType<chia_full_node_service, block_command, TBlockBroadCast>;
export declare function on_block(daemon: TDaemon, callback: (e: WsBlockMessage) => unknown): Promise<() => void>;
export declare const signage_point_command = "signage_point";
export type signage_point_command = typeof signage_point_command;
export type TSignagePointBroadCast = {
broadcast_farmer: NewSignagePoint;
};
export type WsSignagePointMessage = GetMessageType<chia_full_node_service, signage_point_command, TSignagePointBroadCast>;
export declare function on_signage_point(daemon: TDaemon, callback: (e: WsSignagePointMessage) => unknown): Promise<() => void>;
export declare const unfinished_block_command = "unfinished_block";
export type unfinished_block_command = typeof unfinished_block_command;
export type TUnfinishedBlockBroadCast = {
block_duration_in_seconds: float;
validation_time_in_seconds: float;
pre_validation_time_in_seconds: float | None;
unfinished_block: UnfinishedBlock;
};
export type WsUnfinishedBlockMessage = GetMessageType<chia_full_node_service, unfinished_block_command, TUnfinishedBlockBroadCast>;
export declare function on_unfinished_block(daemon: TDaemon, callback: (e: WsUnfinishedBlockMessage) => unknown): Promise<() => void>;
export type WsFullNodeMessage = WsGetConnectionFullNodeMessage | WsGetBlockchainStateMessage | WsBlockMessage | WsSignagePointMessage | WsUnfinishedBlockMessage;
export type chia_full_node_commands = get_blockchain_state_command | get_connections_command | block_command | signage_point_command | unfinished_block_command;
export type TChiaFullNodeBroadcast = TGetBlockchainStateBroadCast | TGetConnectionsBroadCast | TBlockBroadCast | TSignagePointBroadCast | TUnfinishedBlockBroadCast;
export declare function on_message_from_full_node(daemon: TDaemon, callback: (e: WsFullNodeMessage) => unknown): Promise<() => void>;