@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 +0 -10
- package/dist/bridge-status-controller.cjs +9 -35
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +2 -5
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +2 -5
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +10 -36
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -7
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +1 -7
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _BridgeStatusController_instances, _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentStatusManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionFn, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_updateTransactionFn, _BridgeStatusController_estimateGasFeeFn, _BridgeStatusController_trace, _BridgeStatusController_markTxAsFailed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_shouldPollHistoryItem, _BridgeStatusController_getMultichainSelectedAccount, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_getSrcTxHash, _BridgeStatusController_updateSrcTxHash, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_handleNonEvmTx, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, _BridgeStatusController_waitForTxConfirmation, _BridgeStatusController_handleApprovalTx, _BridgeStatusController_handleEvmTransaction, _BridgeStatusController_handleUSDTAllowanceReset, _BridgeStatusController_calculateGasFees, _BridgeStatusController_handleEvmTransactionBatch, _BridgeStatusController_trackUnifiedSwapBridgeEvent;
|
|
13
|
-
import { formatChainIdToHex, isNonEvmChainId, StatusTypes, UnifiedSwapBridgeEventName, formatChainIdToCaip, isCrossChain, isTronChainId, isEvmTxData, isHardwareWallet, MetricsActionType,
|
|
13
|
+
import { formatChainIdToHex, isNonEvmChainId, StatusTypes, UnifiedSwapBridgeEventName, formatChainIdToCaip, isCrossChain, isTronChainId, isEvmTxData, isHardwareWallet, MetricsActionType, isBitcoinTrade, isTronTrade, AbortReason, PollingStatus } from "@metamask/bridge-controller";
|
|
14
14
|
import { toHex } from "@metamask/controller-utils";
|
|
15
15
|
import { StaticIntervalPollingController } from "@metamask/polling-controller";
|
|
16
16
|
import { TransactionStatus, TransactionType } from "@metamask/transaction-controller";
|
|
@@ -156,7 +156,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
156
156
|
action_type: MetricsActionType.SWAPBRIDGE_V1,
|
|
157
157
|
polling_status: PollingStatus.ManuallyRestarted,
|
|
158
158
|
retry_attempts: previousAttempts,
|
|
159
|
-
location: historyItem.location ?? MetaMetricsSwapsEventSource.MainView,
|
|
160
159
|
});
|
|
161
160
|
}
|
|
162
161
|
}
|
|
@@ -205,7 +204,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
205
204
|
});
|
|
206
205
|
});
|
|
207
206
|
_BridgeStatusController_addTxToHistory.set(this, (startPollingForBridgeTxStatusArgs, actionId) => {
|
|
208
|
-
const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled,
|
|
207
|
+
const { bridgeTxMeta, statusRequest, quoteResponse, startTime, slippagePercentage, initialDestAssetBalance, targetContractAddress, approvalTxId, isStxEnabled, accountAddress: selectedAddress, } = startPollingForBridgeTxStatusArgs;
|
|
209
208
|
// Determine the key for this history item:
|
|
210
209
|
// - For pre-submission (non-batch EVM): use actionId
|
|
211
210
|
// - For post-submission or other cases: use bridgeTxMeta.id
|
|
@@ -245,7 +244,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
245
244
|
approvalTxId,
|
|
246
245
|
isStxEnabled: isStxEnabled ?? false,
|
|
247
246
|
featureId: quoteResponse.featureId,
|
|
248
|
-
location,
|
|
249
247
|
};
|
|
250
248
|
this.update((state) => {
|
|
251
249
|
// Use actionId as key for pre-submission, or txMeta.id for post-submission
|
|
@@ -354,7 +352,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
354
352
|
action_type: MetricsActionType.SWAPBRIDGE_V1,
|
|
355
353
|
polling_status: PollingStatus.MaxPollingReached,
|
|
356
354
|
retry_attempts: newAttempts.counter,
|
|
357
|
-
location: historyItem.location ?? MetaMetricsSwapsEventSource.MainView,
|
|
358
355
|
});
|
|
359
356
|
}
|
|
360
357
|
}
|
|
@@ -406,7 +403,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
406
403
|
if (validationFailures.length > 0) {
|
|
407
404
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.StatusValidationFailed, bridgeTxMetaId, {
|
|
408
405
|
failures: validationFailures,
|
|
409
|
-
location: historyItem.location ?? MetaMetricsSwapsEventSource.MainView,
|
|
410
406
|
});
|
|
411
407
|
throw new Error(`Bridge status validation failed: ${validationFailures.join(', ')}`);
|
|
412
408
|
}
|
|
@@ -702,10 +698,9 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
702
698
|
* @param quoteResponse - The quote response
|
|
703
699
|
* @param isStxEnabledOnClient - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension
|
|
704
700
|
* @param quotesReceivedContext - The context for the QuotesReceived event
|
|
705
|
-
* @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, trending_explore)
|
|
706
701
|
* @returns The transaction meta
|
|
707
702
|
*/
|
|
708
|
-
this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext
|
|
703
|
+
this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext) => {
|
|
709
704
|
this.messenger.call('BridgeController:stopPollingForQuotes', AbortReason.TransactionSubmitted,
|
|
710
705
|
// If trade is submitted before all quotes are loaded, the QuotesReceived event is published
|
|
711
706
|
// 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
|
|
@@ -718,10 +713,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
718
713
|
const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, isStxEnabledOnClient, isHardwareAccount);
|
|
719
714
|
// Emit Submitted event after submit button is clicked
|
|
720
715
|
!quoteResponse.featureId &&
|
|
721
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Submitted, undefined,
|
|
722
|
-
...preConfirmationProperties,
|
|
723
|
-
location: location ?? MetaMetricsSwapsEventSource.MainView,
|
|
724
|
-
});
|
|
716
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
|
|
725
717
|
let txMeta;
|
|
726
718
|
let approvalTxId;
|
|
727
719
|
const startTime = Date.now();
|
|
@@ -751,7 +743,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
751
743
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
752
744
|
error_message: error?.message,
|
|
753
745
|
...preConfirmationProperties,
|
|
754
|
-
location: location ?? MetaMetricsSwapsEventSource.MainView,
|
|
755
746
|
});
|
|
756
747
|
throw error;
|
|
757
748
|
}
|
|
@@ -782,7 +773,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
782
773
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, txMeta?.id, {
|
|
783
774
|
error_message: error?.message,
|
|
784
775
|
...preConfirmationProperties,
|
|
785
|
-
location: location ?? MetaMetricsSwapsEventSource.MainView,
|
|
786
776
|
});
|
|
787
777
|
throw error;
|
|
788
778
|
}
|
|
@@ -841,7 +831,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
841
831
|
isStxEnabled: isStxEnabledOnClient,
|
|
842
832
|
startTime,
|
|
843
833
|
approvalTxId,
|
|
844
|
-
location,
|
|
845
834
|
}, actionId);
|
|
846
835
|
// Pass txFee when gasIncluded is true to use the quote's gas fees
|
|
847
836
|
// instead of re-estimating (which would fail for max native token swaps)
|
|
@@ -881,7 +870,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
881
870
|
isStxEnabled: isStxEnabledOnClient,
|
|
882
871
|
startTime,
|
|
883
872
|
approvalTxId,
|
|
884
|
-
location,
|
|
885
873
|
});
|
|
886
874
|
}
|
|
887
875
|
if (isNonEvmChainId(quoteResponse.quote.srcChainId)) {
|
|
@@ -906,11 +894,10 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
906
894
|
* @param params.quoteResponse - Quote carrying intent data
|
|
907
895
|
* @param params.signature - Hex signature produced by eth_signTypedData_v4
|
|
908
896
|
* @param params.accountAddress - The EOA submitting the order
|
|
909
|
-
* @param params.location - The entry point from which the user initiated the swap or bridge
|
|
910
897
|
* @returns A lightweight TransactionMeta-like object for history linking
|
|
911
898
|
*/
|
|
912
899
|
this.submitIntent = async (params) => {
|
|
913
|
-
const { quoteResponse, signature, accountAddress
|
|
900
|
+
const { quoteResponse, signature, accountAddress } = params;
|
|
914
901
|
this.messenger.call('BridgeController:stopPollingForQuotes', AbortReason.TransactionSubmitted);
|
|
915
902
|
// Build pre-confirmation properties for error tracking parity with submitTx
|
|
916
903
|
const account = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
|
|
@@ -1010,7 +997,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1010
997
|
isStxEnabled: false,
|
|
1011
998
|
approvalTxId,
|
|
1012
999
|
startTime,
|
|
1013
|
-
location,
|
|
1014
1000
|
});
|
|
1015
1001
|
// Start polling using the orderId key to route to intent manager
|
|
1016
1002
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
|
|
@@ -1025,7 +1011,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1025
1011
|
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
1026
1012
|
error_message: error?.message,
|
|
1027
1013
|
...preConfirmationProperties,
|
|
1028
|
-
location: location ?? MetaMetricsSwapsEventSource.MainView,
|
|
1029
1014
|
});
|
|
1030
1015
|
throw error;
|
|
1031
1016
|
}
|
|
@@ -1042,32 +1027,26 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1042
1027
|
action_type: MetricsActionType.SWAPBRIDGE_V1,
|
|
1043
1028
|
...(eventProperties ?? {}),
|
|
1044
1029
|
};
|
|
1045
|
-
// The messenger.call for trackUnifiedSwapBridgeEvent is generic but TypeScript
|
|
1046
|
-
// can't narrow EventName within this method's body, so we use `any` for the
|
|
1047
|
-
// properties argument. The real type safety comes from the external call sites.
|
|
1048
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1049
|
-
const callTrack = (properties) => this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, properties);
|
|
1050
1030
|
// This will publish events for PERPS dropped tx failures as well
|
|
1051
1031
|
if (!txMetaId) {
|
|
1052
|
-
|
|
1032
|
+
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, baseProperties);
|
|
1053
1033
|
return;
|
|
1054
1034
|
}
|
|
1055
1035
|
const historyItem = this.state.txHistory[txMetaId];
|
|
1056
1036
|
if (!historyItem) {
|
|
1057
|
-
|
|
1037
|
+
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, eventProperties ?? {});
|
|
1058
1038
|
return;
|
|
1059
1039
|
}
|
|
1060
1040
|
const requestParamProperties = getRequestParamFromHistory(historyItem);
|
|
1061
1041
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
1062
1042
|
if (eventName === UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
1063
|
-
|
|
1043
|
+
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, {
|
|
1064
1044
|
...baseProperties,
|
|
1065
1045
|
chain_id_source: requestParamProperties.chain_id_source,
|
|
1066
1046
|
chain_id_destination: requestParamProperties.chain_id_destination,
|
|
1067
1047
|
token_address_source: requestParamProperties.token_address_source,
|
|
1068
1048
|
token_address_destination: requestParamProperties.token_address_destination,
|
|
1069
1049
|
refresh_count: historyItem.attempts?.counter ?? 0,
|
|
1070
|
-
location: historyItem.location ?? MetaMetricsSwapsEventSource.MainView,
|
|
1071
1050
|
});
|
|
1072
1051
|
return;
|
|
1073
1052
|
}
|
|
@@ -1087,9 +1066,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1087
1066
|
...getTxStatusesFromHistory(historyItem),
|
|
1088
1067
|
...getFinalizedTxProperties(historyItem, txMeta, approvalTxMeta),
|
|
1089
1068
|
...getPriceImpactFromQuote(historyItem.quote),
|
|
1090
|
-
location: historyItem.location ?? MetaMetricsSwapsEventSource.MainView,
|
|
1091
1069
|
};
|
|
1092
|
-
|
|
1070
|
+
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, requiredEventProperties);
|
|
1093
1071
|
});
|
|
1094
1072
|
__classPrivateFieldSet(this, _BridgeStatusController_clientId, clientId, "f");
|
|
1095
1073
|
__classPrivateFieldSet(this, _BridgeStatusController_fetchFn, fetchFn, "f");
|
|
@@ -1141,11 +1119,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1141
1119
|
else if (actionId && this.state.txHistory[actionId]) {
|
|
1142
1120
|
historyKey = actionId;
|
|
1143
1121
|
}
|
|
1144
|
-
|
|
1145
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, historyKey ?? txMetaId, {
|
|
1146
|
-
...getEVMTxPropertiesFromTransactionMeta(transactionMeta),
|
|
1147
|
-
location: historyLocation ?? MetaMetricsSwapsEventSource.MainView,
|
|
1148
|
-
});
|
|
1122
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, UnifiedSwapBridgeEventName.Failed, historyKey ?? txMetaId, getEVMTxPropertiesFromTransactionMeta(transactionMeta));
|
|
1149
1123
|
}
|
|
1150
1124
|
}
|
|
1151
1125
|
});
|