@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
241 lines (240 loc) • 9.28 kB
TypeScript
import { AE_AMOUNT_FORMATS } from './utils/amount-formatter.js';
import { AensName } from './tx/builder/constants.js';
import Node from './Node.js';
import { DryRunResult, DryRunResults, SignedTx } from './apis/node/index.js';
import { Encoded, Encoding } from './utils/encoder.js';
declare function getEventInterval(type: 'key-block' | 'micro-block', { _expectedMineRate, _microBlockCycle, onNode, }: {
_expectedMineRate?: number;
_microBlockCycle?: number;
onNode: Node;
}): Promise<number>;
/**
* @category chain
* @param type - Type
* @param options - Options
*/
export declare function _getPollInterval(type: Parameters<typeof getEventInterval>[0], options: Parameters<typeof getEventInterval>[1]): Promise<number>;
/**
* Obtain current height of the chain
* @category chain
* @param options - Options
* @param options.cached - Get height from the cache. The lag behind the actual height shouldn't
* be more than 1 block. Use if needed to reduce requests count, and approximate value can be used.
* For example, for timeout check in transaction status polling.
* @returns Current chain height
*/
export declare function getHeight({ cached, ...options }: {
onNode: Node;
cached?: boolean;
} & Parameters<typeof _getPollInterval>[1]): Promise<number>;
/**
* Return transaction details if it is mined, fail otherwise.
* If the transaction has ttl specified then would wait till it leaves the mempool.
* Otherwise would fail if a specified amount of blocks were mined.
* @category chain
* @param th - The hash of transaction to poll
* @param options - Options
* @param options.interval - Interval (in ms) at which to poll the chain
* @param options.blocks - Number of blocks mined after which to fail if transaction ttl is not set
* @param options.onNode - Node to use
* @returns The transaction as it was mined
*/
export declare function poll(th: Encoded.TxHash, { blocks, interval, ...options }: {
blocks?: number;
interval?: number;
onNode: Node;
} & Parameters<typeof _getPollInterval>[1]): ReturnType<Node['getTransactionByHash']>;
/**
* Wait for the chain to reach a specific height
* @category chain
* @param height - Height to wait for
* @param options - Options
* @param options.interval - Interval (in ms) at which to poll the chain
* @param options.onNode - Node to use
* @returns Current chain height
*/
export declare function awaitHeight(height: number, { interval, ...options }: {
interval?: number;
onNode: Node;
} & Parameters<typeof _getPollInterval>[1]): Promise<number>;
/**
* Wait for transaction confirmation
* @category chain
* @param txHash - Transaction hash
* @param options - Options
* @param options.confirm - Number of micro blocks to wait for transaction confirmation
* @param options.onNode - Node to use
* @returns Current Height
*/
export declare function waitForTxConfirm(txHash: Encoded.TxHash, { confirm, onNode, ...options }: {
confirm?: number;
onNode: Node;
} & Parameters<typeof awaitHeight>[1]): Promise<number>;
/**
* Get account by account public key
* @category chain
* @param address - Account address (public key)
* @param options - Options
* @param options.height - Get account on specific block by block height
* @param options.hash - Get account on specific block by micro block hash or key block hash
* @param options.onNode - Node to use
*/
export declare function getAccount(address: Encoded.AccountAddress | Encoded.ContractAddress, { height, hash, onNode, }: {
height?: number;
hash?: Encoded.KeyBlockHash | Encoded.MicroBlockHash;
onNode: Node;
}): ReturnType<Node['getAccountByPubkey']>;
/**
* Request the balance of specified account
* @category chain
* @param address - The public account address to obtain the balance for
* @param options - Options
* @param options.format
* @param options.height - The chain height at which to obtain the balance for
* (default: top of chain)
* @param options.hash - The block hash on which to obtain the balance for (default: top of chain)
*/
export declare function getBalance(address: Encoded.AccountAddress | Encoded.ContractAddress | Encoded.OracleAddress, {
/**
* @deprecated no replacement implemented yet
*/
format, ...options }: {
format?: AE_AMOUNT_FORMATS;
} & Parameters<typeof getAccount>[1]): Promise<string>;
/**
* Obtain current generation
* @category chain
* @param options - Options
* @param options.onNode - Node to use
* @returns Current Generation
* @deprecated Use {@link Node.getCurrentGeneration} instead
*/
export declare function getCurrentGeneration({ onNode, }: {
onNode: Node;
}): ReturnType<Node['getCurrentGeneration']>;
/**
* Get generation by hash or height
* @category chain
* @param hashOrHeight - Generation hash or height
* @param options - Options
* @param options.onNode - Node to use
* @returns Generation
* @deprecated Use {@link Node.getGenerationByHash} or {@link Node.getGenerationByHeight} instead
*/
export declare function getGeneration(hashOrHeight: Encoded.KeyBlockHash | number, { onNode }: {
onNode: Node;
}): ReturnType<Node['getGenerationByHash']>;
/**
* Get micro block transactions
* @category chain
* @param hash - Micro block hash
* @param options - Options
* @param options.onNode - Node to use
* @returns Transactions
* @deprecated Use {@link Node.getMicroBlockTransactionsByHash} instead
*/
export declare function getMicroBlockTransactions(hash: Encoded.MicroBlockHash, { onNode }: {
onNode: Node;
}): Promise<SignedTx[]>;
/**
* Get key block
* @category chain
* @param hashOrHeight - Key block hash or height
* @param options - Options
* @param options.onNode - Node to use
* @returns Key Block
* @deprecated Use {@link Node.getKeyBlockByHeight} or {@link Node.getKeyBlockByHash} instead
*/
export declare function getKeyBlock(hashOrHeight: Encoded.KeyBlockHash | number, { onNode }: {
onNode: Node;
}): ReturnType<Node['getKeyBlockByHash']>;
/**
* Get micro block header
* @category chain
* @param hash - Micro block hash
* @param options - Options
* @param options.onNode - Node to use
* @returns Micro block header
* @deprecated Use {@link Node.getMicroBlockHeaderByHash} instead
*/
export declare function getMicroBlockHeader(hash: Encoded.MicroBlockHash, { onNode }: {
onNode: Node;
}): ReturnType<Node['getMicroBlockHeaderByHash']>;
interface TxDryRunArguments {
tx: Encoded.Transaction;
accountAddress: Encoded.AccountAddress;
top?: number | Encoded.KeyBlockHash | Encoded.MicroBlockHash;
txEvents?: any;
resolve: Function;
reject: Function;
}
/**
* Transaction dry-run
* @category chain
* @param tx - transaction to execute
* @param accountAddress - address that will be used to execute transaction
* @param options - Options
* @param options.top - hash of block on which to make dry-run
* @param options.txEvents - collect and return on-chain tx events that would result from the call
* @param options.combine - Enables combining of similar requests to a single dry-run call
* @param options.onNode - Node to use
*/
export declare function txDryRun(tx: Encoded.Transaction, accountAddress: Encoded.AccountAddress, { top, txEvents, combine, onNode, }: {
top?: TxDryRunArguments['top'];
txEvents?: boolean;
combine?: boolean;
onNode: Node;
}): Promise<{
txEvents?: DryRunResults['txEvents'];
} & DryRunResult>;
/**
* Get contract byte code
* @category contract
* @param contractId - Contract address
* @param options - Options
* @param options.onNode - Node to use
* @deprecated Use {@link Node.getContractCode} instead
*/
export declare function getContractByteCode(contractId: Encoded.ContractAddress, { onNode }: {
onNode: Node;
}): ReturnType<Node['getContractCode']>;
/**
* Get contract entry
* @category contract
* @param contractId - Contract address
* @param options - Options
* @param options.onNode - Node to use
* @deprecated Use {@link Node.getContract} instead
*/
export declare function getContract(contractId: Encoded.ContractAddress, { onNode }: {
onNode: Node;
}): ReturnType<Node['getContract']>;
/**
* Get name entry
* @category AENS
* @param name - AENS name
* @param options - Options
* @param options.onNode - Node to use
* @deprecated Use {@link Node.getNameEntryByName} or {@link Name.getState} instead
*/
export declare function getName(name: AensName, { onNode }: {
onNode: Node;
}): ReturnType<Node['getNameEntryByName']>;
/**
* Resolve AENS name and return name hash
* @category AENS
* @param nameOrId - AENS name or address
* @param key - in AENS pointers record
* @param options - Options
* @param options.verify - To ensure that name exist and have a corresponding pointer
* // TODO: avoid that to don't trust to current api gateway
* @param options.resolveByNode - Enables pointer resolving using node
* @param options.onNode - Node to use
* @returns Address or AENS name hash
*/
export declare function resolveName<Type extends Encoding.AccountAddress | Encoding.ContractAddress>(nameOrId: AensName | Encoded.Generic<Type>, key: string, { verify, resolveByNode, onNode, }: {
verify?: boolean;
resolveByNode?: boolean;
onNode: Node;
}): Promise<Encoded.Generic<Type | Encoding.Name>>;
export {};