@metamask/bridge-status-controller 69.0.0 → 70.0.0
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 +9 -1
- package/dist/bridge-status-controller.cjs +77 -192
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts +1 -4
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts +1 -4
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.cjs +6 -7
- package/dist/bridge-status-controller.intent.cjs.map +1 -1
- package/dist/bridge-status-controller.intent.d.cts +2 -5
- package/dist/bridge-status-controller.intent.d.cts.map +1 -1
- package/dist/bridge-status-controller.intent.d.mts +2 -5
- package/dist/bridge-status-controller.intent.d.mts.map +1 -1
- package/dist/bridge-status-controller.intent.mjs +6 -7
- package/dist/bridge-status-controller.intent.mjs.map +1 -1
- package/dist/bridge-status-controller.mjs +79 -194
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/accounts.cjs +8 -0
- package/dist/utils/accounts.cjs.map +1 -0
- package/dist/utils/accounts.d.cts +36 -0
- package/dist/utils/accounts.d.cts.map +1 -0
- package/dist/utils/accounts.d.mts +36 -0
- package/dist/utils/accounts.d.mts.map +1 -0
- package/dist/utils/accounts.mjs +4 -0
- package/dist/utils/accounts.mjs.map +1 -0
- package/dist/utils/authentication.cjs +15 -0
- package/dist/utils/authentication.cjs.map +1 -0
- package/dist/utils/authentication.d.cts +3 -0
- package/dist/utils/authentication.d.cts.map +1 -0
- package/dist/utils/authentication.d.mts +3 -0
- package/dist/utils/authentication.d.mts.map +1 -0
- package/dist/utils/authentication.mjs +11 -0
- package/dist/utils/authentication.mjs.map +1 -0
- package/dist/utils/bridge.cjs +16 -0
- package/dist/utils/bridge.cjs.map +1 -0
- package/dist/utils/bridge.d.cts +10 -0
- package/dist/utils/bridge.d.cts.map +1 -0
- package/dist/utils/bridge.d.mts +10 -0
- package/dist/utils/bridge.d.mts.map +1 -0
- package/dist/utils/bridge.mjs +11 -0
- package/dist/utils/bridge.mjs.map +1 -0
- package/dist/utils/gas.cjs +3 -6
- package/dist/utils/gas.cjs.map +1 -1
- package/dist/utils/gas.d.cts +1 -1
- package/dist/utils/gas.d.cts.map +1 -1
- package/dist/utils/gas.d.mts +1 -1
- package/dist/utils/gas.d.mts.map +1 -1
- package/dist/utils/gas.mjs +3 -6
- package/dist/utils/gas.mjs.map +1 -1
- package/dist/utils/history.cjs +97 -0
- package/dist/utils/history.cjs.map +1 -0
- package/dist/utils/history.d.cts +21 -0
- package/dist/utils/history.d.cts.map +1 -0
- package/dist/utils/history.d.mts +21 -0
- package/dist/utils/history.d.mts.map +1 -0
- package/dist/utils/history.mjs +90 -0
- package/dist/utils/history.mjs.map +1 -0
- package/dist/utils/intent-api.cjs +16 -1
- package/dist/utils/intent-api.cjs.map +1 -1
- package/dist/utils/intent-api.d.cts +9 -1
- package/dist/utils/intent-api.d.cts.map +1 -1
- package/dist/utils/intent-api.d.mts +9 -1
- package/dist/utils/intent-api.d.mts.map +1 -1
- package/dist/utils/intent-api.mjs +14 -0
- package/dist/utils/intent-api.mjs.map +1 -1
- package/dist/utils/keyring.cjs +12 -0
- package/dist/utils/keyring.cjs.map +1 -0
- package/dist/utils/keyring.d.cts +8 -0
- package/dist/utils/keyring.d.cts.map +1 -0
- package/dist/utils/keyring.d.mts +8 -0
- package/dist/utils/keyring.d.mts.map +1 -0
- package/dist/utils/keyring.mjs +8 -0
- package/dist/utils/keyring.mjs.map +1 -0
- package/dist/utils/network.cjs +17 -0
- package/dist/utils/network.cjs.map +1 -0
- package/dist/utils/network.d.cts +5 -0
- package/dist/utils/network.d.cts.map +1 -0
- package/dist/utils/network.d.mts +5 -0
- package/dist/utils/network.d.mts.map +1 -0
- package/dist/utils/network.mjs +12 -0
- package/dist/utils/network.mjs.map +1 -0
- package/dist/utils/snaps.cjs +146 -1
- package/dist/utils/snaps.cjs.map +1 -1
- package/dist/utils/snaps.d.cts +62 -0
- package/dist/utils/snaps.d.cts.map +1 -1
- package/dist/utils/snaps.d.mts +62 -0
- package/dist/utils/snaps.d.mts.map +1 -1
- package/dist/utils/snaps.mjs +141 -0
- package/dist/utils/snaps.mjs.map +1 -1
- package/dist/utils/trace.cjs +31 -0
- package/dist/utils/trace.cjs.map +1 -0
- package/dist/utils/trace.d.cts +17 -0
- package/dist/utils/trace.d.cts.map +1 -0
- package/dist/utils/trace.d.mts +17 -0
- package/dist/utils/trace.d.mts.map +1 -0
- package/dist/utils/trace.mjs +26 -0
- package/dist/utils/trace.mjs.map +1 -0
- package/dist/utils/transaction.cjs +12 -183
- package/dist/utils/transaction.cjs.map +1 -1
- package/dist/utils/transaction.d.cts +5 -78
- package/dist/utils/transaction.d.cts.map +1 -1
- package/dist/utils/transaction.d.mts +5 -78
- package/dist/utils/transaction.d.mts.map +1 -1
- package/dist/utils/transaction.mjs +12 -177
- package/dist/utils/transaction.mjs.map +1 -1
- package/dist/utils/validators.d.cts +2 -2
- package/dist/utils/validators.d.mts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [70.0.0]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **BREAKING:** Replace transaction handlers provided to the `BridgeStatusController` constructor with calls to the TransactionController, through the controller messenger. Clients will need to add the `TransactionControllerUpdateTransactionAction`, `TransactionControllerAddTransactionAction`, and `TransactionControllerEstimateGasFeeAction` permissions to their controller init modules in addition to updating the constructor ([#8188](https://github.com/MetaMask/core/pull/8188))
|
|
15
|
+
- Moved controller calls from bridge-status-controller.ts to their own utils for better readability ([#8226](https://github.com/MetaMask/core/pull/8226))
|
|
16
|
+
|
|
10
17
|
## [69.0.0]
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -1040,7 +1047,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1040
1047
|
|
|
1041
1048
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
1042
1049
|
|
|
1043
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@
|
|
1050
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@70.0.0...HEAD
|
|
1051
|
+
[70.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@69.0.0...@metamask/bridge-status-controller@70.0.0
|
|
1044
1052
|
[69.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.1.0...@metamask/bridge-status-controller@69.0.0
|
|
1045
1053
|
[68.1.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.2...@metamask/bridge-status-controller@68.1.0
|
|
1046
1054
|
[68.0.2]: https://github.com/MetaMask/core/compare/@metamask/bridge-status-controller@68.0.1...@metamask/bridge-status-controller@68.0.2
|
|
@@ -10,22 +10,29 @@ 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
|
|
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_waitForHashAndReturnFinalTxMeta, _BridgeStatusController_waitForTxConfirmation, _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");
|
|
17
17
|
const controller_utils_1 = require("@metamask/controller-utils");
|
|
18
|
-
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
19
18
|
const polling_controller_1 = require("@metamask/polling-controller");
|
|
20
19
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
21
20
|
const utils_1 = require("@metamask/utils");
|
|
22
21
|
const bridge_status_controller_intent_1 = require("./bridge-status-controller.intent.cjs");
|
|
23
22
|
const constants_1 = require("./constants.cjs");
|
|
24
23
|
const types_1 = require("./types.cjs");
|
|
24
|
+
const accounts_1 = require("./utils/accounts.cjs");
|
|
25
|
+
const authentication_1 = require("./utils/authentication.cjs");
|
|
26
|
+
const bridge_1 = require("./utils/bridge.cjs");
|
|
25
27
|
const bridge_status_1 = require("./utils/bridge-status.cjs");
|
|
26
28
|
const gas_1 = require("./utils/gas.cjs");
|
|
29
|
+
const history_1 = require("./utils/history.cjs");
|
|
27
30
|
const intent_api_1 = require("./utils/intent-api.cjs");
|
|
31
|
+
const keyring_1 = require("./utils/keyring.cjs");
|
|
28
32
|
const metrics_1 = require("./utils/metrics.cjs");
|
|
33
|
+
const network_1 = require("./utils/network.cjs");
|
|
34
|
+
const snaps_1 = require("./utils/snaps.cjs");
|
|
35
|
+
const trace_1 = require("./utils/trace.cjs");
|
|
29
36
|
const transaction_1 = require("./utils/transaction.cjs");
|
|
30
37
|
const metadata = {
|
|
31
38
|
// We want to persist the bridge status state so that we can show the proper data for the Activity list
|
|
@@ -38,7 +45,7 @@ const metadata = {
|
|
|
38
45
|
},
|
|
39
46
|
};
|
|
40
47
|
class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPollingController)() {
|
|
41
|
-
constructor({ messenger, state, clientId, fetchFn,
|
|
48
|
+
constructor({ messenger, state, clientId, fetchFn, addTransactionBatchFn, config, traceFn, }) {
|
|
42
49
|
super({
|
|
43
50
|
name: constants_1.BRIDGE_STATUS_CONTROLLER_NAME,
|
|
44
51
|
metadata,
|
|
@@ -49,16 +56,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
49
56
|
...state,
|
|
50
57
|
},
|
|
51
58
|
});
|
|
52
|
-
_BridgeStatusController_instances.add(this);
|
|
53
59
|
_BridgeStatusController_pollingTokensByTxMetaId.set(this, {});
|
|
54
60
|
_BridgeStatusController_intentManager.set(this, void 0);
|
|
55
61
|
_BridgeStatusController_clientId.set(this, void 0);
|
|
56
62
|
_BridgeStatusController_fetchFn.set(this, void 0);
|
|
57
63
|
_BridgeStatusController_config.set(this, void 0);
|
|
58
|
-
_BridgeStatusController_addTransactionFn.set(this, void 0);
|
|
59
64
|
_BridgeStatusController_addTransactionBatchFn.set(this, void 0);
|
|
60
|
-
_BridgeStatusController_updateTransactionFn.set(this, void 0);
|
|
61
|
-
_BridgeStatusController_estimateGasFeeFn.set(this, void 0);
|
|
62
65
|
_BridgeStatusController_trace.set(this, void 0);
|
|
63
66
|
// Mark tx as failed in txHistory if either the approval or trade fails
|
|
64
67
|
_BridgeStatusController_markTxAsFailed.set(this, ({ id: txMetaId, actionId, }) => {
|
|
@@ -93,9 +96,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
93
96
|
});
|
|
94
97
|
}
|
|
95
98
|
else {
|
|
96
|
-
const
|
|
97
|
-
const selectedNetworkClient = this.messenger.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
|
|
98
|
-
const selectedChainId = selectedNetworkClient.configuration.chainId;
|
|
99
|
+
const selectedChainId = (0, network_1.getSelectedChainId)(this.messenger);
|
|
99
100
|
__classPrivateFieldGet(this, _BridgeStatusController_wipeBridgeStatusByChainId, "f").call(this, address, selectedChainId);
|
|
100
101
|
}
|
|
101
102
|
};
|
|
@@ -137,7 +138,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
// Restart polling if it was stopped and this tx still needs status updates
|
|
140
|
-
if (
|
|
141
|
+
if ((0, history_1.shouldPollHistoryItem)(historyItem)) {
|
|
141
142
|
// Check if polling was stopped (no active polling token)
|
|
142
143
|
const existingPollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[targetTxMetaId];
|
|
143
144
|
if (!existingPollingToken) {
|
|
@@ -145,7 +146,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
145
146
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, targetTxMetaId);
|
|
146
147
|
// Track polling manually restarted event
|
|
147
148
|
if (!historyItem.featureId) {
|
|
148
|
-
const selectedAccount = this.messenger
|
|
149
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
149
150
|
const requestParams = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
150
151
|
const requestMetadata = (0, metrics_1.getRequestMetadataFromHistory)(historyItem, selectedAccount);
|
|
151
152
|
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
@@ -194,7 +195,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
194
195
|
})
|
|
195
196
|
// Only restart polling for items that still require status updates
|
|
196
197
|
.filter((historyItem) => {
|
|
197
|
-
return
|
|
198
|
+
return (0, history_1.shouldPollHistoryItem)(historyItem);
|
|
198
199
|
});
|
|
199
200
|
incompleteHistoryItems.forEach((historyItem) => {
|
|
200
201
|
const bridgeTxMetaId = historyItem.txMetaId;
|
|
@@ -207,51 +208,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
207
208
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeTxMetaId);
|
|
208
209
|
});
|
|
209
210
|
});
|
|
210
|
-
_BridgeStatusController_addTxToHistory.set(this, (
|
|
211
|
-
const {
|
|
212
|
-
// Determine the key for this history item:
|
|
213
|
-
// - For pre-submission (non-batch EVM): use actionId
|
|
214
|
-
// - For post-submission or other cases: use bridgeTxMeta.id
|
|
215
|
-
const historyKey = (0, transaction_1.getHistoryKey)(actionId, bridgeTxMeta?.id);
|
|
216
|
-
// Write all non-status fields to state so we can reference the quote in Activity list without the Bridge API
|
|
217
|
-
// We know it's in progress but not the exact status yet
|
|
218
|
-
const txHistoryItem = {
|
|
219
|
-
txMetaId: bridgeTxMeta?.id,
|
|
220
|
-
actionId,
|
|
221
|
-
originalTransactionId: bridgeTxMeta
|
|
222
|
-
?.originalTransactionId || bridgeTxMeta?.id, // Keep original for intent transactions
|
|
223
|
-
batchId: bridgeTxMeta?.batchId,
|
|
224
|
-
quote: quoteResponse.quote,
|
|
225
|
-
startTime,
|
|
226
|
-
estimatedProcessingTimeInSeconds: quoteResponse.estimatedProcessingTimeInSeconds,
|
|
227
|
-
slippagePercentage,
|
|
228
|
-
pricingData: {
|
|
229
|
-
amountSent: quoteResponse.sentAmount?.amount ?? '0',
|
|
230
|
-
amountSentInUsd: quoteResponse.sentAmount?.usd ?? undefined,
|
|
231
|
-
quotedGasInUsd: quoteResponse.gasFee?.effective?.usd ?? undefined,
|
|
232
|
-
quotedReturnInUsd: quoteResponse.toTokenAmount?.usd ?? undefined,
|
|
233
|
-
quotedGasAmount: quoteResponse.gasFee?.effective?.amount ?? undefined,
|
|
234
|
-
},
|
|
235
|
-
initialDestAssetBalance,
|
|
236
|
-
targetContractAddress,
|
|
237
|
-
account: selectedAddress,
|
|
238
|
-
status: {
|
|
239
|
-
// We always have a PENDING status when we start polling for a tx, don't need the Bridge API for that
|
|
240
|
-
// Also we know the bare minimum fields for status at this point in time
|
|
241
|
-
status: bridge_controller_1.StatusTypes.PENDING,
|
|
242
|
-
srcChain: {
|
|
243
|
-
chainId: statusRequest.srcChainId,
|
|
244
|
-
txHash: statusRequest.srcTxHash,
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
hasApprovalTx: Boolean(quoteResponse.approval),
|
|
248
|
-
approvalTxId,
|
|
249
|
-
isStxEnabled: Boolean(isStxEnabled),
|
|
250
|
-
featureId: quoteResponse.featureId,
|
|
251
|
-
location,
|
|
252
|
-
...(abTests && { abTests }),
|
|
253
|
-
...(activeAbTests && { activeAbTests }),
|
|
254
|
-
};
|
|
211
|
+
_BridgeStatusController_addTxToHistory.set(this, (...args) => {
|
|
212
|
+
const { historyKey, txHistoryItem } = (0, history_1.getInitialHistoryItem)(...args);
|
|
255
213
|
this.update((state) => {
|
|
256
214
|
// Use actionId as key for pre-submission, or txMeta.id for post-submission
|
|
257
215
|
state.txHistory[historyKey] = txHistoryItem;
|
|
@@ -268,7 +226,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
268
226
|
*/
|
|
269
227
|
_BridgeStatusController_rekeyHistoryItem.set(this, (actionId, txMeta) => {
|
|
270
228
|
this.update((state) => {
|
|
271
|
-
(0,
|
|
229
|
+
(0, history_1.rekeyHistoryItemInState)(state, actionId, txMeta);
|
|
272
230
|
});
|
|
273
231
|
});
|
|
274
232
|
_BridgeStatusController_startPollingForTxId.set(this, (txId) => {
|
|
@@ -281,18 +239,12 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
281
239
|
if (!txHistoryItem) {
|
|
282
240
|
return;
|
|
283
241
|
}
|
|
284
|
-
if (
|
|
242
|
+
if ((0, history_1.shouldPollHistoryItem)(txHistoryItem)) {
|
|
285
243
|
__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
|
|
286
244
|
bridgeTxMetaId: txId,
|
|
287
245
|
});
|
|
288
246
|
}
|
|
289
247
|
});
|
|
290
|
-
_BridgeStatusController_shouldPollHistoryItem.set(this, (historyItem) => {
|
|
291
|
-
const isIntent = Boolean(historyItem?.quote?.intent);
|
|
292
|
-
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(historyItem.quote.srcChainId, historyItem.quote.destChainId);
|
|
293
|
-
const isTronTx = (0, bridge_controller_1.isTronChainId)(historyItem.quote.srcChainId);
|
|
294
|
-
return [isBridgeTx, isIntent, isTronTx].some(Boolean);
|
|
295
|
-
});
|
|
296
248
|
/**
|
|
297
249
|
* @deprecated For EVM/Solana swap/bridge txs we add tx to history in submitTx()
|
|
298
250
|
* For Solana swap/bridge we start polling in submitTx()
|
|
@@ -344,7 +296,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
344
296
|
// Track max polling reached event
|
|
345
297
|
const historyItem = this.state.txHistory[bridgeTxMetaId];
|
|
346
298
|
if (historyItem && !historyItem.featureId) {
|
|
347
|
-
const selectedAccount = this.messenger
|
|
299
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
348
300
|
const requestParams = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
349
301
|
const requestMetadata = (0, metrics_1.getRequestMetadataFromHistory)(historyItem, selectedAccount);
|
|
350
302
|
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
@@ -400,7 +352,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
400
352
|
}
|
|
401
353
|
__classPrivateFieldGet(this, _BridgeStatusController_updateSrcTxHash, "f").call(this, bridgeTxMetaId, srcTxHash);
|
|
402
354
|
const statusRequest = (0, bridge_status_1.getStatusRequestWithSrcTxHash)(historyItem.quote, srcTxHash);
|
|
403
|
-
const response = await (0, bridge_status_1.fetchBridgeTxStatus)(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), await
|
|
355
|
+
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);
|
|
404
356
|
status = response.status;
|
|
405
357
|
validationFailures = response.validationFailures;
|
|
406
358
|
}
|
|
@@ -456,16 +408,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
456
408
|
__classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
|
|
457
409
|
}
|
|
458
410
|
});
|
|
459
|
-
_BridgeStatusController_getJwt.set(this, async () => {
|
|
460
|
-
try {
|
|
461
|
-
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
462
|
-
return token;
|
|
463
|
-
}
|
|
464
|
-
catch (error) {
|
|
465
|
-
console.error('Error getting JWT token for bridge-api request', error);
|
|
466
|
-
return undefined;
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
411
|
_BridgeStatusController_getSrcTxHash.set(this, (bridgeTxMetaId) => {
|
|
470
412
|
const { txHistory } = this.state;
|
|
471
413
|
// Prefer the srcTxHash from bridgeStatusState so we don't have to l ook up in TransactionController
|
|
@@ -515,34 +457,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
515
457
|
* TX SUBMISSION HANDLING
|
|
516
458
|
*******************************************************
|
|
517
459
|
*/
|
|
518
|
-
/**
|
|
519
|
-
* Submits the transaction to the snap using the new unified ClientRequest interface
|
|
520
|
-
* Works for all non-EVM chains (Solana, BTC, Tron)
|
|
521
|
-
* This adds an approval tx to the ApprovalsController in the background
|
|
522
|
-
* The client needs to handle the approval tx by redirecting to the confirmation page with the approvalTxId in the URL
|
|
523
|
-
*
|
|
524
|
-
* @param trade - The trade data (can be approval or main trade)
|
|
525
|
-
* @param quoteResponse - The quote response containing metadata
|
|
526
|
-
* @param selectedAccount - The account to submit the transaction for
|
|
527
|
-
* @returns The transaction meta
|
|
528
|
-
*/
|
|
529
|
-
_BridgeStatusController_handleNonEvmTx.set(this, async (trade, quoteResponse, selectedAccount) => {
|
|
530
|
-
if (!selectedAccount.metadata?.snap?.id) {
|
|
531
|
-
throw new Error('Failed to submit cross-chain swap transaction: undefined snap id');
|
|
532
|
-
}
|
|
533
|
-
const request = (0, transaction_1.getClientRequest)(trade, quoteResponse.quote.srcChainId, selectedAccount);
|
|
534
|
-
const requestResponse = (await this.messenger.call('SnapController:handleRequest', request));
|
|
535
|
-
// Create quote response with the specified trade
|
|
536
|
-
// This allows the same method to handle both approvals and main trades
|
|
537
|
-
const txQuoteResponse = {
|
|
538
|
-
...quoteResponse,
|
|
539
|
-
trade,
|
|
540
|
-
};
|
|
541
|
-
const txMeta = (0, transaction_1.handleNonEvmTxResponse)(requestResponse, txQuoteResponse, selectedAccount);
|
|
542
|
-
// TODO remove this eventually, just returning it now to match extension behavior
|
|
543
|
-
// OR if the snap can propagate the snapRequestId or keyringReqId to the ApprovalsController, this can return the approvalTxId instead and clients won't need to subscribe to the ApprovalsController state to redirect
|
|
544
|
-
return txMeta;
|
|
545
|
-
});
|
|
546
460
|
_BridgeStatusController_waitForHashAndReturnFinalTxMeta.set(this, async (hashPromise) => {
|
|
547
461
|
const transactionHash = await hashPromise;
|
|
548
462
|
const finalTransactionMeta = this.messenger
|
|
@@ -561,7 +475,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
561
475
|
pollMs,
|
|
562
476
|
});
|
|
563
477
|
});
|
|
564
|
-
_BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
478
|
+
_BridgeStatusController_handleApprovalTx.set(this, async (quoteResponse, isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
565
479
|
if (approval && (0, bridge_controller_1.isEvmTxData)(approval)) {
|
|
566
480
|
const approveTx = async () => {
|
|
567
481
|
await __classPrivateFieldGet(this, _BridgeStatusController_handleUSDTAllowanceReset, "f").call(this, resetApproval);
|
|
@@ -575,15 +489,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
575
489
|
await (0, transaction_1.handleApprovalDelay)(srcChainId);
|
|
576
490
|
return approvalTxMeta;
|
|
577
491
|
};
|
|
578
|
-
return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this,
|
|
579
|
-
name: isBridgeTx
|
|
580
|
-
? constants_1.TraceName.BridgeTransactionApprovalCompleted
|
|
581
|
-
: constants_1.TraceName.SwapTransactionApprovalCompleted,
|
|
582
|
-
data: {
|
|
583
|
-
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(srcChainId),
|
|
584
|
-
stxEnabled: false,
|
|
585
|
-
},
|
|
586
|
-
}, approveTx);
|
|
492
|
+
return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_1.getApprovalTraceParams)(quoteResponse, false), approveTx);
|
|
587
493
|
}
|
|
588
494
|
return undefined;
|
|
589
495
|
});
|
|
@@ -602,13 +508,13 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
602
508
|
*/
|
|
603
509
|
_BridgeStatusController_handleEvmTransaction.set(this, async ({ transactionType, trade, requireApproval = false, txFee, actionId: providedActionId, }) => {
|
|
604
510
|
// Use provided actionId (for pre-submission history) or generate one
|
|
605
|
-
const actionId = providedActionId ?? (0, transaction_1.generateActionId)()
|
|
606
|
-
const selectedAccount = this.messenger
|
|
511
|
+
const actionId = providedActionId ?? (0, transaction_1.generateActionId)();
|
|
512
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, trade.from);
|
|
607
513
|
if (!selectedAccount) {
|
|
608
514
|
throw new Error('Failed to submit cross-chain swap transaction: unknown account in trade data');
|
|
609
515
|
}
|
|
610
516
|
const hexChainId = (0, bridge_controller_1.formatChainIdToHex)(trade.chainId);
|
|
611
|
-
const networkClientId = this.messenger
|
|
517
|
+
const networkClientId = (0, network_1.getNetworkClientIdByChainId)(this.messenger, hexChainId);
|
|
612
518
|
const requestOptions = {
|
|
613
519
|
actionId,
|
|
614
520
|
networkClientId,
|
|
@@ -632,7 +538,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
632
538
|
...transactionParams,
|
|
633
539
|
...(await __classPrivateFieldGet(this, _BridgeStatusController_calculateGasFees, "f").call(this, transactionParams, networkClientId, hexChainId, txFee)),
|
|
634
540
|
};
|
|
635
|
-
const { result } = await
|
|
541
|
+
const { result } = await this.messenger.call('TransactionController:addTransaction', transactionParamsWithMaxGas, requestOptions);
|
|
636
542
|
return await __classPrivateFieldGet(this, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, "f").call(this, result);
|
|
637
543
|
});
|
|
638
544
|
_BridgeStatusController_handleUSDTAllowanceReset.set(this, async (resetApproval) => {
|
|
@@ -655,11 +561,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
655
561
|
};
|
|
656
562
|
}
|
|
657
563
|
const { gasFeeEstimates } = this.messenger.call('GasFeeController:getState');
|
|
658
|
-
const { estimates: txGasFeeEstimates } = await
|
|
659
|
-
transactionParams,
|
|
660
|
-
chainId,
|
|
661
|
-
networkClientId,
|
|
662
|
-
});
|
|
564
|
+
const { estimates: txGasFeeEstimates } = await this.messenger.call('TransactionController:estimateGasFee', { transactionParams, chainId, networkClientId });
|
|
663
565
|
const { maxFeePerGas, maxPriorityFeePerGas } = (0, gas_1.getTxGasEstimates)({
|
|
664
566
|
networkGasFeeEstimates: gasFeeEstimates,
|
|
665
567
|
txGasFeeEstimates,
|
|
@@ -685,7 +587,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
685
587
|
_BridgeStatusController_handleEvmTransactionBatch.set(this, async (args) => {
|
|
686
588
|
const transactionParams = await (0, transaction_1.getAddTransactionBatchParams)({
|
|
687
589
|
messenger: this.messenger,
|
|
688
|
-
estimateGasFeeFn: __classPrivateFieldGet(this, _BridgeStatusController_estimateGasFeeFn, "f"),
|
|
689
590
|
...args,
|
|
690
591
|
});
|
|
691
592
|
const txDataByType = {
|
|
@@ -697,7 +598,6 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
697
598
|
const { batchId } = await __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f").call(this, transactionParams);
|
|
698
599
|
const { approvalMeta, tradeMeta } = (0, transaction_1.findAndUpdateTransactionsInBatch)({
|
|
699
600
|
messenger: this.messenger,
|
|
700
|
-
updateTransactionFn: __classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f"),
|
|
701
601
|
batchId,
|
|
702
602
|
txDataByType,
|
|
703
603
|
});
|
|
@@ -719,11 +619,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
719
619
|
* @returns The transaction meta
|
|
720
620
|
*/
|
|
721
621
|
this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = bridge_controller_1.MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests) => {
|
|
722
|
-
this.messenger
|
|
723
|
-
|
|
724
|
-
// If the trade has a featureId, it means it was submitted outside of the Unified Swap and Bridge experience, so no QuotesReceived event is published
|
|
725
|
-
quoteResponse.featureId ? undefined : quotesReceivedContext);
|
|
726
|
-
const selectedAccount = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
|
|
622
|
+
(0, bridge_1.stopPollingForQuotes)(this.messenger, quoteResponse.featureId, quotesReceivedContext);
|
|
623
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, accountAddress);
|
|
727
624
|
if (!selectedAccount) {
|
|
728
625
|
throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
|
|
729
626
|
}
|
|
@@ -742,19 +639,11 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
742
639
|
if ((0, bridge_controller_1.isNonEvmChainId)(quoteResponse.quote.srcChainId)) {
|
|
743
640
|
// Handle non-EVM approval if present (e.g., Tron token approvals)
|
|
744
641
|
if (quoteResponse.approval && (0, bridge_controller_1.isTronTrade)(quoteResponse.approval)) {
|
|
745
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
746
|
-
name: isBridgeTx
|
|
747
|
-
? constants_1.TraceName.BridgeTransactionApprovalCompleted
|
|
748
|
-
: constants_1.TraceName.SwapTransactionApprovalCompleted,
|
|
749
|
-
data: {
|
|
750
|
-
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
751
|
-
stxEnabled: false,
|
|
752
|
-
},
|
|
753
|
-
}, async () => {
|
|
642
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_1.getApprovalTraceParams)(quoteResponse, false), async () => {
|
|
754
643
|
try {
|
|
755
644
|
return quoteResponse.approval &&
|
|
756
645
|
(0, bridge_controller_1.isTronTrade)(quoteResponse.approval)
|
|
757
|
-
? await
|
|
646
|
+
? await (0, snaps_1.handleNonEvmTx)(this.messenger, quoteResponse.approval, quoteResponse, selectedAccount)
|
|
758
647
|
: /* c8 ignore start */
|
|
759
648
|
undefined;
|
|
760
649
|
/* c8 ignore end */
|
|
@@ -772,22 +661,14 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
772
661
|
// Add delay after approval similar to EVM flow
|
|
773
662
|
await (0, transaction_1.handleApprovalDelay)(quoteResponse.quote.srcChainId);
|
|
774
663
|
}
|
|
775
|
-
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
776
|
-
name: isBridgeTx
|
|
777
|
-
? constants_1.TraceName.BridgeTransactionCompleted
|
|
778
|
-
: constants_1.TraceName.SwapTransactionCompleted,
|
|
779
|
-
data: {
|
|
780
|
-
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
781
|
-
stxEnabled: false,
|
|
782
|
-
},
|
|
783
|
-
}, async () => {
|
|
664
|
+
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_1.getTraceParams)(quoteResponse, false), async () => {
|
|
784
665
|
try {
|
|
785
666
|
if (!((0, bridge_controller_1.isTronTrade)(quoteResponse.trade) ||
|
|
786
667
|
(0, bridge_controller_1.isBitcoinTrade)(quoteResponse.trade) ||
|
|
787
668
|
typeof quoteResponse.trade === 'string')) {
|
|
788
669
|
throw new Error('Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction');
|
|
789
670
|
}
|
|
790
|
-
return await
|
|
671
|
+
return await (0, snaps_1.handleNonEvmTx)(this.messenger, quoteResponse.trade, quoteResponse, selectedAccount);
|
|
791
672
|
}
|
|
792
673
|
catch (error) {
|
|
793
674
|
!quoteResponse.featureId &&
|
|
@@ -805,15 +686,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
805
686
|
// Extension does not have this issue
|
|
806
687
|
const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === types_1.BridgeClientId.MOBILE && isHardwareAccount;
|
|
807
688
|
// Handle smart transactions if enabled
|
|
808
|
-
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
809
|
-
name: isBridgeTx
|
|
810
|
-
? constants_1.TraceName.BridgeTransactionCompleted
|
|
811
|
-
: constants_1.TraceName.SwapTransactionCompleted,
|
|
812
|
-
data: {
|
|
813
|
-
srcChainId: (0, bridge_controller_1.formatChainIdToCaip)(quoteResponse.quote.srcChainId),
|
|
814
|
-
stxEnabled: isStxEnabledOnClient,
|
|
815
|
-
},
|
|
816
|
-
}, async () => {
|
|
689
|
+
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, (0, trace_1.getTraceParams)(quoteResponse, isStxEnabledOnClient), async () => {
|
|
817
690
|
if (!(0, bridge_controller_1.isEvmTxData)(quoteResponse.trade)) {
|
|
818
691
|
throw new Error('Failed to submit cross-chain swap transaction: trade is not an EVM transaction');
|
|
819
692
|
}
|
|
@@ -824,7 +697,8 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
824
697
|
isDelegatedAccount = await (async () => {
|
|
825
698
|
try {
|
|
826
699
|
const atomicBatchSupport = await this.messenger.call('TransactionController:isAtomicBatchSupported', {
|
|
827
|
-
address: quoteResponse.trade
|
|
700
|
+
address: quoteResponse.trade
|
|
701
|
+
.from,
|
|
828
702
|
chainIds: [hexChainId],
|
|
829
703
|
});
|
|
830
704
|
return atomicBatchSupport.some((entry) => entry.isSupported && entry.delegationAddress);
|
|
@@ -851,7 +725,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
851
725
|
return tradeMeta;
|
|
852
726
|
}
|
|
853
727
|
// Set approval time and id if an approval tx is needed
|
|
854
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && (0, bridge_controller_1.isEvmTxData)(quoteResponse.approval)
|
|
728
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && (0, bridge_controller_1.isEvmTxData)(quoteResponse.approval)
|
|
855
729
|
? quoteResponse.approval
|
|
856
730
|
: undefined, quoteResponse.resetApproval, requireApproval);
|
|
857
731
|
approvalTxId = approvalTxMeta?.id;
|
|
@@ -947,28 +821,30 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
947
821
|
*/
|
|
948
822
|
this.submitIntent = async (params) => {
|
|
949
823
|
const { quoteResponse, accountAddress, location, abTests, activeAbTests } = params;
|
|
950
|
-
|
|
824
|
+
// TODO add metrics context
|
|
825
|
+
(0, bridge_1.stopPollingForQuotes)(this.messenger);
|
|
951
826
|
// Build pre-confirmation properties for error tracking parity with submitTx
|
|
952
|
-
const account =
|
|
827
|
+
const account = (0, accounts_1.getAccountByAddress)(this.messenger, accountAddress);
|
|
953
828
|
const isHardwareAccount = Boolean(account) && (0, bridge_controller_1.isHardwareWallet)(account);
|
|
954
829
|
const preConfirmationProperties = (0, metrics_1.getPreConfirmationPropertiesFromQuote)(quoteResponse, false, isHardwareAccount, location, abTests, activeAbTests);
|
|
955
830
|
try {
|
|
956
|
-
const intent = (0,
|
|
831
|
+
const intent = (0, intent_api_1.getIntentFromQuote)(quoteResponse);
|
|
957
832
|
// If backend provided an approval tx for this intent quote, submit it first (on-chain),
|
|
958
833
|
// then proceed with off-chain intent submission.
|
|
959
834
|
const isBridgeTx = (0, bridge_controller_1.isCrossChain)(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
960
835
|
const requireApproval = isHardwareAccount && __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === types_1.BridgeClientId.MOBILE;
|
|
961
836
|
// Handle approval silently for better UX in intent flows
|
|
962
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
837
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
963
838
|
const approvalTxId = approvalTxMeta?.id;
|
|
964
839
|
if (approvalTxId) {
|
|
965
840
|
await __classPrivateFieldGet(this, _BridgeStatusController_waitForTxConfirmation, "f").call(this, approvalTxId);
|
|
966
841
|
}
|
|
967
842
|
const { srcChainId, requestId } = quoteResponse.quote;
|
|
968
|
-
const signature = await
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
843
|
+
const signature = await (0, keyring_1.signTypedMessage)({
|
|
844
|
+
messenger: this.messenger,
|
|
845
|
+
accountAddress,
|
|
846
|
+
typedData: intent.typedData,
|
|
847
|
+
});
|
|
972
848
|
const submissionParams = {
|
|
973
849
|
srcChainId,
|
|
974
850
|
quoteId: requestId,
|
|
@@ -986,7 +862,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
986
862
|
: /* c8 ignore end */
|
|
987
863
|
transaction_controller_1.TransactionType.swap;
|
|
988
864
|
// Create actual transaction in Transaction Controller first
|
|
989
|
-
const networkClientId =
|
|
865
|
+
const networkClientId = (0, network_1.getNetworkClientIdByChainId)(this.messenger, srcChainId);
|
|
990
866
|
// This is a synthetic transaction whose purpose is to be able
|
|
991
867
|
// to track the order status via the history
|
|
992
868
|
const intentTransactionParams = {
|
|
@@ -999,7 +875,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
999
875
|
gas: '0x5208', // Minimal gas for display purposes
|
|
1000
876
|
gasPrice: '0x3b9aca00', // 1 Gwei - will be converted to EIP-1559 fees if network supports it
|
|
1001
877
|
};
|
|
1002
|
-
const { transactionMeta: txMetaPromise } = await
|
|
878
|
+
const { transactionMeta: txMetaPromise } = await this.messenger.call('TransactionController:addTransaction', intentTransactionParams, {
|
|
1003
879
|
origin: 'metamask',
|
|
1004
880
|
actionId: (0, transaction_1.generateActionId)(),
|
|
1005
881
|
requireApproval: false,
|
|
@@ -1099,24 +975,36 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1099
975
|
};
|
|
1100
976
|
// This will publish events for PERPS dropped tx failures as well
|
|
1101
977
|
if (!txMetaId) {
|
|
1102
|
-
|
|
978
|
+
(0, bridge_1.trackMetricsEvent)({
|
|
979
|
+
messenger: this.messenger,
|
|
980
|
+
eventName,
|
|
981
|
+
properties: baseProperties,
|
|
982
|
+
});
|
|
1103
983
|
return;
|
|
1104
984
|
}
|
|
1105
985
|
const historyItem = this.state.txHistory[txMetaId];
|
|
1106
986
|
if (!historyItem) {
|
|
1107
|
-
|
|
987
|
+
(0, bridge_1.trackMetricsEvent)({
|
|
988
|
+
messenger: this.messenger,
|
|
989
|
+
eventName,
|
|
990
|
+
properties: baseProperties,
|
|
991
|
+
});
|
|
1108
992
|
return;
|
|
1109
993
|
}
|
|
1110
994
|
const requestParamProperties = (0, metrics_1.getRequestParamFromHistory)(historyItem);
|
|
1111
995
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
1112
996
|
if (eventName === bridge_controller_1.UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
997
|
+
(0, bridge_1.trackMetricsEvent)({
|
|
998
|
+
messenger: this.messenger,
|
|
999
|
+
eventName,
|
|
1000
|
+
properties: {
|
|
1001
|
+
...baseProperties,
|
|
1002
|
+
chain_id_source: requestParamProperties.chain_id_source,
|
|
1003
|
+
chain_id_destination: requestParamProperties.chain_id_destination,
|
|
1004
|
+
token_address_source: requestParamProperties.token_address_source,
|
|
1005
|
+
token_address_destination: requestParamProperties.token_address_destination,
|
|
1006
|
+
refresh_count: historyItem.attempts?.counter ?? 0,
|
|
1007
|
+
},
|
|
1120
1008
|
});
|
|
1121
1009
|
return;
|
|
1122
1010
|
}
|
|
@@ -1124,7 +1012,7 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1124
1012
|
if (historyItem.featureId) {
|
|
1125
1013
|
return;
|
|
1126
1014
|
}
|
|
1127
|
-
const selectedAccount = this.messenger
|
|
1015
|
+
const selectedAccount = (0, accounts_1.getAccountByAddress)(this.messenger, historyItem.account);
|
|
1128
1016
|
const { transactions } = this.messenger.call('TransactionController:getState');
|
|
1129
1017
|
const txMeta = transactions?.find((tx) => tx.id === txMetaId);
|
|
1130
1018
|
const approvalTxMeta = transactions?.find((tx) => tx.id === historyItem.approvalTxId);
|
|
@@ -1137,24 +1025,23 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1137
1025
|
...(0, metrics_1.getFinalizedTxProperties)(historyItem, txMeta, approvalTxMeta),
|
|
1138
1026
|
...(0, metrics_1.getPriceImpactFromQuote)(historyItem.quote),
|
|
1139
1027
|
};
|
|
1140
|
-
|
|
1028
|
+
(0, bridge_1.trackMetricsEvent)({
|
|
1029
|
+
messenger: this.messenger,
|
|
1030
|
+
eventName,
|
|
1031
|
+
properties: requiredEventProperties,
|
|
1032
|
+
});
|
|
1141
1033
|
});
|
|
1142
1034
|
__classPrivateFieldSet(this, _BridgeStatusController_clientId, clientId, "f");
|
|
1143
1035
|
__classPrivateFieldSet(this, _BridgeStatusController_fetchFn, fetchFn, "f");
|
|
1144
|
-
__classPrivateFieldSet(this, _BridgeStatusController_addTransactionFn, addTransactionFn, "f");
|
|
1145
1036
|
__classPrivateFieldSet(this, _BridgeStatusController_addTransactionBatchFn, addTransactionBatchFn, "f");
|
|
1146
|
-
__classPrivateFieldSet(this, _BridgeStatusController_updateTransactionFn, updateTransactionFn, "f");
|
|
1147
|
-
__classPrivateFieldSet(this, _BridgeStatusController_estimateGasFeeFn, estimateGasFeeFn, "f");
|
|
1148
1037
|
__classPrivateFieldSet(this, _BridgeStatusController_config, {
|
|
1149
1038
|
customBridgeApiBaseUrl: config?.customBridgeApiBaseUrl ?? constants_1.BRIDGE_PROD_API_BASE_URL,
|
|
1150
1039
|
}, "f");
|
|
1151
1040
|
__classPrivateFieldSet(this, _BridgeStatusController_trace, traceFn ?? ((_request, fn) => fn?.()), "f");
|
|
1152
1041
|
__classPrivateFieldSet(this, _BridgeStatusController_intentManager, new bridge_status_controller_intent_1.IntentManager({
|
|
1153
1042
|
messenger: this.messenger,
|
|
1154
|
-
updateTransactionFn: __classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f"),
|
|
1155
1043
|
customBridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
|
|
1156
1044
|
fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
|
|
1157
|
-
getJwt: __classPrivateFieldGet(this, _BridgeStatusController_getJwt, "f"),
|
|
1158
1045
|
}), "f");
|
|
1159
1046
|
// Register action handlers
|
|
1160
1047
|
this.messenger.registerActionHandler(`${constants_1.BRIDGE_STATUS_CONTROLLER_NAME}:startPollingForBridgeTxStatus`, this.startPollingForBridgeTxStatus.bind(this));
|
|
@@ -1212,7 +1099,5 @@ class BridgeStatusController extends (0, polling_controller_1.StaticIntervalPoll
|
|
|
1212
1099
|
}
|
|
1213
1100
|
}
|
|
1214
1101
|
exports.BridgeStatusController = BridgeStatusController;
|
|
1215
|
-
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(),
|
|
1216
|
-
return this.messenger.call('AccountsController:getAccountByAddress', accountAddress);
|
|
1217
|
-
};
|
|
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(), _BridgeStatusController_waitForHashAndReturnFinalTxMeta = new WeakMap(), _BridgeStatusController_waitForTxConfirmation = 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();
|
|
1218
1103
|
//# sourceMappingURL=bridge-status-controller.cjs.map
|