@metamask/bridge-status-controller 68.0.1 → 68.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-status-controller.d.mts","sourceRoot":"","sources":["../src/bridge-status-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,8BAA8B,EAE9B,aAAa,EACb,KAAK,EACN,oCAAoC;AACrC,OAAO,EAIL,0BAA0B,EAO1B,2BAA2B,EAK5B,oCAAoC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAQhE,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAEhB,yCAAyC;AAK1C,OAAO,EAEL,6BAA6B,EAK9B,wBAAoB;AACrB,OAAO,KAAK,EACV,2BAA2B,EAC3B,2CAA2C,EAC3C,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAClB,oBAAgB;AACjB,OAAO,KAAK,EAAE,+BAA+B,EAAE,oBAAgB;AAC/D,OAAO,EAAE,cAAc,EAAE,oBAAgB;AA+CzC,wEAAwE;AACxE,KAAK,wBAAwB,GAAG,uBAAuB,CAAC;AAGxD,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;;;;;;;;;;;;;;;;AACF,qBAAa,sBAAuB,SAAQ,4BAC1C,OAAO,6BAA6B,EACpC,2BAA2B,EAC3B,+BAA+B,CAChC;;gBAuBa,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACN,OAAO,GACR,EAAE;QACD,SAAS,EAAE,+BAA+B,CAAC;QAC3C,KAAK,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;QAC7C,QAAQ,EAAE,cAAc,CAAC;QACzB,OAAO,EAAE,aAAa,CAAC;QACvB,gBAAg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AA2B,CAAC;QACvC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,KAAG,QAAQ,KAAK,eAAe,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,CA6LtE;CA2HH"}
1
+ {"version":3,"file":"bridge-status-controller.d.mts","sourceRoot":"","sources":["../src/bridge-status-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,8BAA8B,EAE9B,aAAa,EACb,KAAK,EACN,oCAAoC;AACrC,OAAO,EAIL,0BAA0B,EAO1B,2BAA2B,EAK5B,oCAAoC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAQhE,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAEhB,yCAAyC;AAK1C,OAAO,EAEL,6BAA6B,EAK9B,wBAAoB;AACrB,OAAO,KAAK,EACV,2BAA2B,EAC3B,2CAA2C,EAC3C,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAClB,oBAAgB;AACjB,OAAO,KAAK,EAAE,+BAA+B,EAAE,oBAAgB;AAC/D,OAAO,EAAE,cAAc,EAAE,oBAAgB;AA+CzC,wEAAwE;AACxE,KAAK,wBAAwB,GAAG,uBAAuB,CAAC;AAGxD,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;;;;;;;;;;;;;;;;AACF,qBAAa,sBAAuB,SAAQ,4BAC1C,OAAO,6BAA6B,EACpC,2BAA2B,EAC3B,+BAA+B,CAChC;;gBAuBa,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,EACN,OAAO,GACR,EAAE;QACD,SAAS,EAAE,+BAA+B,CAAC;QAC3C,KAAK,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;QAC7C,QAAQ,EAAE,c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,WAAkB;QAC5B,aAAa,EAAE,cAAc,KAAK,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC;QAC3D,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,2BAA2B,CAAC;QACvC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,aAAa,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAClD,KAAG,QAAQ,KAAK,eAAe,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,CAgMtE;CAiIH"}
@@ -205,7 +205,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
205
205
  });
206
206
  });
207
207
  _BridgeStatusController_addTxToHistory.set(this, (startPollingForBridgeTxStatusArgs, actionId) => {
208
- const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
208
+ const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, abTests, activeAbTests, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
209
209
  // Determine the key for this history item:
210
210
  // - For pre-submission (non-batch EVM): use actionId
211
211
  // - For post-submission or other cases: use bridgeTxMeta.id
@@ -247,6 +247,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
247
247
  featureId: quoteResponse.featureId,
248
248
  location,
249
249
  ...(abTests && { abTests }),
250
+ ...(activeAbTests && { activeAbTests }),
250
251
  };
251
252
  this.update((state) => {
252
253
  // Use actionId as key for pre-submission, or txMeta.id for post-submission
@@ -711,10 +712,11 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
711
712
  * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
712
713
  * @param quotesReceivedContext - The context for the QuotesReceived event
713
714
  * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)
714
- * @param abTests - A/B test context to attribute events to specific experiments
715
+ * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
716
+ * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
715
717
  * @returns The transaction meta
716
718
  */
717
- this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = MetaMetricsSwapsEventSource.MainView, abTests) => {
719
+ this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests) => {
718
720
  this.messenger.call('BridgeController:stopPollingForQuotes', AbortReason.TransactionSubmitted,
719
721
  // If trade is submitted before all quotes are loaded, the QuotesReceived event is published
720
722
  // If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published
@@ -724,7 +726,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
724
726
  throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
725
727
  }
726
728
  const isHardwareAccount = isHardwareWallet(selectedAccount);
727
- const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabledOnClient, isHardwareAccount, location, abTests);
729
+ const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabledOnClient, isHardwareAccount, location, abTests, activeAbTests);
728
730
  // Emit Submitted event after submit button is clicked
729
731
  !quoteResponse.featureId &&
730
732
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
@@ -847,6 +849,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
847
849
  approvalTxId,
848
850
  location,
849
851
  abTests,
852
+ activeAbTests,
850
853
  }, actionId);
851
854
  // Pass txFee when gasIncluded is true to use the quote's gas fees
852
855
  // instead of re-estimating (which would fail for max native token swaps)
@@ -888,6 +891,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
888
891
  approvalTxId,
889
892
  location,
890
893
  abTests,
894
+ activeAbTests,
891
895
  });
892
896
  }
893
897
  if (isNonEvmChainId(quoteResponse.quote.srcChainId)) {
@@ -912,16 +916,17 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
912
916
  * @param params.quoteResponse - Quote carrying intent data
913
917
  * @param params.accountAddress - The EOA submitting the order
914
918
  * @param params.location - The entry point from which the user initiated the swap or bridge
915
- * @param params.abTests - A/B test context to attribute events to specific experiments
919
+ * @param params.abTests - Legacy A/B test context for `ab_tests` (backward compatibility)
920
+ * @param params.activeAbTests - New A/B test context for `active_ab_tests` (migration target). Attributes events to specific experiments.
916
921
  * @returns A lightweight TransactionMeta-like object for history linking
917
922
  */
918
923
  this.submitIntent = async (params) => {
919
- const { quoteResponse, accountAddress, location, abTests } = params;
924
+ const { quoteResponse, accountAddress, location, abTests, activeAbTests } = params;
920
925
  this.messenger.call('BridgeController:stopPollingForQuotes', AbortReason.TransactionSubmitted);
921
926
  // Build pre-confirmation properties for error tracking parity with submitTx
922
927
  const account = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
923
928
  const isHardwareAccount = Boolean(account) && isHardwareWallet(account);
924
- const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, false, isHardwareAccount, location, abTests);
929
+ const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, false, isHardwareAccount, location, abTests, activeAbTests);
925
930
  try {
926
931
  const intent = getIntentFromQuote(quoteResponse);
927
932
  // If backend provided an approval tx for this intent quote, submit it first (on-chain),
@@ -1021,6 +1026,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
1021
1026
  startTime,
1022
1027
  location,
1023
1028
  abTests,
1029
+ activeAbTests,
1024
1030
  });
1025
1031
  // Start polling using the orderId key to route to intent manager
1026
1032
  __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
@@ -1047,11 +1053,15 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
1047
1053
  * @param eventProperties - The properties for the event
1048
1054
  */
1049
1055
  _BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txMetaId, eventProperties) => {
1050
- const { ab_tests: eventAbTests } = eventProperties ?? {};
1056
+ // Legacy/new metrics fields are intentionally kept independent during migration.
1051
1057
  const historyAbTests = txMetaId
1052
1058
  ? this.state.txHistory?.[txMetaId]?.abTests
1053
1059
  : undefined;
1054
- const resolvedAbTests = eventAbTests ?? historyAbTests ?? undefined;
1060
+ const historyActiveAbTests = txMetaId
1061
+ ? this.state.txHistory?.[txMetaId]?.activeAbTests
1062
+ : undefined;
1063
+ const resolvedAbTests = eventProperties?.ab_tests ?? historyAbTests;
1064
+ const resolvedActiveAbTests = eventProperties?.active_ab_tests ?? historyActiveAbTests;
1055
1065
  const baseProperties = {
1056
1066
  action_type: MetricsActionType.SWAPBRIDGE_V1,
1057
1067
  location: eventProperties?.location ??
@@ -1062,6 +1072,10 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
1062
1072
  Object.keys(resolvedAbTests).length > 0 && {
1063
1073
  ab_tests: resolvedAbTests,
1064
1074
  }),
1075
+ ...(resolvedActiveAbTests &&
1076
+ resolvedActiveAbTests.length > 0 && {
1077
+ active_ab_tests: resolvedActiveAbTests,
1078
+ }),
1065
1079
  };
1066
1080
  // This will publish events for PERPS dropped tx failures as well
1067
1081
  if (!txMetaId) {