index.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
  2. import { BytesLike } from "@ethersproject/bytes";
  3. import { Network } from "@ethersproject/networks";
  4. import { Deferrable, Description } from "@ethersproject/properties";
  5. import { AccessListish, Transaction } from "@ethersproject/transactions";
  6. import { OnceBlockable } from "@ethersproject/web";
  7. export declare type TransactionRequest = {
  8. to?: string;
  9. from?: string;
  10. nonce?: BigNumberish;
  11. gasLimit?: BigNumberish;
  12. gasPrice?: BigNumberish;
  13. data?: BytesLike;
  14. value?: BigNumberish;
  15. chainId?: number;
  16. type?: number;
  17. accessList?: AccessListish;
  18. maxPriorityFeePerGas?: BigNumberish;
  19. maxFeePerGas?: BigNumberish;
  20. customData?: Record<string, any>;
  21. ccipReadEnabled?: boolean;
  22. };
  23. export interface TransactionResponse extends Transaction {
  24. hash: string;
  25. blockNumber?: number;
  26. blockHash?: string;
  27. timestamp?: number;
  28. confirmations: number;
  29. from: string;
  30. raw?: string;
  31. wait: (confirmations?: number) => Promise<TransactionReceipt>;
  32. }
  33. export declare type BlockTag = string | number;
  34. export interface _Block {
  35. hash: string;
  36. parentHash: string;
  37. number: number;
  38. timestamp: number;
  39. nonce: string;
  40. difficulty: number;
  41. _difficulty: BigNumber;
  42. gasLimit: BigNumber;
  43. gasUsed: BigNumber;
  44. miner: string;
  45. extraData: string;
  46. baseFeePerGas?: null | BigNumber;
  47. }
  48. export interface Block extends _Block {
  49. transactions: Array<string>;
  50. }
  51. export interface BlockWithTransactions extends _Block {
  52. transactions: Array<TransactionResponse>;
  53. }
  54. export interface Log {
  55. blockNumber: number;
  56. blockHash: string;
  57. transactionIndex: number;
  58. removed: boolean;
  59. address: string;
  60. data: string;
  61. topics: Array<string>;
  62. transactionHash: string;
  63. logIndex: number;
  64. }
  65. export interface TransactionReceipt {
  66. to: string;
  67. from: string;
  68. contractAddress: string;
  69. transactionIndex: number;
  70. root?: string;
  71. gasUsed: BigNumber;
  72. logsBloom: string;
  73. blockHash: string;
  74. transactionHash: string;
  75. logs: Array<Log>;
  76. blockNumber: number;
  77. confirmations: number;
  78. cumulativeGasUsed: BigNumber;
  79. effectiveGasPrice: BigNumber;
  80. byzantium: boolean;
  81. type: number;
  82. status?: number;
  83. }
  84. export interface FeeData {
  85. maxFeePerGas: null | BigNumber;
  86. maxPriorityFeePerGas: null | BigNumber;
  87. gasPrice: null | BigNumber;
  88. }
  89. export interface EventFilter {
  90. address?: string;
  91. topics?: Array<string | Array<string> | null>;
  92. }
  93. export interface Filter extends EventFilter {
  94. fromBlock?: BlockTag;
  95. toBlock?: BlockTag;
  96. }
  97. export interface FilterByBlockHash extends EventFilter {
  98. blockHash?: string;
  99. }
  100. export declare abstract class ForkEvent extends Description {
  101. readonly expiry: number;
  102. readonly _isForkEvent?: boolean;
  103. static isForkEvent(value: any): value is ForkEvent;
  104. }
  105. export declare class BlockForkEvent extends ForkEvent {
  106. readonly blockHash: string;
  107. readonly _isBlockForkEvent?: boolean;
  108. constructor(blockHash: string, expiry?: number);
  109. }
  110. export declare class TransactionForkEvent extends ForkEvent {
  111. readonly hash: string;
  112. readonly _isTransactionOrderForkEvent?: boolean;
  113. constructor(hash: string, expiry?: number);
  114. }
  115. export declare class TransactionOrderForkEvent extends ForkEvent {
  116. readonly beforeHash: string;
  117. readonly afterHash: string;
  118. constructor(beforeHash: string, afterHash: string, expiry?: number);
  119. }
  120. export declare type EventType = string | Array<string | Array<string>> | EventFilter | ForkEvent;
  121. export declare type Listener = (...args: Array<any>) => void;
  122. export declare abstract class Provider implements OnceBlockable {
  123. abstract getNetwork(): Promise<Network>;
  124. abstract getBlockNumber(): Promise<number>;
  125. abstract getGasPrice(): Promise<BigNumber>;
  126. getFeeData(): Promise<FeeData>;
  127. abstract getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
  128. abstract getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
  129. abstract getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
  130. abstract getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
  131. abstract sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
  132. abstract call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
  133. abstract estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
  134. abstract getBlock(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
  135. abstract getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<BlockWithTransactions>;
  136. abstract getTransaction(transactionHash: string): Promise<TransactionResponse>;
  137. abstract getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
  138. abstract getLogs(filter: Filter): Promise<Array<Log>>;
  139. abstract resolveName(name: string | Promise<string>): Promise<null | string>;
  140. abstract lookupAddress(address: string | Promise<string>): Promise<null | string>;
  141. abstract on(eventName: EventType, listener: Listener): Provider;
  142. abstract once(eventName: EventType, listener: Listener): Provider;
  143. abstract emit(eventName: EventType, ...args: Array<any>): boolean;
  144. abstract listenerCount(eventName?: EventType): number;
  145. abstract listeners(eventName?: EventType): Array<Listener>;
  146. abstract off(eventName: EventType, listener?: Listener): Provider;
  147. abstract removeAllListeners(eventName?: EventType): Provider;
  148. addListener(eventName: EventType, listener: Listener): Provider;
  149. removeListener(eventName: EventType, listener: Listener): Provider;
  150. abstract waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
  151. readonly _isProvider: boolean;
  152. constructor();
  153. static isProvider(value: any): value is Provider;
  154. }
  155. //# sourceMappingURL=index.d.ts.map