@metamask-previews/bridge-status-controller 66.0.2-preview-e8f4442d4 → 66.0.2-preview-d7935cb09

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,16 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Added
11
-
12
- - Added `location` property to `BridgeHistoryItem` to persist the entry point across the transaction lifecycle ([#7931](https://github.com/MetaMask/core/pull/7931))
13
- - Added `location` parameter to `StartPollingForBridgeTxStatusArgs` ([#7931](https://github.com/MetaMask/core/pull/7931))
14
- - Added optional `location` parameter to `submitTx` method ([#7931](https://github.com/MetaMask/core/pull/7931))
15
-
16
- ### Changed
17
-
18
- - All post-submission events (`Submitted`, `Completed`, `Failed`, `PollingStatusUpdated`, `StatusValidationFailed`) now include the `location` property from `BridgeHistoryItem` ([#7931](https://github.com/MetaMask/core/pull/7931))
19
-
20
10
  ### Fixed
21
11
 
22
12
  - Fix `usd_amount_source` default value in EVM transaction metrics properties from `100` to `0` ([#7899](https://github.com/MetaMask/core/pull/7899))
@@ -159,7 +159,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
159
159
  action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
160
160
  polling_status: bridge_controller_1.PollingStatus.ManuallyRestarted,
161
161
  retry_attempts: previousAttempts,
162
- location: historyItem.location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
163
162
  });
164
163
  }
165
164
  }
@@ -208,7 +207,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
208
207
  });
209
208
  });
210
209
  _BridgeStatusController_addTxToHistory.set(this, (startPollingForBridgeTxStatusArgs, actionId) => {
211
- const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, location, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
210
+ const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
212
211
  // Determine the key for this history item:
213
212
  // - For pre-submission (non-batch EVM): use actionId
214
213
  // - For post-submission or other cases: use bridgeTxMeta.id
@@ -248,7 +247,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
248
247
  approvalTxId,
249
248
  isStxEnabled: isStxEnabled ?? false,
250
249
  featureId: quoteResponse.featureId,
251
- location,
252
250
  };
253
251
  this.update((state) => {
254
252
  // Use actionId as key for pre-submission, or txMeta.id for post-submission
@@ -357,7 +355,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
357
355
  action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
358
356
  polling_status: bridge_controller_1.PollingStatus.MaxPollingReached,
359
357
  retry_attempts: newAttempts.counter,
360
- location: historyItem.location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
361
358
  });
362
359
  }
363
360
  }
@@ -409,7 +406,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
409
406
  if (validationFailures.length > 0) {
410
407
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed, bridgeTxMetaId, {
411
408
  failures: validationFailures,
412
- location: historyItem.location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
413
409
  });
414
410
  throw new Error(`Bridge status validation failed: ${validationFailures.join(', ')}`);
415
411
  }
@@ -705,10 +701,9 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
705
701
  * @param quoteResponse - The quote response
706
702
  * @param isStxEnabledOnClient - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
707
703
  * @param quotesReceivedContext - The context for the QuotesReceived event
708
- * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, trending_explore)
709
704
  * @returns The transaction meta
710
705
  */
711
- this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location) => {
706
+ this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext) => {
712
707
  this.messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted,
713
708
  // If trade is submitted before all quotes are loaded, the QuotesReceived event is published
714
709
  // 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
@@ -721,10 +716,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
721
716
  const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabledOnClient, isHardwareAccount);
722
717
  // Emit Submitted event after submit button is clicked
723
718
  !quoteResponse.featureId &&
724
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Submitted, undefined, {
725
- ...preConfirmationProperties,
726
- location: location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
727
- });
719
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
728
720
  let txMeta;
729
721
  let approvalTxId;
730
722
  const startTime = Date.now();
@@ -754,7 +746,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
754
746
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, undefined, {
755
747
  error_message: error?.message,
756
748
  ...preConfirmationProperties,
757
- location: location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
758
749
  });
759
750
  throw error;
760
751
  }
@@ -785,7 +776,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
785
776
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, txMeta?.id, {
786
777
  error_message: error?.message,
787
778
  ...preConfirmationProperties,
788
- location: location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
789
779
  });
790
780
  throw error;
791
781
  }
@@ -844,7 +834,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
844
834
  isStxEnabled: isStxEnabledOnClient,
845
835
  startTime,
846
836
  approvalTxId,
847
- location,
848
837
  }, actionId);
849
838
  // Pass txFee when gasIncluded is true to use the quote's gas fees
850
839
  // instead of re-estimating (which would fail for max native token swaps)
@@ -884,7 +873,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
884
873
  isStxEnabled: isStxEnabledOnClient,
885
874
  startTime,
886
875
  approvalTxId,
887
- location,
888
876
  });
889
877
  }
890
878
  if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
@@ -909,11 +897,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
909
897
  * @param params.quoteResponse - Quote carrying intent data
910
898
  * @param params.signature - Hex signature produced by eth_signTypedData_v4
911
899
  * @param params.accountAddress - The EOA submitting the order
912
- * @param params.location - The entry point from which the user initiated the swap or bridge
913
900
  * @returns A lightweight TransactionMeta-like object for history linking
914
901
  */
915
902
  this.submitIntent = async (params) => {
916
- const { quoteResponse, signature, accountAddress, location } = params;
903
+ const { quoteResponse, signature, accountAddress } = params;
917
904
  this.messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted);
918
905
  // Build pre-confirmation properties for error tracking parity with submitTx
919
906
  const account = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
@@ -1013,7 +1000,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1013
1000
  isStxEnabled: false,
1014
1001
  approvalTxId,
1015
1002
  startTime,
1016
- location,
1017
1003
  });
1018
1004
  // Start polling using the orderId key to route to intent manager
1019
1005
  __classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
@@ -1028,7 +1014,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1028
1014
  __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, undefined, {
1029
1015
  error_message: error?.message,
1030
1016
  ...preConfirmationProperties,
1031
- location: location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
1032
1017
  });
1033
1018
  throw error;
1034
1019
  }
@@ -1045,32 +1030,26 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1045
1030
  action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
1046
1031
  ...(eventProperties ?? {}),
1047
1032
  };
1048
- // The messenger.call for trackUnifiedSwapBridgeEvent is generic but TypeScript
1049
- // can't narrow EventName within this method's body, so we use `any` for the
1050
- // properties argument. The real type safety comes from the external call sites.
1051
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1052
- const callTrack = (properties) => this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, properties);
1053
1033
  // This will publish events for PERPS dropped tx failures as well
1054
1034
  if (!txMetaId) {
1055
- callTrack(baseProperties);
1035
+ this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, baseProperties);
1056
1036
  return;
1057
1037
  }
1058
1038
  const historyItem = this.state.txHistory[txMetaId];
1059
1039
  if (!historyItem) {
1060
- callTrack(eventProperties ?? {});
1040
+ this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, eventProperties ?? {});
1061
1041
  return;
1062
1042
  }
1063
1043
  const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
1064
1044
  // Always publish StatusValidationFailed event, regardless of featureId
1065
1045
  if (eventName === bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed) {
1066
- callTrack({
1046
+ this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, {
1067
1047
  ...baseProperties,
1068
1048
  chain_id_source: requestParamProperties.chain_id_source,
1069
1049
  chain_id_destination: requestParamProperties.chain_id_destination,
1070
1050
  token_address_source: requestParamProperties.token_address_source,
1071
1051
  token_address_destination: requestParamProperties.token_address_destination,
1072
1052
  refresh_count: historyItem.attempts?.counter ?? 0,
1073
- location: historyItem.location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
1074
1053
  });
1075
1054
  return;
1076
1055
  }
@@ -1090,9 +1069,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1090
1069
  ...(0, metrics_1.getTxStatusesFromHistory)(historyItem),
1091
1070
  ...(0, metrics_1.getFinalizedTxProperties)(historyItem, txMeta, approvalTxMeta),
1092
1071
  ...(0, metrics_1.getPriceImpactFromQuote)(historyItem.quote),
1093
- location: historyItem.location ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
1094
1072
  };
1095
- callTrack(requiredEventProperties);
1073
+ this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, requiredEventProperties);
1096
1074
  });
1097
1075
  __classPrivateFieldSet(this, _BridgeStatusController_clientId, clientId, "f");
1098
1076
  __classPrivateFieldSet(this, _BridgeStatusController_fetchFn, fetchFn, "f");
@@ -1144,11 +1122,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
1144
1122
  else if (actionId && this.state.txHistory[actionId]) {
1145
1123
  historyKey = actionId;
1146
1124
  }
1147
- const historyLocation = this.state.txHistory[historyKey ?? txMetaId]?.location;
1148
- __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, historyKey ?? txMetaId, {
1149
- ...(0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(transactionMeta),
1150
- location: historyLocation ?? bridge_controller_1.MetaMetricsSwapsEventSource.MainView,
1151
- });
1125
+ __classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, historyKey ?? txMetaId, (0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(transactionMeta));
1152
1126
  }
1153
1127
  }
1154
1128
  });