import { Api, JsonRpc, RpcInterfaces } from 'eosjs'; import { Models, Interfaces } from '@open-rights-exchange/chain-js'; import { EosChainEndpoint, EosChainSettings, EosEntityName, EOSGetTableRowsParams, EosSignature, EosSymbol, EosTransactionHistory, EosTxResult } from './models'; export declare class EosChainState implements Interfaces.ChainState { private eosChainInfo; private _activeEndpoint; private _chainInfo; private _chainSettings; private _endpoints; private _isConnected; private _signatureProvider; private _rpc; private _api; constructor(endpoints: EosChainEndpoint[], settings?: EosChainSettings); /** apply default value - override defaults with incoming settings */ private applyDefaultSettings; /** Return chain URL endpoints */ get activeEndpoint(): EosChainEndpoint; /** Return chain ID */ get chainId(): string; /** Return chain info - e.g. head block number */ get chainInfo(): Models.ChainInfo; /** Return chain settings */ get chainSettings(): EosChainSettings; /** Return chain URL endpoints */ get endpoints(): EosChainEndpoint[]; /** Whether any information has been retrieved from the chain yet * A value here confirms that the network is working * */ get isConnected(): boolean; /** Return instance of EOSJS API */ get api(): Api; /** Return instance of EOSJS JsonRpc */ get rpc(): JsonRpc; /** Connect to chain endpoint to verify that it is operational and to get latest block info */ connect(): Promise; /** Retrieve lastest chain info including head block number and time */ getChainInfo(): Promise; /** Choose the best Chain endpoint based on health and response time */ private selectEndpoint; /** Configure fetch object with heaqders from chainEndpoint (if any) */ private configureFetchForEndpoint; /** Retrieve a specific block from the chain */ getBlock(blockNumber: number): Promise; static get defaultEOSGetTableRowsParams(): Partial; /** Generic wrapper that in turn calls EOS get_table_rows to fetch data from a contract table */ fetchContractData(contract: EosEntityName, table: string, owner: EosEntityName, indexNumber: number, lowerRow: number, upperRow: number, limit: number, reverseOrder: boolean, showPayer: boolean, keyType: string): Promise; /** Calls EOS get_table_rows to fetch data from a contract table */ fetchContractTable(params: EOSGetTableRowsParams): Promise; /** Get the token balance for an account from the chain */ fetchBalance(account: EosEntityName, symbol: EosSymbol, tokenAddress: EosEntityName): Promise<{ balance: string; }>; /** Confirm that we've connected to the chain - throw if not */ assertIsConnected(): void; /** Return a transaction if its included in a block */ findBlockInTransaction: (block: any, transactionId: string) => any; /** Retrieve the default settings for chain communications */ static get defaultCommunicationSettings(): { blocksToCheck: number; checkInterval: number; getBlockAttempts: number; }; /** Broadcast a signed transaction to the chain */ sendTransaction(signedTransaction: { signatures: EosSignature[]; serializedTransaction: any; }, waitForConfirm?: Models.ConfirmType, communicationSettings?: Models.ChainSettingsCommunicationSettings): Promise; /** Polls the chain until it finds a block that includes the specific transaction Useful when committing sequential transactions with inter-dependencies (must wait for the first one to commit before submitting the next one) transactionResult: The value return to the function calling sendTransaction() - includes response body from submitting the transaction to the chain and transactionId waitForConfirm an enum that specifies how long to wait before 'confirming transaction' and resolving the promise with the tranasction results startFromBlockNumber = first block to start looking for the transaction to appear in blocksToCheck = the number of blocks to check, after committing the transaction, before giving up checkInterval = the time between block checks in MS getBlockAttempts = the number of failed attempts at retrieving a particular block, before giving up */ private awaitTransaction; /** While processing awaitTransaction, check if we've reached our limits to wait * Otherwise, schedule next check */ private checkIfAwaitConditionsReached; /** block has reached the confirmation level requested */ hasReachedConfirmLevel: (transactionBlockNumber: number, waitForConfirm: Models.ConfirmType, blocksToCheck: number) => Promise; /** Return transaction from chain by TxId * IMPORTANT: This requires that the chain endpoint is running the depricated history plugin - likley to fail */ getTransactionHistoryById(id: string, blockHint?: number): Promise; /** Gets an executed or pending transaction (by transaction hash) */ fetchTransaction(transactionId: string): Promise<{ status: Models.TransactionStatus; transaction: EosTransactionHistory; }>; /** Access to underlying eosjs sdk * Warning! You use chainjs functions wherever possible and only use this sdk as an escape hatch */ get eosjs(): { api: Api; jsonRpc: JsonRpc; }; }