@metamask/bridge-controller 64.4.1 → 64.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [64.5.0]
11
+
12
+ ### Added
13
+
14
+ - Add `has_gas_included_quote` property to `QuoteFetchData` type and compute it in `QuotesReceived` event to indicate if any received quote has gas included ([#7611](https://github.com/MetaMask/core/pull/7611))
15
+ - Add optional `usd_balance_source` property to `QuotesReceived` event and `getQuotesReceivedProperties` utility to allow clients to pass the source token balance in USD ([#7611](https://github.com/MetaMask/core/pull/7611))
16
+
17
+ ### Changed
18
+
19
+ - Bump `@metamask/assets-controllers` from `^95.1.0` to `^95.2.0` ([#7622](https://github.com/MetaMask/core/pull/7622))
20
+
10
21
  ## [64.4.1]
11
22
 
12
23
  ### Changed
@@ -987,7 +998,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
987
998
 
988
999
  - Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
989
1000
 
990
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.4.1...HEAD
1001
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.5.0...HEAD
1002
+ [64.5.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.4.1...@metamask/bridge-controller@64.5.0
991
1003
  [64.4.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.4.0...@metamask/bridge-controller@64.4.1
992
1004
  [64.4.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.3.0...@metamask/bridge-controller@64.4.0
993
1005
  [64.3.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@64.2.0...@metamask/bridge-controller@64.3.0
@@ -510,6 +510,7 @@ class BridgeController extends (0, polling_controller_1.StaticIntervalPollingCon
510
510
  quotes_count: this.state.quotes.length,
511
511
  quotes_list: this.state.quotes.map(({ quote }) => (0, properties_1.formatProviderLabel)(quote)),
512
512
  initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,
513
+ has_gas_included_quote: this.state.quotes.some(({ quote }) => quote.gasIncluded),
513
514
  };
514
515
  });
515
516
  _BridgeController_getEventProperties.set(this, (eventName, propertiesFromClient) => {
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller.cjs","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAqD;AACrD,wDAAoD;AACpD,wDAAwD;AAIxD,mEAAuD;AACvD,qEAA+E;AAK/E,mDAM4B;AAC5B,mDAA+C;AAC/C,iDAA6D;AAC7D,mDAA+C;AAC/C,+CAA+D;AAC/D,uCAAwC;AAWxC,+CAAsE;AACtE,iDAAuD;AACvD,+CAMwB;AACxB,iEAIiC;AACjC,6DAG+B;AAC/B,6CAIuB;AACvB,6DAImC;AACnC,+DAQoC;AAOpC,6CAAgE;AAChE,uDAAwD;AACxD,6CAA4E;AAG5E,MAAM,QAAQ,GAAyC;IACrD,YAAY,EAAE;QACZ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,MAAM,EAAE;QACN,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,qBAAqB,EAAE;QACrB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,iBAAiB,EAAE;QACjB,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,KAAK;QACd,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,IAAI;KACf;IACD,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wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n await this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort('New quote request');\n this.#abortController = new AbortController();\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n };\n };\n\n readonly #getEventProperties = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ): CrossChainSwapsEventProperties<T> => {\n const baseProperties = {\n ...propertiesFromClient,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<T>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
1
+ {"version":3,"file":"bridge-controller.cjs","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAqD;AACrD,wDAAoD;AACpD,wDAAwD;AAIxD,mEAAuD;AACvD,qEAA+E;AAK/E,mDAM4B;AAC5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BAAqB,CAClC,GAAG,+BAAsB,8BAA8B,EACvD,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5C,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAClC,GAAG,+BAAsB,uBAAuB,EAChD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CACrC,CAAC;QACF,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAClC,GAAG,+BAAsB,cAAc,EACvC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5B,CAAC;IACJ,CAAC;CAoxBF;AA93BD,4CA83BC;+zCA3OG,aAAoD;IAEpD,MAAM,YAAY,GAAG,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC;IAC5E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,wCAAwC,EACxC,YAAY,CACb,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,qGAE0B,OAAY;IACrC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,gDAAgD,EAChD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n await this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort('New quote request');\n this.#abortController = new AbortController();\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n has_gas_included_quote: this.state.quotes.some(\n ({ quote }) => quote.gasIncluded,\n ),\n };\n };\n\n readonly #getEventProperties = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ): CrossChainSwapsEventProperties<T> => {\n const baseProperties = {\n ...propertiesFromClient,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<T>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller.d.cts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAIhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yCAAyC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA2B;AACzD,OAAO,EACL,sBAAsB,EAKvB,+BAA2B;AAM5B,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EAEV,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACd,oBAAgB;AAwBjB,OAAO,EACL,WAAW,EAEX,0BAA0B,EAC3B,sCAAkC;AAUnC,OAAO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qB,CAAC,SAAS,CAAC,eAAe,CAAC;QACxE,OAAO,EAAE,aAAa,CAAC;QACvB,MAAM,CAAC,EAAE;YACP,sBAAsB,CAAC,EAAE,MAAM,CAAC;SACjC,CAAC;QACF,kBAAkB,EAAE,CAClB,CAAC,SACC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,EAE9E,SAAS,EAAE,CAAC,EACZ,UAAU,EAAE,8BAA8B,CAAC,CAAC,CAAC,KAC1C,IAAI,CAAC;QACV,OAAO,CAAC,EAAE,aAAa,CAAC;KACzB;IAiDD,YAAY,iBAAwB,kBAAkB,mBAEpD;IAEF,8BAA8B,mBACZ,QAAQ,mBAAmB,CAAC,GAAG;QAC7C,aAAa,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;KACrD,WACQ,kBAAkB,CAAC,SAAS,CAAC,mBAyDtC;IAEF;;;;;;;;OAQG;IACH,WAAW,iBACK,mBAAmB,gBACpB,WAAW,GAAG,IAAI,cACpB,SAAS,GAAG,IAAI,KAC1B,QAAQ,CAAC,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,CA+BpD;IAwJF,oBAAoB,YACT,WAAW,YACV,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,UAYnF;IAEF,UAAU,iCAoBR;IAEF;;OAEG;IACH,sBAAsB,aAUpB;IA2ZF;;;;;;;;;OASG;IACH,2BAA2B,iIAoBzB;CA+BH"}
@@ -507,6 +507,7 @@ export class BridgeController extends StaticIntervalPollingController() {
507
507
  quotes_count: this.state.quotes.length,
508
508
  quotes_list: this.state.quotes.map(({ quote }) => formatProviderLabel(quote)),
509
509
  initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,
510
+ has_gas_included_quote: this.state.quotes.some(({ quote }) => quote.gasIncluded),
510
511
  };
511
512
  });
512
513
  _BridgeController_getEventProperties.set(this, (eventName, propertiesFromClient) => {
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-controller.m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I,CACzC,wCAAwC,EACxC,YAAY,CACb,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,qGAE0B,OAAY;IACrC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,gDAAgD,EAChD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n await this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort('New quote request');\n this.#abortController = new AbortController();\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n };\n };\n\n readonly #getEventProperties = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ): CrossChainSwapsEventProperties<T> => {\n const baseProperties = {\n ...propertiesFromClient,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<T>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
1
+ {"version":3,"file":"bridge-controller.mjs","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,iCAAiC;AACrD,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AACpD,OAAO,EAAE,YAAY,EAAE,iCAAiC;AAIxD,OAAO,EAAE,QAAQ,EAAE,oCAAoC;AACvD,OAAO,EAAE,+BAA+B,EAAE,qCAAqC;AAK/E,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,mBAAmB,EACpB,+BAA2B;AAC5B,OAAO,EAAE,SAAS,EAAE,+BAA2B;AAC/C,OAAO,EAAE,wBAAwB,EAAE,8BAA0B;AAC7D,OAAO,EAAE,SAAS,EAAE,+BAA2B;AAC/C,OAAO,EAAE,gCAAgC,EAAE,wBAAoB;AAC/D,OAAO,EAAE,aAAa,EAAE,oBAAgB;AAWxC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,2BAAuB;AACtE,OAAO,EAAE,oBAAoB,EAAE,4BAAwB;AACvD,OAAO,EACL,+BAA+B,EAC/B,YAAY,EACZ,SAAS,EACT,eAAe,EACf,eAAe,EAChB,2BAAuB;AACxB,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,EACnB,oCAAgC;AACjC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EAC1B,kCAA8B;AAC/B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACvB,0BAAsB;AACvB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,0BAA0B,EAC3B,sCAAkC;AACnC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,2BAA2B,EAC5B,uCAAmC;AAOpC,OAA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,YAAY,GAAG,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC;IAC5E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,wCAAwC,EACxC,YAAY,CACb,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,qGAE0B,OAAY;IACrC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,gDAAgD,EAChD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n properties: CrossChainSwapsEventProperties<T>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n await this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort('New quote request');\n this.#abortController = new AbortController();\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n has_gas_included_quote: this.state.quotes.some(\n ({ quote }) => quote.gasIncluded,\n ),\n };\n };\n\n readonly #getEventProperties = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ): CrossChainSwapsEventProperties<T> => {\n const baseProperties = {\n ...propertiesFromClient,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n T extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: T,\n propertiesFromClient: Pick<RequiredEventContextFromClient, T>[T],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<T>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
@@ -69,7 +69,7 @@ const isCustomSlippage = (slippage) => {
69
69
  return slippage !== bridge_1.DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;
70
70
  };
71
71
  exports.isCustomSlippage = isCustomSlippage;
72
- const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmittable = true, recommendedQuote) => {
72
+ const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmittable = true, recommendedQuote, usdBalanceSource) => {
73
73
  const provider = activeQuote ? (0, exports.formatProviderLabel)(activeQuote.quote) : '_';
74
74
  return {
75
75
  can_submit: isSubmittable,
@@ -80,6 +80,7 @@ const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmittable =
80
80
  : 0,
81
81
  usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),
82
82
  usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),
83
+ usd_balance_source: usdBalanceSource ?? 0,
83
84
  best_quote_provider: recommendedQuote
84
85
  ? (0, exports.formatProviderLabel)(recommendedQuote.quote)
85
86
  : provider,
@@ -1 +1 @@
1
- {"version":3,"file":"properties.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAO9C,uDAAyE;AACzE,2CAAsC;AAQtC,0CAAmE;AACnE,4DAG4B;AAEf,QAAA,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,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AC;KACrE,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,2BAA2B,+BAuBtC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\n\nimport { MetricsSwapType } from './constants';\nimport type {\n InputKeys,\n InputValues,\n QuoteWarning,\n RequestParams,\n} from './types';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport { ChainId } from '../../types';\nimport type {\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteRequest,\n QuoteResponse,\n TxData,\n} from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = ({\n srcChainId,\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n}: Partial<GenericQuoteRequest>): Omit<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n> => {\n // Fallback to ETH if srcChainId is not defined. This is ok since the clients default to Ethereum as the source chain\n // This also doesn't happen at runtime since the quote request is validated before metrics are published\n const srcChainIdCaip = formatChainIdToCaip(srcChainId ?? ChainId.ETH);\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\n/**\n * @param slippage - The slippage percentage\n * @returns Whether the default slippage was overridden by the user\n *\n * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.\n */\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n\nexport const getQuotesReceivedProperties = (\n activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>),\n warnings: QuoteWarning[] = [],\n isSubmittable: boolean = true,\n recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>),\n) => {\n const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';\n return {\n can_submit: isSubmittable,\n gas_included: Boolean(activeQuote?.quote?.gasIncluded),\n gas_included_7702: Boolean(activeQuote?.quote?.gasIncluded7702),\n quoted_time_minutes: activeQuote?.estimatedProcessingTimeInSeconds\n ? activeQuote.estimatedProcessingTimeInSeconds / 60\n : 0,\n usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),\n usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),\n best_quote_provider: recommendedQuote\n ? formatProviderLabel(recommendedQuote.quote)\n : provider,\n provider,\n warnings,\n price_impact: Number(activeQuote?.quote.priceData?.priceImpact ?? 0),\n };\n};\n"]}
1
+ {"version":3,"file":"properties.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAO9C,uDAAyE;AACzE,2CAAsC;AAQtC,0CAAmE;AACnE,4DAG4B;AAEf,QAAA,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEW,QAAA,2BAA2B,GAOpC;IACF,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU;QACR,CAAC,CAAC,IAAA,wCAAsB,EAAC,eAAe,IAAI,EAAE,EAAE,UAAU,CAAC;QAC3D,CAAC,CAAC,SAAS;IACf,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAAE,EAAE,CACtD,WAAW;QACT,CAAC,CAAC,IAAA,wCAAsB,EAAC,gBAAgB,IAAI,EAAE,EAAE,WAAW,CAAC;QAC7D,CAAC,CAAC,SAAS;IACf,UAAU,EAAE,CAAC,EA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CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5E,OAAO;QACL,UAAU,EAAE,aAAa;QACzB,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC;QACtD,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC;QAC/D,mBAAmB,EAAE,WAAW,EAAE,gCAAgC;YAChE,CAAC,CAAC,WAAW,CAAC,gCAAgC,GAAG,EAAE;YACnD,CAAC,CAAC,CAAC;QACL,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;QAChE,iBAAiB,EAAE,MAAM,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/D,kBAAkB,EAAE,gBAAgB,IAAI,CAAC;QACzC,mBAAmB,EAAE,gBAAgB;YACnC,CAAC,CAAC,IAAA,2BAAmB,EAAC,gBAAgB,CAAC,KAAK,CAAC;YAC7C,CAAC,CAAC,QAAQ;QACZ,QAAQ;QACR,QAAQ;QACR,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,IAAI,CAAC,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,2BAA2B,+BAyBtC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\n\nimport { MetricsSwapType } from './constants';\nimport type {\n InputKeys,\n InputValues,\n QuoteWarning,\n RequestParams,\n} from './types';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport { ChainId } from '../../types';\nimport type {\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteRequest,\n QuoteResponse,\n TxData,\n} from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = ({\n srcChainId,\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n}: Partial<GenericQuoteRequest>): Omit<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n> => {\n // Fallback to ETH if srcChainId is not defined. This is ok since the clients default to Ethereum as the source chain\n // This also doesn't happen at runtime since the quote request is validated before metrics are published\n const srcChainIdCaip = formatChainIdToCaip(srcChainId ?? ChainId.ETH);\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\n/**\n * @param slippage - The slippage percentage\n * @returns Whether the default slippage was overridden by the user\n *\n * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.\n */\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n\nexport const getQuotesReceivedProperties = (\n activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>),\n warnings: QuoteWarning[] = [],\n isSubmittable: boolean = true,\n recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>),\n usdBalanceSource?: number,\n) => {\n const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';\n return {\n can_submit: isSubmittable,\n gas_included: Boolean(activeQuote?.quote?.gasIncluded),\n gas_included_7702: Boolean(activeQuote?.quote?.gasIncluded7702),\n quoted_time_minutes: activeQuote?.estimatedProcessingTimeInSeconds\n ? activeQuote.estimatedProcessingTimeInSeconds / 60\n : 0,\n usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),\n usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),\n usd_balance_source: usdBalanceSource ?? 0,\n best_quote_provider: recommendedQuote\n ? formatProviderLabel(recommendedQuote.quote)\n : provider,\n provider,\n warnings,\n price_impact: Number(activeQuote?.quote.priceData?.priceImpact ?? 0),\n };\n};\n"]}
@@ -16,13 +16,14 @@ export declare const isHardwareWallet: (selectedAccount?: AccountsControllerStat
16
16
  * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.
17
17
  */
18
18
  export declare const isCustomSlippage: (slippage: GenericQuoteRequest['slippage']) => boolean;
19
- export declare const getQuotesReceivedProperties: (activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>), warnings?: QuoteWarning[], isSubmittable?: boolean, recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>)) => {
19
+ export declare const getQuotesReceivedProperties: (activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>), warnings?: QuoteWarning[], isSubmittable?: boolean, recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>), usdBalanceSource?: number) => {
20
20
  can_submit: boolean;
21
21
  gas_included: boolean;
22
22
  gas_included_7702: boolean;
23
23
  quoted_time_minutes: number;
24
24
  usd_quoted_gas: number;
25
25
  usd_quoted_return: number;
26
+ usd_balance_source: number;
26
27
  best_quote_provider: `${string}_${string}`;
27
28
  provider: `${string}_${string}`;
28
29
  warnings: QuoteWarning[];
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.cts","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAsC;AAE7E,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACd,oBAAgB;AAGjB,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,MAAM,EACP,wBAAoB;AAOrB,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAC7C,MAAM,CAAC,MAAM,YAAY,EAAE,SAAS,CAAC,CAOtC,CAAC;AAEF,eAAO,MA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B,CAAC"}
@@ -16,13 +16,14 @@ export declare const isHardwareWallet: (selectedAccount?: AccountsControllerStat
16
16
  * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.
17
17
  */
18
18
  export declare const isCustomSlippage: (slippage: GenericQuoteRequest['slippage']) => boolean;
19
- export declare const getQuotesReceivedProperties: (activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>), warnings?: QuoteWarning[], isSubmittable?: boolean, recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>)) => {
19
+ export declare const getQuotesReceivedProperties: (activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>), warnings?: QuoteWarning[], isSubmittable?: boolean, recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>), usdBalanceSource?: number) => {
20
20
  can_submit: boolean;
21
21
  gas_included: boolean;
22
22
  gas_included_7702: boolean;
23
23
  quoted_time_minutes: number;
24
24
  usd_quoted_gas: number;
25
25
  usd_quoted_return: number;
26
+ usd_balance_source: number;
26
27
  best_quote_provider: `${string}_${string}`;
27
28
  provider: `${string}_${string}`;
28
29
  warnings: QuoteWarning[];
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAsC;AAE7E,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAC9C,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACd,oBAAgB;AAGjB,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,MAAM,EACP,wBAAoB;AAOrB,eAAO,MAAM,yBAAyB,EAAE,OAAO,CAC7C,MAAM,CAAC,MAAM,YAAY,EAAE,SAAS,CAAC,CAOtC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,OAAO,CAC/C,MAAM,CACJ,MAAM,OAAO,yBAAyB,EACtC,CACE,WAAW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age) => {
61
61
  return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;
62
62
  };
63
- export const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmittable = true, recommendedQuote) => {
63
+ export const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmittable = true, recommendedQuote, usdBalanceSource) => {
64
64
  const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';
65
65
  return {
66
66
  can_submit: isSubmittable,
@@ -71,6 +71,7 @@ export const getQuotesReceivedProperties = (activeQuote, warnings = [], isSubmit
71
71
  : 0,
72
72
  usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),
73
73
  usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),
74
+ usd_balance_source: usdBalanceSource ?? 0,
74
75
  best_quote_provider: recommendedQuote
75
76
  ? formatProviderLabel(recommendedQuote.quote)
76
77
  : provider,
@@ -1 +1 @@
1
- {"version":3,"file":"properties.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAO9C,OAAO,EAAE,+BAA+B,EAAE,mCAA+B;AACzE,OAAO,EAAE,OAAO,EAAE,wBAAoB;AAQtC,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,sBAAkB;AACnE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,+BAA2B;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAOpC;IACF,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU;QACR,CAAC,CAAC,sBAAsB,CAAC,eAAe,IAAI,EAAE,E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AE;IACF,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5E,OAAO;QACL,UAAU,EAAE,aAAa;QACzB,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC;QACtD,iBAAiB,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC;QAC/D,mBAAmB,EAAE,WAAW,EAAE,gCAAgC;YAChE,CAAC,CAAC,WAAW,CAAC,gCAAgC,GAAG,EAAE;YACnD,CAAC,CAAC,CAAC;QACL,cAAc,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;QAChE,iBAAiB,EAAE,MAAM,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/D,mBAAmB,EAAE,gBAAgB;YACnC,CAAC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC7C,CAAC,CAAC,QAAQ;QACZ,QAAQ;QACR,QAAQ;QACR,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,IAAI,CAAC,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\n\nimport { MetricsSwapType } from './constants';\nimport type {\n InputKeys,\n InputValues,\n QuoteWarning,\n RequestParams,\n} from './types';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport { ChainId } from '../../types';\nimport type {\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteRequest,\n QuoteResponse,\n TxData,\n} from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = ({\n srcChainId,\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n}: Partial<GenericQuoteRequest>): Omit<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n> => {\n // Fallback to ETH if srcChainId is not defined. This is ok since the clients default to Ethereum as the source chain\n // This also doesn't happen at runtime since the quote request is validated before metrics are published\n const srcChainIdCaip = formatChainIdToCaip(srcChainId ?? ChainId.ETH);\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\n/**\n * @param slippage - The slippage percentage\n * @returns Whether the default slippage was overridden by the user\n *\n * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.\n */\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n\nexport const getQuotesReceivedProperties = (\n activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>),\n warnings: QuoteWarning[] = [],\n isSubmittable: boolean = true,\n recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>),\n) => {\n const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';\n return {\n can_submit: isSubmittable,\n gas_included: Boolean(activeQuote?.quote?.gasIncluded),\n gas_included_7702: Boolean(activeQuote?.quote?.gasIncluded7702),\n quoted_time_minutes: activeQuote?.estimatedProcessingTimeInSeconds\n ? activeQuote.estimatedProcessingTimeInSeconds / 60\n : 0,\n usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),\n usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),\n best_quote_provider: recommendedQuote\n ? formatProviderLabel(recommendedQuote.quote)\n : provider,\n provider,\n warnings,\n price_impact: Number(activeQuote?.quote.priceData?.priceImpact ?? 0),\n };\n};\n"]}
1
+ {"version":3,"file":"properties.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/properties.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAO9C,OAAO,EAAE,+BAA+B,EAAE,mCAA+B;AACzE,OAAO,EAAE,OAAO,EAAE,wBAAoB;AAQtC,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,sBAAkB;AACnE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,+BAA2B;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GAElC;IACF,eAAe,EAAE,cAAc;IAC/B,gBAAgB,EAAE,mBAAmB;IACrC,UAAU,EAAE,cAAc;IAC1B,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAOpC;IACF,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,EAAE,CACnD,UAAU;QACR,CAAC,CAAC,sBAAsB,CAAC,eAAe,IAAI,EAAE,EAAE,UAAU,CAAC;QAC3D,CAAC,CAAC,SAAS;IACf,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,EAAE,WAAW,EAAE,EAAE,EAAE,CACtD,WAAW;QACT,CAAC,CAAC,sBAAsB,CAAC,gBAAgB,IAAI,EAAE,EAAE,WAAW,CAAC;QAC7D,CAAC,CAAC,SAAS;IACf,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAC7B,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;IAC1D,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAC/B,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;IAC5D,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAA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AC,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/D,kBAAkB,EAAE,gBAAgB,IAAI,CAAC;QACzC,mBAAmB,EAAE,gBAAgB;YACnC,CAAC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC7C,CAAC,CAAC,QAAQ;QACZ,QAAQ;QACR,QAAQ;QACR,YAAY,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,EAAE,WAAW,IAAI,CAAC,CAAC;KACrE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { AccountsControllerState } from '@metamask/accounts-controller';\n\nimport { MetricsSwapType } from './constants';\nimport type {\n InputKeys,\n InputValues,\n QuoteWarning,\n RequestParams,\n} from './types';\nimport { DEFAULT_BRIDGE_CONTROLLER_STATE } from '../../constants/bridge';\nimport { ChainId } from '../../types';\nimport type {\n GenericQuoteRequest,\n QuoteMetadata,\n QuoteRequest,\n QuoteResponse,\n TxData,\n} from '../../types';\nimport { getNativeAssetForChainId, isCrossChain } from '../bridge';\nimport {\n formatAddressToAssetId,\n formatChainIdToCaip,\n} from '../caip-formatters';\n\nexport const toInputChangedPropertyKey: Partial<\n Record<keyof QuoteRequest, InputKeys>\n> = {\n srcTokenAddress: 'token_source',\n destTokenAddress: 'token_destination',\n srcChainId: 'chain_source',\n destChainId: 'chain_destination',\n slippage: 'slippage',\n};\n\nexport const toInputChangedPropertyValue: Partial<\n Record<\n keyof typeof toInputChangedPropertyKey,\n (\n input_value: Partial<GenericQuoteRequest>,\n ) => InputValues[keyof InputValues] | undefined\n >\n> = {\n srcTokenAddress: ({ srcTokenAddress, srcChainId }) =>\n srcChainId\n ? formatAddressToAssetId(srcTokenAddress ?? '', srcChainId)\n : undefined,\n destTokenAddress: ({ destTokenAddress, destChainId }) =>\n destChainId\n ? formatAddressToAssetId(destTokenAddress ?? '', destChainId)\n : undefined,\n srcChainId: ({ srcChainId }) =>\n srcChainId ? formatChainIdToCaip(srcChainId) : undefined,\n destChainId: ({ destChainId }) =>\n destChainId ? formatChainIdToCaip(destChainId) : undefined,\n slippage: ({ slippage }) => (slippage ? Number(slippage) : slippage),\n};\n\nexport const getSwapType = (\n srcChainId?: GenericQuoteRequest['srcChainId'],\n destChainId?: GenericQuoteRequest['destChainId'],\n) => {\n if (srcChainId && !isCrossChain(srcChainId, destChainId ?? srcChainId)) {\n return MetricsSwapType.SINGLE;\n }\n return MetricsSwapType.CROSSCHAIN;\n};\n\nexport const getSwapTypeFromQuote = (\n quoteRequest: Partial<GenericQuoteRequest>,\n) => {\n return getSwapType(quoteRequest.srcChainId, quoteRequest.destChainId);\n};\n\nexport const formatProviderLabel = ({\n bridgeId,\n bridges,\n}: QuoteResponse<TxData | string>['quote']): `${string}_${string}` =>\n `${bridgeId}_${bridges[0]}`;\n\nexport const getRequestParams = ({\n srcChainId,\n destChainId,\n srcTokenAddress,\n destTokenAddress,\n}: Partial<GenericQuoteRequest>): Omit<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n> => {\n // Fallback to ETH if srcChainId is not defined. This is ok since the clients default to Ethereum as the source chain\n // This also doesn't happen at runtime since the quote request is validated before metrics are published\n const srcChainIdCaip = formatChainIdToCaip(srcChainId ?? ChainId.ETH);\n return {\n chain_id_source: srcChainIdCaip,\n chain_id_destination: destChainId ? formatChainIdToCaip(destChainId) : null,\n token_address_source: srcTokenAddress\n ? (formatAddressToAssetId(srcTokenAddress, srcChainIdCaip) ??\n getNativeAssetForChainId(srcChainIdCaip)?.assetId ??\n null)\n : (getNativeAssetForChainId(srcChainIdCaip)?.assetId ?? null),\n token_address_destination: destTokenAddress\n ? (formatAddressToAssetId(\n destTokenAddress,\n destChainId ?? srcChainIdCaip,\n ) ?? null)\n : null,\n };\n};\n\nexport const isHardwareWallet = (\n selectedAccount?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n return selectedAccount?.metadata?.keyring.type?.includes('Hardware') ?? false;\n};\n\n/**\n * @param slippage - The slippage percentage\n * @returns Whether the default slippage was overridden by the user\n *\n * @deprecated This function should not be used. Use {@link selectDefaultSlippagePercentage} instead.\n */\nexport const isCustomSlippage = (slippage: GenericQuoteRequest['slippage']) => {\n return slippage !== DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest.slippage;\n};\n\nexport const getQuotesReceivedProperties = (\n activeQuote: null | (QuoteResponse & Partial<QuoteMetadata>),\n warnings: QuoteWarning[] = [],\n isSubmittable: boolean = true,\n recommendedQuote?: null | (QuoteResponse & Partial<QuoteMetadata>),\n usdBalanceSource?: number,\n) => {\n const provider = activeQuote ? formatProviderLabel(activeQuote.quote) : '_';\n return {\n can_submit: isSubmittable,\n gas_included: Boolean(activeQuote?.quote?.gasIncluded),\n gas_included_7702: Boolean(activeQuote?.quote?.gasIncluded7702),\n quoted_time_minutes: activeQuote?.estimatedProcessingTimeInSeconds\n ? activeQuote.estimatedProcessingTimeInSeconds / 60\n : 0,\n usd_quoted_gas: Number(activeQuote?.gasFee?.effective?.usd ?? 0),\n usd_quoted_return: Number(activeQuote?.toTokenAmount?.usd ?? 0),\n usd_balance_source: usdBalanceSource ?? 0,\n best_quote_provider: recommendedQuote\n ? formatProviderLabel(recommendedQuote.quote)\n : provider,\n provider,\n warnings,\n price_impact: Number(activeQuote?.quote.priceData?.priceImpact ?? 0),\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'price_impact'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet'\n > &\n Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'price_impact'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet'\n > &\n Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
@@ -28,6 +28,7 @@ export type QuoteFetchData = {
28
28
  quotes_list: `${string}_${string}`[];
29
29
  initial_load_time_all_quotes: number;
30
30
  price_impact: number;
31
+ has_gas_included_quote: boolean;
31
32
  };
32
33
  export type TradeData = {
33
34
  usd_quoted_gas: number;
@@ -81,6 +82,7 @@ export type RequiredEventContextFromClient = {
81
82
  best_quote_provider: QuoteFetchData['best_quote_provider'];
82
83
  price_impact: QuoteFetchData['price_impact'];
83
84
  can_submit: QuoteFetchData['can_submit'];
85
+ usd_balance_source?: number;
84
86
  };
85
87
  [UnifiedSwapBridgeEventName.QuotesError]: Pick<RequestMetadata, 'stx_enabled'> & {
86
88
  token_symbol_source: RequestParams['token_symbol_source'];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EAChB,wBAAoB;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;AAE1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,WAAW,CAAC;IAC7B,oBAAoB,EAAE,WAAW,GAAG,IAAI,CAAC;IACzC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,oBAAoB,EAAE,aAAa,CAAC;IACpC,yBAAyB,EAAE,aAAa,GAAG,IAAI,CAAC;CACjD,CAAC;AAEF,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AAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,WAAW,EAAE,iBAAiB,CAAC;CAChC,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -28,6 +28,7 @@ export type QuoteFetchData = {
28
28
  quotes_list: `${string}_${string}`[];
29
29
  initial_load_time_all_quotes: number;
30
30
  price_impact: number;
31
+ has_gas_included_quote: boolean;
31
32
  };
32
33
  export type TradeData = {
33
34
  usd_quoted_gas: number;
@@ -81,6 +82,7 @@ export type RequiredEventContextFromClient = {
81
82
  best_quote_provider: QuoteFetchData['best_quote_provider'];
82
83
  price_impact: QuoteFetchData['price_impact'];
83
84
  can_submit: QuoteFetchData['can_submit'];
85
+ usd_balance_source?: number;
84
86
  };
85
87
  [UnifiedSwapBridgeEventName.QuotesError]: Pick<RequestMetadata, 'stx_enabled'> & {
86
88
  token_symbol_source: RequestParams['token_symbol_source'];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,wBAAwB;AAElE,OAAO,KAAK,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,eAAe,EAChB,wBAAoB;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,wBAAoB;AAE1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,WAA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AC,EAAE,aAAa,GACzD,eAAe,GACf,SAAS,GACT,cAAc,CAAC;IACjB,CAAC,0BAA0B,CAAC,aAAa,CAAC,EAAE,aAAa,GACvD,eAAe,GACf,cAAc,GACd,SAAS,CAAC;IACZ,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,IAAI,CAAC;IAC7D,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,CAAC,0BAA0B,CAAC,sBAAsB,CAAC,EAAE,aAAa,GAAG;QACnE,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,8BAA8B,CACxC,CAAC,SAAS,0BAA0B,IAElC;IACE,WAAW,EAAE,iBAAiB,CAAC;CAChC,GACD,IAAI,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAC9C,IAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'price_impact'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet'\n > &\n Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CaipAssetType, CaipChainId } from '@metamask/utils';\n\nimport type {\n UnifiedSwapBridgeEventName,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n MetricsSwapType,\n} from './constants';\nimport type { SortOrder, StatusTypes } from '../../types';\n\n/**\n * These properties map to properties required by the segment-schema. For example: https://github.com/Consensys/segment-schema/blob/main/libraries/properties/cross-chain-swaps-action.yaml\n */\nexport type RequestParams = {\n chain_id_source: CaipChainId;\n chain_id_destination: CaipChainId | null;\n token_symbol_source: string;\n token_symbol_destination: string | null;\n token_address_source: CaipAssetType;\n token_address_destination: CaipAssetType | null;\n};\n\nexport type RequestMetadata = {\n slippage_limit?: number; // undefined === auto\n custom_slippage: boolean;\n usd_amount_source: number; // Use quoteResponse when available\n stx_enabled: boolean;\n is_hardware_wallet: boolean;\n swap_type: MetricsSwapType;\n security_warnings: string[];\n};\n\nexport type QuoteFetchData = {\n can_submit: boolean;\n best_quote_provider?: `${string}_${string}`;\n quotes_count: number;\n quotes_list: `${string}_${string}`[];\n initial_load_time_all_quotes: number;\n price_impact: number;\n has_gas_included_quote: boolean;\n};\n\nexport type TradeData = {\n usd_quoted_gas: number;\n gas_included: boolean;\n gas_included_7702: boolean;\n quoted_time_minutes: number;\n usd_quoted_return: number;\n provider: `${string}_${string}`;\n};\n\nexport type TxStatusData = {\n allowance_reset_transaction?: StatusTypes;\n approval_transaction?: StatusTypes;\n source_transaction?: StatusTypes;\n destination_transaction?: StatusTypes;\n};\n\nexport type InputKeys =\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n\nexport type InputValues = {\n token_source: CaipAssetType;\n token_destination: CaipAssetType;\n chain_source: CaipChainId;\n chain_destination: CaipChainId;\n slippage: number;\n};\n\nexport type QuoteWarning =\n | 'low_return'\n | 'no_quotes'\n | 'insufficient_gas_balance'\n | 'insufficient_gas_for_selected_quote'\n | 'insufficient_balance'\n | 'price_impact'\n | 'tx_alert';\n\n/**\n * Properties that are required to be provided when trackUnifiedSwapBridgeEvent is called\n */\nexport type RequiredEventContextFromClient = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: {\n location: MetaMetricsSwapsEventSource;\n } & Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'>;\n // When type is object, the payload can be anything\n [UnifiedSwapBridgeEventName.PageViewed]: object;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input:\n | 'token_source'\n | 'token_destination'\n | 'chain_source'\n | 'chain_destination'\n | 'slippage';\n input_value: InputValues[keyof InputValues];\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n token_address_source: RequestParams['token_address_source'];\n token_address_destination: RequestParams['token_address_destination'];\n chain_id_source: RequestParams['chain_id_source'];\n chain_id_destination: RequestParams['chain_id_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n [UnifiedSwapBridgeEventName.QuotesRequested]: Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: TradeData & {\n warnings: QuoteWarning[];\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n usd_balance_source?: number;\n };\n [UnifiedSwapBridgeEventName.QuotesError]: Pick<\n RequestMetadata,\n 'stx_enabled'\n > & {\n token_symbol_source: RequestParams['token_symbol_source'];\n token_symbol_destination: RequestParams['token_symbol_destination'];\n } & Pick<RequestMetadata, 'security_warnings'>;\n // Emitted by BridgeStatusController\n [UnifiedSwapBridgeEventName.Submitted]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n Pick<\n RequestParams,\n | 'token_symbol_source'\n | 'token_symbol_destination'\n | 'chain_id_source'\n | 'chain_id_destination'\n > & {\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Completed]: TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Omit<RequestMetadata, 'security_warnings'> &\n TxStatusData &\n RequestParams & {\n actual_time_minutes: number;\n usd_actual_return: number;\n usd_actual_gas: number;\n quote_vs_execution_ratio: number;\n quoted_vs_used_gas_ratio: number;\n action_type: MetricsActionType;\n };\n [UnifiedSwapBridgeEventName.Failed]:\n | // Tx failed before confirmation\n (TradeData &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'is_hardware_wallet'\n > &\n Pick<\n RequestParams,\n 'token_symbol_source' | 'token_symbol_destination'\n > & { error_message: string }) // Tx failed after confirmation\n | (RequestParams &\n RequestMetadata &\n Pick<QuoteFetchData, 'price_impact'> &\n TxStatusData &\n TradeData & {\n actual_time_minutes: number;\n error_message?: string;\n });\n // Emitted by clients\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: Pick<\n TradeData,\n 'gas_included'\n > &\n Pick<QuoteFetchData, 'price_impact'> &\n Pick<RequestParams, 'token_symbol_source' | 'token_symbol_destination'> & {\n stx_enabled: RequestMetadata['stx_enabled'];\n sort_order: SortOrder;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.QuoteSelected]: TradeData & {\n is_best_quote: boolean;\n best_quote_provider: QuoteFetchData['best_quote_provider'];\n price_impact: QuoteFetchData['price_impact'];\n can_submit: QuoteFetchData['can_submit'];\n };\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: {\n token_name: string;\n token_symbol: string;\n token_contract: string;\n chain_name: string;\n chain_id: string;\n };\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: {\n failures: string[];\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: {\n failures: string[];\n };\n};\n\n/**\n * Properties that can be derived from the bridge controller state\n */\nexport type EventPropertiesFromControllerState = {\n [UnifiedSwapBridgeEventName.ButtonClicked]: RequestParams;\n [UnifiedSwapBridgeEventName.PageViewed]: RequestParams;\n [UnifiedSwapBridgeEventName.InputChanged]: {\n input: InputKeys;\n input_value: string;\n };\n [UnifiedSwapBridgeEventName.InputSourceDestinationSwitched]: RequestParams;\n [UnifiedSwapBridgeEventName.QuotesRequested]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n };\n [UnifiedSwapBridgeEventName.QuotesReceived]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData & {\n refresh_count: number; // starts from 0\n };\n [UnifiedSwapBridgeEventName.QuotesError]: RequestParams &\n RequestMetadata & {\n has_sufficient_funds: boolean;\n error_message: string;\n };\n [UnifiedSwapBridgeEventName.Submitted]: null;\n [UnifiedSwapBridgeEventName.Completed]: null;\n [UnifiedSwapBridgeEventName.Failed]: RequestParams &\n RequestMetadata &\n TxStatusData &\n TradeData &\n Pick<QuoteFetchData, 'price_impact'> & {\n actual_time_minutes: number;\n };\n [UnifiedSwapBridgeEventName.AllQuotesOpened]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.AllQuotesSorted]: RequestParams &\n RequestMetadata &\n TradeData &\n QuoteFetchData;\n [UnifiedSwapBridgeEventName.QuoteSelected]: RequestParams &\n RequestMetadata &\n QuoteFetchData &\n TradeData;\n [UnifiedSwapBridgeEventName.AssetDetailTooltipClicked]: null;\n [UnifiedSwapBridgeEventName.QuotesValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n [UnifiedSwapBridgeEventName.StatusValidationFailed]: RequestParams & {\n refresh_count: number;\n };\n};\n\n/**\n * trackUnifiedSwapBridgeEvent payload properties consist of required properties from the client\n * and properties from the bridge controller\n */\nexport type CrossChainSwapsEventProperties<\n T extends UnifiedSwapBridgeEventName,\n> =\n | {\n action_type: MetricsActionType;\n }\n | Pick<EventPropertiesFromControllerState, T>[T]\n | Pick<RequiredEventContextFromClient, T>[T];\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/bridge-controller",
3
- "version": "64.4.1",
3
+ "version": "64.5.0",
4
4
  "description": "Manages bridge-related quote fetching functionality for MetaMask",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -54,7 +54,7 @@
54
54
  "@ethersproject/contracts": "^5.7.0",
55
55
  "@ethersproject/providers": "^5.7.0",
56
56
  "@metamask/accounts-controller": "^35.0.1",
57
- "@metamask/assets-controllers": "^95.1.0",
57
+ "@metamask/assets-controllers": "^95.2.0",
58
58
  "@metamask/base-controller": "^9.0.0",
59
59
  "@metamask/controller-utils": "^11.18.0",
60
60
  "@metamask/gas-fee-controller": "^26.0.1",