@hashgraph/sdk
Version:
121 lines (120 loc) • 4.15 kB
TypeScript
/**
* @typedef {import("./Client.js").ClientConfiguration} ClientConfiguration
* @typedef {import("../account/AccountId.js").default} AccountId
*/
/**
* Represents a client for interacting with the Hedera network over the web.
* The `WebClient` class extends the base `Client` class and provides methods
* for configuring and managing connections to the Hedera network, including
* setting the network type (mainnet, testnet, previewnet) and handling
* transactions and queries.
* @augments {Client<WebChannel, *>}
*/
export default class WebClient extends Client<WebChannel, any> {
/**
* @param {string | ClientConfiguration} data
* @returns {WebClient}
*/
static fromConfig(data: string | ClientConfiguration): WebClient;
/**
* Construct a client for a specific network.
*
* It is the responsibility of the caller to ensure that all nodes in the map are part of the
* same Hedera network. Failure to do so will result in undefined behavior.
*
* The client will load balance all requests to Hedera using a simple round-robin scheme to
* chose nodes to send transactions to. For one transaction, at most 1/3 of the nodes will be
* tried.
*
* @param {{[key: string]: (string | AccountId)} | string} network
* @returns {WebClient}
*/
static forNetwork(network: {
[key: string]: (string | AccountId);
} | string): WebClient;
/**
* @param {string} network
* @returns {WebClient}
*/
static forName(network: string): WebClient;
/**
* Construct a Hedera client pre-configured for Mainnet access.
*
* @returns {WebClient}
*/
static forMainnet(): WebClient;
/**
* Construct a Hedera client pre-configured for Testnet access.
*
* @returns {WebClient}
*/
static forTestnet(): WebClient;
/**
* Construct a Hedera client pre-configured for Previewnet access.
*
* @returns {WebClient}
*/
static forPreviewnet(): WebClient;
/**
* Construct a Hedera client pre-configured for local-node access.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {WebClient}
*/
static forLocalNode(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): WebClient;
/**
* Construct a Hedera client pre-configured for Mainnet access with network update.
*
* @returns {Promise<WebClient>}
*/
static forMainnetAsync(): Promise<WebClient>;
/**
* Construct a Hedera client pre-configured for Testnet access with network update.
*
* @returns {Promise<WebClient>}
*/
static forTestnetAsync(): Promise<WebClient>;
/**
* Construct a Hedera client pre-configured for Previewnet access with network update.
*
* @returns {Promise<WebClient>}
*/
static forPreviewnetAsync(): Promise<WebClient>;
/**
* Construct a client for a specific network with optional network update.
* Updates network only if the network is not "local-node".
*
* @param {string} network
* @returns {Promise<WebClient>}
*/
static forNameAsync(network: string): Promise<WebClient>;
/**
* Construct a client configured to use mirror nodes.
* This will query the address book to get the network nodes.
*
* @param {string[] | string} mirrorNetwork
* @returns {Promise<WebClient>}
*/
static forMirrorNetwork(mirrorNetwork: string[] | string): Promise<WebClient>;
/**
* @param {ClientConfiguration} [props]
*/
constructor(props?: ClientConfiguration);
/**
* @param {string[] | string} mirrorNetwork
* @returns {this}
*/
setMirrorNetwork(mirrorNetwork: string[] | string): this;
/**
* @override
* @returns {Promise<this>}
*/
override updateNetwork(): Promise<this>;
}
export type ClientConfiguration = import("./Client.js").ClientConfiguration;
export type AccountId = import("../account/AccountId.js").default;
import WebChannel from "../channel/WebChannel.js";
import Client from "./Client.js";