UNPKG

@tangany/waas

Version:

node.js SDK for Tangany Wallet as a Service API

120 lines (119 loc) 6.45 kB
import { BlockchainWallet } from "./blockchain-wallet"; import { EthContractWallet } from "./eth-contract-wallet"; import { EthErc20Wallet } from "./eth-erc20-wallet"; import { EthTransaction } from "./eth-transaction"; import { EthTransactionRequest } from "./eth-transaction-request"; import { ISearchOptions } from "./interfaces/common"; import { IEthereumPersonalSignature, IEthereumRecipient, IEthereumRecipientNoData, IEthereumTransactionEstimation, IEthWalletBalance, IWalletTransactionSearchParams } from "./interfaces/ethereum"; import { ITransmittableTransaction } from "./interfaces/signature"; import { EthTransactionIterable } from "./iterables/auto-pagination/eth-transaction-iterable"; import { EthTransactionPageIterable } from "./iterables/pagewise/eth-transaction-page-iterable"; import { Monitor } from "./monitor"; import { Waas } from "./waas"; import { Wallet } from "./wallet"; /** * Instantiates a new Ethereum wallet interface * @param instance - axios instance created by {@link Waas} * @param limiter - Bottleneck limiter instance * @param walletInstance - instance of Wallet class */ export declare class EthWallet extends BlockchainWallet { constructor(waas: Waas, walletInstance: Wallet); /** * Returns wallet metrics for the Ethereum blockchain like ether balance and the address * @see [docs]{@link https://docs.tangany.com/#0d926cca-e0bd-4045-864d-18845425adfe} */ get(): Promise<IEthWalletBalance>; /** * Sends Ether to address from given wallet * @param recipient - {@link IEthereumRecipient} * @see [docs]{@link https://docs.tangany.com/#1d76974c-579a-47aa-9912-c7cfddf55889} * @deprecated Use {@link sendAsync} instead */ send(recipient: IEthereumRecipient): Promise<EthTransaction>; /** * Sends Ether to address from given wallet *asynchronously* * @param recipient - {@link IEthereumRecipientNoData} * @see [docs]{@link https://docs.tangany.com/#29e9ed85-f4a1-42bc-88fa-8e1f96fb426f} */ sendAsync(recipient: IEthereumRecipientNoData): Promise<EthTransactionRequest>; /** * Creates an RLP encoded transaction that is already signed and can be manually transmitted * to compatible blockchain networks at a later stage. * @param recipient - {@link IEthereumRecipient} * @see [docs]{@link https://docs.tangany.com/#925fd26a-daff-4321-9595-8509dd2ed6b3} * @deprecated This synchronous version is deprecated, but in the future there will be an asynchronous version */ sign(recipient: IEthereumRecipient): Promise<ITransmittableTransaction>; /** * Returns the fee estimation for a transaction with the given parameters * The fee estimation is based on the current ethereum network utilization and can fluctuate in random fashion. * Thus the estimation cannot guarantee to match the actual transaction fee. * @param recipient - {@link IEthereumRecipient} */ estimateFee(recipient: IEthereumRecipient): Promise<IEthereumTransactionEstimation>; /** * Returns the signature of the given string payload * The payload formatted in the following way: `"\x19Ethereum Signed Message:\n" + message.length + message`. * It is then hashed using keccak256 and finally signed using the wallet`s private key. * @param payload - the string to be signed */ personalSign(payload: string): Promise<IEthereumPersonalSignature>; /** * Returns an asynchronous iterable to iterate **page by page** through the transactions that matched the search parameters. * @param [params] - Optional search parameters * @see [docs]{@link https://docs.tangany.com/#63266651-76f9-4a4c-a971-0a39d6ede955} */ getTransactions(params?: IWalletTransactionSearchParams): EthTransactionPageIterable; /** * Returns an asynchronous iterable that yields **one transaction object per iteration**. * A page of transactions that match the search parameters is fetched and saved once, so that all items can be returned one by one. * After that, the next page is loaded from the API and processed item by item again. * @param [params] - Optional search parameters * @param [options] - Additional options that do not affect the API request but the SDK-side processing * @see [docs]{@link https://docs.tangany.com/#63266651-76f9-4a4c-a971-0a39d6ede955} */ getTransactions(params?: IWalletTransactionSearchParams, options?: { autoPagination: true; }): EthTransactionIterable; /** * Returns an asynchronous iterable to iterate **page by page** through the transactions that matched the search parameters. * @param [params] - Optional search parameters * @param [options] - Additional options that do not affect the API request but the SDK-side processing * @see [docs]{@link https://docs.tangany.com/#63266651-76f9-4a4c-a971-0a39d6ede955} */ getTransactions(params?: IWalletTransactionSearchParams, options?: ISearchOptions): EthTransactionPageIterable; /** * Returns wallet calls for the Ethereum ERC20 token * @param tokenAddress - Ethereum ERC20 token address for given eth network */ erc20(tokenAddress: string): EthErc20Wallet; /** * Returns wallet calls for universal Smart Contract method calling */ contract(address: string): EthContractWallet; /** * Returns an object to interact with monitors related to the current wallet. * @param [id] - Monitor id that must be passed if a specific monitor is to be addressed */ monitor(id?: string): Monitor; /** * @deprecated Do not use this outside unit testing */ __test_validateRecipient: (...args: any) => void; /** * @deprecated Do not use this outside unit testing */ __test_validateRecipientNoData: (...args: any) => void; /** * Throws an exception if the passed recipient is invalid or otherwise ends successfully without a return value. * @param recipient - Recipient to be validated ({@link IEthereumRecipient}) */ private validateRecipient; /** * Throws an exception if the passed recipient is invalid or otherwise ends successfully without a return value * Special case for sendAsync method: recipient must not contain property data * @param recipient - Recipient to be validated ({@link IEthereumRecipientNoData}) */ private validateRecipientNoData; }