@metamask/bridge-status-controller 70.0.0 → 70.0.1
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 +14 -1
- package/dist/bridge-status-controller.cjs +48 -172
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +2 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +2 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.cjs +7 -19
- package/dist/bridge-status-controller.intent.cjs.map +1 -1
- package/dist/bridge-status-controller.intent.d.cts +2 -10
- package/dist/bridge-status-controller.intent.d.cts.map +1 -1
- package/dist/bridge-status-controller.intent.d.mts +2 -10
- package/dist/bridge-status-controller.intent.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.mjs +7 -19
- package/dist/bridge-status-controller.intent.mjs.map +1 -1
- package/dist/bridge-status-controller.mjs +51 -175
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +10 -4
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +10 -4
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs +17 -1
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts +8 -2
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts +8 -2
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs +15 -0
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/gas.cjs +1 -58
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +3 -26
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +3 -26
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +0 -55
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/history.cjs +9 -8
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts +3 -2
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts +3 -2
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +9 -8
- package/dist/utils/history.mjs.map +1 -1
- package/dist/utils/intent-api.cjs +26 -26
- package/dist/utils/intent-api.cjs.map +1 -1
- package/dist/utils/intent-api.d.cts +7 -2
- package/dist/utils/intent-api.d.cts.map +1 -1
- package/dist/utils/intent-api.d.mts +7 -2
- package/dist/utils/intent-api.d.mts.map +1 -1
- package/dist/utils/intent-api.mjs +24 -25
- package/dist/utils/intent-api.mjs.map +1 -1
- package/dist/utils/snaps.cjs +5 -5
- package/dist/utils/snaps.cjs.map +1 -1
- package/dist/utils/snaps.d.cts +3 -17
- package/dist/utils/snaps.d.cts.map +1 -1
- package/dist/utils/snaps.d.mts +3 -17
- package/dist/utils/snaps.d.mts.map +1 -1
- package/dist/utils/snaps.mjs +6 -6
- package/dist/utils/snaps.mjs.map +1 -1
- package/dist/utils/transaction.cjs +250 -24
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +91 -169
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +91 -169
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +234 -19
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [70.0.1]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/bridge-controller` from `^69.1.1` to `^69.2.1` ([#8265](https://github.com/MetaMask/core/pull/8265), [#8288](https://github.com/MetaMask/core/pull/8288))
|
|
15
|
+
- Bump `@metamask/transaction-controller` from `^63.0.0` to `^63.1.0` ([#8272](https://github.com/MetaMask/core/pull/8272))
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Keep EIP-7702 batching disabled for gasless transactions that use smart transactions / `eth_sendBundle` when the quote is gas-included but not gas-included-7702 even when the account is a smart account ([#8275](https://github.com/MetaMask/core/pull/8275))
|
|
20
|
+
- For hardware wallets on MetaMask Mobile, non-batch EVM flows with ERC-20 approval now run the hardware-wallet delay before waiting for approval confirmation, preserving Ledger second-prompt spacing while gas estimation still runs after allowance is set on-chain ([#8268](https://github.com/MetaMask/core/pull/8268))
|
|
21
|
+
|
|
10
22
|
## [70.0.0]
|
|
11
23
|
|
|
12
24
|
### Changed
|
|
@@ -1047,7 +1059,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1047
1059
|
|
|
1048
1060
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
1049
1061
|
|
|
1050
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@70.0.
|
|
1062
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@70.0.1...HEAD
|
|
1063
|
+
[70.0.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@70.0.0...@metamask/bridge-status-controller@70.0.1
|
|
1051
1064
|
[70.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@69.0.0...@metamask/bridge-status-controller@70.0.0
|
|
1052
1065
|
[69.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.1.0...@metamask/bridge-status-controller@69.0.0
|
|
1053
1066
|
[68.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.2...@metamask/bridge-status-controller@68.1.0
|
|
@@ -10,11 +10,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_markTxAsFailed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_getSrcTxHash, _BridgeStatusController_updateSrcTxHash, _BridgeStatusController_wipeBridgeStatusByChainId,
|
|
13
|
+
var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_markTxAsFailed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_rekeyHistoryItem, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_getSrcTxHash, _BridgeStatusController_updateSrcTxHash, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_handleApprovalTx, _BridgeStatusController_handleEvmTransactionBatch, _BridgeStatusController_trackUnifiedSwapBridgeEvent;
|
|
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 controller_utils_1 = require("@metamask/controller-utils");
|
|
18
17
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
19
18
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
20
19
|
const utils_1 = require("@metamask/utils");
|
|
@@ -25,7 +24,6 @@ const accounts_1 = require("./utils/accounts.cjs");
|
|
|
25
24
|
const authentication_1 = require("./utils/authentication.cjs");
|
|
26
25
|
const bridge_1 = require("./utils/bridge.cjs");
|
|
27
26
|
const bridge_status_1 = require("./utils/bridge-status.cjs");
|
|
28
|
-
const gas_1 = require("./utils/gas.cjs");
|
|
29
27
|
const history_1 = require("./utils/history.cjs");
|
|
30
28
|
const intent_api_1 = require("./utils/intent-api.cjs");
|
|
31
29
|
const keyring_1 = require("./utils/keyring.cjs");
|
|
@@ -417,8 +415,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
417
415
|
return srcTxHash;
|
|
418
416
|
}
|
|
419
417
|
// Look up in TransactionController if txMeta has been updated with the srcTxHash
|
|
420
|
-
const
|
|
421
|
-
const txMeta = txControllerState.transactions.find((tx) => tx.id === bridgeTxMetaId);
|
|
418
|
+
const txMeta = (0, transaction_1.getTransactionMetaById)(this.messenger, bridgeTxMetaId);
|
|
422
419
|
return txMeta?.hash;
|
|
423
420
|
});
|
|
424
421
|
_BridgeStatusController_updateSrcTxHash.set(this, (bridgeTxMetaId, srcTxHash) => {
|
|
@@ -457,29 +454,18 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
457
454
|
* TX SUBMISSION HANDLING
|
|
458
455
|
*******************************************************
|
|
459
456
|
*/
|
|
460
|
-
_BridgeStatusController_waitForHashAndReturnFinalTxMeta.set(this, async (hashPromise) => {
|
|
461
|
-
const transactionHash = await hashPromise;
|
|
462
|
-
const finalTransactionMeta = this.messenger
|
|
463
|
-
.call('TransactionController:getState')
|
|
464
|
-
.transactions.find((tx) => tx.hash === transactionHash);
|
|
465
|
-
if (!finalTransactionMeta) {
|
|
466
|
-
throw new Error('Failed to submit cross-chain swap tx: txMeta for txHash was not found');
|
|
467
|
-
}
|
|
468
|
-
return finalTransactionMeta;
|
|
469
|
-
});
|
|
470
|
-
// Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.
|
|
471
|
-
_BridgeStatusController_waitForTxConfirmation.set(this, async (txId, { timeoutMs = 5 * 60000, // 5 minutes default
|
|
472
|
-
pollMs = 3000, } = {}) => {
|
|
473
|
-
return await (0, transaction_1.waitForTxConfirmation)(this.messenger, txId, {
|
|
474
|
-
timeoutMs,
|
|
475
|
-
pollMs,
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
457
|
_BridgeStatusController_handleApprovalTx.set(this, async (quoteResponse, isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
479
458
|
if (approval && (0, bridge_controller_1.isEvmTxData)(approval)) {
|
|
480
459
|
const approveTx = async () => {
|
|
481
|
-
|
|
482
|
-
|
|
460
|
+
if (resetApproval) {
|
|
461
|
+
await (0, transaction_1.submitEvmTransaction)({
|
|
462
|
+
messenger: this.messenger,
|
|
463
|
+
transactionType: transaction_controller_1.TransactionType.bridgeApproval,
|
|
464
|
+
trade: resetApproval,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
const approvalTxMeta = await (0, transaction_1.submitEvmTransaction)({
|
|
468
|
+
messenger: this.messenger,
|
|
483
469
|
transactionType: isBridgeTx
|
|
484
470
|
? transaction_controller_1.TransactionType.bridgeApproval
|
|
485
471
|
: transaction_controller_1.TransactionType.swapApproval,
|
|
@@ -493,85 +479,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
493
479
|
}
|
|
494
480
|
return undefined;
|
|
495
481
|
});
|
|
496
|
-
|
|
497
|
-
* Submits an EVM transaction to the TransactionController
|
|
498
|
-
*
|
|
499
|
-
* @param params - The parameters for the transaction
|
|
500
|
-
* @param params.transactionType - The type of transaction to submit
|
|
501
|
-
* @param params.trade - The trade data to confirm
|
|
502
|
-
* @param params.requireApproval - Whether to require approval for the transaction
|
|
503
|
-
* @param params.txFee - Optional gas fee parameters from the quote (used when gasIncluded is true)
|
|
504
|
-
* @param params.txFee.maxFeePerGas - The maximum fee per gas from the quote
|
|
505
|
-
* @param params.txFee.maxPriorityFeePerGas - The maximum priority fee per gas from the quote
|
|
506
|
-
* @param params.actionId - Optional actionId for pre-submission history (if not provided, one is generated)
|
|
507
|
-
* @returns The transaction meta
|
|
508
|
-
*/
|
|
509
|
-
_BridgeStatusController_handleEvmTransaction.set(this, async ({ transactionType, trade, requireApproval = false, txFee, actionId: providedActionId, }) => {
|
|
510
|
-
// Use provided actionId (for pre-submission history) or generate one
|
|
511
|
-
const actionId = providedActionId ?? (0, transaction_1.generateActionId)();
|
|
512
|
-
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, trade.from);
|
|
513
|
-
if (!selectedAccount) {
|
|
514
|
-
throw new Error('Failed to submit cross-chain swap transaction: unknown account in trade data');
|
|
515
|
-
}
|
|
516
|
-
const hexChainId = (0, bridge_controller_1.formatChainIdToHex)(trade.chainId);
|
|
517
|
-
const networkClientId = (0, network_1.getNetworkClientIdByChainId)(this.messenger, hexChainId);
|
|
518
|
-
const requestOptions = {
|
|
519
|
-
actionId,
|
|
520
|
-
networkClientId,
|
|
521
|
-
requireApproval,
|
|
522
|
-
type: transactionType,
|
|
523
|
-
origin: 'metamask',
|
|
524
|
-
};
|
|
525
|
-
// Exclude gasLimit from trade to avoid type issues (it can be null)
|
|
526
|
-
const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;
|
|
527
|
-
const transactionParams = {
|
|
528
|
-
...tradeWithoutGasLimit,
|
|
529
|
-
chainId: hexChainId,
|
|
530
|
-
// Only add gasLimit and gas if they're valid (not undefined/null/zero)
|
|
531
|
-
...(tradeGasLimit &&
|
|
532
|
-
tradeGasLimit !== 0 && {
|
|
533
|
-
gasLimit: tradeGasLimit.toString(),
|
|
534
|
-
gas: tradeGasLimit.toString(),
|
|
535
|
-
}),
|
|
536
|
-
};
|
|
537
|
-
const transactionParamsWithMaxGas = {
|
|
538
|
-
...transactionParams,
|
|
539
|
-
...(await __classPrivateFieldGet(this, _BridgeStatusController_calculateGasFees, "f").call(this, transactionParams, networkClientId, hexChainId, txFee)),
|
|
540
|
-
};
|
|
541
|
-
const { result } = await this.messenger.call('TransactionController:addTransaction', transactionParamsWithMaxGas, requestOptions);
|
|
542
|
-
return await __classPrivateFieldGet(this, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, "f").call(this, result);
|
|
543
|
-
});
|
|
544
|
-
_BridgeStatusController_handleUSDTAllowanceReset.set(this, async (resetApproval) => {
|
|
545
|
-
if (resetApproval) {
|
|
546
|
-
await __classPrivateFieldGet(this, _BridgeStatusController_handleEvmTransaction, "f").call(this, {
|
|
547
|
-
transactionType: transaction_controller_1.TransactionType.bridgeApproval,
|
|
548
|
-
trade: resetApproval,
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
});
|
|
552
|
-
_BridgeStatusController_calculateGasFees.set(this, async (transactionParams, networkClientId, chainId, txFee) => {
|
|
553
|
-
const { gas } = transactionParams;
|
|
554
|
-
// If txFee is provided (gasIncluded case), use the quote's gas fees
|
|
555
|
-
// Convert to hex since txFee values from the quote are decimal strings
|
|
556
|
-
if (txFee) {
|
|
557
|
-
return {
|
|
558
|
-
maxFeePerGas: (0, controller_utils_1.toHex)(txFee.maxFeePerGas),
|
|
559
|
-
maxPriorityFeePerGas: (0, controller_utils_1.toHex)(txFee.maxPriorityFeePerGas),
|
|
560
|
-
gas: gas ? (0, controller_utils_1.toHex)(gas) : undefined,
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
const { gasFeeEstimates } = this.messenger.call('GasFeeController:getState');
|
|
564
|
-
const { estimates: txGasFeeEstimates } = await this.messenger.call('TransactionController:estimateGasFee', { transactionParams, chainId, networkClientId });
|
|
565
|
-
const { maxFeePerGas, maxPriorityFeePerGas } = (0, gas_1.getTxGasEstimates)({
|
|
566
|
-
networkGasFeeEstimates: gasFeeEstimates,
|
|
567
|
-
txGasFeeEstimates,
|
|
568
|
-
});
|
|
569
|
-
return {
|
|
570
|
-
maxFeePerGas,
|
|
571
|
-
maxPriorityFeePerGas,
|
|
572
|
-
gas: gas ? (0, controller_utils_1.toHex)(gas) : undefined,
|
|
573
|
-
};
|
|
574
|
-
});
|
|
482
|
+
// TODO simplify and make more readable
|
|
575
483
|
/**
|
|
576
484
|
* Submits batched EVM transactions to the TransactionController
|
|
577
485
|
*
|
|
@@ -589,22 +497,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
589
497
|
messenger: this.messenger,
|
|
590
498
|
...args,
|
|
591
499
|
});
|
|
592
|
-
|
|
593
|
-
[transaction_controller_1.TransactionType.bridgeApproval]: transactionParams.transactions.find(({ type }) => type === transaction_controller_1.TransactionType.bridgeApproval)?.params.data,
|
|
594
|
-
[transaction_controller_1.TransactionType.swapApproval]: transactionParams.transactions.find(({ type }) => type === transaction_controller_1.TransactionType.swapApproval)?.params.data,
|
|
595
|
-
[transaction_controller_1.TransactionType.bridge]: transactionParams.transactions.find(({ type }) => type === transaction_controller_1.TransactionType.bridge)?.params.data,
|
|
596
|
-
[transaction_controller_1.TransactionType.swap]: transactionParams.transactions.find(({ type }) => type === transaction_controller_1.TransactionType.swap)?.params.data,
|
|
597
|
-
};
|
|
598
|
-
const { batchId } = await __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f").call(this, transactionParams);
|
|
599
|
-
const { approvalMeta, tradeMeta } = (0, transaction_1.findAndUpdateTransactionsInBatch)({
|
|
600
|
-
messenger: this.messenger,
|
|
601
|
-
batchId,
|
|
602
|
-
txDataByType,
|
|
603
|
-
});
|
|
604
|
-
if (!tradeMeta) {
|
|
605
|
-
throw new Error('Failed to update cross-chain swap transaction batch: tradeMeta not found');
|
|
606
|
-
}
|
|
607
|
-
return { approvalMeta, tradeMeta };
|
|
500
|
+
return await (0, transaction_1.addTransactionBatch)(this.messenger, __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f"), transactionParams);
|
|
608
501
|
});
|
|
609
502
|
/**
|
|
610
503
|
* Submits a cross-chain swap transaction
|
|
@@ -694,19 +587,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
694
587
|
// Delegated accounts only allow 1 in-flight tx, so approve + swap
|
|
695
588
|
// must be batched into a single transaction
|
|
696
589
|
const hexChainId = (0, bridge_controller_1.formatChainIdToHex)(quoteResponse.quote.srcChainId);
|
|
697
|
-
isDelegatedAccount = await (
|
|
698
|
-
try {
|
|
699
|
-
const atomicBatchSupport = await this.messenger.call('TransactionController:isAtomicBatchSupported', {
|
|
700
|
-
address: quoteResponse.trade
|
|
701
|
-
.from,
|
|
702
|
-
chainIds: [hexChainId],
|
|
703
|
-
});
|
|
704
|
-
return atomicBatchSupport.some((entry) => entry.isSupported && entry.delegationAddress);
|
|
705
|
-
}
|
|
706
|
-
catch {
|
|
707
|
-
return false;
|
|
708
|
-
}
|
|
709
|
-
})();
|
|
590
|
+
isDelegatedAccount = await (0, transaction_1.checkIsDelegatedAccount)(this.messenger, quoteResponse.trade.from, [hexChainId]);
|
|
710
591
|
if (isStxEnabledOnClient ||
|
|
711
592
|
quoteResponse.quote.gasIncluded7702 ||
|
|
712
593
|
isDelegatedAccount) {
|
|
@@ -729,17 +610,21 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
729
610
|
? quoteResponse.approval
|
|
730
611
|
: undefined, quoteResponse.resetApproval, requireApproval);
|
|
731
612
|
approvalTxId = approvalTxMeta?.id;
|
|
732
|
-
|
|
613
|
+
// Hardware-wallet delay first (Ledger second-prompt spacing), then wait for
|
|
614
|
+
// on-chain approval confirmation so swap gas estimation runs after allowance is set.
|
|
615
|
+
if (requireApproval && approvalTxMeta) {
|
|
616
|
+
await (0, transaction_1.handleMobileHardwareWalletDelay)(requireApproval);
|
|
617
|
+
await (0, transaction_1.waitForTxConfirmation)(this.messenger, approvalTxMeta.id);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
await (0, transaction_1.handleMobileHardwareWalletDelay)(requireApproval);
|
|
621
|
+
}
|
|
733
622
|
// Generate actionId for pre-submission history (non-batch EVM only)
|
|
734
623
|
const actionId = (0, transaction_1.generateActionId)().toString();
|
|
735
624
|
// Add pre-submission history keyed by actionId
|
|
736
625
|
// This ensures we have quote data available if transaction fails during submission
|
|
737
626
|
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
738
627
|
accountAddress: selectedAccount.address,
|
|
739
|
-
statusRequest: {
|
|
740
|
-
...(0, transaction_1.getStatusRequestParams)(quoteResponse),
|
|
741
|
-
srcTxHash: '', // Not available yet
|
|
742
|
-
},
|
|
743
628
|
quoteResponse,
|
|
744
629
|
slippagePercentage: 0,
|
|
745
630
|
isStxEnabled: isStxEnabledOnClient,
|
|
@@ -748,10 +633,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
748
633
|
location,
|
|
749
634
|
abTests,
|
|
750
635
|
activeAbTests,
|
|
751
|
-
|
|
636
|
+
actionId,
|
|
637
|
+
});
|
|
752
638
|
// Pass txFee when gasIncluded is true to use the quote's gas fees
|
|
753
639
|
// instead of re-estimating (which would fail for max native token swaps)
|
|
754
|
-
const tradeTxMeta = await
|
|
640
|
+
const tradeTxMeta = await (0, transaction_1.submitEvmTransaction)({
|
|
641
|
+
messenger: this.messenger,
|
|
755
642
|
transactionType: isBridgeTx
|
|
756
643
|
? transaction_controller_1.TransactionType.bridge
|
|
757
644
|
: transaction_controller_1.TransactionType.swap,
|
|
@@ -779,10 +666,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
779
666
|
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
780
667
|
accountAddress: selectedAccount.address,
|
|
781
668
|
bridgeTxMeta: txMeta, // Only the id field is used by the BridgeStatusController
|
|
782
|
-
statusRequest: {
|
|
783
|
-
...(0, transaction_1.getStatusRequestParams)(quoteResponse),
|
|
784
|
-
srcTxHash: txMeta.hash,
|
|
785
|
-
},
|
|
786
669
|
quoteResponse,
|
|
787
670
|
slippagePercentage: 0, // TODO include slippage provided by quote if using dynamic slippage, or slippage from quote request
|
|
788
671
|
isStxEnabled: isStxEnabledOnClient,
|
|
@@ -823,6 +706,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
823
706
|
const { quoteResponse, accountAddress, location, abTests, activeAbTests } = params;
|
|
824
707
|
// TODO add metrics context
|
|
825
708
|
(0, bridge_1.stopPollingForQuotes)(this.messenger);
|
|
709
|
+
const startTime = Date.now();
|
|
826
710
|
// Build pre-confirmation properties for error tracking parity with submitTx
|
|
827
711
|
const account = (0, accounts_1.getAccountByAddress)(this.messenger, accountAddress);
|
|
828
712
|
const isHardwareAccount = Boolean(account) && (0, bridge_controller_1.isHardwareWallet)(account);
|
|
@@ -837,7 +721,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
837
721
|
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
838
722
|
const approvalTxId = approvalTxMeta?.id;
|
|
839
723
|
if (approvalTxId) {
|
|
840
|
-
await
|
|
724
|
+
await (0, transaction_1.waitForTxConfirmation)(this.messenger, approvalTxId);
|
|
841
725
|
}
|
|
842
726
|
const { srcChainId, requestId } = quoteResponse.quote;
|
|
843
727
|
const signature = await (0, keyring_1.signTypedMessage)({
|
|
@@ -853,8 +737,13 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
853
737
|
userAddress: accountAddress,
|
|
854
738
|
aggregatorId: intent.protocol,
|
|
855
739
|
};
|
|
856
|
-
const
|
|
857
|
-
|
|
740
|
+
const { id: orderUid, status } = await (0, intent_api_1.postSubmitOrder)({
|
|
741
|
+
params: submissionParams,
|
|
742
|
+
clientId: __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"),
|
|
743
|
+
jwt: await (0, authentication_1.getJwt)(this.messenger),
|
|
744
|
+
fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
|
|
745
|
+
bridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
|
|
746
|
+
});
|
|
858
747
|
// Determine transaction type: swap for same-chain, bridge for cross-chain
|
|
859
748
|
const transactionType = isBridgeTx
|
|
860
749
|
? /* c8 ignore start */
|
|
@@ -875,25 +764,16 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
875
764
|
gas: '0x5208', // Minimal gas for display purposes
|
|
876
765
|
gasPrice: '0x3b9aca00', // 1 Gwei - will be converted to EIP-1559 fees if network supports it
|
|
877
766
|
};
|
|
878
|
-
const
|
|
879
|
-
origin: 'metamask',
|
|
880
|
-
actionId: (0, transaction_1.generateActionId)(),
|
|
767
|
+
const initialTxMeta = await (0, transaction_1.addSyntheticTransaction)(this.messenger, intentTransactionParams, {
|
|
881
768
|
requireApproval: false,
|
|
882
|
-
isStateOnly: true,
|
|
883
769
|
networkClientId,
|
|
884
770
|
type: transactionType,
|
|
885
771
|
});
|
|
886
|
-
|
|
887
|
-
// Map intent order status to TransactionController status
|
|
888
|
-
const initialTransactionStatus = (0, intent_api_1.mapIntentOrderStatusToTransactionStatus)(intentOrder.status);
|
|
889
|
-
// Update transaction with proper initial status based on intent order
|
|
890
|
-
const statusUpdatedTxMeta = {
|
|
891
|
-
...intentTxMeta,
|
|
892
|
-
status: initialTransactionStatus,
|
|
893
|
-
};
|
|
894
|
-
// Update with actual transaction metadata
|
|
772
|
+
// Update txHistory with actual transaction metadata
|
|
895
773
|
const syntheticMeta = {
|
|
896
|
-
...
|
|
774
|
+
...initialTxMeta,
|
|
775
|
+
// Map intent order status to TransactionController status
|
|
776
|
+
status: (0, intent_api_1.mapIntentOrderStatusToTransactionStatus)(status),
|
|
897
777
|
isIntentTx: true,
|
|
898
778
|
orderUid,
|
|
899
779
|
};
|
|
@@ -907,14 +787,9 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
907
787
|
id: bridgeHistoryKey,
|
|
908
788
|
originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
|
|
909
789
|
};
|
|
910
|
-
const startTime = Date.now();
|
|
911
790
|
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
912
791
|
accountAddress,
|
|
913
792
|
bridgeTxMeta: bridgeTxMetaForHistory,
|
|
914
|
-
statusRequest: {
|
|
915
|
-
...(0, transaction_1.getStatusRequestParams)(quoteResponse),
|
|
916
|
-
srcTxHash: syntheticMeta.hash ?? '',
|
|
917
|
-
},
|
|
918
793
|
quoteResponse,
|
|
919
794
|
slippagePercentage: 0,
|
|
920
795
|
isStxEnabled: false,
|
|
@@ -991,6 +866,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
991
866
|
});
|
|
992
867
|
return;
|
|
993
868
|
}
|
|
869
|
+
const { featureId, approvalTxId, quote } = historyItem;
|
|
994
870
|
const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
995
871
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
996
872
|
if (eventName === bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
@@ -1009,13 +885,13 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1009
885
|
return;
|
|
1010
886
|
}
|
|
1011
887
|
// Skip tracking all other events when featureId is set (i.e. PERPS)
|
|
1012
|
-
if (
|
|
888
|
+
if (featureId) {
|
|
1013
889
|
return;
|
|
1014
890
|
}
|
|
1015
891
|
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
1016
|
-
const
|
|
1017
|
-
const txMeta = transactions
|
|
1018
|
-
const approvalTxMeta = transactions
|
|
892
|
+
const transactions = (0, transaction_1.getTransactions)(this.messenger);
|
|
893
|
+
const txMeta = transactions.find((tx) => tx.id === txMetaId);
|
|
894
|
+
const approvalTxMeta = transactions.find((tx) => tx.id === approvalTxId);
|
|
1019
895
|
const requiredEventProperties = {
|
|
1020
896
|
...baseProperties,
|
|
1021
897
|
...requestParamProperties,
|
|
@@ -1023,7 +899,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1023
899
|
...(0, metrics_1.getTradeDataFromHistory)(historyItem),
|
|
1024
900
|
...(0, metrics_1.getTxStatusesFromHistory)(historyItem),
|
|
1025
901
|
...(0, metrics_1.getFinalizedTxProperties)(historyItem, txMeta, approvalTxMeta),
|
|
1026
|
-
...(0, metrics_1.getPriceImpactFromQuote)(
|
|
902
|
+
...(0, metrics_1.getPriceImpactFromQuote)(quote),
|
|
1027
903
|
};
|
|
1028
904
|
(0, bridge_1.trackMetricsEvent)({
|
|
1029
905
|
messenger: this.messenger,
|
|
@@ -1099,5 +975,5 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1099
975
|
}
|
|
1100
976
|
}
|
|
1101
977
|
exports.BridgeStatusController = BridgeStatusController;
|
|
1102
|
-
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_markTxAsFailed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_rekeyHistoryItem = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(), _BridgeStatusController_getSrcTxHash = new WeakMap(), _BridgeStatusController_updateSrcTxHash = new WeakMap(), _BridgeStatusController_wipeBridgeStatusByChainId = new WeakMap(),
|
|
978
|
+
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_markTxAsFailed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_rekeyHistoryItem = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(), _BridgeStatusController_getSrcTxHash = new WeakMap(), _BridgeStatusController_updateSrcTxHash = new WeakMap(), _BridgeStatusController_wipeBridgeStatusByChainId = new WeakMap(), _BridgeStatusController_handleApprovalTx = new WeakMap(), _BridgeStatusController_handleEvmTransactionBatch = new WeakMap(), _BridgeStatusController_trackUnifiedSwapBridgeEvent = new WeakMap();
|
|
1103
979
|
//# sourceMappingURL=bridge-status-controller.cjs.map
|