@hashgraph/sdk
Version:
171 lines (170 loc) • 5.9 kB
TypeScript
/**
* @typedef {import("./Client.js").ClientConfiguration} ClientConfiguration
* @typedef {import("../account/AccountId.js").default} AccountId
*/
/**
* @augments {Client<NodeChannel, NodeMirrorChannel>}
* Client for interacting with the Hedera network using Node.js.
* Extends the base Client class with Node.js specific implementations.
*/
export default class NodeClient extends Client<NodeChannel, NodeMirrorChannel> {
/**
* @param {string | ClientConfiguration} data
* @returns {NodeClient}
*/
static fromConfig(data: string | ClientConfiguration): NodeClient;
/**
* @param {string} filename
* @returns {Promise<NodeClient>}
*/
static fromConfigFile(filename: string): Promise<NodeClient>;
/**
* 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)}} network
* @param {ClientConfiguration} [props]
* @returns {NodeClient}
*/
static forNetwork(network: {
[key: string]: (string | AccountId);
}, props?: ClientConfiguration): NodeClient;
/**
* @param {string} network
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {NodeClient}
*/
static forName(network: string, props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): NodeClient;
/**
* Construct a Hedera client pre-configured for Mainnet access.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {NodeClient}
*/
static forMainnet(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): NodeClient;
/**
* Construct a Hedera client pre-configured for Testnet access.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {NodeClient}
*/
static forTestnet(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): NodeClient;
/**
* @param {string[] | string} mirrorNetwork
* @param {number} [shard]
* @param {number} [realm]
* @returns {Promise<NodeClient>}
*/
static forMirrorNetwork(mirrorNetwork: string[] | string, shard?: number, realm?: number): Promise<NodeClient>;
/**
* Construct a Hedera client pre-configured for Previewnet access.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {NodeClient}
*/
static forPreviewnet(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): NodeClient;
/**
* Construct a Hedera client pre-configured for local-node access.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {NodeClient}
*/
static forLocalNode(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): NodeClient;
/**
* Construct a Hedera client pre-configured for Mainnet access with network update.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {Promise<NodeClient>}
*/
static forMainnetAsync(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): Promise<NodeClient>;
/**
* Construct a Hedera client pre-configured for Testnet access with network update.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {Promise<NodeClient>}
*/
static forTestnetAsync(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): Promise<NodeClient>;
/**
* Construct a Hedera client pre-configured for Previewnet access with network update.
*
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {Promise<NodeClient>}
*/
static forPreviewnetAsync(props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): Promise<NodeClient>;
/**
* Construct a client for a specific network with optional network update.
* Updates network only if the network is not "local-node".
*
* @param {string} network
* @param {object} [props]
* @param {boolean} [props.scheduleNetworkUpdate]
* @returns {Promise<NodeClient>}
*/
static forNameAsync(network: string, props?: {
scheduleNetworkUpdate?: boolean | undefined;
}): Promise<NodeClient>;
/**
* @param {ClientConfiguration} [props]
*/
constructor(props?: ClientConfiguration);
/** @private */
private _maxExecutionTime;
/**
* Available only for NodeClient
*
* @param {number} maxExecutionTime
* @returns {this}
*/
setMaxExecutionTime(maxExecutionTime: number): this;
/**
* @private
* @param {string} name
* @returns {this}
*/
private _setNetworkFromName;
/**
* @param {string[] | string} mirrorNetwork
* @returns {this}
*/
setMirrorNetwork(mirrorNetwork: string[] | string): this;
/**
* @override
* @returns {(address: string, cert?: string) => NodeChannel}
*/
override _createNetworkChannel(): (address: string, cert?: string) => NodeChannel;
}
export type ClientConfiguration = import("./Client.js").ClientConfiguration;
export type AccountId = import("../account/AccountId.js").default;
import NodeChannel from "../channel/NodeChannel.js";
import NodeMirrorChannel from "../channel/NodeMirrorChannel.js";
import Client from "./Client.js";