Some checks failed
morphit-release / Build + publish release tarball (push) Has been cancelled
116 lines
5.3 KiB
TypeScript
116 lines
5.3 KiB
TypeScript
import { AccountHistoryAPI } from './helpers/account_history';
|
|
import { Blockchain } from './helpers/blockchain';
|
|
import { BroadcastAPI } from './helpers/broadcast';
|
|
import { CondenserAPI } from './index-browser';
|
|
import { DatabaseAPI } from './helpers/database';
|
|
import { Nexus } from './helpers/nexus';
|
|
import { ReadModels } from './helpers/read_models';
|
|
import { Tools } from './helpers/tools';
|
|
import { TransactionStatusAPI } from './helpers/transaction_status';
|
|
import { RpcTransportKind } from './transports/rpc_transport';
|
|
/** Library version. */
|
|
export declare const VERSION: string;
|
|
/** Main Blurt network chain id */
|
|
export declare const DEFAULT_CHAIN_ID: Buffer;
|
|
/** Main Blurt network address prefix */
|
|
export declare const DEFAULT_ADDRESS_PREFIX = "BLT";
|
|
/**
|
|
* RPC Client options
|
|
* ------------------
|
|
*/
|
|
export interface ClientOptions {
|
|
/** Blurt chain id. Defaults `cd8d90f29ae273abec3eaa7731e25934c63eb654d55080caff2ebb7f5df6381f` */
|
|
chainId?: string;
|
|
/** Blurt address prefix. Defaults to main network: `BLT`*/
|
|
addressPrefix?: string;
|
|
/** how long to wait in milliseconds before giving up on a rpc call. Defaults to 60 * 1000 ms. */
|
|
timeout?: number;
|
|
/**
|
|
* Specifies the amount of times the urls (RPC nodes) should be
|
|
* iterated and retried in case of timeout errors.
|
|
* (important) Requires url parameter to be an array (string[])!
|
|
* Can be set to 0 to iterate and retry forever. Defaults to 3 rounds.
|
|
*/
|
|
failoverThreshold?: number;
|
|
/** Whether a console.log should be made when RPC failed over to another one */
|
|
consoleOnFailover?: boolean;
|
|
/**
|
|
* Application-specific HTTP User-Agent for RPC requests in Node.js.
|
|
* Defaults to `dblurt/<version>`. Browsers do not allow scripts to set this header.
|
|
*/
|
|
userAgent?: string;
|
|
/** Retry backoff function, returns milliseconds. Defaults to dblurt's built-in capped quadratic backoff. */
|
|
backoff?: (tries: number) => number;
|
|
/**
|
|
* Internal migration switch. Defaults to `legacy`; `core` is experimental opt-in
|
|
* and delegates only JSON-RPC transport to blurt-rpc-core.
|
|
*/
|
|
rpcTransport?: RpcTransportKind;
|
|
/** Optional prebuilt blurt-rpc-core compatible client for tests/custom transports. */
|
|
coreClient?: any;
|
|
/** Optional preloaded blurt-rpc-core module for tests/CommonJS integration. */
|
|
coreModule?: any;
|
|
/** Optional blurt-rpc-core node selection strategy, used only with rpcTransport='core'. */
|
|
nodeSelectionStrategy?: 'sticky' | 'round-robin' | 'weighted-random' | 'least-latency' | 'external-score' | any;
|
|
}
|
|
/**
|
|
* Main SDK client for Blurt Layer 1 RPC, Nexus/Bridge social views and helper APIs.
|
|
*
|
|
* A client owns endpoint failover, timeout/backoff settings and helper namespaces.
|
|
* Use `condenser`, `database`, `accountHistory` and `blockchain` for Layer 1
|
|
* reads, `nexus` for indexed Layer 2 social views, `read` for composed read
|
|
* models, and `broadcast` only for explicit signing/broadcast workflows.
|
|
*
|
|
* Can be used in Node.js >=18 and modern browsers with native `fetch` and
|
|
* `AbortController`. Also see {@link ClientOptions}.
|
|
*/
|
|
export declare class Client {
|
|
/** Client options, *immutable*. */
|
|
readonly options: ClientOptions;
|
|
/** Address to Blurt RPC server. String or String[]; *immutable after construction* */
|
|
address: string | string[];
|
|
/** Account and block operation history helper for Layer 1 history reads. */
|
|
readonly accountHistory: AccountHistoryAPI;
|
|
/** Higher-level Layer 1 block and operation iteration helper. */
|
|
readonly blockchain: Blockchain;
|
|
/** Signed Layer 1 broadcast helper. Requires appropriate private keys and has chain side effects. */
|
|
readonly broadcast: BroadcastAPI;
|
|
/** Common Layer 1 condenser API reads such as accounts, content, witnesses and properties. */
|
|
readonly condenser: CondenserAPI;
|
|
/** Appbase database API helper for lower-level Layer 1 database methods. */
|
|
readonly database: DatabaseAPI;
|
|
/** Nexus/Bridge helper for indexed Layer 2 social views. */
|
|
readonly nexus: Nexus;
|
|
/** Composed read-model helper for application-oriented summaries built from public data. */
|
|
readonly read: ReadModels;
|
|
/** Local calculation and conversion helper. */
|
|
readonly tools: Tools;
|
|
/** Transaction status helper for post-broadcast confirmation workflows. */
|
|
readonly transactionStatus: TransactionStatusAPI;
|
|
/** Chain ID for current network. */
|
|
readonly chainId: Buffer;
|
|
/** Address prefix for current network. */
|
|
readonly addressPrefix: string;
|
|
currentAddress: string;
|
|
private timeout;
|
|
private backoff;
|
|
private failoverThreshold;
|
|
private consoleOnFailover;
|
|
private transport;
|
|
/**
|
|
* @param address The address to the Blurt RPC server,
|
|
* e.g. `https://rpc.blurt.blog`. or [`https://rpc.blurt.blog`, `https://another.api.com`]
|
|
* @param options Client options.
|
|
*/
|
|
constructor(address: string | string[], options?: ClientOptions);
|
|
/**
|
|
* Make a RPC call to the server.
|
|
*
|
|
* @param api The API to call, e.g. `database_api`.
|
|
* @param method The API method, e.g. `get_dynamic_global_properties`.
|
|
* @param params Array of parameters to pass to the method, optional.
|
|
*
|
|
*/
|
|
call(api: string, method: string, params?: any): Promise<any>;
|
|
private createTransport;
|
|
}
|