UNPKG

@ellcrys/spell

Version:

The official JavaScript library for Ellcrys

120 lines (119 loc) 3.04 kB
import RPCClient from "../rpcclient"; import Namespace from "./namespace"; /** * Read the state of the Ellcrys blockchain * on a client. * * @export * @class State */ export default class State extends Namespace { /** * Creates an instance of State. * * @param {RPCClient} client * @memberof State */ constructor(client: RPCClient); /** * Get a block by number * * @param {number} num The block number/height * @returns {Promise<Block>} * @memberof State */ getBlock(num: number): Promise<Block>; /** * Get a block by block Hash * * @param {string} blockHash The hash of the block. * @returns {Promise<Block>} * @memberof State */ getBlockByHash(blockHash: string): Promise<Block>; /** * Get the current difficulty and total difficulty * of the network. * * @returns * @memberof State */ getDifficulty(): Promise<Difficulty>; /** * Get all the account on the network * * @returns {Promise<Account[]>} * @memberof State */ listAccounts(): Promise<Account[]>; /** * Get a list of re-organization events * that have occurred from the node's * perspective * * @returns {Promise<ReOrgInfo[]>} * @memberof State */ getReOrgs(): Promise<ReOrgInfo[]>; /** * Get a list of top accounts on the network. * * @param {number} limit The maximum number of top accounts to return * @returns {Promise<Account[]>} * @memberof State */ listTopAccounts(limit: number): Promise<Account[]>; /** * Get a specific account on the network * * @param {string} address The address of the accounts * @returns {Promise<Account>} * @memberof State */ getAccount(address: string): Promise<Account>; /** * Get the nonce of a given address * * @param {string} address The address whose nonce will be fetched * @returns {Promise<number>} * @memberof State */ getAccountNonce(address: string): Promise<number>; /** * Get a transaction by its hash * * @param {string} txHash The transaction's hash * @returns {Promise<Transaction>} * @memberof State */ getTransaction(txHash: string): Promise<Transaction>; /** * Get all the known branches on the node * * @returns {Promise<Branches[]>} * @memberof State */ getBranches(): Promise<Branches[]>; /** * Get orphan blocks on the node * * @returns {Promise<Block>} * @memberof State */ getOrphans(): Promise<Block>; /** * Get the best chain on the node * * @returns {Promise<Chain>} * @memberof State */ getBestChain(): Promise<Chain>; /** * Returns raw db objects (Debug only) * * @param {JSON} filter Filter parameters * @returns {Promise<any>} * @memberof State */ getObjects(filter: JSON): Promise<any>; }