import type { TraceCallback } from "@metamask/controller-utils"; import type { TransactionController } from "@metamask/transaction-controller"; import type { BridgeClientId } from "./constants/bridge.mjs"; import { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.mjs"; import { FeatureId } from "./types.mjs"; import type { L1GasFees, GenericQuoteRequest, NonEvmFees, QuoteResponseV1, BridgeControllerState, BridgeControllerMessenger, FetchFunction, InputPrimaryDenomination } from "./types.mjs"; import { AbortReason, MetaMetricsSwapsEventSource, UnifiedSwapBridgeEventName } from "./utils/metrics/constants.mjs"; import type { RequiredEventContextFromClient } from "./utils/metrics/types.mjs"; import type { CrossChainSwapsEventProperties } from "./utils/metrics/types.mjs"; /** * The input to start polling for the {@link BridgeController} * * @param updatedQuoteRequest - The updated quote request * @param context - The context contains properties that can't be populated by the * controller and need to be provided by the client for analytics */ type BridgePollingInput = { quoteRequests: GenericQuoteRequest[]; context: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesError] & RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesRequested]; }; declare const BridgeController_base: (abstract new (...args: any[]) => { readonly "__#17@#intervalIds": Record; "__#17@#intervalLength": number | undefined; setIntervalLength(intervalLength: number): void; getIntervalLength(): number | undefined; _startPolling(input: BridgePollingInput): void; _stopPollingByPollingTokenSetId(key: string): void; readonly "__#3@#pollingTokenSets": Map>; readonly "__#3@#callbacks": Map void>>; _executePoll(input: BridgePollingInput): Promise; startPolling(input: BridgePollingInput): string; stopAllPolling(): void; stopPollingByPollingToken(pollingToken: string): void; onPollingComplete(input: BridgePollingInput, callback: (input: BridgePollingInput) => void): void; }) & typeof import("@metamask/base-controller").BaseController; export declare class BridgeController extends BridgeController_base { #private; constructor({ messenger, state, clientId, clientVersion, getLayer1GasFee, fetchFn, config, trackMetaMetricsFn, traceFn, getUseAssetsControllerForRates, }: { messenger: BridgeControllerMessenger; state?: Partial; clientId: BridgeClientId; clientVersion: string; getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee; fetchFn: FetchFunction; config?: { customBridgeApiBaseUrl?: string; }; trackMetaMetricsFn: (eventName: EventName, properties: CrossChainSwapsEventProperties) => void; traceFn?: TraceCallback; /** * When provided, called to determine whether to use AssetsController for exchange rates. * When true, rates are read from AssetsController:getExchangeRatesForBridge instead of * MultichainAssetsRatesController, TokenRatesController, and CurrencyRateController. */ getUseAssetsControllerForRates?: () => boolean; }); _executePoll: (pollingInput: BridgePollingInput) => Promise; /** * Updates the quote request at the specified index with the given parameters, then starts * polling for quotes. * * @param paramsToUpdate - The parameters to update in the quote request at the specified index * @param context - metrics context * @param quoteRequestIndex - The index of the quote request to update * @param quoteRequestCount - The number of quote requests in the UI */ updateBridgeQuoteRequestParams: (paramsToUpdate: Partial & { walletAddress: GenericQuoteRequest['walletAddress']; }, context: BridgePollingInput['context'], quoteRequestIndex?: number, quoteRequestCount?: number) => Promise; /** * Fetches quotes for specified request without updating the controller state * This method does not start polling for quotes and does not emit UnifiedSwapBridge events * * @param quoteRequest - The parameters for quote requests to fetch * @param featureId - The feature ID that maps to quoteParam overrides from LD * @param abortSignal - The abort signal to cancel all the requests * @returns A list of validated quotes */ fetchQuotes: (quoteRequest: GenericQuoteRequest, featureId: FeatureId, abortSignal?: AbortSignal | null) => Promise<(QuoteResponseV1 & L1GasFees & NonEvmFees)[]>; /** * Fetches gasless transaction data and fees for BatchSell quotes. * To use this in the clients, add a listener for the recommendedQuotes and call * this handler whenever they change. * * @param quotes - The quotes to fetch the gasless transaction data and fees for * @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature. */ updateBatchSellTrades: (quotes: (QuoteResponseV1 | null)[], stxEnabled: boolean) => Promise; stopPollingForQuotes: (reason?: AbortReason, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void; /** * Sets the location/entry point for the current swap or bridge flow. * Call this when the user enters the flow so that all internally-fired * events (InputChanged, QuotesRequested, etc.) carry the correct location. * * @param location - The entry point from which the user initiated the flow */ setLocation: (location: MetaMetricsSwapsEventSource) => void; /** * Returns the location/entry point for the current swap or bridge flow. * * @returns The entry point from which the user initiated the flow */ getLocation: () => MetaMetricsSwapsEventSource; setInputPrimaryDenomination: (inputPrimaryDenomination: InputPrimaryDenomination) => void; resetState: (reason?: AbortReason, quoteRequestIndex?: number | null, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void; /** * Sets the interval length based on the source chain */ setChainIntervalLength: () => void; /** * This method tracks cross-chain swaps events * * @param eventName - The name of the event to track * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client * @param quoteRequestIndex - The index of the quote request to track the event for * @example * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, { * location: MetaMetricsSwapsEventSource.MainView, * }); */ trackUnifiedSwapBridgeEvent: (eventName: EventName, propertiesFromClient: Pick[EventName], quoteRequestIndex?: number) => void; } export {}; //# sourceMappingURL=bridge-controller.d.mts.map