import { Models, Interfaces } from '@open-rights-exchange/chain-js'; import { AlgorandAddress, AlgorandBlock, AlgorandSymbol, AlgorandTxChainResponse, AlgorandTxResult } from './models'; import { AlgoClient, AlgoClientIndexer, AlgorandChainEndpoint, AlgorandChainInfo, AlgorandChainSettings } from './models/chainModels'; export declare class AlgorandChainState implements Interfaces.ChainState { private _activeEndpoint; private _chainInfo; private _chainSettings; private _endpoints; private _isConnected; private _algoClient; private _algoClientIndexer; constructor(endpoints: AlgorandChainEndpoint[], settings?: AlgorandChainSettings); /** Return chain URL endpoints */ get activeEndpoint(): AlgorandChainEndpoint; /** * Return chain ID */ get chainId(): string; /** Return chain info - e.g. head block number */ get chainInfo(): AlgorandChainInfo; /** Return chain settings */ get chainSettings(): AlgorandChainSettings; /** Return chain URL endpoints */ get endpoints(): AlgorandChainEndpoint[]; /** Whether any information has been retrieved from the chain yet * A value here confirms that the network is working * */ get isConnected(): boolean; /** 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; getBlock(blockNumber: number): Promise>; /** Fetches data from a contract table */ fetchContractData(): Promise; /** Fetches data from a contract table */ fetchContractTable(): Promise; /** Get the balance for an account from the chain * If symbol = 'algo', returns Algo balance (in units of Algo) * Else returns the asset balance of the account for the provided symbol (asset symbol), if the symbol is valid * Returns a string representation of the value to accomodate large numbers */ fetchBalance(account: AlgorandAddress, symbol: AlgorandSymbol, tokenAddress?: AlgorandAddress): Promise<{ balance: string; }>; /** returns balance of Algos for an account (in microalgos) */ getAlgorandBalance(address: AlgorandAddress): Promise; /** returns balance of a specfied asset for an account * assetSymbol is the assetId */ getAssetBalance(address: AlgorandAddress, assetSymbol: string): Promise; /** Confirm that we've connected to the chain - throw if not */ assertIsConnected(): void; /** Submits the transaction to the chain and waits only until it gets a transaction id * Does not wait for the transaction to be finalized on the chain */ sendTransactionWithoutWaitingForConfirm(signedTransaction: string): Promise; /** Retrieve the default settings for chain communications */ static get defaultCommunicationSettings(): { blocksToCheck: number; checkInterval: number; getBlockAttempts: number; }; /** Broadcast a signed transaction to the chain /* if ConfirmType.None, returns the transaction id without waiting for further tx receipt /* if ConfirmType.After001, waits for the transaction to finalize on chain and then returns the tx receipt */ sendTransaction(signedTransaction: string, waitForConfirm?: Models.ConfirmType, communicationSettings?: Models.ChainSettingsCommunicationSettings): Promise; 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) => Promise; /** Return a transaction if its included in a block */ findBlockInTransaction(block: Partial, transactionId: string): AlgorandTxChainResponse; /** Return instance of algo sdk */ get algoClient(): AlgoClient; /** Return instance of algo sdk for sending transactions * Includes content-type: 'application/x-binary' in the header */ get algoClientIndexer(): AlgoClientIndexer; /** Searched transaction on chain by id * Throws if transaction does not exsits (this includes invalid id) */ getTransactionById(id: string): Promise; /** Gets an executed or pending transaction (by transaction hash) * A transction that has enough fees will appear on the chain and quickly be confirmed * Until the transaction is processed by the chain, this function will throw a TxNotFoundOnChain chain error */ fetchTransaction(transactionId: string): Promise<{ status: Models.TransactionStatus; transaction: any; }>; /** Gets the minimum fee (microalgo) used by any transaction * Fee per byte can fall to 0, but the minimum fee is required */ get minimumFeePerTx(): number; /** Gets recommented fee (microalgo) per byte according to network's transaction load */ get suggestedFeePerByte(): number; /** Checks for required header 'X-API_key' */ private assertEndpointHasTokenHeader; private getAlgorandConnectionSettingsForEndpoint; /** * Choose the best Chain endpoint based on health and response time */ private selectEndpoint; /** Ensure that the timeout between requests have a mimimum amount of wait */ private ensureMinIntervalRetry; /** calculates the Date and time of a block number for the connected chain */ determineBlockDateTime(blockNumber: number): Date; }