chia-agent
Version:
chia rpc/websocket client library
77 lines (76 loc) • 2.29 kB
TypeScript
import { Agent as HttpsAgent } from "https";
import { Agent as HttpAgent } from "http";
import { TConfig } from "../config/index";
import { APIAgent } from "../agent/index";
type TDestination = "farmer" | "harvester" | "full_node" | "wallet" | "data_layer" | "daemon" | "pool";
export declare function getConnectionInfoFromConfig(destination: TDestination, config: TConfig): {
hostname: string;
port: number;
};
export declare function getConf(configPath?: string): TConfig;
export declare function loadCertFilesFromConfig(config: TConfig): {
clientCert: Buffer;
clientKey: Buffer;
caCert: Buffer;
};
export type TRPCAgentProps = {
protocol: "https";
host: string;
port: number;
ca_cert?: string | Buffer;
client_cert?: string | Buffer;
client_key?: string | Buffer;
skip_hostname_verification?: boolean;
keepAlive?: boolean;
keepAliveMsecs?: number;
maxSockets?: number;
timeout?: number;
} | {
protocol: "https";
host: string;
port: number;
configPath: string;
skip_hostname_verification?: boolean;
keepAlive?: boolean;
keepAliveMsecs?: number;
maxSockets?: number;
timeout?: number;
} | {
protocol: "http";
host: string;
port: number;
keepAlive?: boolean;
keepAliveMsecs?: number;
maxSockets?: number;
timeout?: number;
} | {
service: TDestination;
host?: string;
port?: number;
configPath?: string;
skip_hostname_verification?: boolean;
keepAlive?: boolean;
keepAliveMsecs?: number;
maxSockets?: number;
timeout?: number;
} | {
httpsAgent: HttpsAgent;
skip_hostname_verification?: boolean;
} | {
httpAgent: HttpAgent;
host: string;
port: number;
skip_hostname_verification?: boolean;
};
export declare class RPCAgent implements APIAgent {
protected _protocol: "http" | "https";
protected _agent: HttpsAgent | HttpAgent;
protected _skip_hostname_verification: boolean;
protected _host: string;
protected _port: number;
constructor(props: TRPCAgentProps);
sendMessage<M>(destination: string, command: string, data?: Record<string, unknown>): Promise<M>;
request<R>(method: string, path: string, data?: any): Promise<R>;
}
export type TRPCAgent = APIAgent;
export {};