@metamask-previews/bridge-status-controller 70.0.5-preview-92fa59a42 → 70.0.5-preview-6b3d5862f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -10
- package/dist/bridge-status-controller.cjs +114 -197
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +118 -201
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/constants.cjs +1 -2
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +0 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +0 -1
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +0 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +5 -6
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +5 -6
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/bridge-status.cjs +1 -42
- package/dist/utils/bridge-status.cjs.map +1 -1
- package/dist/utils/bridge-status.d.cts +1 -2
- package/dist/utils/bridge-status.d.cts.map +1 -1
- package/dist/utils/bridge-status.d.mts +1 -2
- package/dist/utils/bridge-status.d.mts.map +1 -1
- package/dist/utils/bridge-status.mjs +1 -41
- package/dist/utils/bridge-status.mjs.map +1 -1
- package/dist/utils/history.cjs +2 -43
- package/dist/utils/history.cjs.map +1 -1
- package/dist/utils/history.d.cts +1 -19
- package/dist/utils/history.d.cts.map +1 -1
- package/dist/utils/history.d.mts +1 -19
- package/dist/utils/history.d.mts.map +1 -1
- package/dist/utils/history.mjs +2 -40
- package/dist/utils/history.mjs.map +1 -1
- package/dist/utils/metrics.cjs +2 -27
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +2 -25
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +2 -25
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs +1 -25
- package/dist/utils/metrics.mjs.map +1 -1
- package/dist/utils/network.cjs +1 -7
- package/dist/utils/network.cjs.map +1 -1
- package/dist/utils/network.d.cts +2 -4
- package/dist/utils/network.d.cts.map +1 -1
- package/dist/utils/network.d.mts +2 -4
- package/dist/utils/network.d.mts.map +1 -1
- package/dist/utils/network.mjs +0 -5
- package/dist/utils/network.mjs.map +1 -1
- package/dist/utils/transaction.cjs +8 -9
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +0 -1
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +0 -1
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +7 -7
- package/dist/utils/transaction.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/utils/feature-flags.cjs +0 -12
- package/dist/utils/feature-flags.cjs.map +0 -1
- package/dist/utils/feature-flags.d.cts +0 -3
- package/dist/utils/feature-flags.d.cts.map +0 -1
- package/dist/utils/feature-flags.d.mts +0 -3
- package/dist/utils/feature-flags.d.mts.map +0 -1
- package/dist/utils/feature-flags.mjs +0 -8
- package/dist/utils/feature-flags.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,7 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Remove stale bridge transactions from `txHistory` to prevent excessive polling. Once a history item exceeds the configured maximum age, the status is fetched once, then the src tx hash's receipt is retrieved. If there is no receipt, the history item's hash is presumed to be invalid and the entry is deleted from state. ([#8479](https://github.com/MetaMask/core/pull/8479))
|
|
13
12
|
- Add missing action types for public `BridgeStatusController` methods ([#8367](https://github.com/MetaMask/core/pull/8367))
|
|
14
13
|
- The following types are now available:
|
|
15
14
|
- `BridgeStatusControllerSubmitTxAction`
|
|
@@ -18,8 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
18
17
|
|
|
19
18
|
### Changed
|
|
20
19
|
|
|
21
|
-
- **BREAKING:** Replace `transactionFailed` and `transactionConfirmed` event subscriptions with `TransactionController:transactionStatusUpdated` ([#8479](https://github.com/MetaMask/core/pull/8479))
|
|
22
|
-
- **BREAKING:** Add `RemoteFeatureFlags:getState` to allowed actions to retrieve max history item age config ([#8479](https://github.com/MetaMask/core/pull/8479))
|
|
23
20
|
- Add `account_hardware_type` field to all cross-chain swap analytics events ([#8503](https://github.com/MetaMask/core/pull/8503))
|
|
24
21
|
- `account_hardware_type` carries the specific hardware wallet brand (e.g. `'Ledger'`, `'QR Hardware'`) or `null` for software wallets
|
|
25
22
|
- `is_hardware_wallet` is now derived from `account_hardware_type !== null`, keeping both fields in sync
|
|
@@ -31,13 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
31
28
|
- Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
|
|
32
29
|
- Bump `@metamask/bridge-controller` from `^70.0.1` to `^70.1.1` ([#8466](https://github.com/MetaMask/core/pull/8466), [#8474](https://github.com/MetaMask/core/pull/8474))
|
|
33
30
|
|
|
34
|
-
### Fixed
|
|
35
|
-
|
|
36
|
-
- Prevent invalid src hashes from being persisted in `txHistory` ([#8479](https://github.com/MetaMask/core/pull/8479))
|
|
37
|
-
- Make transaction status subscribers generic so that `txHistory` items get updated if there are any transaction updates matching by actionId, txMetaId, hash or type
|
|
38
|
-
- Skip saving smart transaction hashes on transaction submission. This used to make it possible for invalid src hashes to be stored in state and polled indefinitely. Instead, the txHistory item will now be updated with the confirmed tx hash when the `transactionStatusUpdated` event is published
|
|
39
|
-
- If there is no srcTxHash in state, attempt to set it based on the local TransactionController state
|
|
40
|
-
|
|
41
31
|
## [70.0.5]
|
|
42
32
|
|
|
43
33
|
### Changed
|
|
@@ -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_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_onTransactionFailed,
|
|
13
|
+
var _BridgeStatusController_pollingTokensByTxMetaId, _BridgeStatusController_intentManager, _BridgeStatusController_clientId, _BridgeStatusController_fetchFn, _BridgeStatusController_config, _BridgeStatusController_addTransactionBatchFn, _BridgeStatusController_trace, _BridgeStatusController_onTransactionFailed, _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");
|
|
@@ -70,55 +70,60 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
70
70
|
_BridgeStatusController_config.set(this, void 0);
|
|
71
71
|
_BridgeStatusController_addTransactionBatchFn.set(this, void 0);
|
|
72
72
|
_BridgeStatusController_trace.set(this, void 0);
|
|
73
|
-
_BridgeStatusController_onTransactionFailed.set(this, ({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
_BridgeStatusController_onTransactionFailed.set(this, ({ transactionMeta, }) => {
|
|
74
|
+
const { type, status, id: txMetaId, actionId } = transactionMeta;
|
|
75
|
+
if (type &&
|
|
76
|
+
[
|
|
77
|
+
transaction_controller_1.TransactionType.bridge,
|
|
78
|
+
transaction_controller_1.TransactionType.swap,
|
|
79
|
+
transaction_controller_1.TransactionType.bridgeApproval,
|
|
80
|
+
transaction_controller_1.TransactionType.swapApproval,
|
|
81
|
+
].includes(type) &&
|
|
82
|
+
[
|
|
83
|
+
transaction_controller_1.TransactionStatus.failed,
|
|
84
|
+
transaction_controller_1.TransactionStatus.dropped,
|
|
85
|
+
transaction_controller_1.TransactionStatus.rejected,
|
|
86
|
+
].includes(status)) {
|
|
87
|
+
__classPrivateFieldGet(this, _BridgeStatusController_markTxAsFailed, "f").call(this, transactionMeta);
|
|
88
|
+
if (status !== transaction_controller_1.TransactionStatus.rejected) {
|
|
89
|
+
let historyKey;
|
|
90
|
+
if (this.state.txHistory[txMetaId]) {
|
|
91
|
+
historyKey = txMetaId;
|
|
92
|
+
}
|
|
93
|
+
else if (actionId && this.state.txHistory[actionId]) {
|
|
94
|
+
historyKey = actionId;
|
|
95
|
+
}
|
|
96
|
+
const activeHistoryKey = historyKey ?? txMetaId;
|
|
97
|
+
// Skip account lookup and tracking when featureId is set (e.g. PERPS)
|
|
98
|
+
if (this.state.txHistory[activeHistoryKey]?.featureId) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const from = transactionMeta.txParams?.from;
|
|
102
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, activeHistoryKey, (0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(transactionMeta, from
|
|
103
|
+
? this.messenger.call('AccountsController:getAccountByAddress', from)
|
|
104
|
+
: undefined));
|
|
105
|
+
}
|
|
94
106
|
}
|
|
95
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Failed, historyKey, (0, metrics_1.getEVMTxPropertiesFromTransactionMeta)(txMeta));
|
|
96
107
|
});
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
// Mark tx as failed in txHistory if either the approval or trade fails
|
|
109
|
+
_BridgeStatusController_markTxAsFailed.set(this, ({ id: txMetaId, actionId, }) => {
|
|
110
|
+
// Look up by txMetaId first
|
|
111
|
+
let txHistoryKey = this.state.txHistory[txMetaId]
|
|
112
|
+
? txMetaId
|
|
113
|
+
: undefined;
|
|
114
|
+
// If not found by txMetaId, try looking up by actionId (for pre-submission failures)
|
|
115
|
+
if (!txHistoryKey && actionId && this.state.txHistory[actionId]) {
|
|
116
|
+
txHistoryKey = actionId;
|
|
117
|
+
}
|
|
118
|
+
// If still not found, try looking up by approvalTxId
|
|
119
|
+
txHistoryKey ?? (txHistoryKey = Object.keys(this.state.txHistory).find((key) => this.state.txHistory[key].approvalTxId === txMetaId));
|
|
120
|
+
if (!txHistoryKey) {
|
|
102
121
|
return;
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
123
|
+
const key = txHistoryKey;
|
|
124
|
+
this.update((statusState) => {
|
|
125
|
+
statusState.txHistory[key].status.status = bridge_controller_1.StatusTypes.FAILED;
|
|
107
126
|
});
|
|
108
|
-
switch (txMeta.type) {
|
|
109
|
-
case transaction_controller_1.TransactionType.swap:
|
|
110
|
-
__classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
|
|
111
|
-
historyKey,
|
|
112
|
-
status: bridge_controller_1.StatusTypes.COMPLETE,
|
|
113
|
-
});
|
|
114
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, historyKey);
|
|
115
|
-
break;
|
|
116
|
-
default:
|
|
117
|
-
if (historyKey) {
|
|
118
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, historyKey);
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
127
|
});
|
|
123
128
|
this.resetState = () => {
|
|
124
129
|
this.update((state) => {
|
|
@@ -219,31 +224,30 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
219
224
|
_BridgeStatusController_restartPollingForIncompleteHistoryItems.set(this, () => {
|
|
220
225
|
// Check for historyItems that do not have a status of complete and restart polling
|
|
221
226
|
const { txHistory } = this.state;
|
|
222
|
-
const historyItems = Object.
|
|
227
|
+
const historyItems = Object.values(txHistory);
|
|
223
228
|
const incompleteHistoryItems = historyItems
|
|
224
|
-
.filter((
|
|
229
|
+
.filter((historyItem) => historyItem.status.status === bridge_controller_1.StatusTypes.PENDING ||
|
|
225
230
|
historyItem.status.status === bridge_controller_1.StatusTypes.UNKNOWN)
|
|
226
231
|
// Only poll items with txMetaId (post-submission items)
|
|
227
|
-
.filter((
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
232
|
+
.filter((historyItem) => Boolean(historyItem.txMetaId))
|
|
233
|
+
.filter((historyItem) => {
|
|
231
234
|
// Check if we are already polling this tx, if so, skip restarting polling for that
|
|
232
235
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[historyItem.txMetaId];
|
|
233
236
|
return !pollingToken;
|
|
234
237
|
})
|
|
235
238
|
// Only restart polling for items that still require status updates
|
|
236
|
-
.filter((
|
|
239
|
+
.filter((historyItem) => {
|
|
237
240
|
return (0, history_1.shouldPollHistoryItem)(historyItem);
|
|
238
241
|
});
|
|
239
|
-
incompleteHistoryItems.forEach((
|
|
242
|
+
incompleteHistoryItems.forEach((historyItem) => {
|
|
243
|
+
const bridgeTxMetaId = historyItem.txMetaId;
|
|
240
244
|
const shouldSkipFetch = (0, bridge_status_1.shouldSkipFetchDueToFetchFailures)(historyItem.attempts);
|
|
241
245
|
if (shouldSkipFetch) {
|
|
242
246
|
return;
|
|
243
247
|
}
|
|
244
248
|
// We manually call startPolling() here rather than go through startPollingForBridgeTxStatus()
|
|
245
249
|
// because we don't want to overwrite the existing historyItem in state
|
|
246
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this,
|
|
250
|
+
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeTxMetaId);
|
|
247
251
|
});
|
|
248
252
|
});
|
|
249
253
|
_BridgeStatusController_addTxToHistory.set(this, (...args) => {
|
|
@@ -252,7 +256,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
252
256
|
// Use actionId as key for pre-submission, or txMeta.id for post-submission
|
|
253
257
|
state.txHistory[historyKey] = txHistoryItem;
|
|
254
258
|
});
|
|
255
|
-
return historyKey;
|
|
256
259
|
});
|
|
257
260
|
/**
|
|
258
261
|
* Rekeys a history item from actionId to txMeta.id after successful submission.
|
|
@@ -275,7 +278,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
275
278
|
this.stopPollingByPollingToken(existingPollingToken);
|
|
276
279
|
}
|
|
277
280
|
const txHistoryItem = this.state.txHistory[txId];
|
|
278
|
-
if (txHistoryItem
|
|
281
|
+
if (!txHistoryItem) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if ((0, history_1.shouldPollHistoryItem)(txHistoryItem)) {
|
|
279
285
|
__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
|
|
280
286
|
bridgeTxMetaId: txId,
|
|
281
287
|
});
|
|
@@ -296,8 +302,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
296
302
|
if (!bridgeTxMeta?.id) {
|
|
297
303
|
throw new Error('Cannot start polling: bridgeTxMeta.id is required for polling');
|
|
298
304
|
}
|
|
299
|
-
|
|
300
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this,
|
|
305
|
+
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, txHistoryMeta);
|
|
306
|
+
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeTxMeta.id);
|
|
301
307
|
};
|
|
302
308
|
// This will be called after you call this.startPolling()
|
|
303
309
|
// The args passed in are the args you passed in to startPolling()
|
|
@@ -332,44 +338,29 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
332
338
|
// Track max polling reached event
|
|
333
339
|
const historyItem = this.state.txHistory[bridgeTxMetaId];
|
|
334
340
|
if (historyItem && !historyItem.featureId) {
|
|
335
|
-
|
|
336
|
-
|
|
341
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
342
|
+
const requestParams = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
343
|
+
const requestMetadata = (0, metrics_1.getRequestMetadataFromHistory)(historyItem, selectedAccount);
|
|
344
|
+
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
345
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.PollingStatusUpdated, bridgeTxMetaId, {
|
|
346
|
+
...(0, metrics_1.getTradeDataFromHistory)(historyItem),
|
|
347
|
+
...(0, metrics_1.getPriceImpactFromQuote)(historyItem.quote),
|
|
348
|
+
...metadataWithoutWarnings,
|
|
349
|
+
chain_id_source: requestParams.chain_id_source,
|
|
350
|
+
chain_id_destination: requestParams.chain_id_destination,
|
|
351
|
+
token_symbol_source: requestParams.token_symbol_source,
|
|
352
|
+
token_symbol_destination: requestParams.token_symbol_destination,
|
|
353
|
+
action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
|
|
354
|
+
polling_status: bridge_controller_1.PollingStatus.MaxPollingReached,
|
|
355
|
+
retry_attempts: newAttempts.counter,
|
|
356
|
+
});
|
|
337
357
|
}
|
|
338
358
|
}
|
|
339
359
|
// Update the attempts counter
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
attempts: newAttempts,
|
|
360
|
+
this.update((state) => {
|
|
361
|
+
state.txHistory[bridgeTxMetaId].attempts = newAttempts;
|
|
343
362
|
});
|
|
344
363
|
});
|
|
345
|
-
/**
|
|
346
|
-
* Checks if the history item should be preserved so its status can be fetched.
|
|
347
|
-
*
|
|
348
|
-
* @param bridgeTxMetaId - The txMetaId of the bridge tx
|
|
349
|
-
*/
|
|
350
|
-
_BridgeStatusController_handleOldHistoryItem.set(this, async (bridgeTxMetaId) => {
|
|
351
|
-
if (
|
|
352
|
-
// Skip if the history item is finalized or not old
|
|
353
|
-
!(this.state.txHistory[bridgeTxMetaId] &&
|
|
354
|
-
(0, history_1.isHistoryItemTooOld)(this.messenger, this.state.txHistory[bridgeTxMetaId]) &&
|
|
355
|
-
[bridge_controller_1.StatusTypes.PENDING, bridge_controller_1.StatusTypes.UNKNOWN].includes(this.state.txHistory[bridgeTxMetaId].status.status))) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
// Continue polling on next restart if the history item is valid
|
|
359
|
-
if (await (0, bridge_status_1.shouldWaitForFinalBridgeStatus)(this.messenger, this.state.txHistory[bridgeTxMetaId])) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
363
|
-
// Track polling status updated event
|
|
364
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackPollingStatusUpdatedEvent, "f").call(this, bridgeTxMetaId, bridge_controller_1.PollingStatus.InvalidTransactionHash);
|
|
365
|
-
// If we've failed too many times, stop polling for the tx
|
|
366
|
-
if (pollingToken) {
|
|
367
|
-
this.stopPollingByPollingToken(pollingToken);
|
|
368
|
-
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[bridgeTxMetaId];
|
|
369
|
-
}
|
|
370
|
-
// Delete the history item so polling doesn't start over on the next restart
|
|
371
|
-
__classPrivateFieldGet(this, _BridgeStatusController_deleteHistoryItem, "f").call(this, bridgeTxMetaId);
|
|
372
|
-
});
|
|
373
364
|
_BridgeStatusController_fetchBridgeTxStatus.set(this, async ({ bridgeTxMetaId, }) => {
|
|
374
365
|
// 1. Check for history item
|
|
375
366
|
const { txHistory } = this.state;
|
|
@@ -381,7 +372,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
381
372
|
if ((0, bridge_status_1.shouldSkipFetchDueToFetchFailures)(historyItem.attempts)) {
|
|
382
373
|
return;
|
|
383
374
|
}
|
|
384
|
-
// 3. Fetch
|
|
375
|
+
// 3. Fetch transcation status
|
|
385
376
|
try {
|
|
386
377
|
let status;
|
|
387
378
|
let validationFailures = [];
|
|
@@ -397,10 +388,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
397
388
|
// We try here because we receive 500 errors from Bridge API if we try to fetch immediately after submitting the source tx
|
|
398
389
|
// Oddly mostly happens on Optimism, never on Arbitrum. By the 2nd fetch, the Bridge API responds properly.
|
|
399
390
|
// Also srcTxHash may not be available immediately for STX, so we don't want to fetch in those cases
|
|
400
|
-
const srcTxHash = __classPrivateFieldGet(this,
|
|
391
|
+
const srcTxHash = __classPrivateFieldGet(this, _BridgeStatusController_getSrcTxHash, "f").call(this, bridgeTxMetaId);
|
|
401
392
|
if (!srcTxHash) {
|
|
402
393
|
return;
|
|
403
394
|
}
|
|
395
|
+
__classPrivateFieldGet(this, _BridgeStatusController_updateSrcTxHash, "f").call(this, bridgeTxMetaId, srcTxHash);
|
|
404
396
|
const statusRequest = (0, bridge_status_1.getStatusRequestWithSrcTxHash)(historyItem.quote, srcTxHash);
|
|
405
397
|
const response = await (0, bridge_status_1.fetchBridgeTxStatus)(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), await (0, authentication_1.getJwt)(this.messenger), __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl);
|
|
406
398
|
status = response.status;
|
|
@@ -457,65 +449,26 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
457
449
|
console.warn('Failed to fetch bridge tx status', error);
|
|
458
450
|
__classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
|
|
459
451
|
}
|
|
460
|
-
finally {
|
|
461
|
-
await __classPrivateFieldGet(this, _BridgeStatusController_handleOldHistoryItem, "f").call(this, bridgeTxMetaId);
|
|
462
|
-
}
|
|
463
452
|
});
|
|
464
|
-
|
|
465
|
-
* Returns the srcTxHash for a non-STX EVM tx, the hash from the bridge status api,
|
|
466
|
-
* or the local hash from the TransactionController if the tx is in a finalized state
|
|
467
|
-
*
|
|
468
|
-
* @param bridgeTxMetaId - The bridge tx meta id
|
|
469
|
-
* @returns The srcTxHash
|
|
470
|
-
*/
|
|
471
|
-
_BridgeStatusController_setAndGetSrcTxHash.set(this, (bridgeTxMetaId) => {
|
|
453
|
+
_BridgeStatusController_getSrcTxHash.set(this, (bridgeTxMetaId) => {
|
|
472
454
|
const { txHistory } = this.state;
|
|
473
|
-
// Prefer the srcTxHash from bridgeStatusState so we don't have to
|
|
455
|
+
// Prefer the srcTxHash from bridgeStatusState so we don't have to l ook up in TransactionController
|
|
474
456
|
// But it is possible to have bridgeHistoryItem in state without the srcTxHash yet when it is an STX
|
|
475
457
|
const srcTxHash = txHistory[bridgeTxMetaId].status.srcChain.txHash;
|
|
476
|
-
if (srcTxHash
|
|
477
|
-
(0, bridge_controller_1.isNonEvmChainId)(txHistory[bridgeTxMetaId].quote.srcChainId)) {
|
|
458
|
+
if (srcTxHash) {
|
|
478
459
|
return srcTxHash;
|
|
479
460
|
}
|
|
480
|
-
//
|
|
461
|
+
// Look up in TransactionController if txMeta has been updated with the srcTxHash
|
|
481
462
|
const txMeta = (0, transaction_1.getTransactionMetaById)(this.messenger, bridgeTxMetaId);
|
|
482
|
-
|
|
483
|
-
return undefined;
|
|
484
|
-
}
|
|
485
|
-
// Wait for finalized status before updating the history item
|
|
486
|
-
const localTxHash = [
|
|
487
|
-
transaction_controller_1.TransactionStatus.confirmed,
|
|
488
|
-
transaction_controller_1.TransactionStatus.dropped,
|
|
489
|
-
transaction_controller_1.TransactionStatus.rejected,
|
|
490
|
-
transaction_controller_1.TransactionStatus.failed,
|
|
491
|
-
].includes(txMeta.status)
|
|
492
|
-
? txMeta.hash
|
|
493
|
-
: undefined;
|
|
494
|
-
__classPrivateFieldGet(this, _BridgeStatusController_updateHistoryItem, "f").call(this, {
|
|
495
|
-
historyKey: bridgeTxMetaId,
|
|
496
|
-
txHash: localTxHash,
|
|
497
|
-
});
|
|
498
|
-
return localTxHash;
|
|
463
|
+
return txMeta?.hash;
|
|
499
464
|
});
|
|
500
|
-
|
|
501
|
-
|
|
465
|
+
_BridgeStatusController_updateSrcTxHash.set(this, (bridgeTxMetaId, srcTxHash) => {
|
|
466
|
+
const { txHistory } = this.state;
|
|
467
|
+
if (txHistory[bridgeTxMetaId].status.srcChain.txHash) {
|
|
502
468
|
return;
|
|
503
469
|
}
|
|
504
|
-
this.update((
|
|
505
|
-
|
|
506
|
-
currentState.txHistory[historyKey].status.status = status;
|
|
507
|
-
}
|
|
508
|
-
if (txHash) {
|
|
509
|
-
currentState.txHistory[historyKey].status.srcChain.txHash = txHash;
|
|
510
|
-
}
|
|
511
|
-
if (attempts) {
|
|
512
|
-
currentState.txHistory[historyKey].attempts = attempts;
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
});
|
|
516
|
-
_BridgeStatusController_deleteHistoryItem.set(this, (historyKey) => {
|
|
517
|
-
this.update((currentState) => {
|
|
518
|
-
delete currentState.txHistory[historyKey];
|
|
470
|
+
this.update((state) => {
|
|
471
|
+
state.txHistory[bridgeTxMetaId].status.srcChain.txHash = srcTxHash;
|
|
519
472
|
});
|
|
520
473
|
});
|
|
521
474
|
// Wipes the bridge status for the given address and chainId
|
|
@@ -531,7 +484,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
531
484
|
const pollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId];
|
|
532
485
|
if (pollingToken) {
|
|
533
486
|
this.stopPollingByPollingToken(__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId]);
|
|
534
|
-
delete __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[sourceTxMetaId];
|
|
535
487
|
}
|
|
536
488
|
});
|
|
537
489
|
this.update((state) => {
|
|
@@ -698,7 +650,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
698
650
|
const actionId = (0, transaction_1.generateActionId)().toString();
|
|
699
651
|
// Add pre-submission history keyed by actionId
|
|
700
652
|
// This ensures we have quote data available if transaction fails during submission
|
|
701
|
-
|
|
653
|
+
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
702
654
|
accountAddress: selectedAccount.address,
|
|
703
655
|
quoteResponse,
|
|
704
656
|
slippagePercentage: 0,
|
|
@@ -725,7 +677,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
725
677
|
actionId,
|
|
726
678
|
});
|
|
727
679
|
// On success, rekey from actionId to txMeta.id and update srcTxHash
|
|
728
|
-
__classPrivateFieldGet(this, _BridgeStatusController_rekeyHistoryItem, "f").call(this,
|
|
680
|
+
__classPrivateFieldGet(this, _BridgeStatusController_rekeyHistoryItem, "f").call(this, actionId, tradeTxMeta);
|
|
729
681
|
return tradeTxMeta;
|
|
730
682
|
});
|
|
731
683
|
}
|
|
@@ -745,12 +697,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
745
697
|
!isStxEnabledOnClient &&
|
|
746
698
|
!quoteResponse.quote.gasIncluded7702 &&
|
|
747
699
|
!isDelegatedAccount;
|
|
748
|
-
let historyKey = txMeta.id;
|
|
749
700
|
if (!isNonBatchEvm) {
|
|
750
701
|
// Add swap or bridge tx to history
|
|
751
|
-
|
|
702
|
+
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
752
703
|
accountAddress: selectedAccount.address,
|
|
753
|
-
bridgeTxMeta: txMeta, // Only the id
|
|
704
|
+
bridgeTxMeta: txMeta, // Only the id field is used by the BridgeStatusController
|
|
754
705
|
quoteResponse,
|
|
755
706
|
slippagePercentage: 0, // TODO include slippage provided by quote if using dynamic slippage, or slippage from quote request
|
|
756
707
|
isStxEnabled: isStxEnabledOnClient,
|
|
@@ -763,10 +714,10 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
763
714
|
}
|
|
764
715
|
if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
|
|
765
716
|
// Start polling for bridge tx status
|
|
766
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this,
|
|
717
|
+
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, txMeta.id);
|
|
767
718
|
// Track non-EVM Swap completed event
|
|
768
719
|
if (!(isBridgeTx || isTronTx)) {
|
|
769
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed,
|
|
720
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, txMeta.id);
|
|
770
721
|
}
|
|
771
722
|
}
|
|
772
723
|
}
|
|
@@ -865,14 +816,15 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
865
816
|
};
|
|
866
817
|
// Record in bridge history with actual transaction metadata
|
|
867
818
|
try {
|
|
819
|
+
// Use orderId as the history key for intent transactions
|
|
820
|
+
const bridgeHistoryKey = orderUid;
|
|
868
821
|
// Create a bridge transaction metadata that includes the original txId
|
|
869
822
|
const bridgeTxMetaForHistory = {
|
|
870
823
|
...syntheticMeta,
|
|
871
|
-
id:
|
|
824
|
+
id: bridgeHistoryKey,
|
|
872
825
|
originalTransactionId: syntheticMeta.id, // Keep original txId for TransactionController updates
|
|
873
826
|
};
|
|
874
|
-
|
|
875
|
-
const historyKey = __classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
827
|
+
__classPrivateFieldGet(this, _BridgeStatusController_addTxToHistory, "f").call(this, {
|
|
876
828
|
accountAddress,
|
|
877
829
|
bridgeTxMeta: bridgeTxMetaForHistory,
|
|
878
830
|
quoteResponse,
|
|
@@ -885,7 +837,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
885
837
|
activeAbTests,
|
|
886
838
|
});
|
|
887
839
|
// Start polling using the orderId key to route to intent manager
|
|
888
|
-
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this,
|
|
840
|
+
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeHistoryKey);
|
|
889
841
|
}
|
|
890
842
|
catch (error) {
|
|
891
843
|
console.error('📝 [submitIntent] Failed to add to bridge history', error);
|
|
@@ -901,13 +853,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
901
853
|
throw error;
|
|
902
854
|
}
|
|
903
855
|
};
|
|
904
|
-
_BridgeStatusController_trackPollingStatusUpdatedEvent.set(this, (historyKey, pollingStatus) => {
|
|
905
|
-
// Track polling status updated event
|
|
906
|
-
const historyItem = this.state.txHistory[historyKey];
|
|
907
|
-
if (historyItem && !historyItem.featureId) {
|
|
908
|
-
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.PollingStatusUpdated, historyKey, (0, metrics_1.getPollingStatusUpdatedProperties)(this.messenger, pollingStatus, historyItem));
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
856
|
/**
|
|
912
857
|
* Tracks post-submission events for a cross-chain swap based on the history item
|
|
913
858
|
*
|
|
@@ -1015,43 +960,15 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1015
960
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
1016
961
|
// Set interval
|
|
1017
962
|
this.setIntervalLength(constants_1.REFRESH_INTERVAL_MS);
|
|
1018
|
-
this.messenger.subscribe('TransactionController:
|
|
1019
|
-
|
|
1020
|
-
|
|
963
|
+
this.messenger.subscribe('TransactionController:transactionFailed', __classPrivateFieldGet(this, _BridgeStatusController_onTransactionFailed, "f"));
|
|
964
|
+
this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
|
|
965
|
+
const { type, id: txMetaId, chainId } = transactionMeta;
|
|
966
|
+
if (type === transaction_controller_1.TransactionType.swap) {
|
|
967
|
+
__classPrivateFieldGet(this, _BridgeStatusController_trackUnifiedSwapBridgeEvent, "f").call(this, bridge_controller_1.UnifiedSwapBridgeEventName.Completed, txMetaId);
|
|
1021
968
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
// corresponding history item exists
|
|
1025
|
-
const isSwapOrBridgeTransaction = type && (0, transaction_1.isCrossChainTx)(type);
|
|
1026
|
-
if (!isSwapOrBridgeTransaction && !historyKey && !historyItem) {
|
|
1027
|
-
return;
|
|
969
|
+
if (type === transaction_controller_1.TransactionType.bridge && !(0, bridge_controller_1.isNonEvmChainId)(chainId)) {
|
|
970
|
+
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, txMetaId);
|
|
1028
971
|
}
|
|
1029
|
-
switch (status) {
|
|
1030
|
-
case transaction_controller_1.TransactionStatus.confirmed:
|
|
1031
|
-
__classPrivateFieldGet(this, _BridgeStatusController_onTransactionConfirmed, "f").call(this, {
|
|
1032
|
-
txMeta,
|
|
1033
|
-
historyKey,
|
|
1034
|
-
isApprovalTxMeta,
|
|
1035
|
-
});
|
|
1036
|
-
break;
|
|
1037
|
-
case transaction_controller_1.TransactionStatus.failed:
|
|
1038
|
-
case transaction_controller_1.TransactionStatus.dropped:
|
|
1039
|
-
case transaction_controller_1.TransactionStatus.rejected:
|
|
1040
|
-
__classPrivateFieldGet(this, _BridgeStatusController_onTransactionFailed, "f").call(this, { txMeta, historyKey, isApprovalTxMeta });
|
|
1041
|
-
break;
|
|
1042
|
-
default:
|
|
1043
|
-
break;
|
|
1044
|
-
}
|
|
1045
|
-
}, ({ transactionMeta }) => {
|
|
1046
|
-
const entry = (0, history_1.getMatchingHistoryEntryForTxMeta)(this.state.txHistory, transactionMeta);
|
|
1047
|
-
const approvalEntry = (0, history_1.getMatchingHistoryEntryForApprovalTxMeta)(this.state.txHistory, transactionMeta);
|
|
1048
|
-
const entryToUse = entry ?? approvalEntry;
|
|
1049
|
-
return {
|
|
1050
|
-
historyKey: entryToUse?.[0],
|
|
1051
|
-
historyItem: entryToUse?.[1],
|
|
1052
|
-
txMeta: transactionMeta,
|
|
1053
|
-
isApprovalTxMeta: entryToUse?.[1]?.approvalTxId === transactionMeta.id,
|
|
1054
|
-
};
|
|
1055
972
|
});
|
|
1056
973
|
// If you close the extension, but keep the browser open, the polling continues
|
|
1057
974
|
// If you close the browser, the polling stops
|
|
@@ -1060,5 +977,5 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1060
977
|
}
|
|
1061
978
|
}
|
|
1062
979
|
exports.BridgeStatusController = BridgeStatusController;
|
|
1063
|
-
_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_onTransactionFailed = new WeakMap(),
|
|
980
|
+
_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_onTransactionFailed = 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();
|
|
1064
981
|
//# sourceMappingURL=bridge-status-controller.cjs.map
|