import type { Contract } from '@ethersproject/contracts'; import type { Filter, JsonRpcProvider, Log, Network, Provider } from '@ethersproject/providers'; import type { Observable } from 'rxjs'; import type { TypedEvent, TypedEventFilter, TypedListener } from '../contracts/common'; import { HexString } from './types'; declare const _event: unique symbol; /** * A simple Log, but tagged (at typecheck-time) to indicate the logs will map to a specific * TypedEvent/EventTuple */ export interface LogWithEvent extends Log { readonly [_event]: E; } declare type EventFromLog> = L[typeof _event]; declare type EventFromFilter = F extends TypedEventFilter ? E : never; declare type BlockRange = { fromBlock: number; toBlock: number; }; declare type MultiFilter = Omit & { address?: string | string[]; }; /** * Extract the union of TypedEventFilters for a given contract */ export declare type ContractFilter = ReturnType; export declare type ContractEvent = EventFromFilter>; /** * For given TypedEventFilters, return the tuple of arguments plus the TypedEvent as last element */ export declare type EventTuple = Parameters>; export declare function getLogsByChunk$>(provider: JsonRpcProvider, filter: F & BlockRange, chunk?: number, minChunk?: number): Observable>>; export declare function getLogsByChunk$(provider: JsonRpcProvider, filter: MultiFilter & BlockRange, chunk?: number, minChunk?: number): Observable; export declare function fromEthersEvent(target: JsonRpcProvider, event: string | string[]): Observable; export declare function fromEthersEvent>(target: JsonRpcProvider, event: F, opts?: { fromBlock?: number; confirmations?: number | Observable; blockNumber$?: Observable; onPastCompleted?: (elapsedMs: number) => void; }): Observable>>; export declare function fromEthersEvent(target: JsonRpcProvider, event: Filter, opts?: { fromBlock?: number; confirmations?: number | Observable; blockNumber$?: Observable; onPastCompleted?: (elapsedMs: number) => void; }): Observable; /** * Function to map an ethers's Provider log to a contract event tuple * It requires logs coming from getLogsByChunk$ or fromEthersEvent overloads which tag at * type-check time to which set of events the logs belong, and use that information to narrow * the types of the tuple events emitted * * @param contract - Contract fo parse logs for * @returns Function to map logs to event tuples for contract */ export declare function logToContractEvent(contract: C): >>>(log: L) => [...EventFromLog extends infer T ? T extends EventFromLog ? T extends TypedEvent ? any[] : never : never : never, EventFromLog]; /** * Return a network name, if known, or stringified chainId otherwise * * @param network - Network to get name from * @returns name or chainId as string */ export declare function getNetworkName(network: Network): string; /** * Verify that contract has given method * * @param sighash - method to search for, as signature hash * @param contract - Contract-like interface * @param contract.address - Contract's address * @param contract.provider - Contract's provider * @returns truthy if contract has a method with given signature */ export declare function contractHasMethod(sighash: HexString<4>, { address, provider }: { address: string; provider: Provider; }): Promise; /** * Fetches contract's code and parse if it has given method (by name) * * @param contract - contract instance to check * @param method - method name * @returns Observable of true, emitting a single value if successful, or erroring */ export declare function checkContractHasMethod$(contract: C, method: keyof C['functions'] & string): Observable; export {};