@metamask-previews/bridge-status-controller 63.1.0-preview-bfee350 → 64.0.1-preview-5c1b2b1
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 +12 -1
- package/dist/bridge-status-controller.cjs +60 -44
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +3 -4
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +3 -4
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +22 -6
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts +1 -1
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts +1 -1
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +3 -3
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +3 -3
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs.map +1 -1
- package/dist/utils/swap-received-amount.cjs.map +1 -1
- package/dist/utils/swap-received-amount.d.cts +1 -1
- package/dist/utils/swap-received-amount.d.cts.map +1 -1
- package/dist/utils/swap-received-amount.d.mts +1 -1
- package/dist/utils/swap-received-amount.d.mts.map +1 -1
- package/dist/utils/swap-received-amount.mjs.map +1 -1
- package/dist/utils/transaction.cjs +3 -4
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +3 -5
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +3 -5
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +1 -2
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,8 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [64.0.1]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fix MAX native token swap failing with "insufficient gas" when STX is off by using quote's `txFee` instead of re-estimating gas when `gasIncluded` is true ([#7306](https://github.com/MetaMask/core/pull/7306))
|
|
15
|
+
|
|
16
|
+
## [64.0.0]
|
|
17
|
+
|
|
10
18
|
### Changed
|
|
11
19
|
|
|
20
|
+
- **BREAKING:** Bump `@metamask/bridge-controller` from `^63.2.0` to `^64.0.0` ([#7295](https://github.com/MetaMask/core/pull/7295))
|
|
12
21
|
- Improve type safety by replacing tx data type assertions with type predicates ([#7228](https://github.com/MetaMask/core/pull/7228))
|
|
13
22
|
- Submit `resetApproval` tx before the tx approval if it is included in the quoteResponse ([#7228](https://github.com/MetaMask/core/pull/7228))
|
|
14
23
|
- Bump `@metamask/network-controller` from `^26.0.0` to `^27.0.0` ([#7258](https://github.com/MetaMask/core/pull/7258))
|
|
@@ -806,7 +815,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
806
815
|
|
|
807
816
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
808
817
|
|
|
809
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@
|
|
818
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.0.1...HEAD
|
|
819
|
+
[64.0.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.0.0...@metamask/bridge-status-controller@64.0.1
|
|
820
|
+
[64.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@63.1.0...@metamask/bridge-status-controller@64.0.0
|
|
810
821
|
[63.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@63.0.0...@metamask/bridge-status-controller@63.1.0
|
|
811
822
|
[63.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@62.0.0...@metamask/bridge-status-controller@63.0.0
|
|
812
823
|
[62.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@61.0.0...@metamask/bridge-status-controller@62.0.0
|
|
@@ -14,7 +14,6 @@ var _BridgeStatusController_instances, _BridgeStatusController_pollingTokensByTx
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.BridgeStatusController = void 0;
|
|
16
16
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
17
|
-
const bridge_controller_2 = require("@metamask/bridge-controller");
|
|
18
17
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
19
18
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
20
19
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
@@ -66,7 +65,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
this.update((statusState) => {
|
|
69
|
-
statusState.txHistory[txHistoryKey].status.status =
|
|
68
|
+
statusState.txHistory[txHistoryKey].status.status = bridge_controller_1.StatusTypes.FAILED;
|
|
70
69
|
});
|
|
71
70
|
});
|
|
72
71
|
this.resetState = () => {
|
|
@@ -124,7 +123,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
124
123
|
}
|
|
125
124
|
});
|
|
126
125
|
// Restart polling if it was stopped and this is a bridge transaction
|
|
127
|
-
const isBridgeTx = (0,
|
|
126
|
+
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(historyItem.quote.srcChainId, historyItem.quote.destChainId);
|
|
128
127
|
if (isBridgeTx) {
|
|
129
128
|
// Check if polling was stopped (no active polling token)
|
|
130
129
|
const existingPollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[targetTxMetaId];
|
|
@@ -152,8 +151,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
152
151
|
const { txHistory } = this.state;
|
|
153
152
|
const historyItems = Object.values(txHistory);
|
|
154
153
|
const incompleteHistoryItems = historyItems
|
|
155
|
-
.filter((historyItem) => historyItem.status.status ===
|
|
156
|
-
historyItem.status.status ===
|
|
154
|
+
.filter((historyItem) => historyItem.status.status === bridge_controller_1.StatusTypes.PENDING ||
|
|
155
|
+
historyItem.status.status === bridge_controller_1.StatusTypes.UNKNOWN)
|
|
157
156
|
.filter((historyItem) => {
|
|
158
157
|
// Check if we are already polling this tx, if so, skip restarting polling for that
|
|
159
158
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[historyItem.txMetaId];
|
|
@@ -161,7 +160,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
161
160
|
})
|
|
162
161
|
// Swap txs don't need to have their statuses polled
|
|
163
162
|
.filter((historyItem) => {
|
|
164
|
-
const isBridgeTx = (0,
|
|
163
|
+
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(historyItem.quote.srcChainId, historyItem.quote.destChainId);
|
|
165
164
|
return isBridgeTx;
|
|
166
165
|
});
|
|
167
166
|
incompleteHistoryItems.forEach((historyItem) => {
|
|
@@ -199,7 +198,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
199
198
|
status: {
|
|
200
199
|
// We always have a PENDING status when we start polling for a tx, don't need the Bridge API for that
|
|
201
200
|
// Also we know the bare minimum fields for status at this point in time
|
|
202
|
-
status:
|
|
201
|
+
status: bridge_controller_1.StatusTypes.PENDING,
|
|
203
202
|
srcChain: {
|
|
204
203
|
chainId: statusRequest.srcChainId,
|
|
205
204
|
txHash: statusRequest.srcTxHash,
|
|
@@ -226,7 +225,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
226
225
|
return;
|
|
227
226
|
}
|
|
228
227
|
const { quote } = txHistoryItem;
|
|
229
|
-
const isBridgeTx = (0,
|
|
228
|
+
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quote.srcChainId, quote.destChainId);
|
|
230
229
|
if (isBridgeTx) {
|
|
231
230
|
__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
|
|
232
231
|
bridgeTxMetaId: txId,
|
|
@@ -302,7 +301,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
302
301
|
const statusRequest = (0, bridge_status_1.getStatusRequestWithSrcTxHash)(historyItem.quote, srcTxHash);
|
|
303
302
|
const { status, validationFailures } = await (0, bridge_status_1.fetchBridgeTxStatus)(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl);
|
|
304
303
|
if (validationFailures.length > 0) {
|
|
305
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
304
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed, bridgeTxMetaId, {
|
|
306
305
|
failures: validationFailures,
|
|
307
306
|
});
|
|
308
307
|
throw new Error(`Bridge status validation failed: ${validationFailures.join(', ')}`);
|
|
@@ -310,8 +309,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
310
309
|
const newBridgeHistoryItem = {
|
|
311
310
|
...historyItem,
|
|
312
311
|
status,
|
|
313
|
-
completionTime: status.status ===
|
|
314
|
-
status.status ===
|
|
312
|
+
completionTime: status.status === bridge_controller_1.StatusTypes.COMPLETE ||
|
|
313
|
+
status.status === bridge_controller_1.StatusTypes.FAILED
|
|
315
314
|
? Date.now()
|
|
316
315
|
: undefined, // TODO make this more accurate by looking up dest txHash block time
|
|
317
316
|
attempts: undefined,
|
|
@@ -324,8 +323,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
324
323
|
state.txHistory[bridgeTxMetaId] = newBridgeHistoryItem;
|
|
325
324
|
});
|
|
326
325
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
327
|
-
const isFinalStatus = status.status ===
|
|
328
|
-
status.status ===
|
|
326
|
+
const isFinalStatus = status.status === bridge_controller_1.StatusTypes.COMPLETE ||
|
|
327
|
+
status.status === bridge_controller_1.StatusTypes.FAILED;
|
|
329
328
|
if (isFinalStatus && pollingToken) {
|
|
330
329
|
this.stopPollingByPollingToken(pollingToken);
|
|
331
330
|
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
@@ -333,12 +332,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
333
332
|
if (historyItem.featureId) {
|
|
334
333
|
return;
|
|
335
334
|
}
|
|
336
|
-
if (status.status ===
|
|
337
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
335
|
+
if (status.status === bridge_controller_1.StatusTypes.COMPLETE) {
|
|
336
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, bridgeTxMetaId);
|
|
338
337
|
this.messenger.publish('BridgeStatusController:destinationTransactionCompleted', historyItem.quote.destAsset.assetId);
|
|
339
338
|
}
|
|
340
|
-
if (status.status ===
|
|
341
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
339
|
+
if (status.status === bridge_controller_1.StatusTypes.FAILED) {
|
|
340
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, bridgeTxMetaId);
|
|
342
341
|
}
|
|
343
342
|
}
|
|
344
343
|
}
|
|
@@ -453,7 +452,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
453
452
|
? constants_1.TraceName.BridgeTransactionApprovalCompleted
|
|
454
453
|
: constants_1.TraceName.SwapTransactionApprovalCompleted,
|
|
455
454
|
data: {
|
|
456
|
-
srcChainId: (0,
|
|
455
|
+
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(srcChainId),
|
|
457
456
|
stxEnabled: false,
|
|
458
457
|
},
|
|
459
458
|
}, approveTx);
|
|
@@ -467,15 +466,18 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
467
466
|
* @param params.transactionType - The type of transaction to submit
|
|
468
467
|
* @param params.trade - The trade data to confirm
|
|
469
468
|
* @param params.requireApproval - Whether to require approval for the transaction
|
|
469
|
+
* @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)
|
|
470
|
+
* @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote
|
|
471
|
+
* @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote
|
|
470
472
|
* @returns The transaction meta
|
|
471
473
|
*/
|
|
472
|
-
_BridgeStatusController_handleEvmTransaction.set(this, async ({ transactionType, trade, requireApproval = false, }) => {
|
|
474
|
+
_BridgeStatusController_handleEvmTransaction.set(this, async ({ transactionType, trade, requireApproval = false, txFee, }) => {
|
|
473
475
|
const actionId = (0, transaction_1.generateActionId)().toString();
|
|
474
476
|
const selectedAccount = this.messenger.call('AccountsController:getAccountByAddress', trade.from);
|
|
475
477
|
if (!selectedAccount) {
|
|
476
478
|
throw new Error('Failed to submit cross-chain swap transaction: unknown account in trade data');
|
|
477
479
|
}
|
|
478
|
-
const hexChainId = (0,
|
|
480
|
+
const hexChainId = (0, bridge_controller_1.formatChainIdToHex)(trade.chainId);
|
|
479
481
|
const networkClientId = this.messenger.call('NetworkController:findNetworkClientIdByChainId', hexChainId);
|
|
480
482
|
const requestOptions = {
|
|
481
483
|
actionId,
|
|
@@ -492,7 +494,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
492
494
|
};
|
|
493
495
|
const transactionParamsWithMaxGas = {
|
|
494
496
|
...transactionParams,
|
|
495
|
-
...(await __classPrivateFieldGet(this, _BridgeStatusController_calculateGasFees, "f").call(this, transactionParams, networkClientId, hexChainId)),
|
|
497
|
+
...(await __classPrivateFieldGet(this, _BridgeStatusController_calculateGasFees, "f").call(this, transactionParams, networkClientId, hexChainId, txFee)),
|
|
496
498
|
};
|
|
497
499
|
const { result } = await __classPrivateFieldGet(this, _BridgeStatusController_addTransactionFn, "f").call(this, transactionParamsWithMaxGas, requestOptions);
|
|
498
500
|
return await __classPrivateFieldGet(this, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, "f").call(this, result);
|
|
@@ -505,7 +507,17 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
505
507
|
});
|
|
506
508
|
}
|
|
507
509
|
});
|
|
508
|
-
_BridgeStatusController_calculateGasFees.set(this, async (transactionParams, networkClientId, chainId) => {
|
|
510
|
+
_BridgeStatusController_calculateGasFees.set(this, async (transactionParams, networkClientId, chainId, txFee) => {
|
|
511
|
+
const maxGasLimit = (0, controller_utils_1.toHex)(transactionParams.gas ?? 0);
|
|
512
|
+
// If txFee is provided (gasIncluded case), use the quote's gas fees
|
|
513
|
+
// Convert to hex since txFee values from the quote are decimal strings
|
|
514
|
+
if (txFee) {
|
|
515
|
+
return {
|
|
516
|
+
maxFeePerGas: (0, controller_utils_1.toHex)(txFee.maxFeePerGas ?? 0),
|
|
517
|
+
maxPriorityFeePerGas: (0, controller_utils_1.toHex)(txFee.maxPriorityFeePerGas ?? 0),
|
|
518
|
+
gas: maxGasLimit,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
509
521
|
const { gasFeeEstimates } = this.messenger.call('GasFeeController:getState');
|
|
510
522
|
const { estimates: txGasFeeEstimates } = await __classPrivateFieldGet(this, _BridgeStatusController_estimateGasFeeFn, "f").call(this, {
|
|
511
523
|
transactionParams,
|
|
@@ -516,7 +528,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
516
528
|
networkGasFeeEstimates: gasFeeEstimates,
|
|
517
529
|
txGasFeeEstimates,
|
|
518
530
|
});
|
|
519
|
-
const maxGasLimit = (0, controller_utils_1.toHex)(transactionParams.gas ?? 0);
|
|
520
531
|
return {
|
|
521
532
|
maxFeePerGas,
|
|
522
533
|
maxPriorityFeePerGas,
|
|
@@ -569,7 +580,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
569
580
|
* @returns The transaction meta
|
|
570
581
|
*/
|
|
571
582
|
this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext) => {
|
|
572
|
-
this.messenger.call('BridgeController:stopPollingForQuotes',
|
|
583
|
+
this.messenger.call('BridgeController:stopPollingForQuotes', bridge_controller_1.AbortReason.TransactionSubmitted,
|
|
573
584
|
// If trade is submitted before all quotes are loaded, the QuotesReceived event is published
|
|
574
585
|
// 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
|
|
575
586
|
quoteResponse.featureId ? undefined : quotesReceivedContext);
|
|
@@ -577,37 +588,37 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
577
588
|
if (!selectedAccount) {
|
|
578
589
|
throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
|
|
579
590
|
}
|
|
580
|
-
const isHardwareAccount = (0,
|
|
591
|
+
const isHardwareAccount = (0, bridge_controller_1.isHardwareWallet)(selectedAccount);
|
|
581
592
|
const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, isStxEnabledOnClient, isHardwareAccount);
|
|
582
593
|
// Emit Submitted event after submit button is clicked
|
|
583
594
|
!quoteResponse.featureId &&
|
|
584
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
595
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Submitted, undefined, preConfirmationProperties);
|
|
585
596
|
let txMeta;
|
|
586
597
|
let approvalTxId;
|
|
587
598
|
const startTime = Date.now();
|
|
588
|
-
const isBridgeTx = (0,
|
|
599
|
+
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
589
600
|
// Submit non-EVM tx (Solana, BTC, Tron)
|
|
590
|
-
if ((0,
|
|
601
|
+
if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
|
|
591
602
|
// Handle non-EVM approval if present (e.g., Tron token approvals)
|
|
592
|
-
if (quoteResponse.approval && (0,
|
|
603
|
+
if (quoteResponse.approval && (0, bridge_controller_1.isTronTrade)(quoteResponse.approval)) {
|
|
593
604
|
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
594
605
|
name: isBridgeTx
|
|
595
606
|
? constants_1.TraceName.BridgeTransactionApprovalCompleted
|
|
596
607
|
: constants_1.TraceName.SwapTransactionApprovalCompleted,
|
|
597
608
|
data: {
|
|
598
|
-
srcChainId: (0,
|
|
609
|
+
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
599
610
|
stxEnabled: false,
|
|
600
611
|
},
|
|
601
612
|
}, async () => {
|
|
602
613
|
try {
|
|
603
614
|
return quoteResponse.approval &&
|
|
604
|
-
(0,
|
|
615
|
+
(0, bridge_controller_1.isTronTrade)(quoteResponse.approval)
|
|
605
616
|
? await __classPrivateFieldGet(this, _BridgeStatusController_handleNonEvmTx, "f").call(this, quoteResponse.approval, quoteResponse, selectedAccount)
|
|
606
617
|
: undefined;
|
|
607
618
|
}
|
|
608
619
|
catch (error) {
|
|
609
620
|
!quoteResponse.featureId &&
|
|
610
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
621
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
611
622
|
error_message: error?.message,
|
|
612
623
|
...preConfirmationProperties,
|
|
613
624
|
});
|
|
@@ -623,13 +634,13 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
623
634
|
? constants_1.TraceName.BridgeTransactionCompleted
|
|
624
635
|
: constants_1.TraceName.SwapTransactionCompleted,
|
|
625
636
|
data: {
|
|
626
|
-
srcChainId: (0,
|
|
637
|
+
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
627
638
|
stxEnabled: false,
|
|
628
639
|
},
|
|
629
640
|
}, async () => {
|
|
630
641
|
try {
|
|
631
|
-
if (!((0,
|
|
632
|
-
(0,
|
|
642
|
+
if (!((0, bridge_controller_1.isTronTrade)(quoteResponse.trade) ||
|
|
643
|
+
(0, bridge_controller_1.isBitcoinTrade)(quoteResponse.trade) ||
|
|
633
644
|
typeof quoteResponse.trade === 'string')) {
|
|
634
645
|
throw new Error('Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction');
|
|
635
646
|
}
|
|
@@ -637,7 +648,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
637
648
|
}
|
|
638
649
|
catch (error) {
|
|
639
650
|
!quoteResponse.featureId &&
|
|
640
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
651
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, txMeta?.id, {
|
|
641
652
|
error_message: error?.message,
|
|
642
653
|
...preConfirmationProperties,
|
|
643
654
|
});
|
|
@@ -656,7 +667,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
656
667
|
? constants_1.TraceName.BridgeTransactionCompleted
|
|
657
668
|
: constants_1.TraceName.SwapTransactionCompleted,
|
|
658
669
|
data: {
|
|
659
|
-
srcChainId: (0,
|
|
670
|
+
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
660
671
|
stxEnabled: isStxEnabledOnClient,
|
|
661
672
|
},
|
|
662
673
|
}, async () => {
|
|
@@ -683,12 +694,17 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
683
694
|
: undefined, quoteResponse.resetApproval, requireApproval);
|
|
684
695
|
approvalTxId = approvalTxMeta?.id;
|
|
685
696
|
await (0, transaction_1.handleMobileHardwareWalletDelay)(requireApproval);
|
|
697
|
+
// Pass txFee when gasIncluded is true to use the quote's gas fees
|
|
698
|
+
// instead of re-estimating (which would fail for max native token swaps)
|
|
686
699
|
return await __classPrivateFieldGet(this, _BridgeStatusController_handleEvmTransaction, "f").call(this, {
|
|
687
700
|
transactionType: isBridgeTx
|
|
688
701
|
? transaction_controller_1.TransactionType.bridge
|
|
689
702
|
: transaction_controller_1.TransactionType.swap,
|
|
690
703
|
trade: quoteResponse.trade,
|
|
691
704
|
requireApproval,
|
|
705
|
+
txFee: quoteResponse.quote.gasIncluded
|
|
706
|
+
? quoteResponse.quote.feeData.txFee
|
|
707
|
+
: undefined,
|
|
692
708
|
});
|
|
693
709
|
});
|
|
694
710
|
}
|
|
@@ -707,12 +723,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
707
723
|
startTime,
|
|
708
724
|
approvalTxId,
|
|
709
725
|
});
|
|
710
|
-
if ((0,
|
|
726
|
+
if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
|
|
711
727
|
// Start polling for bridge tx status
|
|
712
728
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, txMeta.id);
|
|
713
729
|
// Track non-EVM Swap completed event
|
|
714
730
|
if (!isBridgeTx) {
|
|
715
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
731
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, txMeta.id);
|
|
716
732
|
}
|
|
717
733
|
}
|
|
718
734
|
}
|
|
@@ -730,7 +746,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
730
746
|
*/
|
|
731
747
|
_BridgeStatusController_trackUnifiedSwapBridgeEvent.set(this, (eventName, txMetaId, eventProperties) => {
|
|
732
748
|
const baseProperties = {
|
|
733
|
-
action_type:
|
|
749
|
+
action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
|
|
734
750
|
...(eventProperties ?? {}),
|
|
735
751
|
};
|
|
736
752
|
// This will publish events for PERPS dropped tx failures as well
|
|
@@ -745,7 +761,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
745
761
|
}
|
|
746
762
|
const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
747
763
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
748
|
-
if (eventName ===
|
|
764
|
+
if (eventName === bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
749
765
|
const { chain_id_source, chain_id_destination, token_address_source, token_address_destination, } = requestParamProperties;
|
|
750
766
|
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, {
|
|
751
767
|
...baseProperties,
|
|
@@ -813,16 +829,16 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
813
829
|
__classPrivateFieldGet(this, _BridgeStatusController_markTxAsFailed, "f").call(this, transactionMeta);
|
|
814
830
|
// Track failed event
|
|
815
831
|
if (status !== transaction_controller_1.TransactionStatus.rejected) {
|
|
816
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
832
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, id, (0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(transactionMeta));
|
|
817
833
|
}
|
|
818
834
|
}
|
|
819
835
|
});
|
|
820
836
|
this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
|
|
821
837
|
const { type, id, chainId } = transactionMeta;
|
|
822
838
|
if (type === transaction_controller_1.TransactionType.swap) {
|
|
823
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this,
|
|
839
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, id);
|
|
824
840
|
}
|
|
825
|
-
if (type === transaction_controller_1.TransactionType.bridge && !(0,
|
|
841
|
+
if (type === transaction_controller_1.TransactionType.bridge && !(0, bridge_controller_1.isNonEvmChainId)(chainId)) {
|
|
826
842
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, id);
|
|
827
843
|
}
|
|
828
844
|
});
|