@metamask-previews/bridge-status-controller 72.0.2-preview-513faa49e → 72.0.2-preview-f5ff6e53c
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 +6 -2
- package/dist/bridge-status-controller.cjs +66 -77
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +3 -3
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +3 -3
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +41 -52
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +8 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +7 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/strategy/batch-sell-strategy.cjs +8 -7
- package/dist/strategy/batch-sell-strategy.cjs.map +1 -1
- package/dist/strategy/batch-sell-strategy.d.cts.map +1 -1
- package/dist/strategy/batch-sell-strategy.d.mts.map +1 -1
- package/dist/strategy/batch-sell-strategy.mjs +8 -7
- package/dist/strategy/batch-sell-strategy.mjs.map +1 -1
- package/dist/strategy/types.cjs +20 -0
- package/dist/strategy/types.cjs.map +1 -1
- package/dist/strategy/types.d.cts +39 -0
- package/dist/strategy/types.d.cts.map +1 -1
- package/dist/strategy/types.d.mts +39 -0
- package/dist/strategy/types.d.mts.map +1 -1
- package/dist/strategy/types.mjs +20 -0
- package/dist/strategy/types.mjs.map +1 -1
- package/dist/utils/bridge.cjs +2 -5
- package/dist/utils/bridge.cjs.map +1 -1
- package/dist/utils/bridge.d.cts +2 -2
- package/dist/utils/bridge.d.cts.map +1 -1
- package/dist/utils/bridge.d.mts +2 -2
- package/dist/utils/bridge.d.mts.map +1 -1
- package/dist/utils/bridge.mjs +3 -6
- package/dist/utils/bridge.mjs.map +1 -1
- package/dist/utils/metrics.cjs +6 -22
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +9 -27
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +9 -27
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs +6 -21
- package/dist/utils/metrics.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
###
|
|
10
|
+
### Added
|
|
11
11
|
|
|
12
|
-
-
|
|
12
|
+
- Add `batch_id` property to BatchSell events ([#8964](https://github.com/MetaMask/core/pull/8964))
|
|
13
|
+
- pre-generate the batchId using transaction controller's `generateBatchId` util
|
|
14
|
+
- attach batchId to the `Submitted`, `Completed` and `Failed` events
|
|
15
|
+
- provide batchId to the `TransactionController:addTransactionBatch` to propagate it the TransactionMeta
|
|
16
|
+
- Publish tx submission metrics for `BatchSell`, `QuickBuy` and `UnifiedSwapBridge` actions ([#8964](https://github.com/MetaMask/core/pull/8964))
|
|
13
17
|
|
|
14
18
|
## [72.0.2]
|
|
15
19
|
|
|
@@ -17,6 +17,7 @@ var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_int
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.BridgeStatusController = void 0;
|
|
19
19
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
20
|
+
const bridge_controller_2 = require("@metamask/bridge-controller");
|
|
20
21
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
21
22
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
22
23
|
const utils_1 = require("@metamask/utils");
|
|
@@ -76,11 +77,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
76
77
|
_BridgeStatusController_onTransactionFailed.set(this, ({ txMeta, historyKey, isApprovalTxMeta, }) => {
|
|
77
78
|
// Check if the history item is already marked as a failure
|
|
78
79
|
const isHistoryItemAlreadyFailed = historyKey
|
|
79
|
-
? this.state.txHistory[historyKey]?.status.status ===
|
|
80
|
+
? this.state.txHistory[historyKey]?.status.status === bridge_controller_2.StatusTypes.FAILED
|
|
80
81
|
: false;
|
|
81
82
|
__classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
|
|
82
83
|
historyKey,
|
|
83
|
-
status:
|
|
84
|
+
status: bridge_controller_2.StatusTypes.FAILED,
|
|
84
85
|
txHash: isApprovalTxMeta ? undefined : txMeta.hash,
|
|
85
86
|
completionTime: Date.now(),
|
|
86
87
|
});
|
|
@@ -92,7 +93,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
92
93
|
if (isHistoryItemAlreadyFailed) {
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
96
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, historyKey, (0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(txMeta));
|
|
96
97
|
});
|
|
97
98
|
// Only EVM txs
|
|
98
99
|
_BridgeStatusController_onTransactionConfirmed.set(this, ({ txMeta, historyKey, isApprovalTxMeta, }) => {
|
|
@@ -110,10 +111,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
110
111
|
case true:
|
|
111
112
|
__classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
|
|
112
113
|
historyKey,
|
|
113
|
-
status:
|
|
114
|
+
status: bridge_controller_2.StatusTypes.COMPLETE,
|
|
114
115
|
completionTime: Date.now(),
|
|
115
116
|
});
|
|
116
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
117
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, historyKey);
|
|
117
118
|
break;
|
|
118
119
|
default:
|
|
119
120
|
if (historyKey) {
|
|
@@ -184,24 +185,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
184
185
|
// Restart polling
|
|
185
186
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, targetTxMetaId);
|
|
186
187
|
// Track polling manually restarted event
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
192
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.PollingStatusUpdated, targetTxMetaId, {
|
|
193
|
-
...(0, metrics_1.getTradeDataFromHistory)(historyItem),
|
|
194
|
-
...(0, metrics_1.getPriceImpactFromQuote)(historyItem.quote),
|
|
195
|
-
...metadataWithoutWarnings,
|
|
196
|
-
chain_id_source: requestParams.chain_id_source,
|
|
197
|
-
chain_id_destination: requestParams.chain_id_destination,
|
|
198
|
-
token_symbol_source: requestParams.token_symbol_source,
|
|
199
|
-
token_symbol_destination: requestParams.token_symbol_destination,
|
|
200
|
-
action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
|
|
201
|
-
polling_status: bridge_controller_1.PollingStatus.ManuallyRestarted,
|
|
202
|
-
retry_attempts: previousAttempts,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
188
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.PollingStatusUpdated, targetTxMetaId, {
|
|
189
|
+
polling_status: bridge_controller_2.PollingStatus.ManuallyRestarted,
|
|
190
|
+
retry_attempts: previousAttempts,
|
|
191
|
+
});
|
|
205
192
|
}
|
|
206
193
|
}
|
|
207
194
|
};
|
|
@@ -223,8 +210,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
223
210
|
const { txHistory } = this.state;
|
|
224
211
|
const historyItems = Object.entries(txHistory);
|
|
225
212
|
const incompleteHistoryItems = historyItems
|
|
226
|
-
.filter(([_, historyItem]) => historyItem.status.status ===
|
|
227
|
-
historyItem.status.status ===
|
|
213
|
+
.filter(([_, historyItem]) => historyItem.status.status === bridge_controller_2.StatusTypes.PENDING ||
|
|
214
|
+
historyItem.status.status === bridge_controller_2.StatusTypes.UNKNOWN)
|
|
228
215
|
// Only poll items with txMetaId (post-submission items)
|
|
229
216
|
.filter(([_, historyItem]) => {
|
|
230
217
|
if (!historyItem.txMetaId) {
|
|
@@ -333,9 +320,9 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
333
320
|
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
334
321
|
// Track max polling reached event
|
|
335
322
|
const historyItem = this.state.txHistory[bridgeTxMetaId];
|
|
336
|
-
if (historyItem
|
|
323
|
+
if (historyItem) {
|
|
337
324
|
// Track polling status updated event
|
|
338
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId,
|
|
325
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId, bridge_controller_2.PollingStatus.MaxPollingReached);
|
|
339
326
|
}
|
|
340
327
|
}
|
|
341
328
|
// Update the attempts counter
|
|
@@ -357,7 +344,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
357
344
|
}
|
|
358
345
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
359
346
|
// Track polling status updated event
|
|
360
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId,
|
|
347
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId, bridge_controller_2.PollingStatus.InvalidTransactionHash);
|
|
361
348
|
// If we've failed too many times, stop polling for the tx
|
|
362
349
|
if (pollingToken) {
|
|
363
350
|
this.stopPollingByPollingToken(pollingToken);
|
|
@@ -403,7 +390,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
403
390
|
validationFailures = response.validationFailures;
|
|
404
391
|
}
|
|
405
392
|
if (validationFailures.length > 0) {
|
|
406
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
393
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed, bridgeTxMetaId, {
|
|
407
394
|
failures: validationFailures,
|
|
408
395
|
refresh_count: historyItem.attempts?.counter ?? 0,
|
|
409
396
|
});
|
|
@@ -413,8 +400,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
413
400
|
const newBridgeHistoryItem = {
|
|
414
401
|
...historyItem,
|
|
415
402
|
status,
|
|
416
|
-
completionTime: status.status ===
|
|
417
|
-
status.status ===
|
|
403
|
+
completionTime: status.status === bridge_controller_2.StatusTypes.COMPLETE ||
|
|
404
|
+
status.status === bridge_controller_2.StatusTypes.FAILED
|
|
418
405
|
? Date.now()
|
|
419
406
|
: undefined, // TODO make this more accurate by looking up dest txHash block time
|
|
420
407
|
attempts: undefined,
|
|
@@ -431,21 +418,17 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
431
418
|
}
|
|
432
419
|
// 5. After effects
|
|
433
420
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
434
|
-
const isFinalStatus = status.status ===
|
|
435
|
-
status.status ===
|
|
421
|
+
const isFinalStatus = status.status === bridge_controller_2.StatusTypes.COMPLETE ||
|
|
422
|
+
status.status === bridge_controller_2.StatusTypes.FAILED;
|
|
436
423
|
if (isFinalStatus && pollingToken) {
|
|
437
424
|
this.stopPollingByPollingToken(pollingToken);
|
|
438
425
|
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
if (status.status === bridge_controller_1.StatusTypes.COMPLETE) {
|
|
444
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, bridgeTxMetaId);
|
|
426
|
+
if (status.status === bridge_controller_2.StatusTypes.COMPLETE) {
|
|
427
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, bridgeTxMetaId);
|
|
445
428
|
this.messenger.publish('BridgeStatusController:destinationTransactionCompleted', historyItem.quote.destAsset.assetId);
|
|
446
429
|
}
|
|
447
|
-
if (status.status ===
|
|
448
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
430
|
+
if (status.status === bridge_controller_2.StatusTypes.FAILED) {
|
|
431
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, bridgeTxMetaId);
|
|
449
432
|
}
|
|
450
433
|
}
|
|
451
434
|
}
|
|
@@ -470,7 +453,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
470
453
|
// But it is possible to have bridgeHistoryItem in state without the srcTxHash yet when it is an STX
|
|
471
454
|
const srcTxHash = txHistory[bridgeTxMetaId].status.srcChain.txHash;
|
|
472
455
|
if (srcTxHash ||
|
|
473
|
-
(0,
|
|
456
|
+
(0, bridge_controller_2.isNonEvmChainId)(txHistory[bridgeTxMetaId].quote.srcChainId)) {
|
|
474
457
|
return srcTxHash;
|
|
475
458
|
}
|
|
476
459
|
// Update history with TransactionController's hash if it has been updated
|
|
@@ -578,7 +561,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
578
561
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, payload.historyKey);
|
|
579
562
|
break;
|
|
580
563
|
case types_1.SubmitStep.PublishCompletedEvent:
|
|
581
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
564
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Completed, payload.historyKey);
|
|
582
565
|
break;
|
|
583
566
|
/* c8 ignore start */
|
|
584
567
|
default:
|
|
@@ -607,7 +590,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
607
590
|
* @returns The transaction meta
|
|
608
591
|
* @throws An error if transaction submission fails before it gets published
|
|
609
592
|
*/
|
|
610
|
-
this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location =
|
|
593
|
+
this.submitTx = async (accountAddress, maybeQuoteResponses, isStxEnabled, quotesReceivedContext, location = bridge_controller_2.MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades) => {
|
|
611
594
|
/**
|
|
612
595
|
* If there are multiple quote responses, we assume that they all originate from the same src chain
|
|
613
596
|
* and the same account. In this case its safe to use the first quote response's properties for
|
|
@@ -617,32 +600,35 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
617
600
|
? maybeQuoteResponses
|
|
618
601
|
: [maybeQuoteResponses];
|
|
619
602
|
const quoteResponse = quoteResponses[0];
|
|
620
|
-
const {
|
|
603
|
+
const { quote } = quoteResponse;
|
|
621
604
|
const startTime = Date.now();
|
|
622
|
-
(0, bridge_1.stopPollingForQuotes)(this.messenger,
|
|
605
|
+
(0, bridge_1.stopPollingForQuotes)(this.messenger, quotesReceivedContext);
|
|
623
606
|
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, accountAddress);
|
|
624
607
|
if (!selectedAccount) {
|
|
625
608
|
throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
|
|
626
609
|
}
|
|
627
|
-
const accountHardwareType = (0,
|
|
610
|
+
const accountHardwareType = (0, bridge_controller_2.getAccountHardwareType)(selectedAccount);
|
|
628
611
|
/**
|
|
629
612
|
* For hardware wallets on Mobile, this is fixes an issue where the Ledger does not get prompted for the 2nd approval.
|
|
630
613
|
* Extension does not have this issue
|
|
631
614
|
*/
|
|
632
615
|
const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === types_2.BridgeClientId.MOBILE && accountHardwareType !== null;
|
|
633
|
-
const isBridgeTx = (0,
|
|
634
|
-
const
|
|
616
|
+
const isBridgeTx = (0, bridge_controller_2.isCrossChain)(quote.srcChainId, quote.destChainId);
|
|
617
|
+
const batchId = quoteResponses.some(({ featureId: quoteFeatureId }) => quoteFeatureId === bridge_controller_1.FeatureId.BATCH_SELL)
|
|
618
|
+
? (0, transaction_controller_1.generateBatchId)()
|
|
619
|
+
: undefined;
|
|
620
|
+
const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabled, accountHardwareType, location, abTests, activeAbTests, tokenSecurityTypeDestination, batchSellTrades, batchId);
|
|
635
621
|
try {
|
|
636
622
|
// Emit Submitted event after submit button is clicked
|
|
637
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
623
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
|
|
638
624
|
/**
|
|
639
625
|
* Check if the account is an EIP-7702 delegated account.
|
|
640
626
|
* Delegated accounts only allow 1 in-flight tx, so approve + swap
|
|
641
627
|
* must be batched into a single transaction
|
|
642
628
|
*/
|
|
643
|
-
const isDelegatedAccount = (0,
|
|
629
|
+
const isDelegatedAccount = (0, bridge_controller_2.isNonEvmChainId)(quote.srcChainId)
|
|
644
630
|
? false
|
|
645
|
-
: await (0, transaction_1.checkIsDelegatedAccount)(this.messenger, selectedAccount.address, [(0,
|
|
631
|
+
: await (0, transaction_1.checkIsDelegatedAccount)(this.messenger, selectedAccount.address, [(0, bridge_controller_2.formatChainIdToHex)(quote.srcChainId)]);
|
|
646
632
|
const strategyParams = {
|
|
647
633
|
messenger: this.messenger,
|
|
648
634
|
quoteResponses,
|
|
@@ -657,6 +643,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
657
643
|
addTransactionBatchFn: __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f"),
|
|
658
644
|
fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
|
|
659
645
|
traceFn: __classPrivateFieldGet(this, _BridgeStatusController_trace, "f"),
|
|
646
|
+
batchId,
|
|
660
647
|
};
|
|
661
648
|
return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_1.getTraceParams)(quoteResponse, isStxEnabled), async () => await __classPrivateFieldGet(this, _BridgeStatusController_executeSubmitStrategy, "f").call(this, strategyParams, {
|
|
662
649
|
startTime,
|
|
@@ -667,10 +654,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
667
654
|
}));
|
|
668
655
|
}
|
|
669
656
|
catch (error) {
|
|
670
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
657
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
671
658
|
error_message: error?.message,
|
|
672
659
|
...preConfirmationProperties,
|
|
673
|
-
}
|
|
660
|
+
});
|
|
674
661
|
throw error;
|
|
675
662
|
}
|
|
676
663
|
};
|
|
@@ -706,43 +693,45 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
706
693
|
_BridgeStatusController_trackPollingStatusUpdatedEvent.set(this, (historyKey, pollingStatus) => {
|
|
707
694
|
// Track polling status updated event
|
|
708
695
|
const historyItem = this.state.txHistory[historyKey];
|
|
709
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
696
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_2.UnifiedSwapBridgeEventName.PollingStatusUpdated, historyKey, {
|
|
697
|
+
polling_status: pollingStatus,
|
|
698
|
+
retry_attempts: historyItem.attempts?.counter ?? 0,
|
|
699
|
+
});
|
|
710
700
|
});
|
|
711
701
|
/**
|
|
712
702
|
* Tracks post-submission events for a cross-chain swap based on the history item
|
|
713
703
|
*
|
|
714
704
|
* @param eventName - The name of the event to track
|
|
715
|
-
* @param
|
|
705
|
+
* @param txHistoryKey - The txMetaId of the history item to track the event for
|
|
716
706
|
* @param eventProperties - The properties for the event
|
|
717
|
-
* @param featureIdOverride - The featureId to use when the history item is not available. Should
|
|
718
|
-
* only be provided for events that are not associated with a history item yet, such as Submitted or Failed
|
|
719
707
|
*/
|
|
720
|
-
_BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName,
|
|
721
|
-
const historyItem =
|
|
722
|
-
? this.state.txHistory[
|
|
708
|
+
_BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txHistoryKey, eventProperties) => {
|
|
709
|
+
const historyItem = txHistoryKey
|
|
710
|
+
? this.state.txHistory[txHistoryKey]
|
|
723
711
|
: undefined;
|
|
724
|
-
const featureId =
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
featureId
|
|
728
|
-
|
|
729
|
-
eventName !== bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed;
|
|
730
|
-
if (shouldSkipMetrics) {
|
|
712
|
+
const featureId = eventProperties?.feature_id ??
|
|
713
|
+
historyItem?.featureId ??
|
|
714
|
+
bridge_controller_1.FeatureId.UNIFIED_SWAP_BRIDGE;
|
|
715
|
+
if (!(constants_1.ALLOWED_FEATURE_IDS_FOR_STATUS_EVENTS.includes(featureId) ||
|
|
716
|
+
eventName === bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed)) {
|
|
731
717
|
return;
|
|
732
718
|
}
|
|
733
719
|
// Legacy/new metrics fields are intentionally kept independent during migration.
|
|
734
|
-
const historyAbTests =
|
|
735
|
-
? this.state.txHistory?.[
|
|
720
|
+
const historyAbTests = txHistoryKey
|
|
721
|
+
? this.state.txHistory?.[txHistoryKey]?.abTests
|
|
736
722
|
: undefined;
|
|
737
|
-
const historyActiveAbTests =
|
|
738
|
-
? this.state.txHistory?.[
|
|
723
|
+
const historyActiveAbTests = txHistoryKey
|
|
724
|
+
? this.state.txHistory?.[txHistoryKey]?.activeAbTests
|
|
739
725
|
: undefined;
|
|
740
726
|
const resolvedAbTests = eventProperties?.ab_tests ?? historyAbTests;
|
|
741
727
|
const resolvedActiveAbTests = eventProperties?.active_ab_tests ?? historyActiveAbTests;
|
|
742
|
-
const location = (
|
|
743
|
-
|
|
728
|
+
const location = (txHistoryKey
|
|
729
|
+
? this.state.txHistory?.[txHistoryKey]?.location
|
|
730
|
+
: undefined) ?? bridge_controller_2.MetaMetricsSwapsEventSource.MainView;
|
|
744
731
|
const baseProperties = {
|
|
745
|
-
action_type:
|
|
732
|
+
action_type: bridge_controller_2.MetricsActionType.SWAPBRIDGE_V1,
|
|
733
|
+
feature_id: featureId ?? bridge_controller_1.FeatureId.UNIFIED_SWAP_BRIDGE,
|
|
734
|
+
...(historyItem?.batchId ? { batch_id: historyItem.batchId } : {}),
|
|
746
735
|
...(eventProperties ?? {}),
|
|
747
736
|
location,
|
|
748
737
|
...(resolvedAbTests &&
|
|
@@ -765,7 +754,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
765
754
|
}
|
|
766
755
|
const { approvalTxId, quote } = historyItem;
|
|
767
756
|
const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
768
|
-
if (eventName ===
|
|
757
|
+
if (eventName === bridge_controller_2.UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
769
758
|
(0, bridge_1.trackMetricsEvent)({
|
|
770
759
|
messenger: this.messenger,
|
|
771
760
|
eventName,
|
|
@@ -783,7 +772,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
783
772
|
}
|
|
784
773
|
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
785
774
|
const transactions = (0, transaction_1.getTransactions)(this.messenger);
|
|
786
|
-
const txMeta = transactions.find((tx) => tx.id ===
|
|
775
|
+
const txMeta = transactions.find((tx) => tx.id === txHistoryKey);
|
|
787
776
|
const approvalTxMeta = transactions.find((tx) => tx.id === approvalTxId);
|
|
788
777
|
const requiredEventProperties = {
|
|
789
778
|
...baseProperties,
|