@metamask-previews/bridge-status-controller 71.2.0-preview-c7c3c44 → 71.2.0-preview-8751708e2

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/bridge-status-controller-method-action-types.cjs.map +1 -1
  3. package/dist/bridge-status-controller-method-action-types.d.cts +5 -1
  4. package/dist/bridge-status-controller-method-action-types.d.cts.map +1 -1
  5. package/dist/bridge-status-controller-method-action-types.d.mts +5 -1
  6. package/dist/bridge-status-controller-method-action-types.d.mts.map +1 -1
  7. package/dist/bridge-status-controller-method-action-types.mjs.map +1 -1
  8. package/dist/bridge-status-controller.cjs +152 -364
  9. package/dist/bridge-status-controller.cjs.map +1 -1
  10. package/dist/bridge-status-controller.d.cts +27 -7
  11. package/dist/bridge-status-controller.d.cts.map +1 -1
  12. package/dist/bridge-status-controller.d.mts +27 -7
  13. package/dist/bridge-status-controller.d.mts.map +1 -1
  14. package/dist/bridge-status-controller.mjs +153 -368
  15. package/dist/bridge-status-controller.mjs.map +1 -1
  16. package/dist/strategy/batch-sell-strategy.cjs +163 -0
  17. package/dist/strategy/batch-sell-strategy.cjs.map +1 -0
  18. package/dist/strategy/batch-sell-strategy.d.cts +10 -0
  19. package/dist/strategy/batch-sell-strategy.d.cts.map +1 -0
  20. package/dist/strategy/batch-sell-strategy.d.mts +10 -0
  21. package/dist/strategy/batch-sell-strategy.d.mts.map +1 -0
  22. package/dist/strategy/batch-sell-strategy.mjs +159 -0
  23. package/dist/strategy/batch-sell-strategy.mjs.map +1 -0
  24. package/dist/strategy/batch-strategy.cjs +73 -0
  25. package/dist/strategy/batch-strategy.cjs.map +1 -0
  26. package/dist/strategy/batch-strategy.d.cts +10 -0
  27. package/dist/strategy/batch-strategy.d.cts.map +1 -0
  28. package/dist/strategy/batch-strategy.d.mts +10 -0
  29. package/dist/strategy/batch-strategy.d.mts.map +1 -0
  30. package/dist/strategy/batch-strategy.mjs +69 -0
  31. package/dist/strategy/batch-strategy.mjs.map +1 -0
  32. package/dist/strategy/evm-strategy.cjs +147 -0
  33. package/dist/strategy/evm-strategy.cjs.map +1 -0
  34. package/dist/strategy/evm-strategy.d.cts +38 -0
  35. package/dist/strategy/evm-strategy.d.cts.map +1 -0
  36. package/dist/strategy/evm-strategy.d.mts +38 -0
  37. package/dist/strategy/evm-strategy.d.mts.map +1 -0
  38. package/dist/strategy/evm-strategy.mjs +141 -0
  39. package/dist/strategy/evm-strategy.mjs.map +1 -0
  40. package/dist/strategy/index.cjs +68 -0
  41. package/dist/strategy/index.cjs.map +1 -0
  42. package/dist/strategy/index.d.cts +12 -0
  43. package/dist/strategy/index.d.cts.map +1 -0
  44. package/dist/strategy/index.d.mts +12 -0
  45. package/dist/strategy/index.d.mts.map +1 -0
  46. package/dist/strategy/index.mjs +66 -0
  47. package/dist/strategy/index.mjs.map +1 -0
  48. package/dist/strategy/intent-strategy.cjs +160 -0
  49. package/dist/strategy/intent-strategy.cjs.map +1 -0
  50. package/dist/strategy/intent-strategy.d.cts +17 -0
  51. package/dist/strategy/intent-strategy.d.cts.map +1 -0
  52. package/dist/strategy/intent-strategy.d.mts +17 -0
  53. package/dist/strategy/intent-strategy.d.mts.map +1 -0
  54. package/dist/strategy/intent-strategy.mjs +156 -0
  55. package/dist/strategy/intent-strategy.mjs.map +1 -0
  56. package/dist/strategy/non-evm-strategy.cjs +80 -0
  57. package/dist/strategy/non-evm-strategy.cjs.map +1 -0
  58. package/dist/strategy/non-evm-strategy.d.cts +15 -0
  59. package/dist/strategy/non-evm-strategy.d.cts.map +1 -0
  60. package/dist/strategy/non-evm-strategy.d.mts +15 -0
  61. package/dist/strategy/non-evm-strategy.d.mts.map +1 -0
  62. package/dist/strategy/non-evm-strategy.mjs +76 -0
  63. package/dist/strategy/non-evm-strategy.mjs.map +1 -0
  64. package/dist/strategy/types.cjs +13 -0
  65. package/dist/strategy/types.cjs.map +1 -0
  66. package/dist/strategy/types.d.cts +88 -0
  67. package/dist/strategy/types.d.cts.map +1 -0
  68. package/dist/strategy/types.d.mts +88 -0
  69. package/dist/strategy/types.d.mts.map +1 -0
  70. package/dist/strategy/types.mjs +10 -0
  71. package/dist/strategy/types.mjs.map +1 -0
  72. package/dist/types.cjs.map +1 -1
  73. package/dist/types.d.cts +10 -3
  74. package/dist/types.d.cts.map +1 -1
  75. package/dist/types.d.mts +10 -3
  76. package/dist/types.d.mts.map +1 -1
  77. package/dist/types.mjs.map +1 -1
  78. package/dist/utils/bridge.cjs +5 -1
  79. package/dist/utils/bridge.cjs.map +1 -1
  80. package/dist/utils/bridge.d.cts +2 -2
  81. package/dist/utils/bridge.d.cts.map +1 -1
  82. package/dist/utils/bridge.d.mts +2 -2
  83. package/dist/utils/bridge.d.mts.map +1 -1
  84. package/dist/utils/bridge.mjs +3 -0
  85. package/dist/utils/bridge.mjs.map +1 -1
  86. package/dist/utils/history.cjs +37 -20
  87. package/dist/utils/history.cjs.map +1 -1
  88. package/dist/utils/history.d.cts +3 -5
  89. package/dist/utils/history.d.cts.map +1 -1
  90. package/dist/utils/history.d.mts +3 -5
  91. package/dist/utils/history.d.mts.map +1 -1
  92. package/dist/utils/history.mjs +37 -20
  93. package/dist/utils/history.mjs.map +1 -1
  94. package/dist/utils/metrics.cjs +3 -3
  95. package/dist/utils/metrics.cjs.map +1 -1
  96. package/dist/utils/metrics.d.cts +3 -3
  97. package/dist/utils/metrics.d.cts.map +1 -1
  98. package/dist/utils/metrics.d.mts +3 -3
  99. package/dist/utils/metrics.d.mts.map +1 -1
  100. package/dist/utils/metrics.mjs +3 -3
  101. package/dist/utils/metrics.mjs.map +1 -1
  102. package/dist/utils/trace.cjs +4 -4
  103. package/dist/utils/trace.cjs.map +1 -1
  104. package/dist/utils/trace.d.cts +2 -2
  105. package/dist/utils/trace.d.cts.map +1 -1
  106. package/dist/utils/trace.d.mts +2 -2
  107. package/dist/utils/trace.d.mts.map +1 -1
  108. package/dist/utils/trace.mjs +4 -4
  109. package/dist/utils/trace.mjs.map +1 -1
  110. package/dist/utils/transaction.cjs +211 -229
  111. package/dist/utils/transaction.cjs.map +1 -1
  112. package/dist/utils/transaction.d.cts +64 -99
  113. package/dist/utils/transaction.d.cts.map +1 -1
  114. package/dist/utils/transaction.d.mts +64 -99
  115. package/dist/utils/transaction.d.mts.map +1 -1
  116. package/dist/utils/transaction.mjs +204 -223
  117. package/dist/utils/transaction.mjs.map +1 -1
  118. package/package.json +1 -1
@@ -9,26 +9,25 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_onTransactionFailed, _BridgeStatusController_onTransactionConfirmed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_handleOldHistoryItem, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_setAndGetSrcTxHash, _BridgeStatusController_updateHistoryItem, _BridgeStatusController_deleteHistoryItem, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_handleApprovalTx, _BridgeStatusController_handleEvmTransactionBatch, _BridgeStatusController_trackPollingStatusUpdatedEvent, _BridgeStatusController_trackUnifiedSwapBridgeEvent;
13
- import { formatChainIdToHex, isNonEvmChainId, StatusTypes, getAccountHardwareType, UnifiedSwapBridgeEventName, isCrossChain, isTronChainId, isEvmTxData, MetricsActionType, MetaMetricsSwapsEventSource, isBitcoinTrade, isTronTrade, PollingStatus } from "@metamask/bridge-controller";
12
+ var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_onTransactionFailed, _BridgeStatusController_onTransactionConfirmed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_handleOldHistoryItem, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_setAndGetSrcTxHash, _BridgeStatusController_updateHistoryItem, _BridgeStatusController_deleteHistoryItem, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_executeSubmitStrategy, _BridgeStatusController_trackPollingStatusUpdatedEvent, _BridgeStatusController_trackUnifiedSwapBridgeEvent;
13
+ import { isNonEvmChainId, StatusTypes, getAccountHardwareType, UnifiedSwapBridgeEventName, isCrossChain, MetricsActionType, MetaMetricsSwapsEventSource, PollingStatus, formatChainIdToHex } from "@metamask/bridge-controller";
14
14
  import { StaticIntervalPollingController } from "@metamask/polling-controller";
15
15
  import { TransactionStatus, TransactionType, TransactionController } from "@metamask/transaction-controller";
16
16
  import { numberToHex } from "@metamask/utils";
17
17
  import { IntentManager } from "./bridge-status-controller.intent.mjs";
18
18
  import { BRIDGE_PROD_API_BASE_URL, BRIDGE_STATUS_CONTROLLER_NAME, DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE, MAX_ATTEMPTS, REFRESH_INTERVAL_MS } from "./constants.mjs";
19
+ import executeSubmitStrategy from "./strategy/index.mjs";
20
+ import { SubmitStep } from "./strategy/types.mjs";
19
21
  import { BridgeClientId } from "./types.mjs";
20
22
  import { getAccountByAddress } from "./utils/accounts.mjs";
21
23
  import { getJwt } from "./utils/authentication.mjs";
22
- import { stopPollingForQuotes, trackMetricsEvent } from "./utils/bridge.mjs";
24
+ import { getBatchSellTrades, stopPollingForQuotes, trackMetricsEvent } from "./utils/bridge.mjs";
23
25
  import { fetchBridgeTxStatus, getStatusRequestWithSrcTxHash, shouldSkipFetchDueToFetchFailures, shouldWaitForFinalBridgeStatus } from "./utils/bridge-status.mjs";
24
26
  import { getInitialHistoryItem, getMatchingHistoryEntryForTxMeta, rekeyHistoryItemInState, shouldPollHistoryItem, getMatchingHistoryEntryForApprovalTxMeta } from "./utils/history.mjs";
25
- import { getIntentFromQuote, mapIntentOrderStatusToTransactionStatus, postSubmitOrder } from "./utils/intent-api.mjs";
26
- import { signTypedMessage } from "./utils/keyring.mjs";
27
27
  import { getFinalizedTxProperties, getPriceImpactFromQuote, getRequestMetadataFromHistory, getRequestParamFromHistory, getTradeDataFromHistory, getEVMTxPropertiesFromTransactionMeta, getTxStatusesFromHistory, getPreConfirmationPropertiesFromQuote, getPollingStatusUpdatedProperties } from "./utils/metrics.mjs";
28
- import { getNetworkClientIdByChainId, getSelectedChainId } from "./utils/network.mjs";
29
- import { handleNonEvmTx } from "./utils/snaps.mjs";
30
- import { getApprovalTraceParams, getTraceParams } from "./utils/trace.mjs";
31
- import { getAddTransactionBatchParams, handleApprovalDelay, handleMobileHardwareWalletDelay, generateActionId, waitForTxConfirmation, getTransactionMetaById, addTransactionBatch, addSyntheticTransaction, getTransactions, submitEvmTransaction, checkIsDelegatedAccount, isCrossChainTx } from "./utils/transaction.mjs";
28
+ import { getSelectedChainId } from "./utils/network.mjs";
29
+ import { getTraceParams } from "./utils/trace.mjs";
30
+ import { getTransactionMetaById, getTransactions, checkIsDelegatedAccount, isCrossChainTx, updateTransactionsInBatch } from "./utils/transaction.mjs";
32
31
  const metadata = {
33
32
  // We want to persist the bridge status state so that we can show the proper data for the Activity list
34
33
  // basically match the behavior of TransactionController
@@ -45,6 +44,7 @@ const MESSENGER_EXPOSED_METHODS = [
45
44
  'resetState',
46
45
  'submitTx',
47
46
  'submitIntent',
47
+ 'submitBatchSell',
48
48
  'restartPollingForFailedAttempts',
49
49
  'getBridgeHistoryItemByTxMetaId',
50
50
  ];
@@ -80,10 +80,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
80
80
  if (txMeta.status === TransactionStatus.rejected) {
81
81
  return;
82
82
  }
83
- // Skip account lookup and tracking when featureId is set (e.g. PERPS)
84
- if (historyKey && this.state.txHistory[historyKey]?.featureId) {
85
- return;
86
- }
87
83
  // Skip tracking if this is a duplicate failed event for the same history item
88
84
  // This can happen if the transaction includes an approval tx that fails
89
85
  if (isHistoryItemAlreadyFailed) {
@@ -243,26 +239,25 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
243
239
  __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
244
240
  });
245
241
  });
246
- _BridgeStatusController_addTxToHistory.set(this, (...args) => {
247
- const { historyKey, txHistoryItem } = getInitialHistoryItem(...args);
242
+ _BridgeStatusController_addTxToHistory.set(this, (historyKey, ...args) => {
243
+ const txHistoryItem = getInitialHistoryItem(...args);
248
244
  this.update((state) => {
249
- // Use actionId as key for pre-submission, or txMeta.id for post-submission
250
245
  state.txHistory[historyKey] = txHistoryItem;
251
246
  });
252
- return historyKey;
253
247
  });
254
248
  /**
255
249
  * Rekeys a history item from actionId to txMeta.id after successful submission.
256
250
  * Also updates txMetaId and srcTxHash which weren't available pre-submission.
257
251
  *
258
- * @param actionId - The actionId used as the temporary key for the history item
252
+ * @param oldKey - The temporary key to use for the history item, usually the actionId
253
+ * @param newKey - The new key to use, typcally the txmeta.id
259
254
  * @param txMeta - The transaction meta from the successful submission
260
255
  * @param txMeta.id - The transaction meta id to use as the new key
261
256
  * @param txMeta.hash - The transaction hash to set on the history item
262
257
  */
263
- _BridgeStatusController_rekeyHistoryItem.set(this, (actionId, txMeta) => {
258
+ _BridgeStatusController_rekeyHistoryItem.set(this, (oldKey, newKey, txMeta) => {
264
259
  this.update((state) => {
265
- rekeyHistoryItemInState(state, actionId, txMeta);
260
+ rekeyHistoryItemInState(state, oldKey, newKey, txMeta);
266
261
  });
267
262
  });
268
263
  _BridgeStatusController_startPollingForTxId.set(this, (txId) => {
@@ -293,7 +288,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
293
288
  if (!bridgeTxMeta?.id) {
294
289
  throw new Error('Cannot start polling: bridgeTxMeta.id is required for polling');
295
290
  }
296
- const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, txHistoryMeta);
291
+ const historyKey = bridgeTxMeta.id;
292
+ __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, historyKey, txHistoryMeta);
297
293
  __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
298
294
  };
299
295
  // This will be called after you call this.startPolling()
@@ -537,237 +533,133 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
537
533
  * TX SUBMISSION HANDLING
538
534
  *******************************************************
539
535
  */
540
- _BridgeStatusController_handleApprovalTx.set(this, async (quoteResponse, isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
541
- if (approval && isEvmTxData(approval)) {
542
- const approveTx = async () => {
543
- if (resetApproval) {
544
- await submitEvmTransaction({
545
- messenger: this.messenger,
546
- transactionType: TransactionType.bridgeApproval,
547
- trade: resetApproval,
548
- });
536
+ _BridgeStatusController_executeSubmitStrategy.set(this, async (params, sharedHistoryItemProperties) => {
537
+ let tradeTxMeta;
538
+ const steps = executeSubmitStrategy(params);
539
+ // Each submission strategy determines when to execute step, which means these actions can happen in any order
540
+ for await (const { type, payload } of steps) {
541
+ try {
542
+ switch (type) {
543
+ case SubmitStep.RekeyHistoryItem:
544
+ __classPrivateFieldGet(this, _BridgeStatusController_rekeyHistoryItem, "f").call(this, payload.oldHistoryKey, payload.newHistoryKey, payload.tradeMeta);
545
+ break;
546
+ case SubmitStep.UpdateBatchTransactions:
547
+ updateTransactionsInBatch({
548
+ messenger: this.messenger,
549
+ allTradesWithMetadata: payload.quoteAndTxMetas,
550
+ });
551
+ break;
552
+ case SubmitStep.SetTradeMeta:
553
+ tradeTxMeta = payload.tradeMeta;
554
+ break;
555
+ case SubmitStep.AddHistoryItem:
556
+ __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, payload.historyKey, {
557
+ ...payload,
558
+ ...sharedHistoryItemProperties,
559
+ accountAddress: params.selectedAccount.address,
560
+ isStxEnabled: params.isStxEnabled,
561
+ slippagePercentage: 0, // TODO include slippage provided by quote if using dynamic slippage, or slippage from quote request
562
+ });
563
+ break;
564
+ case SubmitStep.StartPolling:
565
+ __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, payload.historyKey);
566
+ break;
567
+ case SubmitStep.PublishCompletedEvent:
568
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Completed, payload.historyKey);
569
+ break;
570
+ /* c8 ignore start */
571
+ default:
572
+ throw new Error(`Unknown submit step type: ${String(type)}`);
573
+ /* c8 ignore end */
549
574
  }
550
- const approvalTxMeta = await submitEvmTransaction({
551
- messenger: this.messenger,
552
- transactionType: isBridgeTx
553
- ? TransactionType.bridgeApproval
554
- : TransactionType.swapApproval,
555
- trade: approval,
556
- requireApproval,
557
- });
558
- await handleApprovalDelay(srcChainId);
559
- return approvalTxMeta;
560
- };
561
- return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getApprovalTraceParams(quoteResponse, false), approveTx);
575
+ }
576
+ catch (error) {
577
+ console.error('Failed to add to bridge history and start polling.', error);
578
+ }
562
579
  }
563
- return undefined;
564
- });
565
- // TODO simplify and make more readable
566
- /**
567
- * Submits batched EVM transactions to the TransactionController
568
- *
569
- * @param args - The parameters for the transaction
570
- * @param args.isBridgeTx - Whether the transaction is a bridge transaction
571
- * @param args.trade - The trade data to confirm
572
- * @param args.approval - The approval data to confirm
573
- * @param args.resetApproval - The ethereum:USDT reset approval data to confirm
574
- * @param args.quoteResponse - The quote response
575
- * @param args.requireApproval - Whether to require approval for the transaction
576
- * @returns The approvalMeta and tradeMeta for the batched transaction
577
- */
578
- _BridgeStatusController_handleEvmTransactionBatch.set(this, async (args) => {
579
- const transactionParams = await getAddTransactionBatchParams({
580
- messenger: this.messenger,
581
- ...args,
582
- });
583
- return await addTransactionBatch(this.messenger, __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f"), transactionParams);
580
+ return tradeTxMeta;
584
581
  });
585
582
  /**
586
583
  * Submits a cross-chain swap transaction
587
584
  *
588
585
  * @param accountAddress - The address of the account to submit the transaction for
589
- * @param quoteResponse - The quote response
590
- * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
586
+ * @param maybeQuoteResponses - A single quote response or an array of quote responses
587
+ * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
591
588
  * @param quotesReceivedContext - The context for the QuotesReceived event
592
589
  * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)
593
590
  * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
594
591
  * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
595
592
  * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.
593
+ * @param batchSellTrades - Contains transaction data for the quotes, provided by the obtainGaslessBatch API
596
594
  * @returns The transaction meta
595
+ * @throws An error if transaction submission fails before it gets published
597
596
  */
598
- this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests, tokenSecurityTypeDestination) => {
599
- stopPollingForQuotes(this.messenger, quoteResponse.featureId, quotesReceivedContext);
597
+ this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location = MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades) => {
598
+ /**
599
+ * If there are multiple quote responses, we assume that they all originate from the same src chain
600
+ * and the same account. In this case its safe to use the first quote response's properties for
601
+ * metrics and other pre-submission logic
602
+ */
603
+ const quoteResponses = Array.isArray(maybeQuoteResponses)
604
+ ? maybeQuoteResponses
605
+ : [maybeQuoteResponses];
606
+ const quoteResponse = quoteResponses[0];
607
+ const { featureId, quote } = quoteResponse;
608
+ const startTime = Date.now();
609
+ stopPollingForQuotes(this.messenger, featureId, quotesReceivedContext);
600
610
  const selectedAccount = getAccountByAddress(this.messenger, accountAddress);
601
611
  if (!selectedAccount) {
602
612
  throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
603
613
  }
604
614
  const accountHardwareType = getAccountHardwareType(selectedAccount);
605
- const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabledOnClient, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination);
606
- let txMeta;
607
- let approvalTxId;
608
- let isDelegatedAccount = false;
609
- const startTime = Date.now();
610
- const isBridgeTx = isCrossChain(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
611
- const isTronTx = isTronChainId(quoteResponse.quote.srcChainId);
615
+ /**
616
+ * For hardware wallets on Mobile, this is fixes an issue where the Ledger does not get prompted for the 2nd approval.
617
+ * Extension does not have this issue
618
+ */
619
+ const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === BridgeClientId.MOBILE && accountHardwareType !== null;
620
+ const isBridgeTx = isCrossChain(quote.srcChainId, quote.destChainId);
621
+ const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabled, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination);
612
622
  try {
613
623
  // Emit Submitted event after submit button is clicked
614
- !quoteResponse.featureId &&
615
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
616
- // Submit non-EVM tx (Solana, BTC, Tron)
617
- if (isNonEvmChainId(quoteResponse.quote.srcChainId)) {
618
- // Handle non-EVM approval if present (e.g., Tron token approvals)
619
- if (quoteResponse.approval && isTronTrade(quoteResponse.approval)) {
620
- const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getApprovalTraceParams(quoteResponse, false), async () => {
621
- return quoteResponse.approval &&
622
- isTronTrade(quoteResponse.approval)
623
- ? await handleNonEvmTx(this.messenger, quoteResponse.approval, quoteResponse, selectedAccount)
624
- : /* c8 ignore start */
625
- undefined;
626
- /* c8 ignore end */
627
- });
628
- approvalTxId = approvalTxMeta?.id;
629
- // Add delay after approval similar to EVM flow
630
- await handleApprovalDelay(quoteResponse.quote.srcChainId);
631
- }
632
- txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getTraceParams(quoteResponse, false), async () => {
633
- if (!(isTronTrade(quoteResponse.trade) ||
634
- isBitcoinTrade(quoteResponse.trade) ||
635
- typeof quoteResponse.trade === 'string')) {
636
- throw new Error('Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction');
637
- }
638
- return await handleNonEvmTx(this.messenger, quoteResponse.trade, quoteResponse, selectedAccount);
639
- });
640
- }
641
- else {
642
- // Submit EVM tx
643
- // For hardware wallets on Mobile, this is fixes an issue where the Ledger does not get prompted for the 2nd approval
644
- // Extension does not have this issue
645
- const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === BridgeClientId.MOBILE &&
646
- accountHardwareType !== null;
647
- // Handle smart transactions if enabled
648
- txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getTraceParams(quoteResponse, isStxEnabledOnClient), async () => {
649
- if (!isEvmTxData(quoteResponse.trade)) {
650
- throw new Error('Failed to submit cross-chain swap transaction: trade is not an EVM transaction');
651
- }
652
- // Check if the account is an EIP-7702 delegated account
653
- // Delegated accounts only allow 1 in-flight tx, so approve + swap
654
- // must be batched into a single transaction
655
- const hexChainId = formatChainIdToHex(quoteResponse.quote.srcChainId);
656
- isDelegatedAccount = await checkIsDelegatedAccount(this.messenger, quoteResponse.trade.from, [hexChainId]);
657
- if (isStxEnabledOnClient ||
658
- quoteResponse.quote.gasIncluded7702 ||
659
- isDelegatedAccount) {
660
- const { tradeMeta, approvalMeta } = await __classPrivateFieldGet(this, _BridgeStatusController_handleEvmTransactionBatch, "f").call(this, {
661
- isBridgeTx,
662
- resetApproval: quoteResponse.resetApproval,
663
- approval: quoteResponse.approval &&
664
- isEvmTxData(quoteResponse.approval)
665
- ? quoteResponse.approval
666
- : undefined,
667
- trade: quoteResponse.trade,
668
- quoteResponse,
669
- requireApproval,
670
- isDelegatedAccount,
671
- });
672
- approvalTxId = approvalMeta?.id;
673
- return tradeMeta;
674
- }
675
- // Set approval time and id if an approval tx is needed
676
- const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && isEvmTxData(quoteResponse.approval)
677
- ? quoteResponse.approval
678
- : undefined, quoteResponse.resetApproval, requireApproval);
679
- approvalTxId = approvalTxMeta?.id;
680
- // Hardware-wallet delay first (Ledger second-prompt spacing), then wait for
681
- // on-chain approval confirmation so swap gas estimation runs after allowance is set.
682
- if (requireApproval && approvalTxMeta) {
683
- await handleMobileHardwareWalletDelay(requireApproval);
684
- await waitForTxConfirmation(this.messenger, approvalTxMeta.id);
685
- }
686
- else {
687
- await handleMobileHardwareWalletDelay(requireApproval);
688
- }
689
- // Generate actionId for pre-submission history (non-batch EVM only)
690
- const actionId = generateActionId().toString();
691
- // Add pre-submission history keyed by actionId
692
- // This ensures we have quote data available if transaction fails during submission
693
- const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
694
- accountAddress: selectedAccount.address,
695
- quoteResponse,
696
- slippagePercentage: 0,
697
- isStxEnabled: isStxEnabledOnClient,
698
- startTime,
699
- approvalTxId,
700
- location,
701
- abTests,
702
- activeAbTests,
703
- actionId,
704
- tokenSecurityTypeDestination,
705
- });
706
- // Pass txFee when gasIncluded is true to use the quote's gas fees
707
- // instead of re-estimating (which would fail for max native token swaps)
708
- const tradeTxMeta = await submitEvmTransaction({
709
- messenger: this.messenger,
710
- transactionType: isBridgeTx
711
- ? TransactionType.bridge
712
- : TransactionType.swap,
713
- trade: quoteResponse.trade,
714
- requireApproval,
715
- txFee: quoteResponse.quote.gasIncluded
716
- ? quoteResponse.quote.feeData.txFee
717
- : undefined,
718
- actionId,
719
- });
720
- // On success, rekey from actionId to txMeta.id and update srcTxHash
721
- __classPrivateFieldGet(this, _BridgeStatusController_rekeyHistoryItem, "f").call(this, historyKey, tradeTxMeta);
722
- return tradeTxMeta;
723
- });
724
- }
624
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties, featureId);
625
+ /**
626
+ * Check if the account is an EIP-7702 delegated account.
627
+ * Delegated accounts only allow 1 in-flight tx, so approve + swap
628
+ * must be batched into a single transaction
629
+ */
630
+ const isDelegatedAccount = isNonEvmChainId(quote.srcChainId)
631
+ ? false
632
+ : await checkIsDelegatedAccount(this.messenger, selectedAccount.address, [formatChainIdToHex(quote.srcChainId)]);
633
+ const strategyParams = {
634
+ messenger: this.messenger,
635
+ quoteResponses,
636
+ batchSellTrades,
637
+ isStxEnabled,
638
+ isBridgeTx,
639
+ isDelegatedAccount,
640
+ selectedAccount,
641
+ requireApproval,
642
+ clientId: __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"),
643
+ bridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
644
+ addTransactionBatchFn: __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f"),
645
+ fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
646
+ traceFn: __classPrivateFieldGet(this, _BridgeStatusController_trace, "f"),
647
+ };
648
+ return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getTraceParams(quoteResponse, isStxEnabled), async () => await __classPrivateFieldGet(this, _BridgeStatusController_executeSubmitStrategy, "f").call(this, strategyParams, {
649
+ startTime,
650
+ location,
651
+ abTests,
652
+ activeAbTests,
653
+ tokenSecurityTypeDestination,
654
+ }));
725
655
  }
726
656
  catch (error) {
727
- !quoteResponse.featureId &&
728
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, undefined, {
729
- error_message: error?.message,
730
- ...preConfirmationProperties,
731
- });
657
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, undefined, {
658
+ error_message: error?.message,
659
+ ...preConfirmationProperties,
660
+ }, featureId);
732
661
  throw error;
733
662
  }
734
- try {
735
- // For non-batch EVM transactions, history was already added/rekeyed above
736
- // Only add history here for non-EVM and batch EVM transactions
737
- const isNonBatchEvm = !isNonEvmChainId(quoteResponse.quote.srcChainId) &&
738
- !isStxEnabledOnClient &&
739
- !quoteResponse.quote.gasIncluded7702 &&
740
- !isDelegatedAccount;
741
- let historyKey = txMeta.id;
742
- if (!isNonBatchEvm) {
743
- // Add swap or bridge tx to history
744
- historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
745
- accountAddress: selectedAccount.address,
746
- bridgeTxMeta: txMeta, // Only the id and hash fields are used by the BridgeStatusController
747
- quoteResponse,
748
- slippagePercentage: 0, // TODO include slippage provided by quote if using dynamic slippage, or slippage from quote request
749
- isStxEnabled: isStxEnabledOnClient,
750
- startTime,
751
- approvalTxId,
752
- location,
753
- abTests,
754
- activeAbTests,
755
- tokenSecurityTypeDestination,
756
- });
757
- }
758
- if (isNonEvmChainId(quoteResponse.quote.srcChainId)) {
759
- // Start polling for bridge tx status
760
- __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
761
- // Track non-EVM Swap completed event
762
- if (!(isBridgeTx || isTronTx)) {
763
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Completed, historyKey);
764
- }
765
- }
766
- }
767
- catch {
768
- // Ignore errors here, we don't want to crash the app if this fails and tx submission succeeds
769
- }
770
- return txMeta;
771
663
  };
772
664
  /**
773
665
  * Submits an intent order and creates a synthetic history entry for UX.
@@ -779,136 +671,29 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
779
671
  * @param params.location - The entry point from which the user initiated the swap or bridge
780
672
  * @param params.abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
781
673
  * @param params.activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
674
+ * @param params.isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
675
+ * @param params.quotesReceivedContext - The context for the QuotesReceived event
782
676
  * @param params.tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.
783
677
  * @returns A lightweight TransactionMeta-like object for history linking
678
+ * @throws An error if intent or transaction submission fails before they get published
784
679
  */
785
680
  this.submitIntent = async (params) => {
786
- const { quoteResponse, accountAddress, location, abTests, activeAbTests, tokenSecurityTypeDestination, } = params;
681
+ const { quoteResponse, accountAddress, location, abTests, activeAbTests, isStxEnabled = false, quotesReceivedContext, tokenSecurityTypeDestination, } = params;
787
682
  // TODO add metrics context
788
- stopPollingForQuotes(this.messenger);
789
- const startTime = Date.now();
790
- // Build pre-confirmation properties for error tracking parity with submitTx
791
- const account = getAccountByAddress(this.messenger, accountAddress);
792
- const accountHardwareType = getAccountHardwareType(account);
793
- const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, false, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination);
794
- try {
795
- const intent = getIntentFromQuote(quoteResponse);
796
- // If backend provided an approval tx for this intent quote, submit it first (on-chain),
797
- // then proceed with off-chain intent submission.
798
- const isBridgeTx = isCrossChain(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
799
- const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === BridgeClientId.MOBILE &&
800
- accountHardwareType !== null;
801
- // Handle approval silently for better UX in intent flows
802
- const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
803
- const approvalTxId = approvalTxMeta?.id;
804
- if (approvalTxId) {
805
- await waitForTxConfirmation(this.messenger, approvalTxId);
806
- }
807
- const { srcChainId, requestId } = quoteResponse.quote;
808
- const signature = await signTypedMessage({
809
- messenger: this.messenger,
810
- accountAddress,
811
- typedData: intent.typedData,
812
- });
813
- const submissionParams = {
814
- srcChainId,
815
- quoteId: requestId,
816
- signature,
817
- order: intent.order,
818
- userAddress: accountAddress,
819
- aggregatorId: intent.protocol,
820
- };
821
- const { id: orderUid, status } = await postSubmitOrder({
822
- params: submissionParams,
823
- clientId: __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"),
824
- jwt: await getJwt(this.messenger),
825
- fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
826
- bridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
827
- });
828
- // Determine transaction type: swap for same-chain, bridge for cross-chain
829
- const transactionType = isBridgeTx
830
- ? /* c8 ignore start */
831
- TransactionType.bridge
832
- : /* c8 ignore end */
833
- TransactionType.swap;
834
- // Create actual transaction in Transaction Controller first
835
- const networkClientId = getNetworkClientIdByChainId(this.messenger, srcChainId);
836
- // This is a synthetic transaction whose purpose is to be able
837
- // to track the order status via the history
838
- const intentTransactionParams = {
839
- chainId: formatChainIdToHex(srcChainId),
840
- from: accountAddress,
841
- to: intent.settlementContract ??
842
- '0x9008D19f58AAbd9eD0D60971565AA8510560ab41', // Default settlement contract
843
- data: `0x${orderUid.slice(-8)}`, // Use last 8 chars of orderUid to make each transaction unique
844
- value: '0x0',
845
- gas: '0x5208', // Minimal gas for display purposes
846
- gasPrice: '0x3b9aca00', // 1 Gwei - will be converted to EIP-1559 fees if network supports it
847
- };
848
- const initialTxMeta = await addSyntheticTransaction(this.messenger, intentTransactionParams, {
849
- requireApproval: false,
850
- networkClientId,
851
- type: transactionType,
852
- });
853
- // Update txHistory with actual transaction metadata
854
- const syntheticMeta = {
855
- ...initialTxMeta,
856
- // Map intent order status to TransactionController status
857
- status: mapIntentOrderStatusToTransactionStatus(status),
858
- isIntentTx: true,
859
- orderUid,
860
- };
861
- // Record in bridge history with actual transaction metadata
862
- try {
863
- // Create a bridge transaction metadata keyed by orderUid for intent polling
864
- const bridgeTxMetaForHistory = {
865
- ...syntheticMeta,
866
- id: orderUid,
867
- };
868
- // Use orderId as the history key for intent transactions
869
- // IMPORTANT: pass originalTransactionId as a top-level argument so
870
- // `getInitialHistoryItem` reads it. Setting it on `bridgeTxMeta` is a no-op
871
- // because `getInitialHistoryItem` destructures `originalTransactionId` from
872
- // the top-level args, not from `bridgeTxMeta`. Without this, the field
873
- // falls back to `bridgeTxMeta.id` (the orderUid), severing the link between
874
- // the bridge history record and the synthetic TransactionController entry.
875
- const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
876
- accountAddress,
877
- bridgeTxMeta: bridgeTxMetaForHistory,
878
- originalTransactionId: syntheticMeta.id,
879
- quoteResponse,
880
- slippagePercentage: 0,
881
- isStxEnabled: false,
882
- approvalTxId,
883
- startTime,
884
- location,
885
- abTests,
886
- activeAbTests,
887
- tokenSecurityTypeDestination,
888
- });
889
- // Start polling using the orderId key to route to intent manager
890
- __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
891
- }
892
- catch (error) {
893
- console.error('📝 [submitIntent] Failed to add to bridge history', error);
894
- // non-fatal but log the error
895
- }
896
- return syntheticMeta;
897
- }
898
- catch (error) {
899
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, undefined, {
900
- error_message: error?.message,
901
- ...preConfirmationProperties,
902
- });
903
- throw error;
904
- }
683
+ return await this.submitTx(accountAddress, quoteResponse, isStxEnabled, quotesReceivedContext, location, abTests, activeAbTests, tokenSecurityTypeDestination);
684
+ };
685
+ this.submitBatchSell = async (params) => {
686
+ /**
687
+ * Retrieve the batch sell trades from the BridgeController's state to ensure we submit
688
+ * the original response data from the bridge-api
689
+ */
690
+ const batchSellTrades = getBatchSellTrades(this.messenger);
691
+ return await this.submitTx(params.accountAddress, params.quoteResponses.filter((quoteResponse) => quoteResponse !== null), params.isStxEnabled ?? false, params.quotesReceivedContext, params.location, params.abTests, params.activeAbTests, params.tokenSecurityTypeDestination, batchSellTrades);
905
692
  };
906
693
  _BridgeStatusController_trackPollingStatusUpdatedEvent.set(this, (historyKey, pollingStatus) => {
907
694
  // Track polling status updated event
908
695
  const historyItem = this.state.txHistory[historyKey];
909
- if (historyItem && !historyItem.featureId) {
910
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.PollingStatusUpdated, historyKey, getPollingStatusUpdatedProperties(this.messenger, pollingStatus, historyItem));
911
- }
696
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.PollingStatusUpdated, historyKey, getPollingStatusUpdatedProperties(this.messenger, pollingStatus, historyItem));
912
697
  });
913
698
  /**
914
699
  * Tracks post-submission events for a cross-chain swap based on the history item
@@ -916,8 +701,22 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
916
701
  * @param eventName - The name of the event to track
917
702
  * @param txMetaId - The txMetaId of the history item to track the event for
918
703
  * @param eventProperties - The properties for the event
704
+ * @param featureIdOverride - The featureId to use when the history item is not available. Should
705
+ * only be provided for events that are not associated with a history item yet, such as Submitted or Failed
919
706
  */
920
- _BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txMetaId, eventProperties) => {
707
+ _BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txMetaId, eventProperties, featureIdOverride) => {
708
+ const historyItem = txMetaId
709
+ ? this.state.txHistory[txMetaId]
710
+ : undefined;
711
+ const featureId = featureIdOverride ?? historyItem?.featureId;
712
+ const shouldSkipMetrics =
713
+ // Skip tracking all other events when featureId is set (i.e. PERPS)
714
+ featureId &&
715
+ // Always publish StatusValidationFailed event, regardless of featureId
716
+ eventName !== UnifiedSwapBridgeEventName.StatusValidationFailed;
717
+ if (shouldSkipMetrics) {
718
+ return;
719
+ }
921
720
  // Legacy/new metrics fields are intentionally kept independent during migration.
922
721
  const historyAbTests = txMetaId
923
722
  ? this.state.txHistory?.[txMetaId]?.abTests
@@ -927,12 +726,12 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
927
726
  : undefined;
928
727
  const resolvedAbTests = eventProperties?.ab_tests ?? historyAbTests;
929
728
  const resolvedActiveAbTests = eventProperties?.active_ab_tests ?? historyActiveAbTests;
729
+ const location = (txMetaId ? this.state.txHistory?.[txMetaId]?.location : undefined) ??
730
+ MetaMetricsSwapsEventSource.MainView;
930
731
  const baseProperties = {
931
732
  action_type: MetricsActionType.SWAPBRIDGE_V1,
932
- location: eventProperties?.location ??
933
- (txMetaId ? this.state.txHistory?.[txMetaId]?.location : undefined) ??
934
- MetaMetricsSwapsEventSource.MainView,
935
733
  ...(eventProperties ?? {}),
734
+ location,
936
735
  ...(resolvedAbTests &&
937
736
  Object.keys(resolvedAbTests).length > 0 && {
938
737
  ab_tests: resolvedAbTests,
@@ -943,15 +742,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
943
742
  }),
944
743
  };
945
744
  // This will publish events for PERPS dropped tx failures as well
946
- if (!txMetaId) {
947
- trackMetricsEvent({
948
- messenger: this.messenger,
949
- eventName,
950
- properties: baseProperties,
951
- });
952
- return;
953
- }
954
- const historyItem = this.state.txHistory[txMetaId];
955
745
  if (!historyItem) {
956
746
  trackMetricsEvent({
957
747
  messenger: this.messenger,
@@ -960,9 +750,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
960
750
  });
961
751
  return;
962
752
  }
963
- const { featureId, approvalTxId, quote } = historyItem;
753
+ const { approvalTxId, quote } = historyItem;
964
754
  const requestParamProperties = getRequestParamFromHistory(historyItem);
965
- // Always publish StatusValidationFailed event, regardless of featureId
966
755
  if (eventName === UnifiedSwapBridgeEventName.StatusValidationFailed) {
967
756
  trackMetricsEvent({
968
757
  messenger: this.messenger,
@@ -979,10 +768,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
979
768
  });
980
769
  return;
981
770
  }
982
- // Skip tracking all other events when featureId is set (i.e. PERPS)
983
- if (featureId) {
984
- return;
985
- }
986
771
  const selectedAccount = getAccountByAddress(this.messenger, historyItem.account);
987
772
  const transactions = getTransactions(this.messenger);
988
773
  const txMeta = transactions.find((tx) => tx.id === txMetaId);
@@ -1062,5 +847,5 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
1062
847
  __classPrivateFieldGet(this, _BridgeStatusController_restartPollingForIncompleteHistoryItems, "f").call(this);
1063
848
  }
1064
849
  }
1065
- _BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_onTransactionFailed = new WeakMap(), _BridgeStatusController_onTransactionConfirmed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_rekeyHistoryItem = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_handleOldHistoryItem = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(), _BridgeStatusController_setAndGetSrcTxHash = new WeakMap(), _BridgeStatusController_updateHistoryItem = new WeakMap(), _BridgeStatusController_deleteHistoryItem = new WeakMap(), _BridgeStatusController_wipeBridgeStatusByChainId = new WeakMap(), _BridgeStatusController_handleApprovalTx = new WeakMap(), _BridgeStatusController_handleEvmTransactionBatch = new WeakMap(), _BridgeStatusController_trackPollingStatusUpdatedEvent = new WeakMap(), _BridgeStatusController_trackUnifiedSwapBridgeEvent = new WeakMap();
850
+ _BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_onTransactionFailed = new WeakMap(), _BridgeStatusController_onTransactionConfirmed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_rekeyHistoryItem = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_handleOldHistoryItem = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(), _BridgeStatusController_setAndGetSrcTxHash = new WeakMap(), _BridgeStatusController_updateHistoryItem = new WeakMap(), _BridgeStatusController_deleteHistoryItem = new WeakMap(), _BridgeStatusController_wipeBridgeStatusByChainId = new WeakMap(), _BridgeStatusController_executeSubmitStrategy = new WeakMap(), _BridgeStatusController_trackPollingStatusUpdatedEvent = new WeakMap(), _BridgeStatusController_trackUnifiedSwapBridgeEvent = new WeakMap();
1066
851
  //# sourceMappingURL=bridge-status-controller.mjs.map