@metamask/bridge-controller 66.1.1 → 67.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 +28 -1
- package/dist/bridge-controller.cjs +38 -6
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +9 -1
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +9 -1
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +39 -7
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +13 -1
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts +90 -18
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts +90 -18
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs +13 -1
- package/dist/selectors.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils/fetch.cjs +26 -20
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +14 -4
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +14 -4
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +26 -20
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/metrics/constants.cjs +5 -1
- package/dist/utils/metrics/constants.cjs.map +1 -1
- package/dist/utils/metrics/constants.d.cts +6 -2
- package/dist/utils/metrics/constants.d.cts.map +1 -1
- package/dist/utils/metrics/constants.d.mts +6 -2
- package/dist/utils/metrics/constants.d.mts.map +1 -1
- package/dist/utils/metrics/constants.mjs +5 -1
- package/dist/utils/metrics/constants.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +20 -8
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +20 -8
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/package.json +3 -2
|
@@ -9,7 +9,7 @@ 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 _BridgeController_instances, _BridgeController_abortController, _BridgeController_quotesFirstFetched, _BridgeController_clientId, _BridgeController_clientVersion, _BridgeController_getLayer1GasFee, _BridgeController_fetchFn, _BridgeController_trackMetaMetricsFn, _BridgeController_trace, _BridgeController_config, _BridgeController_trackResponseValidationFailures, _BridgeController_getExchangeRateSources, _BridgeController_fetchAssetExchangeRates, _BridgeController_hasInsufficientBalance, _BridgeController_shouldResetApproval, _BridgeController_fetchBridgeQuotes, _BridgeController_handleQuoteStreaming, _BridgeController_setMinimumBalanceForRentExemptionInLamports, _BridgeController_getMultichainSelectedAccount, _BridgeController_getNetworkClientByChainId, _BridgeController_getRequestMetadata, _BridgeController_getQuoteFetchData, _BridgeController_getEventProperties, _BridgeController_trackInputChangedEvents, _BridgeController_getUSDTMainnetAllowance;
|
|
12
|
+
var _BridgeController_instances, _BridgeController_abortController, _BridgeController_quotesFirstFetched, _BridgeController_location, _BridgeController_clientId, _BridgeController_clientVersion, _BridgeController_getLayer1GasFee, _BridgeController_fetchFn, _BridgeController_trackMetaMetricsFn, _BridgeController_trace, _BridgeController_config, _BridgeController_trackResponseValidationFailures, _BridgeController_getExchangeRateSources, _BridgeController_fetchAssetExchangeRates, _BridgeController_hasInsufficientBalance, _BridgeController_shouldResetApproval, _BridgeController_fetchBridgeQuotes, _BridgeController_handleQuoteStreaming, _BridgeController_setMinimumBalanceForRentExemptionInLamports, _BridgeController_getMultichainSelectedAccount, _BridgeController_getNetworkClientByChainId, _BridgeController_getJwt, _BridgeController_getRequestMetadata, _BridgeController_getQuoteFetchData, _BridgeController_getEventProperties, _BridgeController_trackInputChangedEvents, _BridgeController_getUSDTMainnetAllowance;
|
|
13
13
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
14
14
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
15
15
|
import { Contract } from "@ethersproject/contracts";
|
|
@@ -28,7 +28,7 @@ import { getDefaultBridgeControllerState, isCrossChain, isEthUsdt, isNonEvmChain
|
|
|
28
28
|
import { formatAddressToCaipReference, formatChainIdToCaip, formatChainIdToHex } from "./utils/caip-formatters.mjs";
|
|
29
29
|
import { getBridgeFeatureFlags, hasMinimumRequiredVersion } from "./utils/feature-flags.mjs";
|
|
30
30
|
import { fetchAssetPrices, fetchBridgeQuotes, fetchBridgeQuoteStream } from "./utils/fetch.mjs";
|
|
31
|
-
import { AbortReason, MetricsActionType, UnifiedSwapBridgeEventName } from "./utils/metrics/constants.mjs";
|
|
31
|
+
import { AbortReason, MetaMetricsSwapsEventSource, MetricsActionType, UnifiedSwapBridgeEventName } from "./utils/metrics/constants.mjs";
|
|
32
32
|
import { formatProviderLabel, getRequestParams, getSwapTypeFromQuote, isCustomSlippage, isHardwareWallet, toInputChangedPropertyKey, toInputChangedPropertyValue } from "./utils/metrics/properties.mjs";
|
|
33
33
|
import { isValidQuoteRequest, sortQuotes } from "./utils/quote.mjs";
|
|
34
34
|
import { appendFeesToQuotes } from "./utils/quote-fees.mjs";
|
|
@@ -103,6 +103,12 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
103
103
|
_BridgeController_instances.add(this);
|
|
104
104
|
_BridgeController_abortController.set(this, void 0);
|
|
105
105
|
_BridgeController_quotesFirstFetched.set(this, void 0);
|
|
106
|
+
/**
|
|
107
|
+
* Stores the location/entry point from which the user initiated the swap or bridge flow.
|
|
108
|
+
* Set via setLocation() before navigating to the swap/bridge flow.
|
|
109
|
+
* Used as default for all subsequent internal events.
|
|
110
|
+
*/
|
|
111
|
+
_BridgeController_location.set(this, MetaMetricsSwapsEventSource.MainView);
|
|
106
112
|
_BridgeController_clientId.set(this, void 0);
|
|
107
113
|
_BridgeController_clientVersion.set(this, void 0);
|
|
108
114
|
_BridgeController_getLayer1GasFee.set(this, void 0);
|
|
@@ -174,6 +180,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
174
180
|
*/
|
|
175
181
|
this.fetchQuotes = async (quoteRequest, abortSignal = null, featureId = null) => {
|
|
176
182
|
const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);
|
|
183
|
+
const jwt = await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this);
|
|
177
184
|
// If featureId is specified, retrieve the quoteRequestOverrides for that featureId
|
|
178
185
|
const quoteRequestOverrides = featureId
|
|
179
186
|
? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]
|
|
@@ -182,7 +189,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
182
189
|
// If quoteRequestOverrides is specified, merge it with the quoteRequest
|
|
183
190
|
const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(quoteRequestOverrides
|
|
184
191
|
? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }
|
|
185
|
-
: { ...quoteRequest, resetApproval }, abortSignal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, featureId, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
|
|
192
|
+
: { ...quoteRequest, resetApproval }, abortSignal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), jwt, __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, featureId, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
|
|
186
193
|
__classPrivateFieldGet(this, _BridgeController_trackResponseValidationFailures, "f").call(this, validationFailures);
|
|
187
194
|
const quotesWithFees = await appendFeesToQuotes(baseQuotes, this.messenger, __classPrivateFieldGet(this, _BridgeController_getLayer1GasFee, "f"), __classPrivateFieldGet(this, _BridgeController_instances, "m", _BridgeController_getMultichainSelectedAccount).call(this, quoteRequest.walletAddress));
|
|
188
195
|
return sortQuotes(quotesWithFees, featureId);
|
|
@@ -193,6 +200,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
193
200
|
}
|
|
194
201
|
this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.QuotesValidationFailed, {
|
|
195
202
|
failures: validationFailures,
|
|
203
|
+
location: __classPrivateFieldGet(this, _BridgeController_location, "f"),
|
|
196
204
|
});
|
|
197
205
|
});
|
|
198
206
|
_BridgeController_getExchangeRateSources.set(this, () => {
|
|
@@ -290,6 +298,16 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
290
298
|
// Clears quotes list in state
|
|
291
299
|
__classPrivateFieldGet(this, _BridgeController_abortController, "f")?.abort(reason);
|
|
292
300
|
};
|
|
301
|
+
/**
|
|
302
|
+
* Sets the location/entry point for the current swap or bridge flow.
|
|
303
|
+
* Call this when the user enters the flow so that all internally-fired
|
|
304
|
+
* events (InputChanged, QuotesRequested, etc.) carry the correct location.
|
|
305
|
+
*
|
|
306
|
+
* @param location - The entry point from which the user initiated the flow
|
|
307
|
+
*/
|
|
308
|
+
this.setLocation = (location) => {
|
|
309
|
+
__classPrivateFieldSet(this, _BridgeController_location, location, "f");
|
|
310
|
+
};
|
|
293
311
|
this.resetState = (reason = AbortReason.ResetState) => {
|
|
294
312
|
this.stopPollingForQuotes(reason);
|
|
295
313
|
this.update((state) => {
|
|
@@ -338,6 +356,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
338
356
|
state.quotesLastFetched = Date.now();
|
|
339
357
|
state.quotesLoadingStatus = RequestStatus.LOADING;
|
|
340
358
|
});
|
|
359
|
+
const jwt = await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this);
|
|
341
360
|
try {
|
|
342
361
|
await __classPrivateFieldGet(this, _BridgeController_trace, "f").call(this, {
|
|
343
362
|
name: isCrossChain(updatedQuoteRequest.srcChainId, updatedQuoteRequest.destChainId)
|
|
@@ -354,7 +373,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
354
373
|
__classPrivateFieldGet(this, _BridgeController_setMinimumBalanceForRentExemptionInLamports, "f").call(this, updatedQuoteRequest.srcChainId, selectedAccount?.metadata?.snap?.id);
|
|
355
374
|
// Use SSE if enabled and return early
|
|
356
375
|
if (shouldStream) {
|
|
357
|
-
await __classPrivateFieldGet(this, _BridgeController_handleQuoteStreaming, "f").call(this, updatedQuoteRequest, selectedAccount);
|
|
376
|
+
await __classPrivateFieldGet(this, _BridgeController_handleQuoteStreaming, "f").call(this, updatedQuoteRequest, jwt, selectedAccount);
|
|
358
377
|
return;
|
|
359
378
|
}
|
|
360
379
|
// Otherwise use regular fetch
|
|
@@ -421,7 +440,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
421
440
|
this.stopAllPolling();
|
|
422
441
|
}
|
|
423
442
|
});
|
|
424
|
-
_BridgeController_handleQuoteStreaming.set(this, async (updatedQuoteRequest, selectedAccount) => {
|
|
443
|
+
_BridgeController_handleQuoteStreaming.set(this, async (updatedQuoteRequest, jwt, selectedAccount) => {
|
|
425
444
|
/**
|
|
426
445
|
* Tracks the number of valid quotes received from the current stream, which is used
|
|
427
446
|
* to determine when to clear the quotes list and set the initial load time
|
|
@@ -432,7 +451,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
432
451
|
* before setting quotesLoadingStatus to FETCHED
|
|
433
452
|
*/
|
|
434
453
|
const pendingFeeAppendPromises = new Set();
|
|
435
|
-
await fetchBridgeQuoteStream(__classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), updatedQuoteRequest, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, {
|
|
454
|
+
await fetchBridgeQuoteStream(__classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), updatedQuoteRequest, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), jwt, __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, {
|
|
436
455
|
onValidationFailure: __classPrivateFieldGet(this, _BridgeController_trackResponseValidationFailures, "f"),
|
|
437
456
|
onValidQuoteReceived: async (quote) => {
|
|
438
457
|
const feeAppendPromise = (async () => {
|
|
@@ -496,6 +515,16 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
496
515
|
minimumBalanceForRentExemptionInLamports;
|
|
497
516
|
});
|
|
498
517
|
});
|
|
518
|
+
_BridgeController_getJwt.set(this, async () => {
|
|
519
|
+
try {
|
|
520
|
+
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
521
|
+
return token;
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
console.error('Error getting JWT token for bridge-api request', error);
|
|
525
|
+
return undefined;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
499
528
|
_BridgeController_getRequestMetadata.set(this, () => {
|
|
500
529
|
return {
|
|
501
530
|
slippage_limit: this.state.quoteRequest.slippage,
|
|
@@ -512,8 +541,10 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
512
541
|
};
|
|
513
542
|
});
|
|
514
543
|
_BridgeController_getEventProperties.set(this, (eventName, propertiesFromClient) => {
|
|
544
|
+
const clientProps = propertiesFromClient;
|
|
515
545
|
const baseProperties = {
|
|
516
546
|
...propertiesFromClient,
|
|
547
|
+
location: clientProps?.location ?? __classPrivateFieldGet(this, _BridgeController_location, "f"),
|
|
517
548
|
action_type: MetricsActionType.SWAPBRIDGE_V1,
|
|
518
549
|
};
|
|
519
550
|
switch (eventName) {
|
|
@@ -597,6 +628,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
597
628
|
this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.InputChanged, {
|
|
598
629
|
input: inputKey,
|
|
599
630
|
input_value: inputValue,
|
|
631
|
+
location: __classPrivateFieldGet(this, _BridgeController_location, "f"),
|
|
600
632
|
});
|
|
601
633
|
}
|
|
602
634
|
});
|
|
@@ -659,7 +691,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
659
691
|
this.messenger.registerActionHandler(`${BRIDGE_CONTROLLER_NAME}:fetchQuotes`, this.fetchQuotes.bind(this));
|
|
660
692
|
}
|
|
661
693
|
}
|
|
662
|
-
_BridgeController_abortController = new WeakMap(), _BridgeController_quotesFirstFetched = new WeakMap(), _BridgeController_clientId = new WeakMap(), _BridgeController_clientVersion = new WeakMap(), _BridgeController_getLayer1GasFee = new WeakMap(), _BridgeController_fetchFn = new WeakMap(), _BridgeController_trackMetaMetricsFn = new WeakMap(), _BridgeController_trace = new WeakMap(), _BridgeController_config = new WeakMap(), _BridgeController_trackResponseValidationFailures = new WeakMap(), _BridgeController_getExchangeRateSources = new WeakMap(), _BridgeController_fetchAssetExchangeRates = new WeakMap(), _BridgeController_hasInsufficientBalance = new WeakMap(), _BridgeController_shouldResetApproval = new WeakMap(), _BridgeController_fetchBridgeQuotes = new WeakMap(), _BridgeController_handleQuoteStreaming = new WeakMap(), _BridgeController_setMinimumBalanceForRentExemptionInLamports = new WeakMap(), _BridgeController_getRequestMetadata = new WeakMap(), _BridgeController_getQuoteFetchData = new WeakMap(), _BridgeController_getEventProperties = new WeakMap(), _BridgeController_trackInputChangedEvents = new WeakMap(), _BridgeController_getUSDTMainnetAllowance = new WeakMap(), _BridgeController_instances = new WeakSet(), _BridgeController_getMultichainSelectedAccount = function _BridgeController_getMultichainSelectedAccount(walletAddress) {
|
|
694
|
+
_BridgeController_abortController = new WeakMap(), _BridgeController_quotesFirstFetched = new WeakMap(), _BridgeController_location = new WeakMap(), _BridgeController_clientId = new WeakMap(), _BridgeController_clientVersion = new WeakMap(), _BridgeController_getLayer1GasFee = new WeakMap(), _BridgeController_fetchFn = new WeakMap(), _BridgeController_trackMetaMetricsFn = new WeakMap(), _BridgeController_trace = new WeakMap(), _BridgeController_config = new WeakMap(), _BridgeController_trackResponseValidationFailures = new WeakMap(), _BridgeController_getExchangeRateSources = new WeakMap(), _BridgeController_fetchAssetExchangeRates = new WeakMap(), _BridgeController_hasInsufficientBalance = new WeakMap(), _BridgeController_shouldResetApproval = new WeakMap(), _BridgeController_fetchBridgeQuotes = new WeakMap(), _BridgeController_handleQuoteStreaming = new WeakMap(), _BridgeController_setMinimumBalanceForRentExemptionInLamports = new WeakMap(), _BridgeController_getJwt = new WeakMap(), _BridgeController_getRequestMetadata = new WeakMap(), _BridgeController_getQuoteFetchData = new WeakMap(), _BridgeController_getEventProperties = new WeakMap(), _BridgeController_trackInputChangedEvents = new WeakMap(), _BridgeController_getUSDTMainnetAllowance = new WeakMap(), _BridgeController_instances = new WeakSet(), _BridgeController_getMultichainSelectedAccount = function _BridgeController_getMultichainSelectedAccount(walletAddress) {
|
|
663
695
|
const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;
|
|
664
696
|
if (!addressToUse) {
|
|
665
697
|
throw new Error('Account address is required');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-controller.mjs","sourceRoot":"","sources":["../src/bridge-controller.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Y,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,wCAAwC,EACxC,YAAY,CACb,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,qGAE0B,OAAY;IACrC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,gDAAgD,EAChD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort(AbortReason.NewQuoteRequest);\n this.#abortController = new AbortController();\n\n this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n has_gas_included_quote: this.state.quotes.some(\n ({ quote }) => quote.gasIncluded,\n ),\n };\n };\n\n readonly #getEventProperties = <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n ): CrossChainSwapsEventProperties<EventName> => {\n const baseProperties = {\n ...propertiesFromClient,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<EventName>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bridge-controller.mjs","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qEAAqE;AACrE,OAAO,EAAE,SAAS,EAAE,iCAAiC;AACrD,OAAO,EAAE,QAAQ,EAAE,iCAAiC;AACpD,OAAO,EAAE,YAAY,EAAE,iCAAiC;AAIxD,OAAO,EAAE,QAAQ,EAAE,oCAAoC;AACvD,OAAO,EAAE,+BAA+B,EAAE,qCAAqC;AAK/E,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,mBAAmB,EACpB,+BAA2B;AAC5B,OAAO,EAAE,SAAS,EAAE,+BAA2B;AAC/C,OAAO,EAAE,wBAAwB,EAAE,8BAA0B;AAC7D,OAAO,EAAE,SAAS,EAAE,+BAA2B;AAC/C,OAAO,EAAE,gCAAgC,EAAE,wBAAoB;AAC/D,OAAO,EAAE,aAAa,EAAE,oBAAgB;AAWxC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,2BAAuB;AACtE,OAAO,EAAE,oBAAoB,EAAE,4BAAwB;AACvD,OAAO,EACL,+BAA+B,EAC/B,YAAY,EACZ,SAAS,EACT,eAAe,EACf,eAAe,EAChB,2BAAuB;AACxB,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,EACnB,oCAAgC;AACjC,OAAO,EACL,qBAAqB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a,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC;IAC5E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,wCAAwC,EACxC,YAAY,CACb,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,qGAE0B,OAAY;IACrC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACzC,gDAAgD,EAChD,OAAO,CACR,CAAC;IACF,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,wCAAwC,EACxC,eAAe,CAChB,CAAC;IACF,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport { BigNumber } from '@ethersproject/bignumber';\nimport { Contract } from '@ethersproject/contracts';\nimport { Web3Provider } from '@ethersproject/providers';\nimport type { StateMetadata } from '@metamask/base-controller';\nimport type { TraceCallback } from '@metamask/controller-utils';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport { abiERC20 } from '@metamask/metamask-eth-abis';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { TransactionController } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\n\nimport type { BridgeClientId } from './constants/bridge';\nimport {\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_PROD_API_BASE_URL,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_ETHEREUM_ADDRESS,\n REFRESH_INTERVAL_MS,\n} from './constants/bridge';\nimport { CHAIN_IDS } from './constants/chains';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps';\nimport { TraceName } from './constants/traces';\nimport { selectIsAssetExchangeRateInState } from './selectors';\nimport { RequestStatus } from './types';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n QuoteResponse,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n} from './types';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets';\nimport { hasSufficientBalance } from './utils/balance';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n} from './utils/fetch';\nimport {\n AbortReason,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants';\nimport {\n formatProviderLabel,\n getRequestParams,\n getSwapTypeFromQuote,\n isCustomSlippage,\n isHardwareWallet,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types';\nimport { isValidQuoteRequest, sortQuotes } from './utils/quote';\nimport { appendFeesToQuotes } from './utils/quote-fees';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps';\nimport type { FeatureId } from './utils/validators';\n\nconst metadata: StateMetadata<BridgeControllerState> = {\n quoteRequest: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotes: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesInitialLoadTime: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLastFetched: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesLoadingStatus: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteFetchError: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quotesRefreshCount: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n assetExchangeRates: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n minimumBalanceForRentExemptionInLamports: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\n/**\n * The input to start polling for the {@link BridgeController}\n *\n * @param updatedQuoteRequest - The updated quote request\n * @param context - The context contains properties that can't be populated by the\n * controller and need to be provided by the client for analytics\n */\ntype BridgePollingInput = {\n updatedQuoteRequest: GenericQuoteRequest;\n context: Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesError\n >[UnifiedSwapBridgeEventName.QuotesError] &\n Pick<\n RequiredEventContextFromClient,\n UnifiedSwapBridgeEventName.QuotesRequested\n >[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #quotesFirstFetched: number | undefined;\n\n /**\n * Stores the location/entry point from which the user initiated the swap or bridge flow.\n * Set via setLocation() before navigating to the swap/bridge flow.\n * Used as default for all subsequent internal events.\n */\n #location: MetaMetricsSwapsEventSource = MetaMetricsSwapsEventSource.MainView;\n\n readonly #clientId: BridgeClientId;\n\n readonly #clientVersion: string;\n\n readonly #getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n\n readonly #fetchFn: FetchFunction;\n\n readonly #trackMetaMetricsFn: <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n\n readonly #trace: TraceCallback;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n }: {\n messenger: BridgeControllerMessenger;\n state?: Partial<BridgeControllerState>;\n clientId: BridgeClientId;\n clientVersion: string;\n getLayer1GasFee: typeof TransactionController.prototype.getLayer1GasFee;\n fetchFn: FetchFunction;\n config?: {\n customBridgeApiBaseUrl?: string;\n };\n trackMetaMetricsFn: <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n traceFn?: TraceCallback;\n }) {\n super({\n name: BRIDGE_CONTROLLER_NAME,\n metadata,\n messenger,\n state: {\n ...getDefaultBridgeControllerState(),\n ...state,\n },\n });\n\n this.setIntervalLength(REFRESH_INTERVAL_MS);\n\n this.#abortController = new AbortController();\n this.#getLayer1GasFee = getLayer1GasFee;\n this.#clientId = clientId;\n this.#clientVersion = clientVersion;\n this.#fetchFn = fetchFn;\n this.#trackMetaMetricsFn = trackMetaMetricsFn;\n this.#config = config ?? {};\n this.#trace = traceFn ?? (((_request, fn) => fn?.()) as TraceCallback);\n\n // Register action handlers\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:setChainIntervalLength`,\n this.setChainIntervalLength.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:updateBridgeQuoteRequestParams`,\n this.updateBridgeQuoteRequestParams.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:resetState`,\n this.resetState.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:trackUnifiedSwapBridgeEvent`,\n this.trackUnifiedSwapBridgeEvent.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:stopPollingForQuotes`,\n this.stopPollingForQuotes.bind(this),\n );\n this.messenger.registerActionHandler(\n `${BRIDGE_CONTROLLER_NAME}:fetchQuotes`,\n this.fetchQuotes.bind(this),\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n ) => {\n this.#trackInputChangedEvents(paramsToUpdate);\n this.resetState(AbortReason.QuoteRequestUpdated);\n const updatedQuoteRequest = {\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest,\n ...paramsToUpdate,\n };\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n });\n\n if (isValidQuoteRequest(updatedQuoteRequest)) {\n this.#quotesFirstFetched = Date.now();\n const isSrcChainNonEVM = isNonEvmChainId(updatedQuoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(updatedQuoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(paramsToUpdate.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = paramsToUpdate.insufficientBal;\n } else if (providerConfig?.rpcUrl?.includes('tenderly')) {\n // If the rpcUrl is a tenderly fork (e2e tests), set insufficientBal=true\n // The bridge-api filters out quotes if the balance on mainnet is insufficient so this override allows quotes to always be returned\n insufficientBal = true;\n } else {\n // Set loading status if RPC calls are made before the quotes are fetched\n this.update((state) => {\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n resetApproval = await this.#shouldResetApproval(updatedQuoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n paramsToUpdate.insufficientBal ??\n (await this.#hasInsufficientBalance(updatedQuoteRequest));\n }\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n updatedQuoteRequest: {\n ...updatedQuoteRequest,\n insufficientBal,\n resetApproval,\n },\n context,\n });\n }\n };\n\n /**\n * Fetches quotes for specified request without updating the controller state\n * This method does not start polling for quotes and does not emit UnifiedSwapBridge events\n *\n * @param quoteRequest - The parameters for quote requests to fetch\n * @param abortSignal - The abort signal to cancel all the requests\n * @param featureId - The feature ID that maps to quoteParam overrides from LD\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n abortSignal: AbortSignal | null = null,\n featureId: FeatureId | null = null,\n ): Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]> => {\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n const jwt = await this.#getJwt();\n // If featureId is specified, retrieve the quoteRequestOverrides for that featureId\n const quoteRequestOverrides = featureId\n ? bridgeFeatureFlags.quoteRequestOverrides?.[featureId]\n : undefined;\n const resetApproval = await this.#shouldResetApproval(quoteRequest);\n\n // If quoteRequestOverrides is specified, merge it with the quoteRequest\n const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(\n quoteRequestOverrides\n ? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }\n : { ...quoteRequest, resetApproval },\n abortSignal,\n this.#clientId,\n jwt,\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n featureId,\n this.#clientVersion,\n );\n\n this.#trackResponseValidationFailures(validationFailures);\n\n const quotesWithFees = await appendFeesToQuotes(\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n readonly #trackResponseValidationFailures = (\n validationFailures: string[],\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n failures: validationFailures,\n location: this.#location,\n },\n );\n };\n\n readonly #getExchangeRateSources = () => {\n return {\n ...this.messenger.call('MultichainAssetsRatesController:getState'),\n ...this.messenger.call('CurrencyRateController:getState'),\n ...this.messenger.call('TokenRatesController:getState'),\n ...this.state,\n };\n };\n\n /**\n * Fetches the exchange rates for the assets in the quote request if they are not already in the state\n * In addition to the selected tokens, this also fetches the native asset for the source and destination chains\n *\n * @param quoteRequest - The quote request\n * @param quoteRequest.srcChainId - The source chain ID\n * @param quoteRequest.srcTokenAddress - The source token address\n * @param quoteRequest.destChainId - The destination chain ID\n * @param quoteRequest.destTokenAddress - The destination token address\n */\n readonly #fetchAssetExchangeRates = async ({\n srcChainId,\n srcTokenAddress,\n destChainId,\n destTokenAddress,\n }: Partial<GenericQuoteRequest>) => {\n const assetIds: Set<CaipAssetType> = new Set([]);\n const exchangeRateSources = this.#getExchangeRateSources();\n if (\n srcTokenAddress &&\n srcChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n srcChainId,\n srcTokenAddress,\n )\n ) {\n getAssetIdsForToken(srcTokenAddress, srcChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n if (\n destTokenAddress &&\n destChainId &&\n !selectIsAssetExchangeRateInState(\n exchangeRateSources,\n destChainId,\n destTokenAddress,\n )\n ) {\n getAssetIdsForToken(destTokenAddress, destChainId).forEach((assetId) =>\n assetIds.add(assetId),\n );\n }\n\n const currency = this.messenger.call(\n 'CurrencyRateController:getState',\n ).currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency]),\n clientId: this.#clientId,\n clientVersion: this.#clientVersion,\n fetchFn: this.#fetchFn,\n signal: this.#abortController?.signal,\n });\n const exchangeRates = toExchangeRates(currency, pricesByAssetId);\n this.update((state) => {\n state.assetExchangeRates = {\n ...state.assetExchangeRates,\n ...exchangeRates,\n };\n });\n };\n\n readonly #hasInsufficientBalance = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n try {\n const srcChainIdInHex = formatChainIdToHex(quoteRequest.srcChainId);\n const provider =\n this.#getNetworkClientByChainId(srcChainIdInHex)?.provider;\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n\n return !(\n provider &&\n normalizedSrcTokenAddress &&\n quoteRequest.srcTokenAmount &&\n srcChainIdInHex &&\n (await hasSufficientBalance(\n provider,\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.srcTokenAmount,\n srcChainIdInHex,\n ))\n );\n } catch (error) {\n console.warn('Failed to set insufficientBal', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n readonly #shouldResetApproval = async (quoteRequest: GenericQuoteRequest) => {\n if (isNonEvmChainId(quoteRequest.srcChainId)) {\n return false;\n }\n try {\n const normalizedSrcTokenAddress = formatAddressToCaipReference(\n quoteRequest.srcTokenAddress,\n );\n if (isEthUsdt(quoteRequest.srcChainId, normalizedSrcTokenAddress)) {\n const allowance = BigNumber.from(\n await this.#getUSDTMainnetAllowance(\n quoteRequest.walletAddress,\n normalizedSrcTokenAddress,\n quoteRequest.destChainId,\n ),\n );\n return allowance.lt(quoteRequest.srcTokenAmount) && allowance.gt(0);\n }\n return false;\n } catch (error) {\n console.warn('Failed to set resetApproval', error);\n // Fall back to true so the backend returns quotes\n return true;\n }\n };\n\n stopPollingForQuotes = (\n reason?: AbortReason,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopAllPolling();\n // If polling is stopped before quotes finish loading, track QuotesReceived\n if (this.state.quotesLoadingStatus === RequestStatus.LOADING && context) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesReceived,\n context,\n );\n }\n // Clears quotes list in state\n this.#abortController?.abort(reason);\n };\n\n /**\n * Sets the location/entry point for the current swap or bridge flow.\n * Call this when the user enters the flow so that all internally-fired\n * events (InputChanged, QuotesRequested, etc.) carry the correct location.\n *\n * @param location - The entry point from which the user initiated the flow\n */\n setLocation = (location: MetaMetricsSwapsEventSource) => {\n this.#location = location;\n };\n\n resetState = (reason = AbortReason.ResetState) => {\n this.stopPollingForQuotes(reason);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n state.quotesInitialLoadTime =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesInitialLoadTime;\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n state.quotesLastFetched =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLastFetched;\n state.quotesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesLoadingStatus;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesRefreshCount =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount;\n state.assetExchangeRates =\n DEFAULT_BRIDGE_CONTROLLER_STATE.assetExchangeRates;\n state.minimumBalanceForRentExemptionInLamports =\n DEFAULT_BRIDGE_CONTROLLER_STATE.minimumBalanceForRentExemptionInLamports;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n const { srcChainId } = state.quoteRequest;\n const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);\n\n const refreshRateOverride = srcChainId\n ? bridgeFeatureFlags.chains[formatChainIdToCaip(srcChainId)]?.refreshRate\n : undefined;\n const defaultRefreshRate = bridgeFeatureFlags.refreshRate;\n this.setIntervalLength(refreshRateOverride ?? defaultRefreshRate);\n };\n\n readonly #fetchBridgeQuotes = async ({\n updatedQuoteRequest,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort(AbortReason.NewQuoteRequest);\n this.#abortController = new AbortController();\n\n this.#fetchAssetExchangeRates(updatedQuoteRequest).catch((error) =>\n console.warn('Failed to fetch asset exchange rates', error),\n );\n\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesRequested,\n context,\n );\n\n const { sse, maxRefreshCount } = getBridgeFeatureFlags(this.messenger);\n const shouldStream =\n sse?.enabled &&\n hasMinimumRequiredVersion(this.#clientVersion, sse.minimumVersion);\n\n this.update((state) => {\n state.quoteRequest = updatedQuoteRequest;\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n });\n\n const jwt = await this.#getJwt();\n\n try {\n await this.#trace(\n {\n name: isCrossChain(\n updatedQuoteRequest.srcChainId,\n updatedQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched,\n data: {\n srcChainId: formatChainIdToCaip(updatedQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(updatedQuoteRequest.destChainId),\n },\n },\n async () => {\n const selectedAccount = this.#getMultichainSelectedAccount(\n updatedQuoteRequest.walletAddress,\n );\n // This call is not awaited to prevent blocking quote fetching if the snap takes too long to respond\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.#setMinimumBalanceForRentExemptionInLamports(\n updatedQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream) {\n await this.#handleQuoteStreaming(\n updatedQuoteRequest,\n jwt,\n selectedAccount,\n );\n return;\n }\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n updatedQuoteRequest,\n this.#abortController?.signal,\n );\n this.update((state) => {\n // Set the initial load time if this is the first fetch\n if (\n state.quotesRefreshCount ===\n DEFAULT_BRIDGE_CONTROLLER_STATE.quotesRefreshCount &&\n this.#quotesFirstFetched\n ) {\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes;\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n );\n } catch (error) {\n // Reset the quotes list if the fetch fails to avoid showing stale quotes\n this.update((state) => {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n });\n // Ignore abort errors\n if (\n (error as Error).toString().includes('AbortError') ||\n (error as Error).toString().includes('FetchRequestCanceledException') ||\n [\n AbortReason.ResetState,\n AbortReason.NewQuoteRequest,\n AbortReason.QuoteRequestUpdated,\n AbortReason.TransactionSubmitted,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n // Update loading status and error message\n this.update((state) => {\n // The error object reference is not guaranteed to exist on mobile so reading\n // the message directly could cause an error.\n let errorMessage;\n try {\n errorMessage =\n (error as Error)?.message ?? (error as Error).toString();\n } catch {\n // Intentionally empty\n } finally {\n state.quoteFetchError = errorMessage ?? 'Unknown error';\n }\n state.quotesLoadingStatus = RequestStatus.ERROR;\n });\n // Track event and log error\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesError,\n context,\n );\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n }\n\n // Update refresh count after fetching, validation and fee calculation have completed\n this.update((state) => {\n state.quotesRefreshCount += 1;\n });\n // Stop polling if the maximum number of refreshes has been reached\n if (\n updatedQuoteRequest.insufficientBal ||\n (!updatedQuoteRequest.insufficientBal &&\n this.state.quotesRefreshCount >= maxRefreshCount)\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async (\n updatedQuoteRequest: GenericQuoteRequest,\n jwt?: string,\n selectedAccount?: InternalAccount,\n ) => {\n /**\n * Tracks the number of valid quotes received from the current stream, which is used\n * to determine when to clear the quotes list and set the initial load time\n */\n let validQuotesCounter = 0;\n /**\n * Tracks all pending promises from appendFeesToQuotes calls to ensure they complete\n * before setting quotesLoadingStatus to FETCHED\n */\n const pendingFeeAppendPromises = new Set<Promise<void>>();\n\n await fetchBridgeQuoteStream(\n this.#fetchFn,\n updatedQuoteRequest,\n this.#abortController?.signal,\n this.#clientId,\n jwt,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onValidationFailure: this.#trackResponseValidationFailures,\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n }\n this.update((state) => {\n // Clear previous quotes and quotes load time when first quote in the current\n // polling loop is received\n // This enables clients to continue showing the previous quotes while new\n // quotes are loading\n // Note: If there are no valid quotes until the 2nd fetch, quotesInitialLoadTime will be > refreshRate\n if (validQuotesCounter === 1) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n if (!state.quotesInitialLoadTime && this.#quotesFirstFetched) {\n // Set the initial load time after the first quote is received\n state.quotesInitialLoadTime =\n Date.now() - this.#quotesFirstFetched;\n }\n }\n state.quotes = [...state.quotes, ...quotesWithFees];\n });\n })();\n pendingFeeAppendPromises.add(feeAppendPromise);\n feeAppendPromise\n .catch((error) => {\n // Catch errors to prevent them from breaking stream processing\n // If appendFeesToQuotes throws, the state update never happens, so no invalid entry is added\n console.error('Error appending fees to quote', error);\n })\n .finally(() => {\n pendingFeeAppendPromises.delete(feeAppendPromise);\n });\n // Await the promise to ensure errors are caught and handled before continuing\n // The promise is also tracked in pendingFeeAppendPromises for onClose to wait for\n await feeAppendPromise;\n },\n onClose: async () => {\n // Wait for all pending appendFeesToQuotes operations to complete\n // before setting quotesLoadingStatus to FETCHED\n await Promise.allSettled(Array.from(pendingFeeAppendPromises));\n this.update((state) => {\n // If there are no valid quotes in the current stream, clear the quotes list\n // to remove quotes from the previous stream\n if (validQuotesCounter === 0) {\n state.quotes = DEFAULT_BRIDGE_CONTROLLER_STATE.quotes;\n }\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n },\n },\n this.#clientVersion,\n );\n };\n\n readonly #setMinimumBalanceForRentExemptionInLamports = async (\n srcChainId: GenericQuoteRequest['srcChainId'],\n snapId?: string,\n ) => {\n if (!isSolanaChainId(srcChainId) || !snapId) {\n return;\n }\n const minimumBalanceForRentExemptionInLamports =\n await getMinimumBalanceForRentExemptionInLamports(snapId, this.messenger);\n this.update((state) => {\n state.minimumBalanceForRentExemptionInLamports =\n minimumBalanceForRentExemptionInLamports;\n });\n };\n\n #getMultichainSelectedAccount(\n walletAddress?: GenericQuoteRequest['walletAddress'],\n ) {\n const addressToUse = walletAddress ?? this.state.quoteRequest.walletAddress;\n if (!addressToUse) {\n throw new Error('Account address is required');\n }\n const selectedAccount = this.messenger.call(\n 'AccountsController:getAccountByAddress',\n addressToUse,\n );\n return selectedAccount;\n }\n\n #getNetworkClientByChainId(chainId: Hex) {\n const networkClientId = this.messenger.call(\n 'NetworkController:findNetworkClientIdByChainId',\n chainId,\n );\n if (!networkClientId) {\n throw new Error(`No network client found for chainId: ${chainId}`);\n }\n const networkClient = this.messenger.call(\n 'NetworkController:getNetworkClientById',\n networkClientId,\n );\n return networkClient;\n }\n\n readonly #getJwt = async (): Promise<string | undefined> => {\n try {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return token;\n } catch (error) {\n console.error('Error getting JWT token for bridge-api request', error);\n return undefined;\n }\n };\n\n readonly #getRequestMetadata = (): Omit<\n RequestMetadata,\n | 'stx_enabled'\n | 'usd_amount_source'\n | 'security_warnings'\n | 'is_hardware_wallet'\n > => {\n return {\n slippage_limit: this.state.quoteRequest.slippage,\n swap_type: getSwapTypeFromQuote(this.state.quoteRequest),\n custom_slippage: isCustomSlippage(this.state.quoteRequest.slippage),\n };\n };\n\n readonly #getQuoteFetchData = (): Omit<\n QuoteFetchData,\n 'best_quote_provider' | 'price_impact' | 'can_submit'\n > => {\n return {\n quotes_count: this.state.quotes.length,\n quotes_list: this.state.quotes.map(({ quote }) =>\n formatProviderLabel(quote),\n ),\n initial_load_time_all_quotes: this.state.quotesInitialLoadTime ?? 0,\n has_gas_included_quote: this.state.quotes.some(\n ({ quote }) => quote.gasIncluded,\n ),\n };\n };\n\n readonly #getEventProperties = <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n ): CrossChainSwapsEventProperties<EventName> => {\n const clientProps = propertiesFromClient as Record<string, unknown>;\n const baseProperties = {\n ...propertiesFromClient,\n location: clientProps?.location ?? this.#location,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n };\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(this.state.quoteRequest),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !this.state.quoteRequest.insufficientBal,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n is_hardware_wallet: isHardwareWallet(\n this.#getMultichainSelectedAccount(),\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.Failed: {\n // Populate the properties that the error occurred before the tx was submitted\n return {\n ...baseProperties,\n ...getRequestParams(this.state.quoteRequest),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n }\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n return baseProperties;\n // These events may be published after the bridge-controller state is reset\n // So the BridgeStatusController populates all the properties\n case UnifiedSwapBridgeEventName.Submitted:\n case UnifiedSwapBridgeEventName.Completed:\n return propertiesFromClient;\n case UnifiedSwapBridgeEventName.InputChanged:\n default:\n return baseProperties;\n }\n };\n\n readonly #trackInputChangedEvents = (\n paramsToUpdate: Partial<GenericQuoteRequest>,\n ) => {\n Object.entries(paramsToUpdate).forEach(([key, value]) => {\n const inputKey = toInputChangedPropertyKey[key as keyof QuoteRequest];\n const inputValue =\n toInputChangedPropertyValue[key as keyof QuoteRequest]?.(\n paramsToUpdate,\n );\n if (\n inputKey &&\n inputValue !== undefined &&\n value !== this.state.quoteRequest[key as keyof GenericQuoteRequest]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n location: this.#location,\n },\n );\n }\n });\n };\n\n /**\n * This method tracks cross-chain swaps events\n *\n * @param eventName - The name of the event to track\n * @param propertiesFromClient - Properties that can't be calculated from the event name and need to be provided by the client\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n EventName extends\n (typeof UnifiedSwapBridgeEventName)[keyof typeof UnifiedSwapBridgeEventName],\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<EventName>(\n eventName,\n propertiesFromClient,\n );\n\n this.#trackMetaMetricsFn(eventName, combinedPropertiesForEvent);\n } catch (error) {\n console.error(\n `Error tracking cross-chain swaps MetaMetrics event ${eventName}`,\n error,\n );\n }\n };\n\n /**\n *\n * @param walletAddress - The address of the account to get the allowance for\n * @param contractAddress - The address of the ERC20 token contract on mainnet\n * @param destinationChainId - The chain ID of the destination network\n * @returns The atomic allowance of the ERC20 token contract\n */\n readonly #getUSDTMainnetAllowance = async (\n walletAddress: string,\n contractAddress: string,\n destinationChainId: GenericQuoteRequest['destChainId'],\n ): Promise<string> => {\n const networkClient = this.#getNetworkClientByChainId(CHAIN_IDS.MAINNET);\n const provider = networkClient?.provider;\n if (!provider) {\n throw new Error('No provider found');\n }\n\n const ethersProvider = new Web3Provider(provider);\n const contract = new Contract(contractAddress, abiERC20, ethersProvider);\n const spenderAddress = isCrossChain(CHAIN_IDS.MAINNET, destinationChainId)\n ? METABRIDGE_ETHEREUM_ADDRESS\n : SWAPS_CONTRACT_ADDRESSES[CHAIN_IDS.MAINNET];\n const allowance: BigNumber = await contract.allowance(\n walletAddress,\n spenderAddress,\n );\n return allowance.toString();\n };\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.fetchTokens = exports.getSwapsContractAddress = exports.isValidSwapsContractAddress = exports.BRIDGE_DEFAULT_SLIPPAGE = exports.getBridgeFeatureFlags = exports.DEFAULT_FEATURE_FLAG_CONFIG = exports.selectMinimumBalanceForRentExemptionInSOL = exports.selectBridgeFeatureFlags = exports.selectIsQuoteExpired = exports.selectExchangeRateByChainIdAndAddress = exports.selectDefaultSlippagePercentage = exports.selectBridgeQuotes = exports.isEvmTxData = exports.isTronTrade = exports.isBitcoinTrade = exports.extractTradeData = exports.formatAddressToAssetId = exports.formatAddressToCaipReference = exports.formatChainIdToHex = exports.formatChainIdToCaip = exports.getClientHeaders = exports.fetchBridgeTokens = exports.calcLatestSrcBalance = exports.calcSlippagePercentage = exports.formatEtaInMinutes = exports.isValidQuoteRequest = exports.isCrossChain = void 0;
|
|
3
|
+
exports.getNativeAssetForChainId = exports.isNonEvmChainId = exports.isTronChainId = exports.isBitcoinChainId = exports.isSolanaChainId = exports.isNativeAddress = exports.isEthUsdt = exports.MetricsSwapType = exports.MetricsActionType = exports.ALLOWED_CONTRACT_ADDRESSES = exports.SWAPS_WRAPPED_TOKENS_ADDRESSES = exports.SWAPS_CONTRACT_ADDRESSES = exports.SWAPS_API_V2_BASE_URL = exports.SWAPS_CHAINID_DEFAULT_TOKEN_MAP = exports.BRIDGE_PROD_API_BASE_URL = exports.BRIDGE_DEV_API_BASE_URL = exports.METABRIDGE_CHAIN_TO_ADDRESS_MAP = exports.DEFAULT_BRIDGE_CONTROLLER_STATE = exports.DEFAULT_MAX_REFRESH_COUNT = exports.REFRESH_INTERVAL_MS = exports.BRIDGE_MM_FEE_RATE = exports.BRIDGE_PREFERRED_GAS_ESTIMATE = exports.BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE = exports.BRIDGE_QUOTE_MAX_ETA_SECONDS = exports.BRIDGE_CONTROLLER_NAME = exports.BridgeClientId = exports.ALLOWED_BRIDGE_CHAIN_IDS = exports.FeatureId = exports.BridgeAssetSchema = exports.ActionTypes = exports.FeeType = exports.BridgeBackgroundAction = exports.BridgeUserAction = exports.RequestStatus = exports.ChainId = exports.SortOrder = exports.AssetType = exports.StatusTypes = exports.AbortReason = exports.getQuotesReceivedProperties = exports.isCustomSlippage = exports.isHardwareWallet = exports.getSwapType = exports.getRequestParams = exports.formatProviderLabel = exports.PollingStatus = exports.MetaMetricsSwapsEventSource = exports.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY = exports.UnifiedSwapBridgeEventName = exports.BridgeController = void 0;
|
|
4
|
+
exports.fetchTokens = exports.getSwapsContractAddress = exports.isValidSwapsContractAddress = exports.BRIDGE_DEFAULT_SLIPPAGE = exports.getBridgeFeatureFlags = exports.DEFAULT_FEATURE_FLAG_CONFIG = exports.selectMinimumBalanceForRentExemptionInSOL = exports.selectBridgeFeatureFlags = exports.selectIsQuoteExpired = exports.selectExchangeRateByChainIdAndAddress = exports.selectDefaultSlippagePercentage = exports.selectBridgeQuotes = exports.isEvmTxData = exports.isTronTrade = exports.isBitcoinTrade = exports.extractTradeData = exports.formatAddressToAssetId = exports.formatAddressToCaipReference = exports.formatChainIdToHex = exports.formatChainIdToCaip = exports.getClientHeaders = exports.fetchBridgeTokens = exports.calcLatestSrcBalance = exports.calcSlippagePercentage = exports.formatEtaInMinutes = exports.isValidQuoteRequest = exports.isCrossChain = exports.getDefaultBridgeControllerState = void 0;
|
|
5
5
|
var bridge_controller_1 = require("./bridge-controller.cjs");
|
|
6
6
|
Object.defineProperty(exports, "BridgeController", { enumerable: true, get: function () { return bridge_controller_1.BridgeController; } });
|
|
7
7
|
var constants_1 = require("./utils/metrics/constants.cjs");
|
|
8
8
|
Object.defineProperty(exports, "UnifiedSwapBridgeEventName", { enumerable: true, get: function () { return constants_1.UnifiedSwapBridgeEventName; } });
|
|
9
9
|
Object.defineProperty(exports, "UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY", { enumerable: true, get: function () { return constants_1.UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY; } });
|
|
10
|
+
Object.defineProperty(exports, "MetaMetricsSwapsEventSource", { enumerable: true, get: function () { return constants_1.MetaMetricsSwapsEventSource; } });
|
|
10
11
|
Object.defineProperty(exports, "PollingStatus", { enumerable: true, get: function () { return constants_1.PollingStatus; } });
|
|
11
12
|
var properties_1 = require("./utils/metrics/properties.cjs");
|
|
12
13
|
Object.defineProperty(exports, "formatProviderLabel", { enumerable: true, get: function () { return properties_1.formatProviderLabel; } });
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,6DAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AAEzB,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,6DAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AAEzB,2DAKmC;AAJjC,uHAAA,0BAA0B,OAAA;AAC1B,+HAAA,kCAAkC,OAAA;AAClC,wHAAA,2BAA2B,OAAA;AAC3B,0GAAA,aAAa,OAAA;AAcf,6DAOoC;AANlC,iHAAA,mBAAmB,OAAA;AACnB,8GAAA,gBAAgB,OAAA;AAChB,yGAAA,WAAW,OAAA;AACX,8GAAA,gBAAgB,OAAA;AAChB,8GAAA,gBAAgB,OAAA;AAChB,yHAAA,2BAA2B,OAAA;AAgC7B,2DAAwD;AAA/C,wGAAA,WAAW,OAAA;AAEpB,qCAAsC;AAA7B,oGAAA,WAAW,OAAA;AAEpB,qCASiB;AARf,kGAAA,SAAS,OAAA;AACT,kGAAA,SAAS,OAAA;AACT,gGAAA,OAAO,OAAA;AACP,sGAAA,aAAa,OAAA;AACb,yGAAA,gBAAgB,OAAA;AAChB,+GAAA,sBAAsB,OAAA;AAKxB,qDAK4B;AAJ1B,qGAAA,OAAO,OAAA;AACP,yGAAA,WAAW,OAAA;AACX,+GAAA,iBAAiB,OAAA;AACjB,uGAAA,SAAS,OAAA;AAGX,iDAc4B;AAb1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AA,gBAAgB,OAAA;AAChB,6GAAA,cAAc,OAAA;AACd,0GAAA,WAAW,OAAA;AACX,0GAAA,WAAW,OAAA;AAIb,6CAQqB;AAPnB,+GAAA,kBAAkB,OAAA;AAClB,4HAAA,+BAA+B,OAAA;AAE/B,kIAAA,qCAAqC,OAAA;AACrC,iHAAA,oBAAoB,OAAA;AACpB,qHAAA,wBAAwB,OAAA;AACxB,sIAAA,yCAAyC,OAAA;AAG3C,iDAAiE;AAAxD,qHAAA,2BAA2B,OAAA;AAEpC,2DAA8D;AAArD,sHAAA,qBAAqB,OAAA;AAE9B,iDAA2D;AAAlD,mHAAA,uBAAuB,OAAA;AAEhC,2CAKuB;AAJrB,oHAAA,2BAA2B,OAAA;AAC3B,gHAAA,uBAAuB,OAAA;AACvB,oGAAA,WAAW,OAAA","sourcesContent":["export { BridgeController } from './bridge-controller';\n\nexport {\n UnifiedSwapBridgeEventName,\n UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY,\n MetaMetricsSwapsEventSource,\n PollingStatus,\n} from './utils/metrics/constants';\n\nexport type {\n RequiredEventContextFromClient,\n CrossChainSwapsEventProperties,\n TradeData,\n RequestParams,\n RequestMetadata,\n TxStatusData,\n QuoteFetchData,\n QuoteWarning,\n} from './utils/metrics/types';\n\nexport {\n formatProviderLabel,\n getRequestParams,\n getSwapType,\n isHardwareWallet,\n isCustomSlippage,\n getQuotesReceivedProperties,\n} from './utils/metrics/properties';\n\nexport type {\n ChainConfiguration,\n L1GasFees,\n NonEvmFees,\n QuoteMetadata,\n GasMultiplierByChainId,\n FeatureFlagResponse,\n BridgeAsset,\n GenericQuoteRequest,\n Protocol,\n TokenAmountValues,\n Step,\n RefuelData,\n Quote,\n QuoteResponse,\n FeeData,\n TxData,\n Intent,\n IntentOrderLike,\n BitcoinTradeData,\n TronTradeData,\n BridgeControllerState,\n BridgeControllerAction,\n BridgeControllerActions,\n BridgeControllerEvents,\n BridgeControllerMessenger,\n FeatureFlagsPlatformConfig,\n} from './types';\n\nexport { AbortReason } from './utils/metrics/constants';\n\nexport { StatusTypes } from './types';\n\nexport {\n AssetType,\n SortOrder,\n ChainId,\n RequestStatus,\n BridgeUserAction,\n BridgeBackgroundAction,\n type BridgeControllerGetStateAction,\n type BridgeControllerStateChangeEvent,\n} from './types';\n\nexport {\n FeeType,\n ActionTypes,\n BridgeAssetSchema,\n FeatureId,\n} from './utils/validators';\n\nexport {\n ALLOWED_BRIDGE_CHAIN_IDS,\n BridgeClientId,\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_QUOTE_MAX_ETA_SECONDS,\n BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n BRIDGE_MM_FEE_RATE,\n REFRESH_INTERVAL_MS,\n DEFAULT_MAX_REFRESH_COUNT,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_CHAIN_TO_ADDRESS_MAP,\n BRIDGE_DEV_API_BASE_URL,\n BRIDGE_PROD_API_BASE_URL,\n} from './constants/bridge';\n\nexport type { AllowedBridgeChainIds } from './constants/bridge';\n\nexport {\n /**\n * @deprecated This type should not be used. Use {@link BridgeAsset} instead.\n */\n type SwapsTokenObject,\n /**\n * @deprecated This map should not be used. Use getNativeAssetForChainId\" } instead.\n */\n SWAPS_CHAINID_DEFAULT_TOKEN_MAP,\n} from './constants/tokens';\n\nexport {\n SWAPS_API_V2_BASE_URL,\n SWAPS_CONTRACT_ADDRESSES,\n SWAPS_WRAPPED_TOKENS_ADDRESSES,\n ALLOWED_CONTRACT_ADDRESSES,\n} from './constants/swaps';\n\nexport { MetricsActionType, MetricsSwapType } from './utils/metrics/constants';\n\nexport {\n isEthUsdt,\n isNativeAddress,\n isSolanaChainId,\n isBitcoinChainId,\n isTronChainId,\n isNonEvmChainId,\n getNativeAssetForChainId,\n getDefaultBridgeControllerState,\n isCrossChain,\n} from './utils/bridge';\n\nexport {\n isValidQuoteRequest,\n formatEtaInMinutes,\n calcSlippagePercentage,\n} from './utils/quote';\n\nexport { calcLatestSrcBalance } from './utils/balance';\n\nexport { fetchBridgeTokens, getClientHeaders } from './utils/fetch';\n\nexport {\n formatChainIdToCaip,\n formatChainIdToHex,\n formatAddressToCaipReference,\n formatAddressToAssetId,\n} from './utils/caip-formatters';\n\nexport {\n extractTradeData,\n isBitcoinTrade,\n isTronTrade,\n isEvmTxData,\n type Trade,\n} from './utils/trade-utils';\n\nexport {\n selectBridgeQuotes,\n selectDefaultSlippagePercentage,\n type BridgeAppState,\n selectExchangeRateByChainIdAndAddress,\n selectIsQuoteExpired,\n selectBridgeFeatureFlags,\n selectMinimumBalanceForRentExemptionInSOL,\n} from './selectors';\n\nexport { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge';\n\nexport { getBridgeFeatureFlags } from './utils/feature-flags';\n\nexport { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage';\n\nexport {\n isValidSwapsContractAddress,\n getSwapsContractAddress,\n fetchTokens,\n type SwapsToken,\n} from './utils/swaps';\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BridgeController } from "./bridge-controller.cjs";
|
|
2
|
-
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, PollingStatus, } from "./utils/metrics/constants.cjs";
|
|
2
|
+
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, MetaMetricsSwapsEventSource, PollingStatus, } from "./utils/metrics/constants.cjs";
|
|
3
3
|
export type { RequiredEventContextFromClient, CrossChainSwapsEventProperties, TradeData, RequestParams, RequestMetadata, TxStatusData, QuoteFetchData, QuoteWarning, } from "./utils/metrics/types.cjs";
|
|
4
4
|
export { formatProviderLabel, getRequestParams, getSwapType, isHardwareWallet, isCustomSlippage, getQuotesReceivedProperties, } from "./utils/metrics/properties.cjs";
|
|
5
5
|
export type { ChainConfiguration, L1GasFees, NonEvmFees, QuoteMetadata, GasMultiplierByChainId, FeatureFlagResponse, BridgeAsset, GenericQuoteRequest, Protocol, TokenAmountValues, Step, RefuelData, Quote, QuoteResponse, FeeData, TxData, Intent, IntentOrderLike, BitcoinTradeData, TronTradeData, BridgeControllerState, BridgeControllerAction, BridgeControllerActions, BridgeControllerEvents, BridgeControllerMessenger, FeatureFlagsPlatformConfig, } from "./types.cjs";
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAA4B;AAEvD,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,aAAa,GACd,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,GACb,kCAA8B;AAE/B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC5B,uCAAmC;AAEpC,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACV,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,EACN,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,oBAAgB;AAEjB,OAAO,EAAE,WAAW,EAAE,sCAAkC;AAExD,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,KAAK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,2BAA2B,EAAE,+BAA2B;AAEjE,OAAO,EAAE,qBAAqB,EAAE,kCAA8B;AAE9D,OAAO,EAAE,uBAAuB,EAAE,6BAAyB;AAE3D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,KAAK,UAAU,GAChB,0BAAsB"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAA4B;AAEvD,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,2BAA2B,EAC3B,aAAa,GACd,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,GACb,kCAA8B;AAE/B,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC5B,uCAAmC;AAEpC,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACV,KAAK,EACL,aAAa,EACb,OAAO,EACP,MAAM,EACN,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,GAC3B,oBAAgB;AAEjB,OAAO,EAAE,WAAW,EAAE,sCAAkC;AAExD,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,GACtC,oBAAgB;AAEjB,OAAO,EACL,OAAO,EACP,WAA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O,EAAE,uBAAuB,EAAE,6BAAyB;AAE3D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,KAAK,UAAU,GAChB,0BAAsB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BridgeController } from "./bridge-controller.mjs";
|
|
2
|
-
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, PollingStatus, } from "./utils/metrics/constants.mjs";
|
|
2
|
+
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, MetaMetricsSwapsEventSource, PollingStatus, } from "./utils/metrics/constants.mjs";
|
|
3
3
|
export type { RequiredEventContextFromClient, CrossChainSwapsEventProperties, TradeData, RequestParams, RequestMetadata, TxStatusData, QuoteFetchData, QuoteWarning, } from "./utils/metrics/types.mjs";
|
|
4
4
|
export { formatProviderLabel, getRequestParams, getSwapType, isHardwareWallet, isCustomSlippage, getQuotesReceivedProperties, } from "./utils/metrics/properties.mjs";
|
|
5
5
|
export type { ChainConfiguration, L1GasFees, NonEvmFees, QuoteMetadata, GasMultiplierByChainId, FeatureFlagResponse, BridgeAsset, GenericQuoteRequest, Protocol, TokenAmountValues, Step, RefuelData, Quote, QuoteResponse, FeeData, TxData, Intent, IntentOrderLike, BitcoinTradeData, TronTradeData, BridgeControllerState, BridgeControllerAction, BridgeControllerActions, BridgeControllerEvents, BridgeControllerMessenger, FeatureFlagsPlatformConfig, } from "./types.mjs";
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAA4B;AAEvD,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,aAAa,GACd,sCAAkC;AAEnC,YAAY,EACV,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,EACT,a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E,OAAO,EACL,SAAS,EACT,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,+BAA+B,EAC/B,YAAY,GACb,2BAAuB;AAExB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,0BAAsB;AAEvB,OAAO,EAAE,oBAAoB,EAAE,4BAAwB;AAEvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,0BAAsB;AAEpE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,GACvB,oCAAgC;AAEjC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,EACX,KAAK,KAAK,GACX,gCAA4B;AAE7B,OAAO,EACL,kBAAkB,EAClB,+BAA+B,EAC/B,KAAK,cAAc,EACnB,qCAAqC,EACrC,oBAAoB,EACpB,wBAAwB,EACxB,yCAAyC,GAC1C,wBAAoB;AAErB,OAAO,EAAE,2BAA2B,EAAE,+BAA2B;AAEjE,OAAO,EAAE,qBAAqB,EAAE,kCAA8B;AAE9D,OAAO,EAAE,uBAAuB,EAAE,6BAAyB;AAE3D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,KAAK,UAAU,GAChB,0BAAsB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BridgeController } from "./bridge-controller.mjs";
|
|
2
|
-
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, PollingStatus } from "./utils/metrics/constants.mjs";
|
|
2
|
+
export { UnifiedSwapBridgeEventName, UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY, MetaMetricsSwapsEventSource, PollingStatus } from "./utils/metrics/constants.mjs";
|
|
3
3
|
export { formatProviderLabel, getRequestParams, getSwapType, isHardwareWallet, isCustomSlippage, getQuotesReceivedProperties } from "./utils/metrics/properties.mjs";
|
|
4
4
|
export { AbortReason } from "./utils/metrics/constants.mjs";
|
|
5
5
|
export { StatusTypes } from "./types.mjs";
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAA4B;AAEvD,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,aAAa,EACd,sCAAkC;AAanC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC5B,uCAAmC;AA+BpC,OAAO,EAAE,WAAW,EAAE,sCAAkC;AAExD,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EAGvB,oBAAgB;AAEjB,OAAO,EACL,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,SAAS,EACV,+BAA2B;AAE5B,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,sBAAsB,EACtB,4BAA4B,EAC5B,6CAA6C,EAC7C,6BAA6B,EAC7B,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,+BAA+B,EAC/B,+BAA+B,EAC/B,uBAAuB,EACvB,wBAAwB,EACzB,+BAA2B;AAI5B,OAAO;AAKL;;GAEG;AACH,+BAA+B,EAChC,+BAA2B;AAE5B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,8BAA8B,EAC9B,0BAA0B,EAC3B,8BAA0B;AAE3B,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,sCAAkC;AAE/E,OAAO,EACL,SAAS,EACT,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,+BAA+B,EAC/B,YAAY,EACb,2BAAuB;AAExB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACvB,0BAAsB;AAEvB,OAAO,EAAE,oBAAoB,EAAE,4BAAwB;AAEvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,0BAAsB;AAEpE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACvB,oCAAgC;AAEjC,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,WAAW,EAEZ,gCAA4B;AAE7B,OAAO,EACL,kBAAkB,EAClB,+BAA+B,EAE/B,qCAAqC,EACrC,oBAAoB,EACpB,wBAAwB,EACxB,yCAAyC,EAC1C,wBAAoB;AAErB,OAAO,EAAE,2BAA2B,EAAE,+BAA2B;AAEjE,OAAO,EAAE,qBAAqB,EAAE,kCAA8B;AAE9D,OAAO,EAAE,uBAAuB,EAAE,6BAAyB;AAE3D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EAEZ,0BAAsB","sourcesContent":["export { BridgeController } from './bridge-controller';\n\nexport {\n UnifiedSwapBridgeEventName,\n UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY,\n PollingStatus,\n} from './utils/metrics/constants';\n\nexport type {\n RequiredEventContextFromClient,\n CrossChainSwapsEventProperties,\n TradeData,\n RequestParams,\n RequestMetadata,\n TxStatusData,\n QuoteFetchData,\n QuoteWarning,\n} from './utils/metrics/types';\n\nexport {\n formatProviderLabel,\n getRequestParams,\n getSwapType,\n isHardwareWallet,\n isCustomSlippage,\n getQuotesReceivedProperties,\n} from './utils/metrics/properties';\n\nexport type {\n ChainConfiguration,\n L1GasFees,\n NonEvmFees,\n QuoteMetadata,\n GasMultiplierByChainId,\n FeatureFlagResponse,\n BridgeAsset,\n GenericQuoteRequest,\n Protocol,\n TokenAmountValues,\n Step,\n RefuelData,\n Quote,\n QuoteResponse,\n FeeData,\n TxData,\n Intent,\n IntentOrderLike,\n BitcoinTradeData,\n TronTradeData,\n BridgeControllerState,\n BridgeControllerAction,\n BridgeControllerActions,\n BridgeControllerEvents,\n BridgeControllerMessenger,\n FeatureFlagsPlatformConfig,\n} from './types';\n\nexport { AbortReason } from './utils/metrics/constants';\n\nexport { StatusTypes } from './types';\n\nexport {\n AssetType,\n SortOrder,\n ChainId,\n RequestStatus,\n BridgeUserAction,\n BridgeBackgroundAction,\n type BridgeControllerGetStateAction,\n type BridgeControllerStateChangeEvent,\n} from './types';\n\nexport {\n FeeType,\n ActionTypes,\n BridgeAssetSchema,\n FeatureId,\n} from './utils/validators';\n\nexport {\n ALLOWED_BRIDGE_CHAIN_IDS,\n BridgeClientId,\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_QUOTE_MAX_ETA_SECONDS,\n BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n BRIDGE_MM_FEE_RATE,\n REFRESH_INTERVAL_MS,\n DEFAULT_MAX_REFRESH_COUNT,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_CHAIN_TO_ADDRESS_MAP,\n BRIDGE_DEV_API_BASE_URL,\n BRIDGE_PROD_API_BASE_URL,\n} from './constants/bridge';\n\nexport type { AllowedBridgeChainIds } from './constants/bridge';\n\nexport {\n /**\n * @deprecated This type should not be used. Use {@link BridgeAsset} instead.\n */\n type SwapsTokenObject,\n /**\n * @deprecated This map should not be used. Use getNativeAssetForChainId\" } instead.\n */\n SWAPS_CHAINID_DEFAULT_TOKEN_MAP,\n} from './constants/tokens';\n\nexport {\n SWAPS_API_V2_BASE_URL,\n SWAPS_CONTRACT_ADDRESSES,\n SWAPS_WRAPPED_TOKENS_ADDRESSES,\n ALLOWED_CONTRACT_ADDRESSES,\n} from './constants/swaps';\n\nexport { MetricsActionType, MetricsSwapType } from './utils/metrics/constants';\n\nexport {\n isEthUsdt,\n isNativeAddress,\n isSolanaChainId,\n isBitcoinChainId,\n isTronChainId,\n isNonEvmChainId,\n getNativeAssetForChainId,\n getDefaultBridgeControllerState,\n isCrossChain,\n} from './utils/bridge';\n\nexport {\n isValidQuoteRequest,\n formatEtaInMinutes,\n calcSlippagePercentage,\n} from './utils/quote';\n\nexport { calcLatestSrcBalance } from './utils/balance';\n\nexport { fetchBridgeTokens, getClientHeaders } from './utils/fetch';\n\nexport {\n formatChainIdToCaip,\n formatChainIdToHex,\n formatAddressToCaipReference,\n formatAddressToAssetId,\n} from './utils/caip-formatters';\n\nexport {\n extractTradeData,\n isBitcoinTrade,\n isTronTrade,\n isEvmTxData,\n type Trade,\n} from './utils/trade-utils';\n\nexport {\n selectBridgeQuotes,\n selectDefaultSlippagePercentage,\n type BridgeAppState,\n selectExchangeRateByChainIdAndAddress,\n selectIsQuoteExpired,\n selectBridgeFeatureFlags,\n selectMinimumBalanceForRentExemptionInSOL,\n} from './selectors';\n\nexport { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge';\n\nexport { getBridgeFeatureFlags } from './utils/feature-flags';\n\nexport { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage';\n\nexport {\n isValidSwapsContractAddress,\n getSwapsContractAddress,\n fetchTokens,\n type SwapsToken,\n} from './utils/swaps';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gCAA4B;AAEvD,OAAO,EACL,0BAA0B,EAC1B,kCAAkC,EAClC,2BAA2B,EAC3B,aAAa,EACd,sCAAkC;AAanC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC5B,uCAAmC;AA+BpC,OAAO,EAAE,WAAW,EAAE,sCAAkC;AAExD,OAAO,EAAE,WAAW,EAAE,oBAAgB;AAEtC,OAAO,EACL,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EAGvB,oBAAgB;AAEjB,OAA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,EAEZ,0BAAsB","sourcesContent":["export { BridgeController } from './bridge-controller';\n\nexport {\n UnifiedSwapBridgeEventName,\n UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY,\n MetaMetricsSwapsEventSource,\n PollingStatus,\n} from './utils/metrics/constants';\n\nexport type {\n RequiredEventContextFromClient,\n CrossChainSwapsEventProperties,\n TradeData,\n RequestParams,\n RequestMetadata,\n TxStatusData,\n QuoteFetchData,\n QuoteWarning,\n} from './utils/metrics/types';\n\nexport {\n formatProviderLabel,\n getRequestParams,\n getSwapType,\n isHardwareWallet,\n isCustomSlippage,\n getQuotesReceivedProperties,\n} from './utils/metrics/properties';\n\nexport type {\n ChainConfiguration,\n L1GasFees,\n NonEvmFees,\n QuoteMetadata,\n GasMultiplierByChainId,\n FeatureFlagResponse,\n BridgeAsset,\n GenericQuoteRequest,\n Protocol,\n TokenAmountValues,\n Step,\n RefuelData,\n Quote,\n QuoteResponse,\n FeeData,\n TxData,\n Intent,\n IntentOrderLike,\n BitcoinTradeData,\n TronTradeData,\n BridgeControllerState,\n BridgeControllerAction,\n BridgeControllerActions,\n BridgeControllerEvents,\n BridgeControllerMessenger,\n FeatureFlagsPlatformConfig,\n} from './types';\n\nexport { AbortReason } from './utils/metrics/constants';\n\nexport { StatusTypes } from './types';\n\nexport {\n AssetType,\n SortOrder,\n ChainId,\n RequestStatus,\n BridgeUserAction,\n BridgeBackgroundAction,\n type BridgeControllerGetStateAction,\n type BridgeControllerStateChangeEvent,\n} from './types';\n\nexport {\n FeeType,\n ActionTypes,\n BridgeAssetSchema,\n FeatureId,\n} from './utils/validators';\n\nexport {\n ALLOWED_BRIDGE_CHAIN_IDS,\n BridgeClientId,\n BRIDGE_CONTROLLER_NAME,\n BRIDGE_QUOTE_MAX_ETA_SECONDS,\n BRIDGE_QUOTE_MAX_RETURN_DIFFERENCE_PERCENTAGE,\n BRIDGE_PREFERRED_GAS_ESTIMATE,\n BRIDGE_MM_FEE_RATE,\n REFRESH_INTERVAL_MS,\n DEFAULT_MAX_REFRESH_COUNT,\n DEFAULT_BRIDGE_CONTROLLER_STATE,\n METABRIDGE_CHAIN_TO_ADDRESS_MAP,\n BRIDGE_DEV_API_BASE_URL,\n BRIDGE_PROD_API_BASE_URL,\n} from './constants/bridge';\n\nexport type { AllowedBridgeChainIds } from './constants/bridge';\n\nexport {\n /**\n * @deprecated This type should not be used. Use {@link BridgeAsset} instead.\n */\n type SwapsTokenObject,\n /**\n * @deprecated This map should not be used. Use getNativeAssetForChainId\" } instead.\n */\n SWAPS_CHAINID_DEFAULT_TOKEN_MAP,\n} from './constants/tokens';\n\nexport {\n SWAPS_API_V2_BASE_URL,\n SWAPS_CONTRACT_ADDRESSES,\n SWAPS_WRAPPED_TOKENS_ADDRESSES,\n ALLOWED_CONTRACT_ADDRESSES,\n} from './constants/swaps';\n\nexport { MetricsActionType, MetricsSwapType } from './utils/metrics/constants';\n\nexport {\n isEthUsdt,\n isNativeAddress,\n isSolanaChainId,\n isBitcoinChainId,\n isTronChainId,\n isNonEvmChainId,\n getNativeAssetForChainId,\n getDefaultBridgeControllerState,\n isCrossChain,\n} from './utils/bridge';\n\nexport {\n isValidQuoteRequest,\n formatEtaInMinutes,\n calcSlippagePercentage,\n} from './utils/quote';\n\nexport { calcLatestSrcBalance } from './utils/balance';\n\nexport { fetchBridgeTokens, getClientHeaders } from './utils/fetch';\n\nexport {\n formatChainIdToCaip,\n formatChainIdToHex,\n formatAddressToCaipReference,\n formatAddressToAssetId,\n} from './utils/caip-formatters';\n\nexport {\n extractTradeData,\n isBitcoinTrade,\n isTronTrade,\n isEvmTxData,\n type Trade,\n} from './utils/trade-utils';\n\nexport {\n selectBridgeQuotes,\n selectDefaultSlippagePercentage,\n type BridgeAppState,\n selectExchangeRateByChainIdAndAddress,\n selectIsQuoteExpired,\n selectBridgeFeatureFlags,\n selectMinimumBalanceForRentExemptionInSOL,\n} from './selectors';\n\nexport { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge';\n\nexport { getBridgeFeatureFlags } from './utils/feature-flags';\n\nexport { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage';\n\nexport {\n isValidSwapsContractAddress,\n getSwapsContractAddress,\n fetchTokens,\n type SwapsToken,\n} from './utils/swaps';\n"]}
|