UNPKG

@solsdk/jito-ts

Version:

## What is it and why do you need it?

82 lines (81 loc) 3.69 kB
import { Keypair } from '@solana/web3.js'; import { ChannelOptions, status } from '@grpc/grpc-js'; import { BundleResult } from '../../gen/block-engine/bundle'; import { SearcherServiceClient, SlotList } from '../../gen/block-engine/searcher'; import { Bundle } from './types'; import { Result } from './utils'; export declare class SearcherClientError extends Error { code: status; details: string; constructor(code: status, message: string, details: string); } export declare class SearcherClient { private client; private readonly retryOptions; constructor(client: SearcherServiceClient); private handleError; private retryWithBackoff; private isRetryableError; /** * Submits a bundle to the block-engine. * * @param bundle - The Bundle object to be sent. * @returns A Promise that resolves to the bundle's UUID (string) on successful submission. * @throws A ServiceError if there's an issue with the server while sending the bundle. */ sendBundle(bundle: Bundle): Promise<Result<string, SearcherClientError>>; /** * Retrieves tip accounts from the server. * * @returns A Promise that resolves to an array of account strings (usually public keys). * @throws A ServiceError if there's an issue with the server while fetching tip accounts. */ getTipAccounts(): Promise<Result<string[], SearcherClientError>>; /** * Retrieves connected leaders (validators) from the server. * * @returns A Promise that resolves to a map, where keys are validator identity keys (usually public keys), and values are SlotList objects. * @throws A ServiceError if there's an issue with the server while fetching connected leaders. */ getConnectedLeaders(): Promise<Result<{ [key: string]: SlotList; }, SearcherClientError>>; /** * Returns the next scheduled leader connected to the block-engine. * * @returns A Promise that resolves with an object containing: * - currentSlot: The current slot number the backend is on * - nextLeaderSlot: The slot number of the next scheduled leader * - nextLeaderIdentity: The identity of the next scheduled leader * @throws A ServiceError if there's an issue with the server while fetching the next scheduled leader. */ getNextScheduledLeader(): Promise<Result<{ currentSlot: number; nextLeaderSlot: number; nextLeaderIdentity: string; }, SearcherClientError>>; /** * Triggers the provided callback on BundleResult updates. * * @param successCallback - A callback function that receives the BundleResult updates * @param errorCallback - A callback function that receives the stream error (Error) * @returns A function to cancel the subscription */ onBundleResult(successCallback: (bundleResult: BundleResult) => void, errorCallback: (e: Error) => void): () => void; /** * Yields on bundle results. * * @param onError - A callback function that receives the stream error (Error) * @returns An async generator that yields BundleResult updates */ bundleResults(onError: (e: Error) => void): AsyncGenerator<BundleResult>; } /** * Creates and returns a SearcherClient instance. * * @param url - The URL of the SearcherService * @param authKeypair - Optional Keypair authorized for the block engine * @param grpcOptions - Optional configuration options for the gRPC client * @returns SearcherClient - An instance of the SearcherClient */ export declare const searcherClient: (url: string, authKeypair?: Keypair, grpcOptions?: Partial<ChannelOptions>) => SearcherClient;