UNPKG

3.01 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Blockchain } from './helpers/blockchain';
3import { BroadcastAPI } from './helpers/broadcast';
4import { DatabaseAPI } from './helpers/database';
5/**
6 * Library version.
7 */
8export declare const VERSION: string;
9/**
10 * Main steem network chain id.
11 */
12export declare const DEFAULT_CHAIN_ID: Buffer;
13/**
14 * Main steem network address prefix.
15 */
16export declare const DEFAULT_ADDRESS_PREFIX = "STM";
17/**
18 * RPC Client options
19 * ------------------
20 */
21export interface ClientOptions {
22 /**
23 * Steem chain id. Defaults to main steem network:
24 * `0000000000000000000000000000000000000000000000000000000000000000`
25 */
26 chainId?: string;
27 /**
28 * Steem address prefix. Defaults to main steem network:
29 * `STM`
30 */
31 addressPrefix?: string;
32 /**
33 * Send timeout, how long to wait in milliseconds before giving
34 * up on a rpc call. Note that this is not an exact timeout,
35 * no in-flight requests will be aborted, they will just not
36 * be retried any more past the timeout.
37 * Can be set to 0 to retry forever. Defaults to 60 * 1000 ms.
38 */
39 timeout?: number;
40 /**
41 * Retry backoff function, returns milliseconds. Default = {@link defaultBackoff}.
42 */
43 backoff?: (tries: number) => number;
44 /**
45 * Node.js http(s) agent, use if you want http keep-alive.
46 * Defaults to using https.globalAgent.
47 * @see https://nodejs.org/api/http.html#http_new_agent_options.
48 */
49 agent?: any;
50}
51/**
52 * RPC Client
53 * ----------
54 * Can be used in both node.js and the browser. Also see {@link ClientOptions}.
55 */
56export declare class Client {
57 /**
58 * Create a new client instance configured for the testnet.
59 */
60 static testnet(options?: ClientOptions): Client;
61 /**
62 * Client options, *read-only*.
63 */
64 readonly options: ClientOptions;
65 /**
66 * Address to Steem RPC server, *read-only*.
67 */
68 readonly address: string;
69 /**
70 * Database API helper.
71 */
72 readonly database: DatabaseAPI;
73 /**
74 * Broadcast API helper.
75 */
76 readonly broadcast: BroadcastAPI;
77 /**
78 * Blockchain helper.
79 */
80 readonly blockchain: Blockchain;
81 /**
82 * Chain ID for current network.
83 */
84 readonly chainId: Buffer;
85 /**
86 * Address prefix for current network.
87 */
88 readonly addressPrefix: string;
89 private seqNo;
90 private timeout;
91 private backoff;
92 /**
93 * @param address The address to the Steem RPC server, e.g. `https://steemd.steemit.com`.
94 * @param options Client options.
95 */
96 constructor(address: string, options?: ClientOptions);
97 /**
98 * Make a RPC call to the server.
99 *
100 * @param api The API to call, e.g. `database_api`.
101 * @param method The API method, e.g. `get_dynamic_global_properties`.
102 * @param params Array of parameters to pass to the method, optional.
103 *
104 */
105 call(api: string, method: string, params?: any[]): Promise<any>;
106}