@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
|
@@ -9,21 +9,28 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
import { formatChainIdToHex, isNonEvmChainId, StatusTypes, UnifiedSwapBridgeEventName,
|
|
12
|
+
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;
|
|
13
|
+
import { formatChainIdToHex, isNonEvmChainId, StatusTypes, UnifiedSwapBridgeEventName, isCrossChain, isTronChainId, isEvmTxData, isHardwareWallet, MetricsActionType, MetaMetricsSwapsEventSource, isBitcoinTrade, isTronTrade, PollingStatus } from "@metamask/bridge-controller";
|
|
14
14
|
import { toHex } from "@metamask/controller-utils";
|
|
15
|
-
import { SignTypedDataVersion } from "@metamask/keyring-controller";
|
|
16
15
|
import { StaticIntervalPollingController } from "@metamask/polling-controller";
|
|
17
16
|
import { TransactionStatus, TransactionType } from "@metamask/transaction-controller";
|
|
18
17
|
import { numberToHex } from "@metamask/utils";
|
|
19
18
|
import { IntentManager } from "./bridge-status-controller.intent.mjs";
|
|
20
|
-
import { BRIDGE_PROD_API_BASE_URL, BRIDGE_STATUS_CONTROLLER_NAME, DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE, MAX_ATTEMPTS, REFRESH_INTERVAL_MS
|
|
19
|
+
import { BRIDGE_PROD_API_BASE_URL, BRIDGE_STATUS_CONTROLLER_NAME, DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE, MAX_ATTEMPTS, REFRESH_INTERVAL_MS } from "./constants.mjs";
|
|
21
20
|
import { BridgeClientId } from "./types.mjs";
|
|
21
|
+
import { getAccountByAddress } from "./utils/accounts.mjs";
|
|
22
|
+
import { getJwt } from "./utils/authentication.mjs";
|
|
23
|
+
import { stopPollingForQuotes, trackMetricsEvent } from "./utils/bridge.mjs";
|
|
22
24
|
import { fetchBridgeTxStatus, getStatusRequestWithSrcTxHash, shouldSkipFetchDueToFetchFailures } from "./utils/bridge-status.mjs";
|
|
23
25
|
import { getTxGasEstimates } from "./utils/gas.mjs";
|
|
24
|
-
import {
|
|
26
|
+
import { getInitialHistoryItem, rekeyHistoryItemInState, shouldPollHistoryItem } from "./utils/history.mjs";
|
|
27
|
+
import { getIntentFromQuote, mapIntentOrderStatusToTransactionStatus } from "./utils/intent-api.mjs";
|
|
28
|
+
import { signTypedMessage } from "./utils/keyring.mjs";
|
|
25
29
|
import { getFinalizedTxProperties, getPriceImpactFromQuote, getRequestMetadataFromHistory, getRequestParamFromHistory, getTradeDataFromHistory, getEVMTxPropertiesFromTransactionMeta, getTxStatusesFromHistory, getPreConfirmationPropertiesFromQuote } from "./utils/metrics.mjs";
|
|
26
|
-
import {
|
|
30
|
+
import { getNetworkClientIdByChainId, getSelectedChainId } from "./utils/network.mjs";
|
|
31
|
+
import { handleNonEvmTx } from "./utils/snaps.mjs";
|
|
32
|
+
import { getApprovalTraceParams, getTraceParams } from "./utils/trace.mjs";
|
|
33
|
+
import { findAndUpdateTransactionsInBatch, getAddTransactionBatchParams, getStatusRequestParams, handleApprovalDelay, handleMobileHardwareWalletDelay, generateActionId, waitForTxConfirmation } from "./utils/transaction.mjs";
|
|
27
34
|
const metadata = {
|
|
28
35
|
// We want to persist the bridge status state so that we can show the proper data for the Activity list
|
|
29
36
|
// basically match the behavior of TransactionController
|
|
@@ -35,7 +42,7 @@ const metadata = {
|
|
|
35
42
|
},
|
|
36
43
|
};
|
|
37
44
|
export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
38
|
-
constructor({ messenger, state, clientId, fetchFn,
|
|
45
|
+
constructor({ messenger, state, clientId, fetchFn, addTransactionBatchFn, config, traceFn, }) {
|
|
39
46
|
super({
|
|
40
47
|
name: BRIDGE_STATUS_CONTROLLER_NAME,
|
|
41
48
|
metadata,
|
|
@@ -46,16 +53,12 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
46
53
|
...state,
|
|
47
54
|
},
|
|
48
55
|
});
|
|
49
|
-
_BridgeStatusController_instances.add(this);
|
|
50
56
|
_BridgeStatusController_pollingTokensByTxMetaId.set(this, {});
|
|
51
57
|
_BridgeStatusController_intentManager.set(this, void 0);
|
|
52
58
|
_BridgeStatusController_clientId.set(this, void 0);
|
|
53
59
|
_BridgeStatusController_fetchFn.set(this, void 0);
|
|
54
60
|
_BridgeStatusController_config.set(this, void 0);
|
|
55
|
-
_BridgeStatusController_addTransactionFn.set(this, void 0);
|
|
56
61
|
_BridgeStatusController_addTransactionBatchFn.set(this, void 0);
|
|
57
|
-
_BridgeStatusController_updateTransactionFn.set(this, void 0);
|
|
58
|
-
_BridgeStatusController_estimateGasFeeFn.set(this, void 0);
|
|
59
62
|
_BridgeStatusController_trace.set(this, void 0);
|
|
60
63
|
// Mark tx as failed in txHistory if either the approval or trade fails
|
|
61
64
|
_BridgeStatusController_markTxAsFailed.set(this, ({ id: txMetaId, actionId, }) => {
|
|
@@ -90,9 +93,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
90
93
|
});
|
|
91
94
|
}
|
|
92
95
|
else {
|
|
93
|
-
const
|
|
94
|
-
const selectedNetworkClient = this.messenger.call('NetworkController:getNetworkClientById', selectedNetworkClientId);
|
|
95
|
-
const selectedChainId = selectedNetworkClient.configuration.chainId;
|
|
96
|
+
const selectedChainId = getSelectedChainId(this.messenger);
|
|
96
97
|
__classPrivateFieldGet(this, _BridgeStatusController_wipeBridgeStatusByChainId, "f").call(this, address, selectedChainId);
|
|
97
98
|
}
|
|
98
99
|
};
|
|
@@ -134,7 +135,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
// Restart polling if it was stopped and this tx still needs status updates
|
|
137
|
-
if (
|
|
138
|
+
if (shouldPollHistoryItem(historyItem)) {
|
|
138
139
|
// Check if polling was stopped (no active polling token)
|
|
139
140
|
const existingPollingToken = __classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[targetTxMetaId];
|
|
140
141
|
if (!existingPollingToken) {
|
|
@@ -142,7 +143,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
142
143
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, targetTxMetaId);
|
|
143
144
|
// Track polling manually restarted event
|
|
144
145
|
if (!historyItem.featureId) {
|
|
145
|
-
const selectedAccount = this.messenger
|
|
146
|
+
const selectedAccount = getAccountByAddress(this.messenger, historyItem.account);
|
|
146
147
|
const requestParams = getRequestParamFromHistory(historyItem);
|
|
147
148
|
const requestMetadata = getRequestMetadataFromHistory(historyItem, selectedAccount);
|
|
148
149
|
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
@@ -191,7 +192,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
191
192
|
})
|
|
192
193
|
// Only restart polling for items that still require status updates
|
|
193
194
|
.filter((historyItem) => {
|
|
194
|
-
return
|
|
195
|
+
return shouldPollHistoryItem(historyItem);
|
|
195
196
|
});
|
|
196
197
|
incompleteHistoryItems.forEach((historyItem) => {
|
|
197
198
|
const bridgeTxMetaId = historyItem.txMetaId;
|
|
@@ -204,51 +205,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
204
205
|
__classPrivateFieldGet(this, _BridgeStatusController_startPollingForTxId, "f").call(this, bridgeTxMetaId);
|
|
205
206
|
});
|
|
206
207
|
});
|
|
207
|
-
_BridgeStatusController_addTxToHistory.set(this, (
|
|
208
|
-
const {
|
|
209
|
-
// Determine the key for this history item:
|
|
210
|
-
// - For pre-submission (non-batch EVM): use actionId
|
|
211
|
-
// - For post-submission or other cases: use bridgeTxMeta.id
|
|
212
|
-
const historyKey = getHistoryKey(actionId, bridgeTxMeta?.id);
|
|
213
|
-
// Write all non-status fields to state so we can reference the quote in Activity list without the Bridge API
|
|
214
|
-
// We know it's in progress but not the exact status yet
|
|
215
|
-
const txHistoryItem = {
|
|
216
|
-
txMetaId: bridgeTxMeta?.id,
|
|
217
|
-
actionId,
|
|
218
|
-
originalTransactionId: bridgeTxMeta
|
|
219
|
-
?.originalTransactionId || bridgeTxMeta?.id, // Keep original for intent transactions
|
|
220
|
-
batchId: bridgeTxMeta?.batchId,
|
|
221
|
-
quote: quoteResponse.quote,
|
|
222
|
-
startTime,
|
|
223
|
-
estimatedProcessingTimeInSeconds: quoteResponse.estimatedProcessingTimeInSeconds,
|
|
224
|
-
slippagePercentage,
|
|
225
|
-
pricingData: {
|
|
226
|
-
amountSent: quoteResponse.sentAmount?.amount ?? '0',
|
|
227
|
-
amountSentInUsd: quoteResponse.sentAmount?.usd ?? undefined,
|
|
228
|
-
quotedGasInUsd: quoteResponse.gasFee?.effective?.usd ?? undefined,
|
|
229
|
-
quotedReturnInUsd: quoteResponse.toTokenAmount?.usd ?? undefined,
|
|
230
|
-
quotedGasAmount: quoteResponse.gasFee?.effective?.amount ?? undefined,
|
|
231
|
-
},
|
|
232
|
-
initialDestAssetBalance,
|
|
233
|
-
targetContractAddress,
|
|
234
|
-
account: selectedAddress,
|
|
235
|
-
status: {
|
|
236
|
-
// We always have a PENDING status when we start polling for a tx, don't need the Bridge API for that
|
|
237
|
-
// Also we know the bare minimum fields for status at this point in time
|
|
238
|
-
status: StatusTypes.PENDING,
|
|
239
|
-
srcChain: {
|
|
240
|
-
chainId: statusRequest.srcChainId,
|
|
241
|
-
txHash: statusRequest.srcTxHash,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
hasApprovalTx: Boolean(quoteResponse.approval),
|
|
245
|
-
approvalTxId,
|
|
246
|
-
isStxEnabled: Boolean(isStxEnabled),
|
|
247
|
-
featureId: quoteResponse.featureId,
|
|
248
|
-
location,
|
|
249
|
-
...(abTests && { abTests }),
|
|
250
|
-
...(activeAbTests && { activeAbTests }),
|
|
251
|
-
};
|
|
208
|
+
_BridgeStatusController_addTxToHistory.set(this, (...args) => {
|
|
209
|
+
const { historyKey, txHistoryItem } = getInitialHistoryItem(...args);
|
|
252
210
|
this.update((state) => {
|
|
253
211
|
// Use actionId as key for pre-submission, or txMeta.id for post-submission
|
|
254
212
|
state.txHistory[historyKey] = txHistoryItem;
|
|
@@ -278,18 +236,12 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
278
236
|
if (!txHistoryItem) {
|
|
279
237
|
return;
|
|
280
238
|
}
|
|
281
|
-
if (
|
|
239
|
+
if (shouldPollHistoryItem(txHistoryItem)) {
|
|
282
240
|
__classPrivateFieldGet(this, _BridgeStatusController_pollingTokensByTxMetaId, "f")[txId] = this.startPolling({
|
|
283
241
|
bridgeTxMetaId: txId,
|
|
284
242
|
});
|
|
285
243
|
}
|
|
286
244
|
});
|
|
287
|
-
_BridgeStatusController_shouldPollHistoryItem.set(this, (historyItem) => {
|
|
288
|
-
const isIntent = Boolean(historyItem?.quote?.intent);
|
|
289
|
-
const isBridgeTx = isCrossChain(historyItem.quote.srcChainId, historyItem.quote.destChainId);
|
|
290
|
-
const isTronTx = isTronChainId(historyItem.quote.srcChainId);
|
|
291
|
-
return [isBridgeTx, isIntent, isTronTx].some(Boolean);
|
|
292
|
-
});
|
|
293
245
|
/**
|
|
294
246
|
* @deprecated For EVM/Solana swap/bridge txs we add tx to history in submitTx()
|
|
295
247
|
* For Solana swap/bridge we start polling in submitTx()
|
|
@@ -341,7 +293,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
341
293
|
// Track max polling reached event
|
|
342
294
|
const historyItem = this.state.txHistory[bridgeTxMetaId];
|
|
343
295
|
if (historyItem && !historyItem.featureId) {
|
|
344
|
-
const selectedAccount = this.messenger
|
|
296
|
+
const selectedAccount = getAccountByAddress(this.messenger, historyItem.account);
|
|
345
297
|
const requestParams = getRequestParamFromHistory(historyItem);
|
|
346
298
|
const requestMetadata = getRequestMetadataFromHistory(historyItem, selectedAccount);
|
|
347
299
|
const { security_warnings: _, ...metadataWithoutWarnings } = requestMetadata;
|
|
@@ -397,7 +349,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
397
349
|
}
|
|
398
350
|
__classPrivateFieldGet(this, _BridgeStatusController_updateSrcTxHash, "f").call(this, bridgeTxMetaId, srcTxHash);
|
|
399
351
|
const statusRequest = getStatusRequestWithSrcTxHash(historyItem.quote, srcTxHash);
|
|
400
|
-
const response = await fetchBridgeTxStatus(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), await
|
|
352
|
+
const response = await fetchBridgeTxStatus(statusRequest, __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f"), await getJwt(this.messenger), __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl);
|
|
401
353
|
status = response.status;
|
|
402
354
|
validationFailures = response.validationFailures;
|
|
403
355
|
}
|
|
@@ -453,16 +405,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
453
405
|
__classPrivateFieldGet(this, _BridgeStatusController_handleFetchFailure, "f").call(this, bridgeTxMetaId);
|
|
454
406
|
}
|
|
455
407
|
});
|
|
456
|
-
_BridgeStatusController_getJwt.set(this, async () => {
|
|
457
|
-
try {
|
|
458
|
-
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
459
|
-
return token;
|
|
460
|
-
}
|
|
461
|
-
catch (error) {
|
|
462
|
-
console.error('Error getting JWT token for bridge-api request', error);
|
|
463
|
-
return undefined;
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
408
|
_BridgeStatusController_getSrcTxHash.set(this, (bridgeTxMetaId) => {
|
|
467
409
|
const { txHistory } = this.state;
|
|
468
410
|
// Prefer the srcTxHash from bridgeStatusState so we don't have to l ook up in TransactionController
|
|
@@ -512,34 +454,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
512
454
|
* TX SUBMISSION HANDLING
|
|
513
455
|
*******************************************************
|
|
514
456
|
*/
|
|
515
|
-
/**
|
|
516
|
-
* Submits the transaction to the snap using the new unified ClientRequest interface
|
|
517
|
-
* Works for all non-EVM chains (Solana, BTC, Tron)
|
|
518
|
-
* This adds an approval tx to the ApprovalsController in the background
|
|
519
|
-
* The client needs to handle the approval tx by redirecting to the confirmation page with the approvalTxId in the URL
|
|
520
|
-
*
|
|
521
|
-
* @param trade - The trade data (can be approval or main trade)
|
|
522
|
-
* @param quoteResponse - The quote response containing metadata
|
|
523
|
-
* @param selectedAccount - The account to submit the transaction for
|
|
524
|
-
* @returns The transaction meta
|
|
525
|
-
*/
|
|
526
|
-
_BridgeStatusController_handleNonEvmTx.set(this, async (trade, quoteResponse, selectedAccount) => {
|
|
527
|
-
if (!selectedAccount.metadata?.snap?.id) {
|
|
528
|
-
throw new Error('Failed to submit cross-chain swap transaction: undefined snap id');
|
|
529
|
-
}
|
|
530
|
-
const request = getClientRequest(trade, quoteResponse.quote.srcChainId, selectedAccount);
|
|
531
|
-
const requestResponse = (await this.messenger.call('SnapController:handleRequest', request));
|
|
532
|
-
// Create quote response with the specified trade
|
|
533
|
-
// This allows the same method to handle both approvals and main trades
|
|
534
|
-
const txQuoteResponse = {
|
|
535
|
-
...quoteResponse,
|
|
536
|
-
trade,
|
|
537
|
-
};
|
|
538
|
-
const txMeta = handleNonEvmTxResponse(requestResponse, txQuoteResponse, selectedAccount);
|
|
539
|
-
// TODO remove this eventually, just returning it now to match extension behavior
|
|
540
|
-
// 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
|
|
541
|
-
return txMeta;
|
|
542
|
-
});
|
|
543
457
|
_BridgeStatusController_waitForHashAndReturnFinalTxMeta.set(this, async (hashPromise) => {
|
|
544
458
|
const transactionHash = await hashPromise;
|
|
545
459
|
const finalTransactionMeta = this.messenger
|
|
@@ -558,7 +472,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
558
472
|
pollMs,
|
|
559
473
|
});
|
|
560
474
|
});
|
|
561
|
-
_BridgeStatusController_handleApprovalTx.set(this, async (isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
475
|
+
_BridgeStatusController_handleApprovalTx.set(this, async (quoteResponse, isBridgeTx, srcChainId, approval, resetApproval, requireApproval) => {
|
|
562
476
|
if (approval && isEvmTxData(approval)) {
|
|
563
477
|
const approveTx = async () => {
|
|
564
478
|
await __classPrivateFieldGet(this, _BridgeStatusController_handleUSDTAllowanceReset, "f").call(this, resetApproval);
|
|
@@ -572,15 +486,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
572
486
|
await handleApprovalDelay(srcChainId);
|
|
573
487
|
return approvalTxMeta;
|
|
574
488
|
};
|
|
575
|
-
return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this,
|
|
576
|
-
name: isBridgeTx
|
|
577
|
-
? TraceName.BridgeTransactionApprovalCompleted
|
|
578
|
-
: TraceName.SwapTransactionApprovalCompleted,
|
|
579
|
-
data: {
|
|
580
|
-
srcChainId: formatChainIdToCaip(srcChainId),
|
|
581
|
-
stxEnabled: false,
|
|
582
|
-
},
|
|
583
|
-
}, approveTx);
|
|
489
|
+
return await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getApprovalTraceParams(quoteResponse, false), approveTx);
|
|
584
490
|
}
|
|
585
491
|
return undefined;
|
|
586
492
|
});
|
|
@@ -599,13 +505,13 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
599
505
|
*/
|
|
600
506
|
_BridgeStatusController_handleEvmTransaction.set(this, async ({ transactionType, trade, requireApproval = false, txFee, actionId: providedActionId, }) => {
|
|
601
507
|
// Use provided actionId (for pre-submission history) or generate one
|
|
602
|
-
const actionId = providedActionId ?? generateActionId()
|
|
603
|
-
const selectedAccount = this.messenger
|
|
508
|
+
const actionId = providedActionId ?? generateActionId();
|
|
509
|
+
const selectedAccount = getAccountByAddress(this.messenger, trade.from);
|
|
604
510
|
if (!selectedAccount) {
|
|
605
511
|
throw new Error('Failed to submit cross-chain swap transaction: unknown account in trade data');
|
|
606
512
|
}
|
|
607
513
|
const hexChainId = formatChainIdToHex(trade.chainId);
|
|
608
|
-
const networkClientId = this.messenger
|
|
514
|
+
const networkClientId = getNetworkClientIdByChainId(this.messenger, hexChainId);
|
|
609
515
|
const requestOptions = {
|
|
610
516
|
actionId,
|
|
611
517
|
networkClientId,
|
|
@@ -629,7 +535,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
629
535
|
...transactionParams,
|
|
630
536
|
...(await __classPrivateFieldGet(this, _BridgeStatusController_calculateGasFees, "f").call(this, transactionParams, networkClientId, hexChainId, txFee)),
|
|
631
537
|
};
|
|
632
|
-
const { result } = await
|
|
538
|
+
const { result } = await this.messenger.call('TransactionController:addTransaction', transactionParamsWithMaxGas, requestOptions);
|
|
633
539
|
return await __classPrivateFieldGet(this, _BridgeStatusController_waitForHashAndReturnFinalTxMeta, "f").call(this, result);
|
|
634
540
|
});
|
|
635
541
|
_BridgeStatusController_handleUSDTAllowanceReset.set(this, async (resetApproval) => {
|
|
@@ -652,11 +558,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
652
558
|
};
|
|
653
559
|
}
|
|
654
560
|
const { gasFeeEstimates } = this.messenger.call('GasFeeController:getState');
|
|
655
|
-
const { estimates: txGasFeeEstimates } = await
|
|
656
|
-
transactionParams,
|
|
657
|
-
chainId,
|
|
658
|
-
networkClientId,
|
|
659
|
-
});
|
|
561
|
+
const { estimates: txGasFeeEstimates } = await this.messenger.call('TransactionController:estimateGasFee', { transactionParams, chainId, networkClientId });
|
|
660
562
|
const { maxFeePerGas, maxPriorityFeePerGas } = getTxGasEstimates({
|
|
661
563
|
networkGasFeeEstimates: gasFeeEstimates,
|
|
662
564
|
txGasFeeEstimates,
|
|
@@ -682,7 +584,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
682
584
|
_BridgeStatusController_handleEvmTransactionBatch.set(this, async (args) => {
|
|
683
585
|
const transactionParams = await getAddTransactionBatchParams({
|
|
684
586
|
messenger: this.messenger,
|
|
685
|
-
estimateGasFeeFn: __classPrivateFieldGet(this, _BridgeStatusController_estimateGasFeeFn, "f"),
|
|
686
587
|
...args,
|
|
687
588
|
});
|
|
688
589
|
const txDataByType = {
|
|
@@ -694,7 +595,6 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
694
595
|
const { batchId } = await __classPrivateFieldGet(this, _BridgeStatusController_addTransactionBatchFn, "f").call(this, transactionParams);
|
|
695
596
|
const { approvalMeta, tradeMeta } = findAndUpdateTransactionsInBatch({
|
|
696
597
|
messenger: this.messenger,
|
|
697
|
-
updateTransactionFn: __classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f"),
|
|
698
598
|
batchId,
|
|
699
599
|
txDataByType,
|
|
700
600
|
});
|
|
@@ -716,11 +616,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
716
616
|
* @returns The transaction meta
|
|
717
617
|
*/
|
|
718
618
|
this.submitTx = async (accountAddress, quoteResponse, isStxEnabledOnClient, quotesReceivedContext, location = MetaMetricsSwapsEventSource.MainView, abTests, activeAbTests) => {
|
|
719
|
-
this.messenger
|
|
720
|
-
|
|
721
|
-
// 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
|
|
722
|
-
quoteResponse.featureId ? undefined : quotesReceivedContext);
|
|
723
|
-
const selectedAccount = __classPrivateFieldGet(this, _BridgeStatusController_instances, "m", _BridgeStatusController_getMultichainSelectedAccount).call(this, accountAddress);
|
|
619
|
+
stopPollingForQuotes(this.messenger, quoteResponse.featureId, quotesReceivedContext);
|
|
620
|
+
const selectedAccount = getAccountByAddress(this.messenger, accountAddress);
|
|
724
621
|
if (!selectedAccount) {
|
|
725
622
|
throw new Error('Failed to submit cross-chain swap transaction: undefined multichain account');
|
|
726
623
|
}
|
|
@@ -739,19 +636,11 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
739
636
|
if (isNonEvmChainId(quoteResponse.quote.srcChainId)) {
|
|
740
637
|
// Handle non-EVM approval if present (e.g., Tron token approvals)
|
|
741
638
|
if (quoteResponse.approval && isTronTrade(quoteResponse.approval)) {
|
|
742
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
743
|
-
name: isBridgeTx
|
|
744
|
-
? TraceName.BridgeTransactionApprovalCompleted
|
|
745
|
-
: TraceName.SwapTransactionApprovalCompleted,
|
|
746
|
-
data: {
|
|
747
|
-
srcChainId: formatChainIdToCaip(quoteResponse.quote.srcChainId),
|
|
748
|
-
stxEnabled: false,
|
|
749
|
-
},
|
|
750
|
-
}, async () => {
|
|
639
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getApprovalTraceParams(quoteResponse, false), async () => {
|
|
751
640
|
try {
|
|
752
641
|
return quoteResponse.approval &&
|
|
753
642
|
isTronTrade(quoteResponse.approval)
|
|
754
|
-
? await
|
|
643
|
+
? await handleNonEvmTx(this.messenger, quoteResponse.approval, quoteResponse, selectedAccount)
|
|
755
644
|
: /* c8 ignore start */
|
|
756
645
|
undefined;
|
|
757
646
|
/* c8 ignore end */
|
|
@@ -769,22 +658,14 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
769
658
|
// Add delay after approval similar to EVM flow
|
|
770
659
|
await handleApprovalDelay(quoteResponse.quote.srcChainId);
|
|
771
660
|
}
|
|
772
|
-
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
773
|
-
name: isBridgeTx
|
|
774
|
-
? TraceName.BridgeTransactionCompleted
|
|
775
|
-
: TraceName.SwapTransactionCompleted,
|
|
776
|
-
data: {
|
|
777
|
-
srcChainId: formatChainIdToCaip(quoteResponse.quote.srcChainId),
|
|
778
|
-
stxEnabled: false,
|
|
779
|
-
},
|
|
780
|
-
}, async () => {
|
|
661
|
+
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getTraceParams(quoteResponse, false), async () => {
|
|
781
662
|
try {
|
|
782
663
|
if (!(isTronTrade(quoteResponse.trade) ||
|
|
783
664
|
isBitcoinTrade(quoteResponse.trade) ||
|
|
784
665
|
typeof quoteResponse.trade === 'string')) {
|
|
785
666
|
throw new Error('Failed to submit cross-chain swap transaction: trade is not a non-EVM transaction');
|
|
786
667
|
}
|
|
787
|
-
return await
|
|
668
|
+
return await handleNonEvmTx(this.messenger, quoteResponse.trade, quoteResponse, selectedAccount);
|
|
788
669
|
}
|
|
789
670
|
catch (error) {
|
|
790
671
|
!quoteResponse.featureId &&
|
|
@@ -802,15 +683,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
802
683
|
// Extension does not have this issue
|
|
803
684
|
const requireApproval = __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === BridgeClientId.MOBILE && isHardwareAccount;
|
|
804
685
|
// Handle smart transactions if enabled
|
|
805
|
-
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, {
|
|
806
|
-
name: isBridgeTx
|
|
807
|
-
? TraceName.BridgeTransactionCompleted
|
|
808
|
-
: TraceName.SwapTransactionCompleted,
|
|
809
|
-
data: {
|
|
810
|
-
srcChainId: formatChainIdToCaip(quoteResponse.quote.srcChainId),
|
|
811
|
-
stxEnabled: isStxEnabledOnClient,
|
|
812
|
-
},
|
|
813
|
-
}, async () => {
|
|
686
|
+
txMeta = await __classPrivateFieldGet(this, _BridgeStatusController_trace, "f").call(this, getTraceParams(quoteResponse, isStxEnabledOnClient), async () => {
|
|
814
687
|
if (!isEvmTxData(quoteResponse.trade)) {
|
|
815
688
|
throw new Error('Failed to submit cross-chain swap transaction: trade is not an EVM transaction');
|
|
816
689
|
}
|
|
@@ -821,7 +694,8 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
821
694
|
isDelegatedAccount = await (async () => {
|
|
822
695
|
try {
|
|
823
696
|
const atomicBatchSupport = await this.messenger.call('TransactionController:isAtomicBatchSupported', {
|
|
824
|
-
address: quoteResponse.trade
|
|
697
|
+
address: quoteResponse.trade
|
|
698
|
+
.from,
|
|
825
699
|
chainIds: [hexChainId],
|
|
826
700
|
});
|
|
827
701
|
return atomicBatchSupport.some((entry) => entry.isSupported && entry.delegationAddress);
|
|
@@ -848,7 +722,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
848
722
|
return tradeMeta;
|
|
849
723
|
}
|
|
850
724
|
// Set approval time and id if an approval tx is needed
|
|
851
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && isEvmTxData(quoteResponse.approval)
|
|
725
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval && isEvmTxData(quoteResponse.approval)
|
|
852
726
|
? quoteResponse.approval
|
|
853
727
|
: undefined, quoteResponse.resetApproval, requireApproval);
|
|
854
728
|
approvalTxId = approvalTxMeta?.id;
|
|
@@ -944,9 +818,10 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
944
818
|
*/
|
|
945
819
|
this.submitIntent = async (params) => {
|
|
946
820
|
const { quoteResponse, accountAddress, location, abTests, activeAbTests } = params;
|
|
947
|
-
|
|
821
|
+
// TODO add metrics context
|
|
822
|
+
stopPollingForQuotes(this.messenger);
|
|
948
823
|
// Build pre-confirmation properties for error tracking parity with submitTx
|
|
949
|
-
const account =
|
|
824
|
+
const account = getAccountByAddress(this.messenger, accountAddress);
|
|
950
825
|
const isHardwareAccount = Boolean(account) && isHardwareWallet(account);
|
|
951
826
|
const preConfirmationProperties = getPreConfirmationPropertiesFromQuote(quoteResponse, false, isHardwareAccount, location, abTests, activeAbTests);
|
|
952
827
|
try {
|
|
@@ -956,16 +831,17 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
956
831
|
const isBridgeTx = isCrossChain(quoteResponse.quote.srcChainId, quoteResponse.quote.destChainId);
|
|
957
832
|
const requireApproval = isHardwareAccount && __classPrivateFieldGet(this, _BridgeStatusController_clientId, "f") === BridgeClientId.MOBILE;
|
|
958
833
|
// Handle approval silently for better UX in intent flows
|
|
959
|
-
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
834
|
+
const approvalTxMeta = await __classPrivateFieldGet(this, _BridgeStatusController_handleApprovalTx, "f").call(this, quoteResponse, isBridgeTx, quoteResponse.quote.srcChainId, quoteResponse.approval, quoteResponse.resetApproval, requireApproval);
|
|
960
835
|
const approvalTxId = approvalTxMeta?.id;
|
|
961
836
|
if (approvalTxId) {
|
|
962
837
|
await __classPrivateFieldGet(this, _BridgeStatusController_waitForTxConfirmation, "f").call(this, approvalTxId);
|
|
963
838
|
}
|
|
964
839
|
const { srcChainId, requestId } = quoteResponse.quote;
|
|
965
|
-
const signature = await
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
840
|
+
const signature = await signTypedMessage({
|
|
841
|
+
messenger: this.messenger,
|
|
842
|
+
accountAddress,
|
|
843
|
+
typedData: intent.typedData,
|
|
844
|
+
});
|
|
969
845
|
const submissionParams = {
|
|
970
846
|
srcChainId,
|
|
971
847
|
quoteId: requestId,
|
|
@@ -983,7 +859,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
983
859
|
: /* c8 ignore end */
|
|
984
860
|
TransactionType.swap;
|
|
985
861
|
// Create actual transaction in Transaction Controller first
|
|
986
|
-
const networkClientId = this.messenger
|
|
862
|
+
const networkClientId = getNetworkClientIdByChainId(this.messenger, srcChainId);
|
|
987
863
|
// This is a synthetic transaction whose purpose is to be able
|
|
988
864
|
// to track the order status via the history
|
|
989
865
|
const intentTransactionParams = {
|
|
@@ -996,7 +872,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
996
872
|
gas: '0x5208', // Minimal gas for display purposes
|
|
997
873
|
gasPrice: '0x3b9aca00', // 1 Gwei - will be converted to EIP-1559 fees if network supports it
|
|
998
874
|
};
|
|
999
|
-
const { transactionMeta: txMetaPromise } = await
|
|
875
|
+
const { transactionMeta: txMetaPromise } = await this.messenger.call('TransactionController:addTransaction', intentTransactionParams, {
|
|
1000
876
|
origin: 'metamask',
|
|
1001
877
|
actionId: generateActionId(),
|
|
1002
878
|
requireApproval: false,
|
|
@@ -1096,24 +972,36 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1096
972
|
};
|
|
1097
973
|
// This will publish events for PERPS dropped tx failures as well
|
|
1098
974
|
if (!txMetaId) {
|
|
1099
|
-
|
|
975
|
+
trackMetricsEvent({
|
|
976
|
+
messenger: this.messenger,
|
|
977
|
+
eventName,
|
|
978
|
+
properties: baseProperties,
|
|
979
|
+
});
|
|
1100
980
|
return;
|
|
1101
981
|
}
|
|
1102
982
|
const historyItem = this.state.txHistory[txMetaId];
|
|
1103
983
|
if (!historyItem) {
|
|
1104
|
-
|
|
984
|
+
trackMetricsEvent({
|
|
985
|
+
messenger: this.messenger,
|
|
986
|
+
eventName,
|
|
987
|
+
properties: baseProperties,
|
|
988
|
+
});
|
|
1105
989
|
return;
|
|
1106
990
|
}
|
|
1107
991
|
const requestParamProperties = getRequestParamFromHistory(historyItem);
|
|
1108
992
|
// Always publish StatusValidationFailed event, regardless of featureId
|
|
1109
993
|
if (eventName === UnifiedSwapBridgeEventName.StatusValidationFailed) {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
994
|
+
trackMetricsEvent({
|
|
995
|
+
messenger: this.messenger,
|
|
996
|
+
eventName,
|
|
997
|
+
properties: {
|
|
998
|
+
...baseProperties,
|
|
999
|
+
chain_id_source: requestParamProperties.chain_id_source,
|
|
1000
|
+
chain_id_destination: requestParamProperties.chain_id_destination,
|
|
1001
|
+
token_address_source: requestParamProperties.token_address_source,
|
|
1002
|
+
token_address_destination: requestParamProperties.token_address_destination,
|
|
1003
|
+
refresh_count: historyItem.attempts?.counter ?? 0,
|
|
1004
|
+
},
|
|
1117
1005
|
});
|
|
1118
1006
|
return;
|
|
1119
1007
|
}
|
|
@@ -1121,7 +1009,7 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1121
1009
|
if (historyItem.featureId) {
|
|
1122
1010
|
return;
|
|
1123
1011
|
}
|
|
1124
|
-
const selectedAccount = this.messenger
|
|
1012
|
+
const selectedAccount = getAccountByAddress(this.messenger, historyItem.account);
|
|
1125
1013
|
const { transactions } = this.messenger.call('TransactionController:getState');
|
|
1126
1014
|
const txMeta = transactions?.find((tx) => tx.id === txMetaId);
|
|
1127
1015
|
const approvalTxMeta = transactions?.find((tx) => tx.id === historyItem.approvalTxId);
|
|
@@ -1134,24 +1022,23 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1134
1022
|
...getFinalizedTxProperties(historyItem, txMeta, approvalTxMeta),
|
|
1135
1023
|
...getPriceImpactFromQuote(historyItem.quote),
|
|
1136
1024
|
};
|
|
1137
|
-
|
|
1025
|
+
trackMetricsEvent({
|
|
1026
|
+
messenger: this.messenger,
|
|
1027
|
+
eventName,
|
|
1028
|
+
properties: requiredEventProperties,
|
|
1029
|
+
});
|
|
1138
1030
|
});
|
|
1139
1031
|
__classPrivateFieldSet(this, _BridgeStatusController_clientId, clientId, "f");
|
|
1140
1032
|
__classPrivateFieldSet(this, _BridgeStatusController_fetchFn, fetchFn, "f");
|
|
1141
|
-
__classPrivateFieldSet(this, _BridgeStatusController_addTransactionFn, addTransactionFn, "f");
|
|
1142
1033
|
__classPrivateFieldSet(this, _BridgeStatusController_addTransactionBatchFn, addTransactionBatchFn, "f");
|
|
1143
|
-
__classPrivateFieldSet(this, _BridgeStatusController_updateTransactionFn, updateTransactionFn, "f");
|
|
1144
|
-
__classPrivateFieldSet(this, _BridgeStatusController_estimateGasFeeFn, estimateGasFeeFn, "f");
|
|
1145
1034
|
__classPrivateFieldSet(this, _BridgeStatusController_config, {
|
|
1146
1035
|
customBridgeApiBaseUrl: config?.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,
|
|
1147
1036
|
}, "f");
|
|
1148
1037
|
__classPrivateFieldSet(this, _BridgeStatusController_trace, traceFn ?? ((_request, fn) => fn?.()), "f");
|
|
1149
1038
|
__classPrivateFieldSet(this, _BridgeStatusController_intentManager, new IntentManager({
|
|
1150
1039
|
messenger: this.messenger,
|
|
1151
|
-
updateTransactionFn: __classPrivateFieldGet(this, _BridgeStatusController_updateTransactionFn, "f"),
|
|
1152
1040
|
customBridgeApiBaseUrl: __classPrivateFieldGet(this, _BridgeStatusController_config, "f").customBridgeApiBaseUrl,
|
|
1153
1041
|
fetchFn: __classPrivateFieldGet(this, _BridgeStatusController_fetchFn, "f"),
|
|
1154
|
-
getJwt: __classPrivateFieldGet(this, _BridgeStatusController_getJwt, "f"),
|
|
1155
1042
|
}), "f");
|
|
1156
1043
|
// Register action handlers
|
|
1157
1044
|
this.messenger.registerActionHandler(`${BRIDGE_STATUS_CONTROLLER_NAME}:startPollingForBridgeTxStatus`, this.startPollingForBridgeTxStatus.bind(this));
|
|
@@ -1208,7 +1095,5 @@ export class BridgeStatusController extends StaticIntervalPollingController() {
|
|
|
1208
1095
|
__classPrivateFieldGet(this, _BridgeStatusController_restartPollingForIncompleteHistoryItems, "f").call(this);
|
|
1209
1096
|
}
|
|
1210
1097
|
}
|
|
1211
|
-
_BridgeStatusController_pollingTokensByTxMetaId = new WeakMap(), _BridgeStatusController_intentManager = new WeakMap(), _BridgeStatusController_clientId = new WeakMap(), _BridgeStatusController_fetchFn = new WeakMap(), _BridgeStatusController_config = new WeakMap(),
|
|
1212
|
-
return this.messenger.call('AccountsController:getAccountByAddress', accountAddress);
|
|
1213
|
-
};
|
|
1098
|
+
_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();
|
|
1214
1099
|
//# sourceMappingURL=bridge-status-controller.mjs.map
|