@metamask-previews/bridge-status-controller 64.1.0-preview-8cfea65a → 64.2.0-preview-d24ded2
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 +5 -2
- package/dist/bridge-status-controller.cjs +15 -405
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +1 -16
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +1 -16
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +15 -405
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/types.cjs +7 -9
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +16 -26
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +16 -26
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +7 -9
- package/dist/types.mjs.map +1 -1
- package/dist/utils/transaction.d.cts +2 -21
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +2 -21
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/validators.d.cts +0 -1
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +0 -1
- package/dist/utils/validators.d.mts.map +1 -1
- package/package.json +2 -2
- package/dist/intent-api.cjs +0 -58
- package/dist/intent-api.cjs.map +0 -1
- package/dist/intent-api.d.cts +0 -19
- package/dist/intent-api.d.cts.map +0 -1
- package/dist/intent-api.d.mts +0 -19
- package/dist/intent-api.d.mts.map +0 -1
- package/dist/intent-api.mjs +0 -54
- package/dist/intent-api.mjs.map +0 -1
- package/dist/intent-order-status.cjs +0 -14
- package/dist/intent-order-status.cjs.map +0 -1
- package/dist/intent-order-status.d.cts +0 -10
- package/dist/intent-order-status.d.cts.map +0 -1
- package/dist/intent-order-status.d.mts +0 -10
- package/dist/intent-order-status.d.mts.map +0 -1
- package/dist/intent-order-status.mjs +0 -11
- package/dist/intent-order-status.mjs.map +0 -1
- package/dist/intent-order.cjs +0 -4
- package/dist/intent-order.cjs.map +0 -1
- package/dist/intent-order.d.cts +0 -10
- package/dist/intent-order.d.cts.map +0 -1
- package/dist/intent-order.d.mts +0 -10
- package/dist/intent-order.d.mts.map +0 -1
- package/dist/intent-order.mjs +0 -2
- package/dist/intent-order.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [64.2.0]
|
|
11
|
+
|
|
10
12
|
### Changed
|
|
11
13
|
|
|
12
|
-
- **BREAKING** Use CrossChain API instead of the intent manager package for intent order submission ([#6547](https://github.com/MetaMask/core/pull/6547))
|
|
13
14
|
- Bump `@metamask/transaction-controller` from `^62.5.0` to `^62.7.0` ([#7430](https://github.com/MetaMask/core/pull/7430), [#7494](https://github.com/MetaMask/core/pull/7494))
|
|
15
|
+
- Bump `@metamask/bridge-controller` from `^64.1.0` to `^64.2.0` ([#7509](https://github.com/MetaMask/core/pull/7509))
|
|
14
16
|
|
|
15
17
|
## [64.1.0]
|
|
16
18
|
|
|
@@ -827,7 +829,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
827
829
|
|
|
828
830
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
829
831
|
|
|
830
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.
|
|
832
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.2.0...HEAD
|
|
833
|
+
[64.2.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.1.0...@metamask/bridge-status-controller@64.2.0
|
|
831
834
|
[64.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.0.1...@metamask/bridge-status-controller@64.1.0
|
|
832
835
|
[64.0.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@64.0.0...@metamask/bridge-status-controller@64.0.1
|
|
833
836
|
[64.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@63.1.0...@metamask/bridge-status-controller@64.0.0
|
|
@@ -10,7 +10,7 @@ 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_instances, _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionFn, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_updateTransactionFn, _BridgeStatusController_estimateGasFeeFn, _BridgeStatusController_trace, _BridgeStatusController_markTxAsFailed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_getMultichainSelectedAccount, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_fetchBridgeTxStatus,
|
|
13
|
+
var _BridgeStatusController_instances, _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionFn, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_updateTransactionFn, _BridgeStatusController_estimateGasFeeFn, _BridgeStatusController_trace, _BridgeStatusController_markTxAsFailed, _BridgeStatusController_restartPollingForIncompleteHistoryItems, _BridgeStatusController_addTxToHistory, _BridgeStatusController_startPollingForTxId, _BridgeStatusController_getMultichainSelectedAccount, _BridgeStatusController_handleFetchFailure, _BridgeStatusController_fetchBridgeTxStatus, _BridgeStatusController_getSrcTxHash, _BridgeStatusController_updateSrcTxHash, _BridgeStatusController_wipeBridgeStatusByChainId, _BridgeStatusController_handleNonEvmTx, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, _BridgeStatusController_handleApprovalTx, _BridgeStatusController_handleEvmTransaction, _BridgeStatusController_handleUSDTAllowanceReset, _BridgeStatusController_calculateGasFees, _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");
|
|
@@ -19,8 +19,6 @@ const polling_controller_1 = require("@metamask/polling-controller");
|
|
|
19
19
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
20
20
|
const utils_1 = require("@metamask/utils");
|
|
21
21
|
const constants_1 = require("./constants.cjs");
|
|
22
|
-
const intent_api_1 = require("./intent-api.cjs");
|
|
23
|
-
const intent_order_status_1 = require("./intent-order-status.cjs");
|
|
24
22
|
const types_1 = require("./types.cjs");
|
|
25
23
|
const bridge_status_1 = require("./utils/bridge-status.cjs");
|
|
26
24
|
const gas_1 = require("./utils/gas.cjs");
|
|
@@ -182,8 +180,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
182
180
|
// We know it's in progress but not the exact status yet
|
|
183
181
|
const txHistoryItem = {
|
|
184
182
|
txMetaId: bridgeTxMeta.id,
|
|
185
|
-
originalTransactionId: bridgeTxMeta
|
|
186
|
-
.originalTransactionId || bridgeTxMeta.id, // Keep original for intent transactions
|
|
187
183
|
batchId: bridgeTxMeta.batchId,
|
|
188
184
|
quote: quoteResponse.quote,
|
|
189
185
|
startTime,
|
|
@@ -229,9 +225,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
229
225
|
return;
|
|
230
226
|
}
|
|
231
227
|
const { quote } = txHistoryItem;
|
|
232
|
-
const isIntent = txId.startsWith('intent:');
|
|
233
228
|
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quote.srcChainId, quote.destChainId);
|
|
234
|
-
if (isBridgeTx
|
|
229
|
+
if (isBridgeTx) {
|
|
235
230
|
__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
|
|
236
231
|
bridgeTxMetaId: txId,
|
|
237
232
|
});
|
|
@@ -290,11 +285,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
290
285
|
});
|
|
291
286
|
_BridgeStatusController_fetchBridgeTxStatus.set(this, async ({ bridgeTxMetaId, }) => {
|
|
292
287
|
const { txHistory } = this.state;
|
|
293
|
-
// Intent-based items: poll intent provider instead of Bridge API
|
|
294
|
-
if (bridgeTxMetaId.startsWith('intent:')) {
|
|
295
|
-
await __classPrivateFieldGet(this, _BridgeStatusController_fetchIntentOrderStatus, "f").call(this, { bridgeTxMetaId });
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
288
|
if ((0, bridge_status_1.shouldSkipFetchDueToFetchFailures)(txHistory[bridgeTxMetaId]?.attempts)) {
|
|
299
289
|
return;
|
|
300
290
|
}
|
|
@@ -351,33 +341,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
351
341
|
}
|
|
352
342
|
}
|
|
353
343
|
}
|
|
354
|
-
catch (
|
|
355
|
-
console.warn('Failed to fetch bridge tx status',
|
|
356
|
-
__classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
_BridgeStatusController_fetchIntentOrderStatus.set(this, async ({ bridgeTxMetaId, }) => {
|
|
360
|
-
const { txHistory } = this.state;
|
|
361
|
-
const historyItem = txHistory[bridgeTxMetaId];
|
|
362
|
-
if (!historyItem) {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
// Backoff handling
|
|
366
|
-
if ((0, bridge_status_1.shouldSkipFetchDueToFetchFailures)(historyItem.attempts)) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
try {
|
|
370
|
-
const orderId = bridgeTxMetaId.replace(/^intent:/u, '');
|
|
371
|
-
const { srcChainId } = historyItem.quote;
|
|
372
|
-
// Extract provider name from order metadata or default to empty
|
|
373
|
-
const providerName = historyItem.quote.intent?.protocol ?? '';
|
|
374
|
-
const intentApi = new intent_api_1.IntentApiImpl(__classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl, __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"));
|
|
375
|
-
const intentOrder = (await intentApi.getOrderStatus(orderId, providerName, srcChainId.toString()));
|
|
376
|
-
// Update bridge history with intent order status
|
|
377
|
-
__classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_updateBridgeHistoryFromIntentOrder).call(this, bridgeTxMetaId, intentOrder, historyItem);
|
|
378
|
-
}
|
|
379
|
-
catch (error) {
|
|
380
|
-
console.error('Failed to fetch intent order status:', error);
|
|
344
|
+
catch (e) {
|
|
345
|
+
console.warn('Failed to fetch bridge tx status', e);
|
|
381
346
|
__classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
|
|
382
347
|
}
|
|
383
348
|
});
|
|
@@ -468,36 +433,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
468
433
|
}
|
|
469
434
|
return finalTransactionMeta;
|
|
470
435
|
});
|
|
471
|
-
// Waits until a given transaction (by id) reaches confirmed/finalized status or fails/times out.
|
|
472
|
-
_BridgeStatusController_waitForTxConfirmation.set(this, async (txId, { timeoutMs = 5 * 60000, // 5 minutes default
|
|
473
|
-
pollMs = 2000, } = {}) => {
|
|
474
|
-
const start = Date.now();
|
|
475
|
-
// Poll the TransactionController state for status changes
|
|
476
|
-
// We intentionally keep this simple to avoid extra wiring/subscriptions in this controller
|
|
477
|
-
// and because we only need it for the rare intent+approval path.
|
|
478
|
-
while (true) {
|
|
479
|
-
const { transactions } = this.messenger.call('TransactionController:getState');
|
|
480
|
-
const meta = transactions.find((tx) => tx.id === txId);
|
|
481
|
-
if (meta) {
|
|
482
|
-
// Treat both 'confirmed' and 'finalized' as success to match TC lifecycle
|
|
483
|
-
if (meta.status === transaction_controller_1.TransactionStatus.confirmed ||
|
|
484
|
-
// Some environments move directly to finalized
|
|
485
|
-
transaction_controller_1.TransactionStatus.finalized ===
|
|
486
|
-
meta.status) {
|
|
487
|
-
return meta;
|
|
488
|
-
}
|
|
489
|
-
if (meta.status === transaction_controller_1.TransactionStatus.failed ||
|
|
490
|
-
meta.status === transaction_controller_1.TransactionStatus.dropped ||
|
|
491
|
-
meta.status === transaction_controller_1.TransactionStatus.rejected) {
|
|
492
|
-
throw new Error('Approval transaction did not confirm');
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
if (Date.now() - start > timeoutMs) {
|
|
496
|
-
throw new Error('Timed out waiting for approval confirmation');
|
|
497
|
-
}
|
|
498
|
-
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
436
|
_BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
502
437
|
if (approval) {
|
|
503
438
|
const approveTx = async () => {
|
|
@@ -551,17 +486,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
551
486
|
type: transactionType,
|
|
552
487
|
origin: 'metamask',
|
|
553
488
|
};
|
|
554
|
-
// Exclude gasLimit from trade to avoid type issues (it can be null)
|
|
555
|
-
const { gasLimit: tradeGasLimit, ...tradeWithoutGasLimit } = trade;
|
|
556
489
|
const transactionParams = {
|
|
557
|
-
...
|
|
490
|
+
...trade,
|
|
558
491
|
chainId: hexChainId,
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
tradeGasLimit !== 0 && {
|
|
562
|
-
gasLimit: tradeGasLimit.toString(),
|
|
563
|
-
gas: tradeGasLimit.toString(),
|
|
564
|
-
}),
|
|
492
|
+
gasLimit: trade.gasLimit?.toString(),
|
|
493
|
+
gas: trade.gasLimit?.toString(),
|
|
565
494
|
};
|
|
566
495
|
const transactionParamsWithMaxGas = {
|
|
567
496
|
...transactionParams,
|
|
@@ -808,169 +737,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
808
737
|
}
|
|
809
738
|
return txMeta;
|
|
810
739
|
};
|
|
811
|
-
/**
|
|
812
|
-
* UI-signed intent submission (fast path): the UI generates the EIP-712 signature and calls this with the raw signature.
|
|
813
|
-
* Here we submit the order to the intent provider and create a synthetic history entry for UX.
|
|
814
|
-
*
|
|
815
|
-
* @param params - Object containing intent submission parameters
|
|
816
|
-
* @param params.quoteResponse - Quote carrying intent data
|
|
817
|
-
* @param params.signature - Hex signature produced by eth_signTypedData_v4
|
|
818
|
-
* @param params.accountAddress - The EOA submitting the order
|
|
819
|
-
* @returns A lightweight TransactionMeta-like object for history linking
|
|
820
|
-
*/
|
|
821
|
-
this.submitIntent = async (params) => {
|
|
822
|
-
const { quoteResponse, signature, accountAddress } = params;
|
|
823
|
-
// Build pre-confirmation properties for error tracking parity with submitTx
|
|
824
|
-
const account = this.messenger.call('AccountsController:getAccountByAddress', accountAddress);
|
|
825
|
-
const isHardwareAccount = Boolean(account) && (0, bridge_controller_1.isHardwareWallet)(account);
|
|
826
|
-
const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, false, isHardwareAccount);
|
|
827
|
-
try {
|
|
828
|
-
const { intent } = quoteResponse
|
|
829
|
-
.quote;
|
|
830
|
-
if (!intent) {
|
|
831
|
-
throw new Error('submitIntent: missing intent data');
|
|
832
|
-
}
|
|
833
|
-
// If backend provided an approval tx for this intent quote, submit it first (on-chain),
|
|
834
|
-
// then proceed with off-chain intent submission.
|
|
835
|
-
let approvalTxId;
|
|
836
|
-
if (quoteResponse.approval) {
|
|
837
|
-
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
838
|
-
// Handle approval silently for better UX in intent flows
|
|
839
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && (0, bridge_controller_1.isEvmTxData)(quoteResponse.approval)
|
|
840
|
-
? quoteResponse.approval
|
|
841
|
-
: undefined, quoteResponse.resetApproval,
|
|
842
|
-
/* requireApproval */ false);
|
|
843
|
-
approvalTxId = approvalTxMeta?.id;
|
|
844
|
-
// Optionally wait for approval confirmation with timeout and graceful fallback
|
|
845
|
-
// Intent order can be created before allowance is mined, but waiting helps avoid MEV issues
|
|
846
|
-
if (approvalTxId) {
|
|
847
|
-
try {
|
|
848
|
-
// Wait with a shorter timeout and continue if it fails
|
|
849
|
-
await __classPrivateFieldGet(this, _BridgeStatusController_waitForTxConfirmation, "f").call(this, approvalTxId, {
|
|
850
|
-
timeoutMs: 30000, // 30 seconds instead of 5 minutes
|
|
851
|
-
pollMs: 3000, // Poll less frequently to avoid rate limits
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
catch (error) {
|
|
855
|
-
// Log but don't throw - continue with intent order submission
|
|
856
|
-
console.warn('Approval confirmation failed, continuing with intent submission:', error);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
// Create intent quote from bridge quote response
|
|
861
|
-
const intentQuote = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_convertBridgeQuoteToIntentQuote).call(this, quoteResponse, intent);
|
|
862
|
-
const chainId = quoteResponse.quote.srcChainId;
|
|
863
|
-
const submissionParams = {
|
|
864
|
-
srcChainId: chainId.toString(),
|
|
865
|
-
quoteId: intentQuote.id,
|
|
866
|
-
signature,
|
|
867
|
-
order: intentQuote.metadata.order,
|
|
868
|
-
userAddress: accountAddress,
|
|
869
|
-
aggregatorId: 'cowswap',
|
|
870
|
-
};
|
|
871
|
-
const intentApi = new intent_api_1.IntentApiImpl(__classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl, __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"));
|
|
872
|
-
const intentOrder = (await intentApi.submitIntent(submissionParams));
|
|
873
|
-
const orderUid = intentOrder.id;
|
|
874
|
-
// Determine transaction type: swap for same-chain, bridge for cross-chain
|
|
875
|
-
const isCrossChainTx = (0, bridge_controller_1.isCrossChain)(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
876
|
-
const transactionType = isCrossChainTx
|
|
877
|
-
? transaction_controller_1.TransactionType.bridge
|
|
878
|
-
: transaction_controller_1.TransactionType.swap;
|
|
879
|
-
// Create actual transaction in Transaction Controller first
|
|
880
|
-
const networkClientId = this.messenger.call('NetworkController:findNetworkClientIdByChainId', (0, bridge_controller_1.formatChainIdToHex)(chainId));
|
|
881
|
-
const intentTransactionParams = {
|
|
882
|
-
chainId: (0, bridge_controller_1.formatChainIdToHex)(chainId),
|
|
883
|
-
from: accountAddress,
|
|
884
|
-
to: intent.settlementContract ??
|
|
885
|
-
'0x9008D19f58AAbd9eD0D60971565AA8510560ab41', // Default settlement contract
|
|
886
|
-
data: `0x${orderUid.slice(-8)}`, // Use last 8 chars of orderUid to make each transaction unique
|
|
887
|
-
value: '0x0',
|
|
888
|
-
gas: '0x5208', // Minimal gas for display purposes
|
|
889
|
-
gasPrice: '0x3b9aca00', // 1 Gwei - will be converted to EIP-1559 fees if network supports it
|
|
890
|
-
skipInitialGasEstimate: true,
|
|
891
|
-
};
|
|
892
|
-
const { transactionMeta: txMetaPromise } = await __classPrivateFieldGet(this, _BridgeStatusController_addTransactionFn, "f").call(this, intentTransactionParams, {
|
|
893
|
-
origin: 'metamask',
|
|
894
|
-
actionId: (0, transaction_1.generateActionId)(),
|
|
895
|
-
requireApproval: false,
|
|
896
|
-
networkClientId,
|
|
897
|
-
type: transactionType,
|
|
898
|
-
swaps: {
|
|
899
|
-
meta: {
|
|
900
|
-
// Add token symbols from quoteResponse for proper display
|
|
901
|
-
sourceTokenSymbol: quoteResponse.quote.srcAsset.symbol,
|
|
902
|
-
destinationTokenSymbol: quoteResponse.quote.destAsset.symbol,
|
|
903
|
-
sourceTokenAmount: quoteResponse.quote.srcTokenAmount,
|
|
904
|
-
destinationTokenAmount: quoteResponse.quote.destTokenAmount,
|
|
905
|
-
sourceTokenDecimals: quoteResponse.quote.srcAsset.decimals,
|
|
906
|
-
destinationTokenDecimals: quoteResponse.quote.destAsset.decimals,
|
|
907
|
-
sourceTokenAddress: quoteResponse.quote.srcAsset.address,
|
|
908
|
-
destinationTokenAddress: quoteResponse.quote.destAsset.address,
|
|
909
|
-
swapTokenValue: quoteResponse.sentAmount.amount,
|
|
910
|
-
approvalTxId,
|
|
911
|
-
swapMetaData: {
|
|
912
|
-
isIntentTx: true,
|
|
913
|
-
orderUid,
|
|
914
|
-
intentType: isCrossChainTx ? 'bridge' : 'swap',
|
|
915
|
-
},
|
|
916
|
-
},
|
|
917
|
-
},
|
|
918
|
-
});
|
|
919
|
-
const intentTxMeta = txMetaPromise;
|
|
920
|
-
// Map intent order status to TransactionController status
|
|
921
|
-
const initialTransactionStatus = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_mapIntentOrderStatusToTransactionStatus).call(this, intentOrder.status);
|
|
922
|
-
// Update transaction with proper initial status based on intent order
|
|
923
|
-
const statusUpdatedTxMeta = {
|
|
924
|
-
...intentTxMeta,
|
|
925
|
-
status: initialTransactionStatus,
|
|
926
|
-
};
|
|
927
|
-
__classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f").call(this, statusUpdatedTxMeta, `BridgeStatusController - Initial intent order status: ${intentOrder.status}`);
|
|
928
|
-
// Update with actual transaction metadata
|
|
929
|
-
const syntheticMeta = {
|
|
930
|
-
...statusUpdatedTxMeta,
|
|
931
|
-
isIntentTx: true,
|
|
932
|
-
orderUid,
|
|
933
|
-
intentType: isCrossChainTx ? 'bridge' : 'swap',
|
|
934
|
-
};
|
|
935
|
-
// Record in bridge history with actual transaction metadata
|
|
936
|
-
try {
|
|
937
|
-
// Use 'intent:' prefix for intent transactions
|
|
938
|
-
const bridgeHistoryKey = `intent:${orderUid}`;
|
|
939
|
-
// Create a bridge transaction metadata that includes the original txId
|
|
940
|
-
const bridgeTxMetaForHistory = {
|
|
941
|
-
...syntheticMeta,
|
|
942
|
-
id: bridgeHistoryKey, // Use intent: prefix for bridge history key
|
|
943
|
-
originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
|
|
944
|
-
};
|
|
945
|
-
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
946
|
-
accountAddress,
|
|
947
|
-
bridgeTxMeta: bridgeTxMetaForHistory,
|
|
948
|
-
statusRequest: {
|
|
949
|
-
...(0, transaction_1.getStatusRequestParams)(quoteResponse),
|
|
950
|
-
srcTxHash: syntheticMeta.hash ?? '',
|
|
951
|
-
},
|
|
952
|
-
quoteResponse,
|
|
953
|
-
slippagePercentage: 0,
|
|
954
|
-
isStxEnabled: false,
|
|
955
|
-
approvalTxId,
|
|
956
|
-
});
|
|
957
|
-
// Start polling using the intent: prefixed key to route to intent manager
|
|
958
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
|
|
959
|
-
}
|
|
960
|
-
catch (error) {
|
|
961
|
-
console.error('📝 [submitIntent] Failed to add to bridge history', error);
|
|
962
|
-
// non-fatal but log the error
|
|
963
|
-
}
|
|
964
|
-
return syntheticMeta;
|
|
965
|
-
}
|
|
966
|
-
catch (error) {
|
|
967
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, undefined, {
|
|
968
|
-
error_message: error?.message,
|
|
969
|
-
...preConfirmationProperties,
|
|
970
|
-
});
|
|
971
|
-
throw error;
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
740
|
/**
|
|
975
741
|
* Tracks post-submission events for a cross-chain swap based on the history item
|
|
976
742
|
*
|
|
@@ -996,12 +762,13 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
996
762
|
const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
997
763
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
998
764
|
if (eventName === bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
765
|
+
const { chain_id_source, chain_id_destination, token_address_source, token_address_destination, } = requestParamProperties;
|
|
999
766
|
this.messenger.call('BridgeController:trackUnifiedSwapBridgeEvent', eventName, {
|
|
1000
767
|
...baseProperties,
|
|
1001
|
-
chain_id_source
|
|
1002
|
-
chain_id_destination
|
|
1003
|
-
token_address_source
|
|
1004
|
-
token_address_destination
|
|
768
|
+
chain_id_source,
|
|
769
|
+
chain_id_destination,
|
|
770
|
+
token_address_source,
|
|
771
|
+
token_address_destination,
|
|
1005
772
|
refresh_count: historyItem.attempts?.counter ?? 0,
|
|
1006
773
|
});
|
|
1007
774
|
return;
|
|
@@ -1012,8 +779,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1012
779
|
}
|
|
1013
780
|
const selectedAccount = this.messenger.call('AccountsController:getAccountByAddress', historyItem.account);
|
|
1014
781
|
const { transactions } = this.messenger.call('TransactionController:getState');
|
|
1015
|
-
const txMeta = transactions?.find((
|
|
1016
|
-
const approvalTxMeta = transactions?.find((
|
|
782
|
+
const txMeta = transactions?.find(({ id }) => id === txMetaId);
|
|
783
|
+
const approvalTxMeta = transactions?.find(({ id }) => id === historyItem.approvalTxId);
|
|
1017
784
|
const requiredEventProperties = {
|
|
1018
785
|
...baseProperties,
|
|
1019
786
|
...requestParamProperties,
|
|
@@ -1040,19 +807,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1040
807
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:wipeBridgeStatus`, this.wipeBridgeStatus.bind(this));
|
|
1041
808
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:resetState`, this.resetState.bind(this));
|
|
1042
809
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:submitTx`, this.submitTx.bind(this));
|
|
1043
|
-
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:submitIntent`, this.submitIntent.bind(this));
|
|
1044
810
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:restartPollingForFailedAttempts`, this.restartPollingForFailedAttempts.bind(this));
|
|
1045
811
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:getBridgeHistoryItemByTxMetaId`, this.getBridgeHistoryItemByTxMetaId.bind(this));
|
|
1046
812
|
// Set interval
|
|
1047
813
|
this.setIntervalLength(constants_1.REFRESH_INTERVAL_MS);
|
|
1048
814
|
this.messenger.subscribe('TransactionController:transactionFailed', ({ transactionMeta }) => {
|
|
1049
815
|
const { type, status, id } = transactionMeta;
|
|
1050
|
-
// Skip intent transactions - they have their own tracking via CoW API
|
|
1051
|
-
// Skip intent transactions - they have their own tracking via CoW API
|
|
1052
|
-
if (transactionMeta
|
|
1053
|
-
.swapMetaData?.isIntentTx) {
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
816
|
if (type &&
|
|
1057
817
|
[
|
|
1058
818
|
transaction_controller_1.TransactionType.bridge,
|
|
@@ -1089,157 +849,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1089
849
|
}
|
|
1090
850
|
}
|
|
1091
851
|
exports.BridgeStatusController = BridgeStatusController;
|
|
1092
|
-
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionFn = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_updateTransactionFn = new WeakMap(), _BridgeStatusController_estimateGasFeeFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_markTxAsFailed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = new WeakMap(), _BridgeStatusController_startPollingForTxId = new WeakMap(), _BridgeStatusController_handleFetchFailure = new WeakMap(), _BridgeStatusController_fetchBridgeTxStatus = new WeakMap(),
|
|
852
|
+
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(), _BridgeStatusController_addTransactionFn = new WeakMap(), _BridgeStatusController_addTransactionBatchFn = new WeakMap(), _BridgeStatusController_updateTransactionFn = new WeakMap(), _BridgeStatusController_estimateGasFeeFn = new WeakMap(), _BridgeStatusController_trace = new WeakMap(), _BridgeStatusController_markTxAsFailed = new WeakMap(), _BridgeStatusController_restartPollingForIncompleteHistoryItems = new WeakMap(), _BridgeStatusController_addTxToHistory = 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_handleNonEvmTx = new WeakMap(), _BridgeStatusController_waitForHashAndReturnFinalTxMeta = new WeakMap(), _BridgeStatusController_handleApprovalTx = new WeakMap(), _BridgeStatusController_handleEvmTransaction = new WeakMap(), _BridgeStatusController_handleUSDTAllowanceReset = new WeakMap(), _BridgeStatusController_calculateGasFees = new WeakMap(), _BridgeStatusController_handleEvmTransactionBatch = new WeakMap(), _BridgeStatusController_trackUnifiedSwapBridgeEvent = new WeakMap(), _BridgeStatusController_instances = new WeakSet(), _BridgeStatusController_getMultichainSelectedAccount = function _BridgeStatusController_getMultichainSelectedAccount(accountAddress) {
|
|
1093
853
|
return this.messenger.call('AccountsController:getAccountByAddress', accountAddress);
|
|
1094
|
-
}, _BridgeStatusController_updateBridgeHistoryFromIntentOrder = function _BridgeStatusController_updateBridgeHistoryFromIntentOrder(bridgeTxMetaId, intentOrder, historyItem) {
|
|
1095
|
-
const { srcChainId } = historyItem.quote;
|
|
1096
|
-
// Map intent order status to bridge status using enum values
|
|
1097
|
-
let statusType;
|
|
1098
|
-
const isComplete = [
|
|
1099
|
-
intent_order_status_1.IntentOrderStatus.CONFIRMED,
|
|
1100
|
-
intent_order_status_1.IntentOrderStatus.COMPLETED,
|
|
1101
|
-
].includes(intentOrder.status);
|
|
1102
|
-
const isFailed = [
|
|
1103
|
-
intent_order_status_1.IntentOrderStatus.FAILED,
|
|
1104
|
-
intent_order_status_1.IntentOrderStatus.EXPIRED,
|
|
1105
|
-
].includes(intentOrder.status);
|
|
1106
|
-
const isPending = [intent_order_status_1.IntentOrderStatus.PENDING].includes(intentOrder.status);
|
|
1107
|
-
const isSubmitted = [intent_order_status_1.IntentOrderStatus.SUBMITTED].includes(intentOrder.status);
|
|
1108
|
-
if (isComplete) {
|
|
1109
|
-
statusType = bridge_controller_1.StatusTypes.COMPLETE;
|
|
1110
|
-
}
|
|
1111
|
-
else if (isFailed) {
|
|
1112
|
-
statusType = bridge_controller_1.StatusTypes.FAILED;
|
|
1113
|
-
}
|
|
1114
|
-
else if (isPending) {
|
|
1115
|
-
statusType = bridge_controller_1.StatusTypes.PENDING;
|
|
1116
|
-
}
|
|
1117
|
-
else if (isSubmitted) {
|
|
1118
|
-
statusType = bridge_controller_1.StatusTypes.SUBMITTED;
|
|
1119
|
-
}
|
|
1120
|
-
else {
|
|
1121
|
-
statusType = bridge_controller_1.StatusTypes.UNKNOWN;
|
|
1122
|
-
}
|
|
1123
|
-
// Extract transaction hashes from intent order
|
|
1124
|
-
const txHash = intentOrder.txHash ?? '';
|
|
1125
|
-
// Check metadata for additional transaction hashes
|
|
1126
|
-
const metadataTxHashes = Array.isArray(intentOrder.metadata.txHashes)
|
|
1127
|
-
? intentOrder.metadata.txHashes
|
|
1128
|
-
: [];
|
|
1129
|
-
let allHashes;
|
|
1130
|
-
if (metadataTxHashes.length > 0) {
|
|
1131
|
-
allHashes = metadataTxHashes;
|
|
1132
|
-
}
|
|
1133
|
-
else if (txHash) {
|
|
1134
|
-
allHashes = [txHash];
|
|
1135
|
-
}
|
|
1136
|
-
else {
|
|
1137
|
-
allHashes = [];
|
|
1138
|
-
}
|
|
1139
|
-
const newStatus = {
|
|
1140
|
-
status: statusType,
|
|
1141
|
-
srcChain: {
|
|
1142
|
-
chainId: srcChainId,
|
|
1143
|
-
txHash: txHash ?? historyItem.status.srcChain.txHash ?? '',
|
|
1144
|
-
},
|
|
1145
|
-
};
|
|
1146
|
-
const newBridgeHistoryItem = {
|
|
1147
|
-
...historyItem,
|
|
1148
|
-
status: newStatus,
|
|
1149
|
-
completionTime: newStatus.status === bridge_controller_1.StatusTypes.COMPLETE ||
|
|
1150
|
-
newStatus.status === bridge_controller_1.StatusTypes.FAILED
|
|
1151
|
-
? Date.now()
|
|
1152
|
-
: undefined,
|
|
1153
|
-
attempts: undefined,
|
|
1154
|
-
srcTxHashes: allHashes.length > 0
|
|
1155
|
-
? Array.from(new Set([...(historyItem.srcTxHashes ?? []), ...allHashes]))
|
|
1156
|
-
: historyItem.srcTxHashes,
|
|
1157
|
-
};
|
|
1158
|
-
this.update((state) => {
|
|
1159
|
-
state.txHistory[bridgeTxMetaId] = newBridgeHistoryItem;
|
|
1160
|
-
});
|
|
1161
|
-
// Update the actual transaction in TransactionController to sync with intent status
|
|
1162
|
-
// Use the original transaction ID (not the intent: prefixed bridge history key)
|
|
1163
|
-
const originalTxId = historyItem.originalTransactionId ?? historyItem.txMetaId;
|
|
1164
|
-
if (originalTxId && !originalTxId.startsWith('intent:')) {
|
|
1165
|
-
try {
|
|
1166
|
-
const transactionStatus = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_mapIntentOrderStatusToTransactionStatus).call(this, intentOrder.status);
|
|
1167
|
-
// Merge with existing TransactionMeta to avoid wiping required fields
|
|
1168
|
-
const { transactions } = this.messenger.call('TransactionController:getState');
|
|
1169
|
-
const existingTxMeta = transactions.find((tx) => tx.id === originalTxId);
|
|
1170
|
-
if (existingTxMeta) {
|
|
1171
|
-
const updatedTxMeta = {
|
|
1172
|
-
...existingTxMeta,
|
|
1173
|
-
status: transactionStatus,
|
|
1174
|
-
...(txHash ? { hash: txHash } : {}),
|
|
1175
|
-
...(txHash
|
|
1176
|
-
? {
|
|
1177
|
-
txReceipt: {
|
|
1178
|
-
...existingTxMeta.txReceipt,
|
|
1179
|
-
transactionHash: txHash,
|
|
1180
|
-
status: (isComplete ? '0x1' : '0x0'),
|
|
1181
|
-
},
|
|
1182
|
-
}
|
|
1183
|
-
: {}),
|
|
1184
|
-
};
|
|
1185
|
-
__classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f").call(this, updatedTxMeta, `BridgeStatusController - Intent order status updated: ${intentOrder.status}`);
|
|
1186
|
-
}
|
|
1187
|
-
else {
|
|
1188
|
-
console.warn('📝 [fetchIntentOrderStatus] Skipping update; transaction not found', { originalTxId, bridgeHistoryKey: bridgeTxMetaId });
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
catch (error) {
|
|
1192
|
-
console.error('📝 [fetchIntentOrderStatus] Failed to update transaction status', {
|
|
1193
|
-
originalTxId,
|
|
1194
|
-
bridgeHistoryKey: bridgeTxMetaId,
|
|
1195
|
-
error,
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
1200
|
-
const isFinal = newStatus.status === bridge_controller_1.StatusTypes.COMPLETE ||
|
|
1201
|
-
newStatus.status === bridge_controller_1.StatusTypes.FAILED;
|
|
1202
|
-
if (isFinal && pollingToken) {
|
|
1203
|
-
this.stopPollingByPollingToken(pollingToken);
|
|
1204
|
-
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
1205
|
-
if (newStatus.status === bridge_controller_1.StatusTypes.COMPLETE) {
|
|
1206
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, bridgeTxMetaId);
|
|
1207
|
-
}
|
|
1208
|
-
else if (newStatus.status === bridge_controller_1.StatusTypes.FAILED) {
|
|
1209
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, bridgeTxMetaId);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
}, _BridgeStatusController_convertBridgeQuoteToIntentQuote = function _BridgeStatusController_convertBridgeQuoteToIntentQuote(quoteResponse, intent) {
|
|
1213
|
-
return {
|
|
1214
|
-
id: `bridge-${Date.now()}`,
|
|
1215
|
-
provider: intent.protocol,
|
|
1216
|
-
srcAmount: quoteResponse.quote.srcTokenAmount,
|
|
1217
|
-
destAmount: quoteResponse.quote.destTokenAmount,
|
|
1218
|
-
estimatedGas: '21000',
|
|
1219
|
-
estimatedTime: 300, // 5 minutes
|
|
1220
|
-
priceImpact: 0,
|
|
1221
|
-
fees: [],
|
|
1222
|
-
validUntil: Date.now() + 300000, // 5 minutes from now
|
|
1223
|
-
metadata: {
|
|
1224
|
-
order: intent.order,
|
|
1225
|
-
settlementContract: intent.settlementContract ?? '',
|
|
1226
|
-
chainId: quoteResponse.quote.srcChainId,
|
|
1227
|
-
bridgeQuote: quoteResponse,
|
|
1228
|
-
},
|
|
1229
|
-
};
|
|
1230
|
-
}, _BridgeStatusController_mapIntentOrderStatusToTransactionStatus = function _BridgeStatusController_mapIntentOrderStatusToTransactionStatus(intentStatus) {
|
|
1231
|
-
switch (intentStatus) {
|
|
1232
|
-
case intent_order_status_1.IntentOrderStatus.PENDING:
|
|
1233
|
-
case intent_order_status_1.IntentOrderStatus.SUBMITTED:
|
|
1234
|
-
return transaction_controller_1.TransactionStatus.submitted;
|
|
1235
|
-
case intent_order_status_1.IntentOrderStatus.CONFIRMED:
|
|
1236
|
-
case intent_order_status_1.IntentOrderStatus.COMPLETED:
|
|
1237
|
-
return transaction_controller_1.TransactionStatus.confirmed;
|
|
1238
|
-
case intent_order_status_1.IntentOrderStatus.FAILED:
|
|
1239
|
-
case intent_order_status_1.IntentOrderStatus.EXPIRED:
|
|
1240
|
-
return transaction_controller_1.TransactionStatus.failed;
|
|
1241
|
-
default:
|
|
1242
|
-
return transaction_controller_1.TransactionStatus.submitted;
|
|
1243
|
-
}
|
|
1244
854
|
};
|
|
1245
855
|
//# sourceMappingURL=bridge-status-controller.cjs.map
|