@kaiachain/ethers-ext
Version:
ethers.js extension for kaia blockchain
31 lines (30 loc) • 2.62 kB
TypeScript
import { Provider, TransactionLike, TransactionResponse, SigningKey, Transaction } from "ethers";
import { SignatureLike } from "@kaiachain/js-ext-core";
import { TransactionRequest } from "./types.js";
export declare function getTransactionRequest(transactionOrRLP: TransactionRequest | string | Transaction): Promise<TransactionLike<string>>;
export declare function populateFrom(tx: TransactionRequest, expectedFrom: string): Promise<void>;
export declare function populateTo(tx: TransactionRequest, provider: Provider | null): Promise<void>;
export declare function populateNonce(tx: TransactionRequest, provider: Provider | null, fromAddress: string): Promise<void>;
export declare function populateGasLimit(tx: TransactionRequest, provider: Provider | null): Promise<void>;
export declare function populateGasPrice(tx: TransactionRequest, provider: Provider | null): Promise<void>;
export declare function eip155sign(key: SigningKey, digest: string, chainId: number): SignatureLike;
export declare function populateChainId(tx: TransactionRequest, provider: Provider | null): Promise<void>;
export declare function populateFeePayerAndSignatures(tx: TransactionRequest, expectedFeePayer: string): Promise<void>;
/**
* Delay the execution inside an async function in miliseconds.
*
* @param time (miliseconds) the amount of time to be delayed.
*/
export declare function sleep(time: number): Promise<void>;
/**
* The poll function implements a retry mechanism for asynchronous operations.
* It repeatedly calls the callback function to fetch data and then uses the
* verify function to check if the retrieved data meets the desired criteria.
*
* @param callback A callback function that is responsible for fetching or retrieving data. It should be an asynchronous function that returns a Promise.
* @param verify A callback function that determines if the retrieved data meets the desired criteria. It should accept the data returned by callback and return a boolean value (true if the data is valid, false otherwise).
* @param retries (optional): An integer specifying the maximum number of times the function will attempt to poll before giving up. Defaults to 100.
* @returns A Promise that resolves to the data retrieved by callback when the verify function returns true, or rejects with an error if the maximum number of retries is reached.
*/
export declare function poll<T>(callback: () => Promise<T | null>, verify: CallableFunction, retries?: number): Promise<T>;
export declare function pollTransactionInPool(txhash: string, provider: Provider): Promise<TransactionResponse>;