ethers.js/packages/abstract-provider/lib/index.d.ts

142 lines
5.7 KiB
TypeScript
Raw Permalink Normal View History

2019-05-14 18:48:48 -04:00
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
import { BytesLike } from "@ethersproject/bytes";
import { Network } from "@ethersproject/networks";
2020-06-01 05:04:12 -04:00
import { Deferrable, Description } from "@ethersproject/properties";
2021-03-30 15:22:45 -04:00
import { AccessListish, Transaction } from "@ethersproject/transactions";
2019-05-14 18:48:48 -04:00
import { OnceBlockable } from "@ethersproject/web";
export declare type TransactionRequest = {
2020-06-01 05:04:12 -04:00
to?: string;
from?: string;
nonce?: BigNumberish;
gasLimit?: BigNumberish;
gasPrice?: BigNumberish;
data?: BytesLike;
value?: BigNumberish;
chainId?: number;
2021-03-30 15:22:45 -04:00
type?: number;
accessList?: AccessListish;
2019-05-14 18:48:48 -04:00
};
export interface TransactionResponse extends Transaction {
2019-06-11 17:57:04 -04:00
hash: string;
2019-05-14 18:48:48 -04:00
blockNumber?: number;
blockHash?: string;
timestamp?: number;
confirmations: number;
from: string;
raw?: string;
wait: (confirmations?: number) => Promise<TransactionReceipt>;
}
export declare type BlockTag = string | number;
interface _Block {
hash: string;
parentHash: string;
number: number;
timestamp: number;
nonce: string;
difficulty: number;
gasLimit: BigNumber;
gasUsed: BigNumber;
miner: string;
extraData: string;
}
export interface Block extends _Block {
transactions: Array<string>;
}
export interface BlockWithTransactions extends _Block {
transactions: Array<TransactionResponse>;
}
export interface Log {
2020-04-03 22:13:06 -04:00
blockNumber: number;
blockHash: string;
transactionIndex: number;
2020-01-18 21:48:12 -05:00
removed: boolean;
2019-05-14 18:48:48 -04:00
address: string;
data: string;
topics: Array<string>;
2020-04-03 22:13:06 -04:00
transactionHash: string;
logIndex: number;
2019-05-14 18:48:48 -04:00
}
export interface TransactionReceipt {
2020-01-18 21:48:12 -05:00
to: string;
from: string;
contractAddress: string;
transactionIndex: number;
2019-05-14 18:48:48 -04:00
root?: string;
2020-01-18 21:48:12 -05:00
gasUsed: BigNumber;
logsBloom: string;
blockHash: string;
transactionHash: string;
logs: Array<Log>;
blockNumber: number;
confirmations: number;
cumulativeGasUsed: BigNumber;
2019-05-14 18:48:48 -04:00
byzantium: boolean;
status?: number;
}
export interface EventFilter {
address?: string;
2021-05-17 16:19:36 -04:00
topics?: Array<string | Array<string> | null>;
2019-05-14 18:48:48 -04:00
}
export interface Filter extends EventFilter {
fromBlock?: BlockTag;
toBlock?: BlockTag;
}
export interface FilterByBlockHash extends EventFilter {
2020-05-21 00:07:41 -04:00
blockHash?: string;
2019-05-14 18:48:48 -04:00
}
2019-06-11 17:57:04 -04:00
export declare abstract class ForkEvent extends Description {
2019-05-14 18:48:48 -04:00
readonly expiry: number;
2020-01-07 19:58:04 -05:00
readonly _isForkEvent?: boolean;
2019-06-11 17:57:04 -04:00
static isForkEvent(value: any): value is ForkEvent;
2019-05-14 18:48:48 -04:00
}
export declare class BlockForkEvent extends ForkEvent {
2020-05-21 00:07:41 -04:00
readonly blockHash: string;
2020-01-07 19:58:04 -05:00
readonly _isBlockForkEvent?: boolean;
2020-05-21 00:07:41 -04:00
constructor(blockHash: string, expiry?: number);
2019-05-14 18:48:48 -04:00
}
export declare class TransactionForkEvent extends ForkEvent {
readonly hash: string;
2020-01-07 19:58:04 -05:00
readonly _isTransactionOrderForkEvent?: boolean;
2019-05-14 18:48:48 -04:00
constructor(hash: string, expiry?: number);
}
export declare class TransactionOrderForkEvent extends ForkEvent {
readonly beforeHash: string;
readonly afterHash: string;
constructor(beforeHash: string, afterHash: string, expiry?: number);
}
export declare type EventType = string | Array<string | Array<string>> | EventFilter | ForkEvent;
export declare type Listener = (...args: Array<any>) => void;
export declare abstract class Provider implements OnceBlockable {
abstract getNetwork(): Promise<Network>;
abstract getBlockNumber(): Promise<number>;
abstract getGasPrice(): Promise<BigNumber>;
abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
abstract getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
abstract getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
abstract getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
abstract sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
2020-06-01 05:04:12 -04:00
abstract call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
abstract estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
2019-05-14 18:48:48 -04:00
abstract getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
abstract getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<BlockWithTransactions>;
abstract getTransaction(transactionHash: string): Promise<TransactionResponse>;
abstract getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
abstract getLogs(filter: Filter): Promise<Array<Log>>;
abstract resolveName(name: string | Promise<string>): Promise<string>;
abstract lookupAddress(address: string | Promise<string>): Promise<string>;
abstract on(eventName: EventType, listener: Listener): Provider;
abstract once(eventName: EventType, listener: Listener): Provider;
abstract emit(eventName: EventType, ...args: Array<any>): boolean;
abstract listenerCount(eventName?: EventType): number;
abstract listeners(eventName?: EventType): Array<Listener>;
abstract off(eventName: EventType, listener?: Listener): Provider;
abstract removeAllListeners(eventName?: EventType): Provider;
addListener(eventName: EventType, listener: Listener): Provider;
removeListener(eventName: EventType, listener: Listener): Provider;
2020-02-04 01:06:47 -05:00
abstract waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
2019-06-11 17:57:04 -04:00
readonly _isProvider: boolean;
2019-05-14 18:48:48 -04:00
constructor();
2019-06-11 17:57:04 -04:00
static isProvider(value: any): value is Provider;
2019-05-14 18:48:48 -04:00
}
export {};
//# sourceMappingURL=index.d.ts.map