import { Wallet } from 'ethers'; import EventSource from "eventsource"; import { BundleParams, MevShareNetwork, TransactionOptions, StreamEventType, IPendingTransaction, IPendingBundle, SimBundleOptions, ISimBundleResult, ISendBundleResult, StreamEventName, EventHistoryInfo, EventHistoryParams, EventHistoryEntry } from './api/interfaces'; export default class MevShareClient { private authSigner; private network; constructor(authSigner: Wallet, network: MevShareNetwork); /** Connect to Flashbots MEV-Share node on Mainnet. */ static useEthereumMainnet(authSigner: Wallet): MevShareClient; /** Connect to Flashbots MEV-Share node on Goerli. */ static useEthereumGoerli(authSigner: Wallet): MevShareClient; /** Connect to supported networks by specifying a network with a `chainId`. */ static fromNetwork(authSigner: Wallet, { chainId }: { chainId: number | bigint; }): MevShareClient; /** Make an HTTP POST request to a JSON-RPC endpoint. * @param url - URL to send the request to. * @param payload - body & headers. * @returns Response data. */ private postRpc; /** Make an HTTP GET request. * @param urlSuffix - URL to send the request to. */ private streamGet; /** * Sends a POST request to the MEV-Share API and returns the data. * @param params - JSON-RPC params. * @param method - JSON-RPC method. * @returns Response data from the API request. */ private handleApiRequest; /** * Registers the provided callback to be called when a new MEV-Share transaction is received. * @param event - The event received from the event stream. * @param callback - Async function to process pending tx. */ private onTransaction; /** * Registers the provided callback to be called when a new MEV-Share bundle is received. * @param event - The event received from the event stream. * @param callback - Async function to process pending tx. */ private onBundle; /** * Starts listening to the MEV-Share event stream and registers the given callback to be invoked when the given event type is received. * @param eventType - The type of event to listen for. Options specified by StreamEvent enum. * @param callback - The function to call when a new event is received. * @returns Stream handler. Call `.close()` on it before terminating your program. */ on(eventType: StreamEventType | StreamEventName, callback: (data: IPendingBundle | IPendingTransaction) => void): EventSource; /** Sends a private transaction with MEV hints to the Flashbots MEV-Share node. * @param signedTx - Signed transaction to send. * @param options - Tx preferences; hints & block range. * @returns Transaction hash. */ sendTransaction(signedTx: string, options?: TransactionOptions): Promise; /** Sends a bundle to mev-share. * @param params - Parameters for the bundle. * @returns Array of bundle hashes. */ sendBundle(params: BundleParams): Promise; /** * Internal mev_simBundle call. * * Note: This may only be used on matched bundles. * Simulating unmatched bundles (i.e. bundles with a hash present) will throw an error. * @param params - Parameters for the bundle. * @param simOptions - Simulation options; override block header data for simulation. * @returns Simulation result. */ private simBundle; /** Simulates a bundle specified by `params`. * * Bundles containing pending transactions (specified by `{hash}` instead of `{tx}` in `params.body`) may * only be simulated after those transactions have landed on chain. If the bundle contains * pending transactions, this method will wait for the transactions to land before simulating. * @param params - Parameters for the bundle. * @param simOptions - Simulation options; override block header data for simulation. * @returns Simulation result. */ simulateBundle(params: BundleParams, simOptions?: SimBundleOptions): Promise; /** Gets information about query parameters for the event history endpoint. */ getEventHistoryInfo(): Promise; /** Gets past events that were broadcast via the SSE event stream. */ getEventHistory(params?: EventHistoryParams): Promise>; } //# sourceMappingURL=client.d.ts.map