@metamask-previews/bridge-controller 82.0.3-preview-aeb52ce4f → 83.0.0-preview-a583980c5
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 +16 -2
- package/dist/bridge-controller.d.ts +3 -2
- package/dist/bridge-controller.d.ts.map +1 -1
- package/dist/bridge-controller.js +10 -6
- package/dist/bridge-controller.js.map +1 -1
- package/dist/constants/traces.d.ts +30 -1
- package/dist/constants/traces.d.ts.map +1 -1
- package/dist/constants/traces.js +42 -0
- package/dist/constants/traces.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validators/quote-response.d.ts +28 -28
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,15 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [83.0.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Export trace-related constants and types to ensure client requests include required fields ([#10893](https://github.com/MetaMask/core/pull/10893))
|
|
15
|
+
- `SwapFeatureTag` and `BRIDGE_FEATURE_ID_TO_FEATURE_TAG` for supported features
|
|
16
|
+
- `SwapRelatedTraceName` filters Swap, Bridge and Batch Sell traces from client-defined `TraceName`
|
|
17
|
+
- `SwapTraceRequest` defines required request fields for swap trace calls
|
|
18
|
+
- `SwapTraceFunction` is the type-safe shared trace interface that works for mobile, extension and controller consumers
|
|
19
|
+
- Populate the `tags` field with the active `feature` when tracing swap/bridge operations ([#10893](https://github.com/MetaMask/core/pull/10893))
|
|
20
|
+
|
|
10
21
|
### Changed
|
|
11
22
|
|
|
23
|
+
- **BREAKING:** Require `traceFn` when initializing the BridgeController ([#10893](https://github.com/MetaMask/core/pull/10893))
|
|
12
24
|
- Bump `@metamask/keyring-api` from `^24.1.0` to `^24.3.0` ([#10792](https://github.com/MetaMask/core/pull/10792), [#10844](https://github.com/MetaMask/core/pull/10844))
|
|
13
25
|
- Bump `@metamask/transaction-controller` from `^72.2.0` to `^72.2.1` ([#10817](https://github.com/MetaMask/core/pull/10817))
|
|
14
26
|
- Bump `@metamask/accounts-controller` from `^40.0.0` to `^40.1.0` ([#10851](https://github.com/MetaMask/core/pull/10851))
|
|
15
27
|
- Bump `@metamask/base-controller` from `^10.0.0` to `^10.1.0` ([#10864](https://github.com/MetaMask/core/pull/10864))
|
|
16
28
|
- Bump `@metamask/network-controller` from `^37.0.1` to `^37.1.0` ([#10864](https://github.com/MetaMask/core/pull/10864))
|
|
17
29
|
- Bump `@metamask/assets-controller` from `^19.0.0` to `^19.1.0` ([#10876](https://github.com/MetaMask/core/pull/10876))
|
|
18
|
-
- Bump `@metamask/profile-sync-controller` from `^34.0.3` to `^
|
|
30
|
+
- Bump `@metamask/profile-sync-controller` from `^34.0.3` to `^35.0.0` ([#10905](https://github.com/MetaMask/core/pull/10905), [#10925](https://github.com/MetaMask/core/pull/10925))
|
|
31
|
+
- Bump `@metamask/assets-controllers` from `^112.1.2` to `^112.1.3` ([#10925](https://github.com/MetaMask/core/pull/10925))
|
|
19
32
|
|
|
20
33
|
## [82.0.3]
|
|
21
34
|
|
|
@@ -2148,7 +2161,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
2148
2161
|
|
|
2149
2162
|
- Initial release ([#5317](https://github.com/MetaMask/core/pull/5317))
|
|
2150
2163
|
|
|
2151
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@
|
|
2164
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@83.0.0...HEAD
|
|
2165
|
+
[83.0.0]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@82.0.3...@metamask/bridge-controller@83.0.0
|
|
2152
2166
|
[82.0.3]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@82.0.2...@metamask/bridge-controller@82.0.3
|
|
2153
2167
|
[82.0.2]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@82.0.1...@metamask/bridge-controller@82.0.2
|
|
2154
2168
|
[82.0.1]: https://github.com/MetaMask/core/compare/@metamask/bridge-controller@82.0.0...@metamask/bridge-controller@82.0.1
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { TraceCallback } from '@metamask/controller-utils';
|
|
2
1
|
import type { TransactionController } from '@metamask/transaction-controller';
|
|
3
2
|
import type { BridgeClientId } from './constants/bridge.js';
|
|
4
3
|
import { BRIDGE_CONTROLLER_NAME } from './constants/bridge.js';
|
|
4
|
+
import { TraceName } from './constants/traces.js';
|
|
5
|
+
import type { SwapTraceFunction } from './index.js';
|
|
5
6
|
import type { L1GasFees, GenericQuoteRequest, NonEvmFees, BridgeControllerState, BridgeControllerMessenger, FetchFunction, InputPrimaryDenomination } from './types.js';
|
|
6
7
|
import { AbortReason, UnifiedSwapBridgeEventName } from './utils/metrics/constants.js';
|
|
7
8
|
import type { BridgeControllerMetricsEventName, BridgeControllerMetricsLocation } from './utils/metrics/constants.js';
|
|
@@ -49,7 +50,7 @@ export declare class BridgeController extends BridgeController_base<typeof BRIDG
|
|
|
49
50
|
customBridgeApiBaseUrl?: string;
|
|
50
51
|
};
|
|
51
52
|
trackMetaMetricsFn: <EventName extends BridgeControllerMetricsEventName>(eventName: EventName, properties: CrossChainSwapsEventProperties<EventName>) => void;
|
|
52
|
-
traceFn
|
|
53
|
+
traceFn: SwapTraceFunction<TraceName>;
|
|
53
54
|
/**
|
|
54
55
|
* When provided, called to determine whether to use AssetsController for exchange rates.
|
|
55
56
|
* When true, rates are read from AssetsController:getExchangeRatesForBridge instead of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-controller.d.ts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bridge-controller.d.ts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAK9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,sBAAsB,EAKvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAEL,SAAS,EACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EAEV,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACb,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAyBpB,OAAO,EACL,WAAW,EAMX,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,8BAA8B,CAAC;AAYtC,OAAO,KAAK,EAGV,8BAA8B,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAI/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AA+FpE;;;;;;GAMG;AACH,KAAK,kBAAkB,GAAG;IACxB,aAAa,EAAE,mBAAmB,EAAE,CAAC;IACrC,OAAO,EAAE,8BAA8B,CAAC,0BAA0B,CAAC,WAAW,CAAC,GAC7E,8BAA8B,CAAC,0BAA0B,CAAC,eAAe,CAAC,CAAC;CAC9E,CAAC;;;;;;;;;;;;;;;;AAwCF,qBAAa,gBAAiB,SAAQ,sBACpC,OA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,cACpB,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAsDd;IAqKF,oBAAoB,YACT,WAAW,YACV,8BAA8B,CAAC,0BAA0B,CAAC,cAAc,CAAC,UAanF;IAEF;;;;;;OAMG;IACH,WAAW,aAAc,+BAA+B,UAEtD;IAEF;;;;OAIG;IACH,WAAW,QAAO,+BAA+B,CAE/C;IAEF,2BAA2B,6BACC,wBAAwB,UAKlD;IAEF,UAAU,6CAEW,MAAM,GAAG,IAAI,YACtB,8BAA8B,CAAC,0BAA0B,CAAC,cAAc,CAAC,UAsCnF;IAEF;;OAEG;IACH,sBAAsB,aAYpB;IA+pBF;;;;;;;;;;OAUG;IACH,2BAA2B,GACzB,SAAS,SAAS,gCAAgC,aAEvC,SAAS,wBACE,IAAI,CACxB,8BAA8B,EAC9B,SAAS,CACV,CAAC,SAAS,CAAC,sBACO,MAAM,UAmBzB;CA+BH"}
|
|
@@ -9,7 +9,7 @@ import { toQuoteResponseV2 } from './coercers/quote-response-v1-to-v2.js';
|
|
|
9
9
|
import { BRIDGE_CONTROLLER_NAME, BRIDGE_PROD_API_BASE_URL, DEFAULT_BRIDGE_CONTROLLER_STATE, METABRIDGE_ETHEREUM_ADDRESS, REFRESH_INTERVAL_MS, } from './constants/bridge.js';
|
|
10
10
|
import { CHAIN_IDS } from './constants/chains.js';
|
|
11
11
|
import { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps.js';
|
|
12
|
-
import { TraceName } from './constants/traces.js';
|
|
12
|
+
import { BRIDGE_FEATURE_ID_TO_FEATURE_TAG, TraceName, } from './constants/traces.js';
|
|
13
13
|
import { RequestStatus } from './types.js';
|
|
14
14
|
import { getAssetIdsForToken, toExchangeRates } from './utils/assets.js';
|
|
15
15
|
import { hasSufficientBalance } from './utils/balance.js';
|
|
@@ -182,7 +182,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
182
182
|
this.#fetchFn = fetchFn;
|
|
183
183
|
this.#trackMetaMetricsFn = trackMetaMetricsFn;
|
|
184
184
|
this.#config = config ?? {};
|
|
185
|
-
this.#trace = traceFn
|
|
185
|
+
this.#trace = traceFn;
|
|
186
186
|
this.#getUseAssetsControllerForRates =
|
|
187
187
|
getUseAssetsControllerForRates ?? (() => false);
|
|
188
188
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
@@ -547,9 +547,14 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
547
547
|
: TraceName.SwapQuotesFetched;
|
|
548
548
|
}
|
|
549
549
|
const tracedProviders = new Set();
|
|
550
|
-
const traceWithoutImpact =
|
|
550
|
+
const traceWithoutImpact = (request) => {
|
|
551
551
|
try {
|
|
552
|
-
|
|
552
|
+
this.#trace({
|
|
553
|
+
...request,
|
|
554
|
+
tags: {
|
|
555
|
+
feature: BRIDGE_FEATURE_ID_TO_FEATURE_TAG[context.feature_id],
|
|
556
|
+
},
|
|
557
|
+
}, () => undefined);
|
|
553
558
|
}
|
|
554
559
|
catch {
|
|
555
560
|
// Telemetry failures must not affect quote fetching or state updates.
|
|
@@ -562,7 +567,6 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
562
567
|
}
|
|
563
568
|
tracedProviders.add(provider);
|
|
564
569
|
// Provider telemetry must not delay quote processing.
|
|
565
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
566
570
|
traceWithoutImpact({
|
|
567
571
|
name: TraceName.QuoteProviderFirstResult,
|
|
568
572
|
startTime: quoteTraceStartTime,
|
|
@@ -654,7 +658,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
654
658
|
console.log(`Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`, error);
|
|
655
659
|
}
|
|
656
660
|
finally {
|
|
657
|
-
|
|
661
|
+
traceWithoutImpact({
|
|
658
662
|
name: traceName,
|
|
659
663
|
startTime: quoteTraceStartTime,
|
|
660
664
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-controller.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zD,SAAS,EACT,oBAAoB,EACpB,iBAAiB,CAClB,CAAC;YAEF,IAAI,CAAC,mBAAmB,CACtB,SAAS,EACT,0BAAuE,CACxE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,sDAAsD,SAAS,EAAE,EACjE,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF;;;;;;OAMG;IACM,wBAAwB,GAAG,KAAK,EACvC,aAAqB,EACrB,eAAuB,EACvB,kBAAsD,EACrC,EAAE;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,0BAA0B,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,aAAa,EAAE,QAAQ,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,kBAAkB,CAAC;YACxE,CAAC,CAAC,2BAA2B;YAC7B,CAAC,CAAC,wBAAwB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,SAAS,GAAc,MAAM,QAAQ,CAAC,SAAS,CACnD,aAAa,EACb,cAAc,CACf,CAAC;QACF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC,CAAC;CACH","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, TraceRequest } 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';\nimport { v4 as uuid } from 'uuid';\n\nimport { toQuoteResponseV2 } from './coercers/quote-response-v1-to-v2.js';\nimport type { BridgeClientId } from './constants/bridge.js';\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.js';\nimport { CHAIN_IDS } from './constants/chains.js';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps.js';\nimport { TraceName } from './constants/traces.js';\nimport { RequestStatus } from './types.js';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n InputPrimaryDenomination,\n} from './types.js';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets.js';\nimport { hasSufficientBalance } from './utils/balance.js';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge.js';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters.js';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags.js';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n fetchBatchSellTrades,\n} from './utils/fetch.js';\nimport {\n AbortReason,\n BatchSellMetricsEventName,\n FailurePhase,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n SwapBridgeErrorCode,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants.js';\nimport type {\n BridgeControllerMetricsEventName,\n BridgeControllerMetricsLocation,\n} from './utils/metrics/constants.js';\nimport { getQuoteFetchErrorCode } from './utils/metrics/failure-telemetry.js';\nimport {\n formatProviderLabel,\n getAccountHardwareType,\n getRequestParams,\n getSwapType,\n getSwapTypeFromQuote,\n isCustomSlippage,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties.js';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types.js';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types.js';\nimport { appendFeesToQuotes } from './utils/quote-fees.js';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps.js';\nimport { sortQuotes } from './utils/sort-quotes.js';\nimport type { FeatureId } from './validators/feature-flags.js';\nimport {\n isValidQuoteRequest,\n isValidBatchSellQuoteRequest,\n} from './validators/quote-request.js';\nimport type { QuoteResponseV1 } from './validators/quote-response-v1.js';\nimport type { QuoteResponse } from './validators/quote-response.js';\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 tokenWarnings: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n tokenSecurityTypeDestination: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n inputPrimaryDenomination: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteStreamComplete: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n batchSellTrades: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n batchSellTradesLoadingStatus: {\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 quoteRequests: GenericQuoteRequest[];\n context: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesError] &\n RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\ntype QuoteTraceResult = 'success' | 'cancelled' | 'no_quotes' | 'error';\n\nconst QUOTE_ABORT_REASONS = new Set<string>(Object.values(AbortReason));\n\nconst isExpectedQuoteAbort = (\n error: unknown,\n signal?: AbortSignal,\n): boolean => {\n if (signal?.aborted) {\n return true;\n }\n\n if (QUOTE_ABORT_REASONS.has(String(error))) {\n return true;\n }\n\n const errorText =\n error instanceof Error ? `${error.name} ${error.message}` : String(error);\n\n return (\n errorText.includes('AbortError') ||\n errorText.includes('FetchRequestCanceledException')\n );\n};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'updateBridgeQuoteRequestParams',\n 'fetchQuotes',\n 'updateBatchSellTrades',\n 'stopPollingForQuotes',\n 'setLocation',\n 'getLocation',\n 'setInputPrimaryDenomination',\n 'resetState',\n 'setChainIntervalLength',\n 'trackUnifiedSwapBridgeEvent',\n] as const;\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #batchSellTradesAbortController: 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: BridgeControllerMetricsLocation =\n MetaMetricsSwapsEventSource.Unknown;\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 BridgeControllerMetricsEventName,\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 /**\n * Returns whether to use AssetsController for exchange rates.\n * Set via constructor option getUseAssetsControllerForRates; defaults to false.\n *\n * @returns True when exchange rates should be read from AssetsController:getExchangeRatesForBridge.\n */\n readonly #getUseAssetsControllerForRates: () => boolean;\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n getUseAssetsControllerForRates,\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: <EventName extends BridgeControllerMetricsEventName>(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n traceFn?: TraceCallback;\n /**\n * When provided, called to determine whether to use AssetsController for exchange rates.\n * When true, rates are read from AssetsController:getExchangeRatesForBridge instead of\n * MultichainAssetsRatesController, TokenRatesController, and CurrencyRateController.\n */\n getUseAssetsControllerForRates?: () => boolean;\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 this.#getUseAssetsControllerForRates =\n getUseAssetsControllerForRates ?? (() => false);\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n /**\n * Updates the quote request at the specified index with the given parameters, then starts\n * polling for quotes.\n *\n * @param paramsToUpdate - The parameters to update in the quote request at the specified index\n * @param context - metrics context\n * @param quoteRequestIndex - The index of the quote request to update\n * @param quoteRequestCount - The number of quote requests in the UI\n */\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n quoteRequestIndex: number = 0,\n quoteRequestCount: number = 1,\n ) => {\n // Guard against updating a quote request that doesn't exist\n if (quoteRequestIndex >= quoteRequestCount) {\n return;\n }\n this.#trackInputChangedEvents(\n paramsToUpdate,\n context.feature_id,\n quoteRequestIndex,\n );\n this.resetState(AbortReason.QuoteRequestUpdated, quoteRequestIndex);\n this.update((state) => {\n // Update only the specified quote request and keep the rest of the quote requests unchanged\n state.quoteRequest = state.quoteRequest\n .slice(0, quoteRequestIndex)\n .concat({\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest[0],\n ...paramsToUpdate,\n })\n .concat(\n state.quoteRequest.slice(quoteRequestIndex + 1, quoteRequestCount),\n );\n state.tokenSecurityTypeDestination =\n context.token_security_type_destination ?? null;\n });\n\n // BatchSell and Unified swaps both use the same polling logic so both validations should pass\n if (\n isValidQuoteRequest(paramsToUpdate) &&\n isValidBatchSellQuoteRequest(this.state.quoteRequest)\n ) {\n this.#quotesFirstFetched = Date.now();\n // Update the insufficientBal and resetApproval params for the quote request\n const quoteWithInsufficientBalAndResetApproval =\n await this.#appendInsufficientBalAndResetApproval(paramsToUpdate);\n this.update((state) => {\n state.quoteRequest[quoteRequestIndex] =\n quoteWithInsufficientBalAndResetApproval;\n });\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n quoteRequests: this.state.quoteRequest,\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 featureId - The feature ID that maps to quoteParam overrides from LD\n * @param abortSignal - The abort signal to cancel all the requests\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n featureId: FeatureId,\n abortSignal: AbortSignal | null = null,\n ): Promise<(QuoteResponseV1 & 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.#trackQuoteValidationFailures(validationFailures, featureId);\n const srcChainIds = Array.from(\n new Set(baseQuotes.map((quote) => quote.quote.srcChainId)),\n ).filter(Boolean);\n\n const quotesWithFees =\n srcChainIds.length > 1 || srcChainIds.length === 0\n ? // Don't append fees if there are multiple srcChainIds\n baseQuotes\n : await appendFeesToQuotes(\n formatChainIdToCaip(srcChainIds[0]),\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n /**\n * Fetches gasless transaction data and fees for BatchSell quotes.\n * To use this in the clients, add a listener for the recommendedQuotes and call\n * this handler whenever they change.\n *\n * @param quotes - The quotes to fetch the gasless transaction data and fees for\n * @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature.\n */\n updateBatchSellTrades = async (\n quotes: (QuoteResponse | null)[],\n stxEnabled: boolean,\n ): Promise<void> => {\n this.#batchSellTradesAbortController?.abort(\n AbortReason.GaslessTxBatchFetched,\n );\n this.#batchSellTradesAbortController = new AbortController();\n\n this.update((state) => {\n // Set loading status again if recommended quotes are re-ordered\n state.batchSellTradesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n const batchSellTradesResponse = await fetchBatchSellTrades(\n quotes,\n stxEnabled,\n this.#batchSellTradesAbortController.signal,\n this.#clientId,\n await this.#getJwt(),\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n this.#clientVersion,\n );\n\n this.update((state) => {\n state.batchSellTrades = batchSellTradesResponse;\n state.batchSellTradesLoadingStatus = RequestStatus.FETCHED;\n });\n\n // TODO if fee.asset.assetId is not in exchange rates, fetch the exchange rate and update the state\n } catch (error) {\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 AbortReason.GaslessTxBatchFetched,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n this.update((state) => {\n // Reset the batch sell trades if the fetch fails to avoid showing stale data\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n // Update loading status\n state.batchSellTradesLoadingStatus = RequestStatus.ERROR;\n });\n console.log(`Failed to fetch batch sell trades`, error);\n }\n };\n\n readonly #trackQuoteValidationFailures = (\n validationFailures: string[],\n featureId: FeatureId,\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n feature_id: featureId,\n failures: validationFailures,\n location: this.#location,\n },\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 quoteRequests - The quote requests to fetch the exchange rates for\n */\n readonly #fetchAssetExchangeRates = async (\n quoteRequests: GenericQuoteRequest[],\n ) => {\n // Get unique assetIds for all quote requests\n const assetIds = new Set<CaipAssetType>(\n quoteRequests.flatMap((quoteRequest) =>\n [\n getAssetIdsForToken(\n quoteRequest.srcTokenAddress,\n quoteRequest.srcChainId,\n ),\n getAssetIdsForToken(\n quoteRequest.destTokenAddress,\n quoteRequest.destChainId,\n ),\n ].flat(),\n ),\n );\n\n const currency = this.#getUseAssetsControllerForRates()\n ? this.messenger.call('AssetsController:getExchangeRatesForBridge')\n .currentCurrency\n : this.messenger.call('CurrencyRateController:getState').currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency, 'usd']),\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 #appendInsufficientBalAndResetApproval = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n const isSrcChainNonEVM = isNonEvmChainId(quoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(quoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(quoteRequest.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = quoteRequest.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(quoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n quoteRequest.insufficientBal ??\n (await this.#hasInsufficientBalance(quoteRequest));\n }\n\n return {\n ...quoteRequest,\n insufficientBal,\n resetApproval,\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 this.#batchSellTradesAbortController?.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: BridgeControllerMetricsLocation) => {\n this.#location = location;\n };\n\n /**\n * Returns the location/entry point for the current swap or bridge flow.\n *\n * @returns The entry point from which the user initiated the flow\n */\n getLocation = (): BridgeControllerMetricsLocation => {\n return this.#location;\n };\n\n setInputPrimaryDenomination = (\n inputPrimaryDenomination: InputPrimaryDenomination,\n ) => {\n this.update((state) => {\n state.inputPrimaryDenomination = inputPrimaryDenomination;\n });\n };\n\n resetState = (\n reason = AbortReason.ResetState,\n quoteRequestIndex: number | null = null,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopPollingForQuotes(reason, context);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n if (quoteRequestIndex === null) {\n // Clear all requests if index is null\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n } else {\n // Otherwise only clear the specified request\n state.quoteRequest = state.quoteRequest\n .slice(0, quoteRequestIndex)\n .concat(DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest[0])\n .concat(state.quoteRequest.slice(quoteRequestIndex + 1));\n }\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 state.tokenWarnings = DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings;\n state.tokenSecurityTypeDestination =\n DEFAULT_BRIDGE_CONTROLLER_STATE.tokenSecurityTypeDestination;\n state.quoteStreamComplete =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n state.batchSellTradesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTradesLoadingStatus;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n // Assume that BatchSell quote requests all have the same source chain\n // Use the first one to determine refresh rate\n const { srcChainId } = state.quoteRequest[0];\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 quoteRequests,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort(AbortReason.NewQuoteRequest);\n this.#batchSellTradesAbortController?.abort(AbortReason.NewQuoteRequest);\n\n this.#abortController = new AbortController();\n const quoteTraceStartTime = Date.now();\n const quoteTraceRequestId = uuid();\n const quoteAbortSignal = this.#abortController.signal;\n\n this.#fetchAssetExchangeRates(quoteRequests).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 const isBatchSellRequest = quoteRequests.length > 1;\n\n this.update((state) => {\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.tokenWarnings = DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings;\n state.quoteStreamComplete =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n // Prevent clients from displaying stale batch sell fees\n if (quoteRequests.length > 1) {\n state.batchSellTradesLoadingStatus = RequestStatus.LOADING;\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n }\n });\n\n const jwt = await this.#getJwt();\n\n const [firstQuoteRequest] = quoteRequests;\n let traceResult: QuoteTraceResult = 'error';\n let traceName = TraceName.BatchSellQuotesFetched;\n if (!isBatchSellRequest) {\n traceName = isCrossChain(\n firstQuoteRequest.srcChainId,\n firstQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched;\n }\n const tracedProviders = new Set<string>();\n const traceWithoutImpact = async (request: TraceRequest): Promise<void> => {\n try {\n await this.#trace(request, () => undefined);\n } catch {\n // Telemetry failures must not affect quote fetching or state updates.\n }\n };\n const traceProviderFirstResult = (\n providerData: Parameters<typeof formatProviderLabel>[0],\n ) => {\n const provider = formatProviderLabel(providerData);\n if (isBatchSellRequest || tracedProviders.has(provider)) {\n return;\n }\n tracedProviders.add(provider);\n // Provider telemetry must not delay quote processing.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n traceWithoutImpact({\n name: TraceName.QuoteProviderFirstResult,\n startTime: quoteTraceStartTime,\n data: {\n provider,\n feature_id: context.feature_id,\n request_id: quoteTraceRequestId,\n swap_type: getSwapType(\n firstQuoteRequest.srcChainId,\n firstQuoteRequest.destChainId,\n ),\n srcChainId: formatChainIdToCaip(firstQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(firstQuoteRequest.destChainId),\n result: 'success',\n },\n });\n };\n\n try {\n const selectedAccount = this.#getMultichainSelectedAccount(\n firstQuoteRequest.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 firstQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream || isBatchSellRequest) {\n const quoteCount = await this.#handleQuoteStreaming({\n quoteRequests,\n featureId: context.feature_id,\n jwt,\n selectedAccount,\n signal: quoteAbortSignal,\n traceProviderFirstResult,\n });\n if (quoteAbortSignal.aborted) {\n traceResult = 'cancelled';\n return;\n }\n traceResult = quoteCount > 0 ? 'success' : 'no_quotes';\n } else {\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n firstQuoteRequest,\n context.feature_id,\n quoteAbortSignal,\n );\n for (const quote of quotes) {\n traceProviderFirstResult(quote.quote);\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 = Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes.map(toQuoteResponseV2);\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n traceResult = quotes.length > 0 ? 'success' : 'no_quotes';\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 (isExpectedQuoteAbort(error, quoteAbortSignal)) {\n traceResult = 'cancelled';\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(UnifiedSwapBridgeEventName.QuotesError, {\n ...context,\n failure_phase: FailurePhase.Quote,\n error_code: getQuoteFetchErrorCode(error),\n });\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n } finally {\n await traceWithoutImpact({\n name: traceName,\n startTime: quoteTraceStartTime,\n data: {\n srcChainId: formatChainIdToCaip(firstQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(firstQuoteRequest.destChainId),\n ...(!isBatchSellRequest && {\n request_id: quoteTraceRequestId,\n feature_id: context.feature_id,\n result: traceResult,\n }),\n },\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 const hasNoFundedQuoteRequests = quoteRequests.every(\n ({ insufficientBal }) => Boolean(insufficientBal),\n );\n\n if (\n hasNoFundedQuoteRequests\n ? // If all quote requests are insufficiently funded, stop polling\n // So if a BatchSell has at least 1 sufficiently funded quote request, polling continues\n true\n : // Otherwise continue polling until the maximum number of refreshes has been reached\n this.state.quotesRefreshCount >= maxRefreshCount\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async ({\n quoteRequests,\n featureId,\n jwt,\n selectedAccount,\n signal,\n traceProviderFirstResult,\n }: {\n quoteRequests: GenericQuoteRequest[];\n featureId: FeatureId;\n jwt?: string;\n selectedAccount?: InternalAccount;\n signal?: AbortSignal;\n traceProviderFirstResult: (\n providerData: Parameters<typeof formatProviderLabel>[0],\n ) => void;\n }): Promise<number> => {\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 quoteRequests,\n signal,\n featureId,\n this.#clientId,\n jwt,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onQuoteValidationFailure: (validationFailures) =>\n this.#trackQuoteValidationFailures(validationFailures, featureId),\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n quote.chainId,\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n traceProviderFirstResult(quote.quote);\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 onTokenWarning: (warning) => {\n this.update((state) => {\n const isDuplicate = state.tokenWarnings.some(\n (existing) => existing.feature_id === warning.feature_id,\n );\n if (!isDuplicate) {\n state.tokenWarnings = [...state.tokenWarnings, warning];\n }\n });\n },\n onComplete: (data) => {\n this.update((state) => {\n state.quoteStreamComplete = data;\n });\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 return validQuotesCounter;\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 // Assume that all quotes in a batch are for the same account\n const addressToUse =\n walletAddress ?? this.state.quoteRequest[0].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 = (\n quoteRequestIndex: number = 0,\n ): Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n > => {\n const quoteRequest = this.state.quoteRequest[quoteRequestIndex];\n const { walletAddress } = quoteRequest;\n const accountHardwareType = getAccountHardwareType(\n walletAddress\n ? this.#getMultichainSelectedAccount(walletAddress)\n : undefined,\n );\n\n return {\n slippage_limit: quoteRequest.slippage ?? 0,\n swap_type: getSwapTypeFromQuote(quoteRequest),\n custom_slippage: isCustomSlippage(quoteRequest.slippage),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\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 BridgeControllerMetricsEventName,\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n quoteRequestIndex: number = 0,\n ) => {\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 const inputPrimaryDenominationProperties = {\n input_primary_denomination: this.state.inputPrimaryDenomination,\n };\n const batchSellClientChainProperties = propertiesFromClient as Pick<\n RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellTokenPageViewed],\n 'chain_id_source' | 'chain_id_destination'\n >;\n const batchSellBaseProperties = {\n chain_id_source: batchSellClientChainProperties.chain_id_source,\n chain_id_destination: batchSellClientChainProperties.chain_id_destination,\n location: clientProps?.location ?? this.#location,\n };\n const quoteRequest = this.state.quoteRequest[quoteRequestIndex];\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case BatchSellMetricsEventName.BatchSellTokenPageViewed:\n return batchSellBaseProperties;\n case BatchSellMetricsEventName.BatchSellTokenPageContinueClicked: {\n const propsFromClient =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellTokenPageContinueClicked];\n return {\n ...batchSellBaseProperties,\n source_token_count: propsFromClient.source_token_addresses.length,\n source_token_symbols: propsFromClient.source_token_symbols,\n source_token_addresses: propsFromClient.source_token_addresses,\n };\n }\n case BatchSellMetricsEventName.BatchSellQuotePageViewed:\n case BatchSellMetricsEventName.BatchSellQuotePageReviewClicked: {\n const propsFromClient =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellQuotePageViewed];\n return {\n ...batchSellBaseProperties,\n source_token_count: propsFromClient.source_token_addresses.length,\n source_token_symbols: propsFromClient.source_token_symbols,\n source_token_addresses: propsFromClient.source_token_addresses,\n destination_token_symbol: propsFromClient.destination_token_symbol,\n destination_token_address: propsFromClient.destination_token_address,\n usd_amount_source_tokens: propsFromClient.usd_amount_source_tokens,\n usd_amount_source_total: propsFromClient.usd_amount_source_total,\n source_token_slippages: propsFromClient.source_token_slippages,\n };\n }\n case BatchSellMetricsEventName.BatchSellReviewModalSubmitted: {\n const reviewModalProperties =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellReviewModalSubmitted];\n return {\n ...batchSellBaseProperties,\n source_token_count:\n reviewModalProperties.source_token_addresses.length,\n source_token_symbols: reviewModalProperties.source_token_symbols,\n source_token_addresses: reviewModalProperties.source_token_addresses,\n destination_token_symbol:\n reviewModalProperties.destination_token_symbol,\n destination_token_address:\n reviewModalProperties.destination_token_address,\n usd_amount_source_tokens:\n reviewModalProperties.usd_amount_source_tokens,\n usd_amount_source_total:\n reviewModalProperties.usd_amount_source_total,\n source_token_slippages: reviewModalProperties.source_token_slippages,\n usd_quoted_gas: reviewModalProperties.usd_quoted_gas,\n usd_quoted_return: reviewModalProperties.usd_quoted_return,\n };\n }\n case UnifiedSwapBridgeEventName.FiatCryptoToggleClicked:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n swap_type: getSwapTypeFromQuote(quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n refresh_count: this.state.quotesRefreshCount,\n has_sufficient_funds: !quoteRequest.insufficientBal,\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n has_sufficient_funds: !quoteRequest.insufficientBal,\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !quoteRequest.insufficientBal,\n failure_phase: FailurePhase.Quote,\n error_code: SwapBridgeErrorCode.QuoteFetchFailed,\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(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n case UnifiedSwapBridgeEventName.AssetPickerOpened:\n return baseProperties;\n // Inject `token_security_type_destination` from controller state so the\n // field is always present on this event. `baseProperties` (which spreads\n // `propertiesFromClient`) wins if the client supplies a value explicitly.\n case UnifiedSwapBridgeEventName.InputSourceDestinationSwitched:\n return {\n token_security_type_destination:\n this.state.tokenSecurityTypeDestination,\n ...baseProperties,\n };\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 featureId: FeatureId,\n quoteRequestIndex: number = 0,\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 this.state.quoteRequest[quoteRequestIndex] &&\n value !==\n this.state.quoteRequest[quoteRequestIndex][\n key as keyof GenericQuoteRequest\n ]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n location: this.#location,\n feature_id: featureId,\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 * @param quoteRequestIndex - The index of the quote request to track the event for\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n EventName extends BridgeControllerMetricsEventName,\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n quoteRequestIndex: number = 0,\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<EventName>(\n eventName,\n propertiesFromClient,\n quoteRequestIndex,\n );\n\n this.#trackMetaMetricsFn(\n eventName,\n combinedPropertiesForEvent as CrossChainSwapsEventProperties<EventName>,\n );\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.js","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,YAAY,EA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S,EAAE,EACjE,KAAK,CACN,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF;;;;;;OAMG;IACM,wBAAwB,GAAG,KAAK,EACvC,aAAqB,EACrB,eAAuB,EACvB,kBAAsD,EACrC,EAAE;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,0BAA0B,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,aAAa,EAAE,QAAQ,CAAC;QACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,kBAAkB,CAAC;YACxE,CAAC,CAAC,2BAA2B;YAC7B,CAAC,CAAC,wBAAwB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,SAAS,GAAc,MAAM,QAAQ,CAAC,SAAS,CACnD,aAAa,EACb,cAAc,CACf,CAAC;QACF,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC,CAAC;CACH","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 { 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';\nimport { v4 as uuid } from 'uuid';\n\nimport { toQuoteResponseV2 } from './coercers/quote-response-v1-to-v2.js';\nimport type { BridgeClientId } from './constants/bridge.js';\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.js';\nimport { CHAIN_IDS } from './constants/chains.js';\nimport { SWAPS_CONTRACT_ADDRESSES } from './constants/swaps.js';\nimport {\n BRIDGE_FEATURE_ID_TO_FEATURE_TAG,\n TraceName,\n} from './constants/traces.js';\nimport type { SwapTraceFunction } from './index.js';\nimport { RequestStatus } from './types.js';\nimport type {\n L1GasFees,\n GenericQuoteRequest,\n NonEvmFees,\n QuoteRequest,\n BridgeControllerState,\n BridgeControllerMessenger,\n FetchFunction,\n InputPrimaryDenomination,\n SwapTraceRequest,\n} from './types.js';\nimport { getAssetIdsForToken, toExchangeRates } from './utils/assets.js';\nimport { hasSufficientBalance } from './utils/balance.js';\nimport {\n getDefaultBridgeControllerState,\n isCrossChain,\n isEthUsdt,\n isNonEvmChainId,\n isSolanaChainId,\n} from './utils/bridge.js';\nimport {\n formatAddressToCaipReference,\n formatChainIdToCaip,\n formatChainIdToHex,\n} from './utils/caip-formatters.js';\nimport {\n getBridgeFeatureFlags,\n hasMinimumRequiredVersion,\n} from './utils/feature-flags.js';\nimport {\n fetchAssetPrices,\n fetchBridgeQuotes,\n fetchBridgeQuoteStream,\n fetchBatchSellTrades,\n} from './utils/fetch.js';\nimport {\n AbortReason,\n BatchSellMetricsEventName,\n FailurePhase,\n MetaMetricsSwapsEventSource,\n MetricsActionType,\n SwapBridgeErrorCode,\n UnifiedSwapBridgeEventName,\n} from './utils/metrics/constants.js';\nimport type {\n BridgeControllerMetricsEventName,\n BridgeControllerMetricsLocation,\n} from './utils/metrics/constants.js';\nimport { getQuoteFetchErrorCode } from './utils/metrics/failure-telemetry.js';\nimport {\n formatProviderLabel,\n getAccountHardwareType,\n getRequestParams,\n getSwapType,\n getSwapTypeFromQuote,\n isCustomSlippage,\n toInputChangedPropertyKey,\n toInputChangedPropertyValue,\n} from './utils/metrics/properties.js';\nimport type {\n QuoteFetchData,\n RequestMetadata,\n RequiredEventContextFromClient,\n} from './utils/metrics/types.js';\nimport type { CrossChainSwapsEventProperties } from './utils/metrics/types.js';\nimport { appendFeesToQuotes } from './utils/quote-fees.js';\nimport { getMinimumBalanceForRentExemptionInLamports } from './utils/snaps.js';\nimport { sortQuotes } from './utils/sort-quotes.js';\nimport type { FeatureId } from './validators/feature-flags.js';\nimport {\n isValidQuoteRequest,\n isValidBatchSellQuoteRequest,\n} from './validators/quote-request.js';\nimport type { QuoteResponseV1 } from './validators/quote-response-v1.js';\nimport type { QuoteResponse } from './validators/quote-response.js';\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 tokenWarnings: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n tokenSecurityTypeDestination: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n inputPrimaryDenomination: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n quoteStreamComplete: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n batchSellTrades: {\n includeInStateLogs: true,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n batchSellTradesLoadingStatus: {\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 quoteRequests: GenericQuoteRequest[];\n context: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesError] &\n RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesRequested];\n};\n\ntype QuoteTraceResult = 'success' | 'cancelled' | 'no_quotes' | 'error';\n\nconst QUOTE_ABORT_REASONS = new Set<string>(Object.values(AbortReason));\n\nconst isExpectedQuoteAbort = (\n error: unknown,\n signal?: AbortSignal,\n): boolean => {\n if (signal?.aborted) {\n return true;\n }\n\n if (QUOTE_ABORT_REASONS.has(String(error))) {\n return true;\n }\n\n const errorText =\n error instanceof Error ? `${error.name} ${error.message}` : String(error);\n\n return (\n errorText.includes('AbortError') ||\n errorText.includes('FetchRequestCanceledException')\n );\n};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'updateBridgeQuoteRequestParams',\n 'fetchQuotes',\n 'updateBatchSellTrades',\n 'stopPollingForQuotes',\n 'setLocation',\n 'getLocation',\n 'setInputPrimaryDenomination',\n 'resetState',\n 'setChainIntervalLength',\n 'trackUnifiedSwapBridgeEvent',\n] as const;\n\nexport class BridgeController extends StaticIntervalPollingController<BridgePollingInput>()<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState,\n BridgeControllerMessenger\n> {\n #abortController: AbortController | undefined;\n\n #batchSellTradesAbortController: 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: BridgeControllerMetricsLocation =\n MetaMetricsSwapsEventSource.Unknown;\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 BridgeControllerMetricsEventName,\n >(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n\n readonly #trace: SwapTraceFunction<TraceName>;\n\n readonly #config: {\n customBridgeApiBaseUrl?: string;\n };\n\n /**\n * Returns whether to use AssetsController for exchange rates.\n * Set via constructor option getUseAssetsControllerForRates; defaults to false.\n *\n * @returns True when exchange rates should be read from AssetsController:getExchangeRatesForBridge.\n */\n readonly #getUseAssetsControllerForRates: () => boolean;\n\n constructor({\n messenger,\n state,\n clientId,\n clientVersion,\n getLayer1GasFee,\n fetchFn,\n config,\n trackMetaMetricsFn,\n traceFn,\n getUseAssetsControllerForRates,\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: <EventName extends BridgeControllerMetricsEventName>(\n eventName: EventName,\n properties: CrossChainSwapsEventProperties<EventName>,\n ) => void;\n traceFn: SwapTraceFunction<TraceName>;\n /**\n * When provided, called to determine whether to use AssetsController for exchange rates.\n * When true, rates are read from AssetsController:getExchangeRatesForBridge instead of\n * MultichainAssetsRatesController, TokenRatesController, and CurrencyRateController.\n */\n getUseAssetsControllerForRates?: () => boolean;\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;\n this.#getUseAssetsControllerForRates =\n getUseAssetsControllerForRates ?? (() => false);\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n _executePoll = async (pollingInput: BridgePollingInput) => {\n await this.#fetchBridgeQuotes(pollingInput);\n };\n\n /**\n * Updates the quote request at the specified index with the given parameters, then starts\n * polling for quotes.\n *\n * @param paramsToUpdate - The parameters to update in the quote request at the specified index\n * @param context - metrics context\n * @param quoteRequestIndex - The index of the quote request to update\n * @param quoteRequestCount - The number of quote requests in the UI\n */\n updateBridgeQuoteRequestParams = async (\n paramsToUpdate: Partial<GenericQuoteRequest> & {\n walletAddress: GenericQuoteRequest['walletAddress'];\n },\n context: BridgePollingInput['context'],\n quoteRequestIndex: number = 0,\n quoteRequestCount: number = 1,\n ) => {\n // Guard against updating a quote request that doesn't exist\n if (quoteRequestIndex >= quoteRequestCount) {\n return;\n }\n this.#trackInputChangedEvents(\n paramsToUpdate,\n context.feature_id,\n quoteRequestIndex,\n );\n this.resetState(AbortReason.QuoteRequestUpdated, quoteRequestIndex);\n this.update((state) => {\n // Update only the specified quote request and keep the rest of the quote requests unchanged\n state.quoteRequest = state.quoteRequest\n .slice(0, quoteRequestIndex)\n .concat({\n ...DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest[0],\n ...paramsToUpdate,\n })\n .concat(\n state.quoteRequest.slice(quoteRequestIndex + 1, quoteRequestCount),\n );\n state.tokenSecurityTypeDestination =\n context.token_security_type_destination ?? null;\n });\n\n // BatchSell and Unified swaps both use the same polling logic so both validations should pass\n if (\n isValidQuoteRequest(paramsToUpdate) &&\n isValidBatchSellQuoteRequest(this.state.quoteRequest)\n ) {\n this.#quotesFirstFetched = Date.now();\n // Update the insufficientBal and resetApproval params for the quote request\n const quoteWithInsufficientBalAndResetApproval =\n await this.#appendInsufficientBalAndResetApproval(paramsToUpdate);\n this.update((state) => {\n state.quoteRequest[quoteRequestIndex] =\n quoteWithInsufficientBalAndResetApproval;\n });\n\n // Set refresh rate based on the source chain before starting polling\n this.setChainIntervalLength();\n this.startPolling({\n quoteRequests: this.state.quoteRequest,\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 featureId - The feature ID that maps to quoteParam overrides from LD\n * @param abortSignal - The abort signal to cancel all the requests\n * @returns A list of validated quotes\n */\n fetchQuotes = async (\n quoteRequest: GenericQuoteRequest,\n featureId: FeatureId,\n abortSignal: AbortSignal | null = null,\n ): Promise<(QuoteResponseV1 & 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.#trackQuoteValidationFailures(validationFailures, featureId);\n const srcChainIds = Array.from(\n new Set(baseQuotes.map((quote) => quote.quote.srcChainId)),\n ).filter(Boolean);\n\n const quotesWithFees =\n srcChainIds.length > 1 || srcChainIds.length === 0\n ? // Don't append fees if there are multiple srcChainIds\n baseQuotes\n : await appendFeesToQuotes(\n formatChainIdToCaip(srcChainIds[0]),\n baseQuotes,\n this.messenger,\n this.#getLayer1GasFee,\n this.#getMultichainSelectedAccount(quoteRequest.walletAddress),\n );\n\n return sortQuotes(quotesWithFees, featureId);\n };\n\n /**\n * Fetches gasless transaction data and fees for BatchSell quotes.\n * To use this in the clients, add a listener for the recommendedQuotes and call\n * this handler whenever they change.\n *\n * @param quotes - The quotes to fetch the gasless transaction data and fees for\n * @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature.\n */\n updateBatchSellTrades = async (\n quotes: (QuoteResponse | null)[],\n stxEnabled: boolean,\n ): Promise<void> => {\n this.#batchSellTradesAbortController?.abort(\n AbortReason.GaslessTxBatchFetched,\n );\n this.#batchSellTradesAbortController = new AbortController();\n\n this.update((state) => {\n // Set loading status again if recommended quotes are re-ordered\n state.batchSellTradesLoadingStatus = RequestStatus.LOADING;\n });\n\n try {\n const batchSellTradesResponse = await fetchBatchSellTrades(\n quotes,\n stxEnabled,\n this.#batchSellTradesAbortController.signal,\n this.#clientId,\n await this.#getJwt(),\n this.#fetchFn,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n this.#clientVersion,\n );\n\n this.update((state) => {\n state.batchSellTrades = batchSellTradesResponse;\n state.batchSellTradesLoadingStatus = RequestStatus.FETCHED;\n });\n\n // TODO if fee.asset.assetId is not in exchange rates, fetch the exchange rate and update the state\n } catch (error) {\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 AbortReason.GaslessTxBatchFetched,\n ].includes(error as AbortReason)\n ) {\n // Exit the function early to prevent other state updates\n return;\n }\n\n this.update((state) => {\n // Reset the batch sell trades if the fetch fails to avoid showing stale data\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n // Update loading status\n state.batchSellTradesLoadingStatus = RequestStatus.ERROR;\n });\n console.log(`Failed to fetch batch sell trades`, error);\n }\n };\n\n readonly #trackQuoteValidationFailures = (\n validationFailures: string[],\n featureId: FeatureId,\n ) => {\n if (validationFailures.length === 0) {\n return;\n }\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.QuotesValidationFailed,\n {\n feature_id: featureId,\n failures: validationFailures,\n location: this.#location,\n },\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 quoteRequests - The quote requests to fetch the exchange rates for\n */\n readonly #fetchAssetExchangeRates = async (\n quoteRequests: GenericQuoteRequest[],\n ) => {\n // Get unique assetIds for all quote requests\n const assetIds = new Set<CaipAssetType>(\n quoteRequests.flatMap((quoteRequest) =>\n [\n getAssetIdsForToken(\n quoteRequest.srcTokenAddress,\n quoteRequest.srcChainId,\n ),\n getAssetIdsForToken(\n quoteRequest.destTokenAddress,\n quoteRequest.destChainId,\n ),\n ].flat(),\n ),\n );\n\n const currency = this.#getUseAssetsControllerForRates()\n ? this.messenger.call('AssetsController:getExchangeRatesForBridge')\n .currentCurrency\n : this.messenger.call('CurrencyRateController:getState').currentCurrency;\n\n if (assetIds.size === 0) {\n return;\n }\n\n const pricesByAssetId = await fetchAssetPrices({\n assetIds,\n currencies: new Set([currency, 'usd']),\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 #appendInsufficientBalAndResetApproval = async (\n quoteRequest: GenericQuoteRequest,\n ) => {\n const isSrcChainNonEVM = isNonEvmChainId(quoteRequest.srcChainId);\n const providerConfig = isSrcChainNonEVM\n ? undefined\n : this.#getNetworkClientByChainId(\n formatChainIdToHex(quoteRequest.srcChainId),\n )?.configuration;\n\n let insufficientBal: boolean | undefined;\n let resetApproval: boolean = Boolean(quoteRequest.resetApproval);\n if (isSrcChainNonEVM) {\n // If the source chain is not an EVM network, use value from params\n insufficientBal = quoteRequest.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(quoteRequest);\n // Otherwise query the src token balance from the RPC provider\n insufficientBal =\n quoteRequest.insufficientBal ??\n (await this.#hasInsufficientBalance(quoteRequest));\n }\n\n return {\n ...quoteRequest,\n insufficientBal,\n resetApproval,\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 this.#batchSellTradesAbortController?.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: BridgeControllerMetricsLocation) => {\n this.#location = location;\n };\n\n /**\n * Returns the location/entry point for the current swap or bridge flow.\n *\n * @returns The entry point from which the user initiated the flow\n */\n getLocation = (): BridgeControllerMetricsLocation => {\n return this.#location;\n };\n\n setInputPrimaryDenomination = (\n inputPrimaryDenomination: InputPrimaryDenomination,\n ) => {\n this.update((state) => {\n state.inputPrimaryDenomination = inputPrimaryDenomination;\n });\n };\n\n resetState = (\n reason = AbortReason.ResetState,\n quoteRequestIndex: number | null = null,\n context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n ) => {\n this.stopPollingForQuotes(reason, context);\n this.update((state) => {\n // Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field\n if (quoteRequestIndex === null) {\n // Clear all requests if index is null\n state.quoteRequest = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest;\n } else {\n // Otherwise only clear the specified request\n state.quoteRequest = state.quoteRequest\n .slice(0, quoteRequestIndex)\n .concat(DEFAULT_BRIDGE_CONTROLLER_STATE.quoteRequest[0])\n .concat(state.quoteRequest.slice(quoteRequestIndex + 1));\n }\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 state.tokenWarnings = DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings;\n state.tokenSecurityTypeDestination =\n DEFAULT_BRIDGE_CONTROLLER_STATE.tokenSecurityTypeDestination;\n state.quoteStreamComplete =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n state.batchSellTradesLoadingStatus =\n DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTradesLoadingStatus;\n });\n };\n\n /**\n * Sets the interval length based on the source chain\n */\n setChainIntervalLength = () => {\n const { state } = this;\n // Assume that BatchSell quote requests all have the same source chain\n // Use the first one to determine refresh rate\n const { srcChainId } = state.quoteRequest[0];\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 quoteRequests,\n context,\n }: BridgePollingInput) => {\n this.#abortController?.abort(AbortReason.NewQuoteRequest);\n this.#batchSellTradesAbortController?.abort(AbortReason.NewQuoteRequest);\n\n this.#abortController = new AbortController();\n const quoteTraceStartTime = Date.now();\n const quoteTraceRequestId = uuid();\n const quoteAbortSignal = this.#abortController.signal;\n\n this.#fetchAssetExchangeRates(quoteRequests).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 const isBatchSellRequest = quoteRequests.length > 1;\n\n this.update((state) => {\n state.quoteFetchError = DEFAULT_BRIDGE_CONTROLLER_STATE.quoteFetchError;\n state.tokenWarnings = DEFAULT_BRIDGE_CONTROLLER_STATE.tokenWarnings;\n state.quoteStreamComplete =\n DEFAULT_BRIDGE_CONTROLLER_STATE.quoteStreamComplete;\n state.quotesLastFetched = Date.now();\n state.quotesLoadingStatus = RequestStatus.LOADING;\n // Prevent clients from displaying stale batch sell fees\n if (quoteRequests.length > 1) {\n state.batchSellTradesLoadingStatus = RequestStatus.LOADING;\n state.batchSellTrades = DEFAULT_BRIDGE_CONTROLLER_STATE.batchSellTrades;\n }\n });\n\n const jwt = await this.#getJwt();\n\n const [firstQuoteRequest] = quoteRequests;\n let traceResult: QuoteTraceResult = 'error';\n let traceName: TraceName = TraceName.BatchSellQuotesFetched;\n if (!isBatchSellRequest) {\n traceName = isCrossChain(\n firstQuoteRequest.srcChainId,\n firstQuoteRequest.destChainId,\n )\n ? TraceName.BridgeQuotesFetched\n : TraceName.SwapQuotesFetched;\n }\n const tracedProviders = new Set<string>();\n const traceWithoutImpact = (\n request: Omit<SwapTraceRequest<TraceName>, 'tags'>,\n ) => {\n try {\n this.#trace(\n {\n ...request,\n tags: {\n feature: BRIDGE_FEATURE_ID_TO_FEATURE_TAG[context.feature_id],\n },\n },\n () => undefined,\n );\n } catch {\n // Telemetry failures must not affect quote fetching or state updates.\n }\n };\n const traceProviderFirstResult = (\n providerData: Parameters<typeof formatProviderLabel>[0],\n ) => {\n const provider = formatProviderLabel(providerData);\n if (isBatchSellRequest || tracedProviders.has(provider)) {\n return;\n }\n tracedProviders.add(provider);\n // Provider telemetry must not delay quote processing.\n traceWithoutImpact({\n name: TraceName.QuoteProviderFirstResult,\n startTime: quoteTraceStartTime,\n data: {\n provider,\n feature_id: context.feature_id,\n request_id: quoteTraceRequestId,\n swap_type: getSwapType(\n firstQuoteRequest.srcChainId,\n firstQuoteRequest.destChainId,\n ),\n srcChainId: formatChainIdToCaip(firstQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(firstQuoteRequest.destChainId),\n result: 'success',\n },\n });\n };\n\n try {\n const selectedAccount = this.#getMultichainSelectedAccount(\n firstQuoteRequest.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 firstQuoteRequest.srcChainId,\n selectedAccount?.metadata?.snap?.id,\n );\n // Use SSE if enabled and return early\n if (shouldStream || isBatchSellRequest) {\n const quoteCount = await this.#handleQuoteStreaming({\n quoteRequests,\n featureId: context.feature_id,\n jwt,\n selectedAccount,\n signal: quoteAbortSignal,\n traceProviderFirstResult,\n });\n if (quoteAbortSignal.aborted) {\n traceResult = 'cancelled';\n return;\n }\n traceResult = quoteCount > 0 ? 'success' : 'no_quotes';\n } else {\n // Otherwise use regular fetch\n const quotes = await this.fetchQuotes(\n firstQuoteRequest,\n context.feature_id,\n quoteAbortSignal,\n );\n for (const quote of quotes) {\n traceProviderFirstResult(quote.quote);\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 = Date.now() - this.#quotesFirstFetched;\n }\n state.quotes = quotes.map(toQuoteResponseV2);\n state.quotesLoadingStatus = RequestStatus.FETCHED;\n });\n traceResult = quotes.length > 0 ? 'success' : 'no_quotes';\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 (isExpectedQuoteAbort(error, quoteAbortSignal)) {\n traceResult = 'cancelled';\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(UnifiedSwapBridgeEventName.QuotesError, {\n ...context,\n failure_phase: FailurePhase.Quote,\n error_code: getQuoteFetchErrorCode(error),\n });\n console.log(\n `Failed to ${shouldStream ? 'stream' : 'fetch'} bridge quotes`,\n error,\n );\n } finally {\n traceWithoutImpact({\n name: traceName,\n startTime: quoteTraceStartTime,\n data: {\n srcChainId: formatChainIdToCaip(firstQuoteRequest.srcChainId),\n destChainId: formatChainIdToCaip(firstQuoteRequest.destChainId),\n ...(!isBatchSellRequest && {\n request_id: quoteTraceRequestId,\n feature_id: context.feature_id,\n result: traceResult,\n }),\n },\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 const hasNoFundedQuoteRequests = quoteRequests.every(\n ({ insufficientBal }) => Boolean(insufficientBal),\n );\n\n if (\n hasNoFundedQuoteRequests\n ? // If all quote requests are insufficiently funded, stop polling\n // So if a BatchSell has at least 1 sufficiently funded quote request, polling continues\n true\n : // Otherwise continue polling until the maximum number of refreshes has been reached\n this.state.quotesRefreshCount >= maxRefreshCount\n ) {\n this.stopAllPolling();\n }\n };\n\n readonly #handleQuoteStreaming = async ({\n quoteRequests,\n featureId,\n jwt,\n selectedAccount,\n signal,\n traceProviderFirstResult,\n }: {\n quoteRequests: GenericQuoteRequest[];\n featureId: FeatureId;\n jwt?: string;\n selectedAccount?: InternalAccount;\n signal?: AbortSignal;\n traceProviderFirstResult: (\n providerData: Parameters<typeof formatProviderLabel>[0],\n ) => void;\n }): Promise<number> => {\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 quoteRequests,\n signal,\n featureId,\n this.#clientId,\n jwt,\n this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,\n {\n onQuoteValidationFailure: (validationFailures) =>\n this.#trackQuoteValidationFailures(validationFailures, featureId),\n onValidQuoteReceived: async (quote: QuoteResponse) => {\n const feeAppendPromise = (async () => {\n const quotesWithFees = await appendFeesToQuotes(\n quote.chainId,\n [quote],\n this.messenger,\n this.#getLayer1GasFee,\n selectedAccount,\n );\n if (quotesWithFees.length > 0) {\n validQuotesCounter += 1;\n traceProviderFirstResult(quote.quote);\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 onTokenWarning: (warning) => {\n this.update((state) => {\n const isDuplicate = state.tokenWarnings.some(\n (existing) => existing.feature_id === warning.feature_id,\n );\n if (!isDuplicate) {\n state.tokenWarnings = [...state.tokenWarnings, warning];\n }\n });\n },\n onComplete: (data) => {\n this.update((state) => {\n state.quoteStreamComplete = data;\n });\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 return validQuotesCounter;\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 // Assume that all quotes in a batch are for the same account\n const addressToUse =\n walletAddress ?? this.state.quoteRequest[0].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 = (\n quoteRequestIndex: number = 0,\n ): Omit<\n RequestMetadata,\n 'stx_enabled' | 'usd_amount_source' | 'security_warnings'\n > => {\n const quoteRequest = this.state.quoteRequest[quoteRequestIndex];\n const { walletAddress } = quoteRequest;\n const accountHardwareType = getAccountHardwareType(\n walletAddress\n ? this.#getMultichainSelectedAccount(walletAddress)\n : undefined,\n );\n\n return {\n slippage_limit: quoteRequest.slippage ?? 0,\n swap_type: getSwapTypeFromQuote(quoteRequest),\n custom_slippage: isCustomSlippage(quoteRequest.slippage),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\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 BridgeControllerMetricsEventName,\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n quoteRequestIndex: number = 0,\n ) => {\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 const inputPrimaryDenominationProperties = {\n input_primary_denomination: this.state.inputPrimaryDenomination,\n };\n const batchSellClientChainProperties = propertiesFromClient as Pick<\n RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellTokenPageViewed],\n 'chain_id_source' | 'chain_id_destination'\n >;\n const batchSellBaseProperties = {\n chain_id_source: batchSellClientChainProperties.chain_id_source,\n chain_id_destination: batchSellClientChainProperties.chain_id_destination,\n location: clientProps?.location ?? this.#location,\n };\n const quoteRequest = this.state.quoteRequest[quoteRequestIndex];\n switch (eventName) {\n case UnifiedSwapBridgeEventName.ButtonClicked:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.PageViewed:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case BatchSellMetricsEventName.BatchSellTokenPageViewed:\n return batchSellBaseProperties;\n case BatchSellMetricsEventName.BatchSellTokenPageContinueClicked: {\n const propsFromClient =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellTokenPageContinueClicked];\n return {\n ...batchSellBaseProperties,\n source_token_count: propsFromClient.source_token_addresses.length,\n source_token_symbols: propsFromClient.source_token_symbols,\n source_token_addresses: propsFromClient.source_token_addresses,\n };\n }\n case BatchSellMetricsEventName.BatchSellQuotePageViewed:\n case BatchSellMetricsEventName.BatchSellQuotePageReviewClicked: {\n const propsFromClient =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellQuotePageViewed];\n return {\n ...batchSellBaseProperties,\n source_token_count: propsFromClient.source_token_addresses.length,\n source_token_symbols: propsFromClient.source_token_symbols,\n source_token_addresses: propsFromClient.source_token_addresses,\n destination_token_symbol: propsFromClient.destination_token_symbol,\n destination_token_address: propsFromClient.destination_token_address,\n usd_amount_source_tokens: propsFromClient.usd_amount_source_tokens,\n usd_amount_source_total: propsFromClient.usd_amount_source_total,\n source_token_slippages: propsFromClient.source_token_slippages,\n };\n }\n case BatchSellMetricsEventName.BatchSellReviewModalSubmitted: {\n const reviewModalProperties =\n propertiesFromClient as RequiredEventContextFromClient[BatchSellMetricsEventName.BatchSellReviewModalSubmitted];\n return {\n ...batchSellBaseProperties,\n source_token_count:\n reviewModalProperties.source_token_addresses.length,\n source_token_symbols: reviewModalProperties.source_token_symbols,\n source_token_addresses: reviewModalProperties.source_token_addresses,\n destination_token_symbol:\n reviewModalProperties.destination_token_symbol,\n destination_token_address:\n reviewModalProperties.destination_token_address,\n usd_amount_source_tokens:\n reviewModalProperties.usd_amount_source_tokens,\n usd_amount_source_total:\n reviewModalProperties.usd_amount_source_total,\n source_token_slippages: reviewModalProperties.source_token_slippages,\n usd_quoted_gas: reviewModalProperties.usd_quoted_gas,\n usd_quoted_return: reviewModalProperties.usd_quoted_return,\n };\n }\n case UnifiedSwapBridgeEventName.FiatCryptoToggleClicked:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n swap_type: getSwapTypeFromQuote(quoteRequest),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesValidationFailed:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n refresh_count: this.state.quotesRefreshCount,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesReceived:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n refresh_count: this.state.quotesRefreshCount,\n has_sufficient_funds: !quoteRequest.insufficientBal,\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesRequested:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n has_sufficient_funds: !quoteRequest.insufficientBal,\n ...inputPrimaryDenominationProperties,\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.QuotesError:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n error_message: this.state.quoteFetchError,\n has_sufficient_funds: !quoteRequest.insufficientBal,\n failure_phase: FailurePhase.Quote,\n error_code: SwapBridgeErrorCode.QuoteFetchFailed,\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(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...propertiesFromClient,\n };\n case UnifiedSwapBridgeEventName.AllQuotesOpened:\n case UnifiedSwapBridgeEventName.AllQuotesSorted:\n case UnifiedSwapBridgeEventName.QuoteSelected:\n return {\n ...getRequestParams(\n quoteRequest,\n this.state.tokenSecurityTypeDestination,\n ),\n ...this.#getRequestMetadata(),\n ...this.#getQuoteFetchData(),\n ...baseProperties,\n };\n case UnifiedSwapBridgeEventName.AssetDetailTooltipClicked:\n case UnifiedSwapBridgeEventName.AssetPickerOpened:\n return baseProperties;\n // Inject `token_security_type_destination` from controller state so the\n // field is always present on this event. `baseProperties` (which spreads\n // `propertiesFromClient`) wins if the client supplies a value explicitly.\n case UnifiedSwapBridgeEventName.InputSourceDestinationSwitched:\n return {\n token_security_type_destination:\n this.state.tokenSecurityTypeDestination,\n ...baseProperties,\n };\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 featureId: FeatureId,\n quoteRequestIndex: number = 0,\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 this.state.quoteRequest[quoteRequestIndex] &&\n value !==\n this.state.quoteRequest[quoteRequestIndex][\n key as keyof GenericQuoteRequest\n ]\n ) {\n this.trackUnifiedSwapBridgeEvent(\n UnifiedSwapBridgeEventName.InputChanged,\n {\n input: inputKey,\n input_value: inputValue,\n location: this.#location,\n feature_id: featureId,\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 * @param quoteRequestIndex - The index of the quote request to track the event for\n * @example\n * this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.ActionOpened, {\n * location: MetaMetricsSwapsEventSource.MainView,\n * });\n */\n trackUnifiedSwapBridgeEvent = <\n EventName extends BridgeControllerMetricsEventName,\n >(\n eventName: EventName,\n propertiesFromClient: Pick<\n RequiredEventContextFromClient,\n EventName\n >[EventName],\n quoteRequestIndex: number = 0,\n ) => {\n try {\n const combinedPropertiesForEvent = this.#getEventProperties<EventName>(\n eventName,\n propertiesFromClient,\n quoteRequestIndex,\n );\n\n this.#trackMetaMetricsFn(\n eventName,\n combinedPropertiesForEvent as CrossChainSwapsEventProperties<EventName>,\n );\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,7 +1,36 @@
|
|
|
1
|
+
import { FeatureId } from '../validators/feature-flags.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sentry trace names published by the BridgeController
|
|
4
|
+
*/
|
|
1
5
|
export declare enum TraceName {
|
|
2
6
|
BatchSellQuotesFetched = "Batch Sell Quotes Fetched",
|
|
3
7
|
BridgeQuotesFetched = "Bridge Quotes Fetched",
|
|
4
8
|
QuoteProviderFirstResult = "Quote Provider First Result",
|
|
5
|
-
SwapQuotesFetched = "Swap Quotes Fetched"
|
|
9
|
+
SwapQuotesFetched = "Swap Quotes Fetched",
|
|
10
|
+
SwapQuoteFetch = "Swap Quote Fetch",
|
|
11
|
+
SwapTokenSearch = "Swap Token Search",
|
|
12
|
+
SwapPopularTokensFetch = "Swap Popular Tokens Fetch",
|
|
13
|
+
SwapViewLoaded = "Swap View Loaded",
|
|
14
|
+
BridgeBalancesUpdated = "Bridge Balances Updated"
|
|
6
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Sentry tags used to identify swap/bridge features
|
|
18
|
+
*/
|
|
19
|
+
export declare enum TraceFeatureTag {
|
|
20
|
+
SWAP = "swap",
|
|
21
|
+
BATCH_SELL = "batch_sell",
|
|
22
|
+
QUICK_BUY = "quick_buy",
|
|
23
|
+
PERPS = "perps",
|
|
24
|
+
DAPP_SWAP = "dapp_swap",
|
|
25
|
+
LIMIT_ORDER = "limit_order",
|
|
26
|
+
RECURRING_ORDER = "recurring_order"
|
|
27
|
+
}
|
|
28
|
+
export declare enum TraceOperation {
|
|
29
|
+
BridgeScreenPerformance = "bridge.screen.performance",
|
|
30
|
+
BridgeDataFetch = "bridge.data_fetch"
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Map of FeatureId to Sentry Trace Feature Tag
|
|
34
|
+
*/
|
|
35
|
+
export declare const BRIDGE_FEATURE_ID_TO_FEATURE_TAG: Record<FeatureId, TraceFeatureTag>;
|
|
7
36
|
//# sourceMappingURL=traces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../../src/constants/traces.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,sBAAsB,8BAA8B;IACpD,mBAAmB,0BAA0B;IAC7C,wBAAwB,gCAAgC;IACxD,iBAAiB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../../src/constants/traces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D;;GAEG;AACH,oBAAY,SAAS;IACnB,sBAAsB,8BAA8B;IACpD,mBAAmB,0BAA0B;IAC7C,wBAAwB,gCAAgC;IACxD,iBAAiB,wBAAwB;IACzC,cAAc,qBAAqB;IACnC,eAAe,sBAAsB;IACrC,sBAAsB,8BAA8B;IACpD,cAAc,qBAAqB;IACnC,qBAAqB,4BAA4B;CAClD;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;CACpC;AAED,oBAAY,cAAc;IACxB,uBAAuB,8BAA8B;IACrD,eAAe,sBAAsB;CACtC;AAED;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAE,MAAM,CACnD,SAAS,EACT,eAAe,CAYhB,CAAC"}
|
package/dist/constants/traces.js
CHANGED
|
@@ -1,8 +1,50 @@
|
|
|
1
|
+
import { FeatureId } from '../validators/feature-flags.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sentry trace names published by the BridgeController
|
|
4
|
+
*/
|
|
1
5
|
export var TraceName;
|
|
2
6
|
(function (TraceName) {
|
|
3
7
|
TraceName["BatchSellQuotesFetched"] = "Batch Sell Quotes Fetched";
|
|
4
8
|
TraceName["BridgeQuotesFetched"] = "Bridge Quotes Fetched";
|
|
5
9
|
TraceName["QuoteProviderFirstResult"] = "Quote Provider First Result";
|
|
6
10
|
TraceName["SwapQuotesFetched"] = "Swap Quotes Fetched";
|
|
11
|
+
TraceName["SwapQuoteFetch"] = "Swap Quote Fetch";
|
|
12
|
+
TraceName["SwapTokenSearch"] = "Swap Token Search";
|
|
13
|
+
TraceName["SwapPopularTokensFetch"] = "Swap Popular Tokens Fetch";
|
|
14
|
+
TraceName["SwapViewLoaded"] = "Swap View Loaded";
|
|
15
|
+
TraceName["BridgeBalancesUpdated"] = "Bridge Balances Updated";
|
|
7
16
|
})(TraceName || (TraceName = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Sentry tags used to identify swap/bridge features
|
|
19
|
+
*/
|
|
20
|
+
export var TraceFeatureTag;
|
|
21
|
+
(function (TraceFeatureTag) {
|
|
22
|
+
TraceFeatureTag["SWAP"] = "swap";
|
|
23
|
+
TraceFeatureTag["BATCH_SELL"] = "batch_sell";
|
|
24
|
+
TraceFeatureTag["QUICK_BUY"] = "quick_buy";
|
|
25
|
+
TraceFeatureTag["PERPS"] = "perps";
|
|
26
|
+
TraceFeatureTag["DAPP_SWAP"] = "dapp_swap";
|
|
27
|
+
TraceFeatureTag["LIMIT_ORDER"] = "limit_order";
|
|
28
|
+
TraceFeatureTag["RECURRING_ORDER"] = "recurring_order";
|
|
29
|
+
})(TraceFeatureTag || (TraceFeatureTag = {}));
|
|
30
|
+
export var TraceOperation;
|
|
31
|
+
(function (TraceOperation) {
|
|
32
|
+
TraceOperation["BridgeScreenPerformance"] = "bridge.screen.performance";
|
|
33
|
+
TraceOperation["BridgeDataFetch"] = "bridge.data_fetch";
|
|
34
|
+
})(TraceOperation || (TraceOperation = {}));
|
|
35
|
+
/**
|
|
36
|
+
* Map of FeatureId to Sentry Trace Feature Tag
|
|
37
|
+
*/
|
|
38
|
+
export const BRIDGE_FEATURE_ID_TO_FEATURE_TAG = {
|
|
39
|
+
[FeatureId.UNIFIED_SWAP_BRIDGE]: TraceFeatureTag.SWAP,
|
|
40
|
+
[FeatureId.BATCH_SELL]: TraceFeatureTag.BATCH_SELL,
|
|
41
|
+
[FeatureId.PERPS]: TraceFeatureTag.PERPS,
|
|
42
|
+
[FeatureId.QUICK_BUY_FOLLOW_TRADING]: TraceFeatureTag.QUICK_BUY,
|
|
43
|
+
[FeatureId.QUICK_BUY_EXPLORE]: TraceFeatureTag.QUICK_BUY,
|
|
44
|
+
[FeatureId.QUICK_BUY_TOKEN_DETAILS]: TraceFeatureTag.QUICK_BUY,
|
|
45
|
+
[FeatureId.DAPP_SWAP]: TraceFeatureTag.DAPP_SWAP,
|
|
46
|
+
[FeatureId.LIMIT_ORDER]: TraceFeatureTag.LIMIT_ORDER,
|
|
47
|
+
[FeatureId.RECURRING_ORDER]: TraceFeatureTag.RECURRING_ORDER,
|
|
48
|
+
[FeatureId.UNKNOWN]: TraceFeatureTag.SWAP,
|
|
49
|
+
};
|
|
8
50
|
//# sourceMappingURL=traces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../src/constants/traces.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"traces.js","sourceRoot":"","sources":["../../src/constants/traces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAN,IAAY,SAUX;AAVD,WAAY,SAAS;IACnB,iEAAoD,CAAA;IACpD,0DAA6C,CAAA;IAC7C,qEAAwD,CAAA;IACxD,sDAAyC,CAAA;IACzC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,iEAAoD,CAAA;IACpD,gDAAmC,CAAA;IACnC,8DAAiD,CAAA;AACnD,CAAC,EAVW,SAAS,KAAT,SAAS,QAUpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAQX;AARD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,4CAAyB,CAAA;IACzB,0CAAuB,CAAA;IACvB,kCAAe,CAAA;IACf,0CAAuB,CAAA;IACvB,8CAA2B,CAAA;IAC3B,sDAAmC,CAAA;AACrC,CAAC,EARW,eAAe,KAAf,eAAe,QAQ1B;AAED,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uEAAqD,CAAA;IACrD,uDAAqC,CAAA;AACvC,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAGzC;IACF,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE,eAAe,CAAC,IAAI;IACrD,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,UAAU;IAClD,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,KAAK;IACxC,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAAE,eAAe,CAAC,SAAS;IAC/D,CAAC,SAAS,CAAC,iBAAiB,CAAC,EAAE,eAAe,CAAC,SAAS;IACxD,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,eAAe,CAAC,SAAS;IAC9D,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,SAAS;IAChD,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,WAAW;IACpD,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,eAAe;IAC5D,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI;CAC1C,CAAC","sourcesContent":["import { FeatureId } from '../validators/feature-flags.js';\n\n/**\n * Sentry trace names published by the BridgeController\n */\nexport enum TraceName {\n BatchSellQuotesFetched = 'Batch Sell Quotes Fetched',\n BridgeQuotesFetched = 'Bridge Quotes Fetched',\n QuoteProviderFirstResult = 'Quote Provider First Result',\n SwapQuotesFetched = 'Swap Quotes Fetched',\n SwapQuoteFetch = 'Swap Quote Fetch',\n SwapTokenSearch = 'Swap Token Search',\n SwapPopularTokensFetch = 'Swap Popular Tokens Fetch',\n SwapViewLoaded = 'Swap View Loaded',\n BridgeBalancesUpdated = 'Bridge Balances Updated',\n}\n\n/**\n * Sentry tags used to identify swap/bridge features\n */\nexport enum TraceFeatureTag {\n SWAP = 'swap',\n BATCH_SELL = 'batch_sell',\n QUICK_BUY = 'quick_buy',\n PERPS = 'perps',\n DAPP_SWAP = 'dapp_swap',\n LIMIT_ORDER = 'limit_order',\n RECURRING_ORDER = 'recurring_order',\n}\n\nexport enum TraceOperation {\n BridgeScreenPerformance = 'bridge.screen.performance',\n BridgeDataFetch = 'bridge.data_fetch',\n}\n\n/**\n * Map of FeatureId to Sentry Trace Feature Tag\n */\nexport const BRIDGE_FEATURE_ID_TO_FEATURE_TAG: Record<\n FeatureId,\n TraceFeatureTag\n> = {\n [FeatureId.UNIFIED_SWAP_BRIDGE]: TraceFeatureTag.SWAP,\n [FeatureId.BATCH_SELL]: TraceFeatureTag.BATCH_SELL,\n [FeatureId.PERPS]: TraceFeatureTag.PERPS,\n [FeatureId.QUICK_BUY_FOLLOW_TRADING]: TraceFeatureTag.QUICK_BUY,\n [FeatureId.QUICK_BUY_EXPLORE]: TraceFeatureTag.QUICK_BUY,\n [FeatureId.QUICK_BUY_TOKEN_DETAILS]: TraceFeatureTag.QUICK_BUY,\n [FeatureId.DAPP_SWAP]: TraceFeatureTag.DAPP_SWAP,\n [FeatureId.LIMIT_ORDER]: TraceFeatureTag.LIMIT_ORDER,\n [FeatureId.RECURRING_ORDER]: TraceFeatureTag.RECURRING_ORDER,\n [FeatureId.UNKNOWN]: TraceFeatureTag.SWAP,\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { hasSufficientGasForQuote } from './utils/quote-warnings/insufficient-ga
|
|
|
8
8
|
export { hasNetworkFee } from './utils/quote-warnings/network-fee-unavailable.js';
|
|
9
9
|
export { getAccountHardwareType, formatProviderLabel, getRequestParams, getSwapType, isHardwareWallet, isCustomSlippage, getQuotesReceivedProperties, } from './utils/metrics/properties.js';
|
|
10
10
|
export { getQuoteFetchErrorCode } from './utils/metrics/failure-telemetry.js';
|
|
11
|
-
export type { ChainConfiguration, L1GasFees, NonEvmFees, GasMultiplierByChainId, FeatureFlagResponse, GenericQuoteRequest, BatchSellTradesResponse, GaslessProperties, SimulatedGasFeeLimits, Step, RefuelData, FeeData, Intent, IntentOrderLike, BridgeControllerState, InputPrimaryDenomination, BridgeControllerAction, BridgeControllerActions, BridgeControllerEvents, BridgeControllerMessenger, FeatureFlagsPlatformConfig, TxFeeGasLimits, TokenFeature, QuoteStreamCompleteData, BridgeControllerGetStateAction, BridgeControllerStateChangeEvent, DeepPartial, } from './types.js';
|
|
11
|
+
export type { ChainConfiguration, L1GasFees, NonEvmFees, GasMultiplierByChainId, FeatureFlagResponse, GenericQuoteRequest, BatchSellTradesResponse, GaslessProperties, SimulatedGasFeeLimits, Step, RefuelData, FeeData, Intent, IntentOrderLike, BridgeControllerState, InputPrimaryDenomination, BridgeControllerAction, BridgeControllerActions, BridgeControllerEvents, BridgeControllerMessenger, FeatureFlagsPlatformConfig, TxFeeGasLimits, TokenFeature, QuoteStreamCompleteData, BridgeControllerGetStateAction, BridgeControllerStateChangeEvent, DeepPartial, SwapTraceRequest, SwapTraceFunction, SwapRelatedTraceName, } from './types.js';
|
|
12
12
|
export { type QuoteMetadata, type TokenAmountValues, QuoteMetadataMigrationPhase, } from './utils/quote-metadata/types.js';
|
|
13
13
|
export { validateQuoteResponseV1, QuoteResponseSchemaV1, type QuoteResponseV1, } from './validators/quote-response-v1.js';
|
|
14
14
|
export { mergeQuoteMetadata } from './utils/quote-metadata/merge.js';
|
|
@@ -57,6 +57,7 @@ export { appendFeesToQuotes } from './utils/quote-fees.js';
|
|
|
57
57
|
export { formatChainIdToCaip, formatChainIdToHex, formatAddressToCaipReference, formatAddressToAssetId, formatChainIdToDec, } from './utils/caip-formatters.js';
|
|
58
58
|
export { extractTradeData } from './utils/trade-utils.js';
|
|
59
59
|
export { selectBridgeQuotes, selectBatchSellQuotes, selectBatchSellTrades, selectDefaultSlippagePercentage, type BridgeAppState, selectExchangeRateByAssetId, selectIsQuoteExpired, selectBridgeFeatureFlags, selectMinimumBalanceForRentExemptionInSOL, selectTokenWarnings, } from './selectors.js';
|
|
60
|
+
export { BRIDGE_FEATURE_ID_TO_FEATURE_TAG, TraceFeatureTag as SwapFeatureTag, } from './constants/traces.js';
|
|
60
61
|
export { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge.js';
|
|
61
62
|
export { getBridgeFeatureFlags } from './utils/feature-flags.js';
|
|
62
63
|
export { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,kCAAkC,EAClC,wBAAwB,EACxB,iBAAiB,EACjB,2BAA2B,EAC3B,aAAa,EACb,YAAY,EACZ,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AACrF,YAAY,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAEpF,YAAY,EACV,mBAAmB,EACnB,8BAA8B,EAC9B,8BAA8B,EAC9B,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sDAAsD,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAElF,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,YAAY,EACV,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,iBA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M,gBAAgB,CAAC;AAExB,OAAO,EACL,gCAAgC,EAChC,eAAe,IAAI,cAAc,GAClC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { appendFeesToQuotes } from './utils/quote-fees.js';
|
|
|
43
43
|
export { formatChainIdToCaip, formatChainIdToHex, formatAddressToCaipReference, formatAddressToAssetId, formatChainIdToDec, } from './utils/caip-formatters.js';
|
|
44
44
|
export { extractTradeData } from './utils/trade-utils.js';
|
|
45
45
|
export { selectBridgeQuotes, selectBatchSellQuotes, selectBatchSellTrades, selectDefaultSlippagePercentage, selectExchangeRateByAssetId, selectIsQuoteExpired, selectBridgeFeatureFlags, selectMinimumBalanceForRentExemptionInSOL, selectTokenWarnings, } from './selectors.js';
|
|
46
|
+
export { BRIDGE_FEATURE_ID_TO_FEATURE_TAG, TraceFeatureTag as SwapFeatureTag, } from './constants/traces.js';
|
|
46
47
|
export { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge.js';
|
|
47
48
|
export { getBridgeFeatureFlags } from './utils/feature-flags.js';
|
|
48
49
|
export { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,kCAAkC,EAClC,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,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAE/B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,yCAAyC,EACzC,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,GAEZ,MAAM,kBAAkB,CAAC","sourcesContent":["export { BridgeController } from './bridge-controller.js';\n\nexport {\n BatchSellMetricsEventName,\n UnifiedSwapBridgeEventName,\n BATCH_SELL_EVENT_CATEGORY,\n UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY,\n BatchSellMetricsLocation,\n InputAmountPreset,\n MetaMetricsSwapsEventSource,\n PollingStatus,\n FailurePhase,\n SwapBridgeErrorCode,\n} from './utils/metrics/constants.js';\n\nexport type { BridgeControllerMetricsEventName } from './utils/metrics/constants.js';\nexport type { BridgeControllerMetricsLocation } from './utils/metrics/constants.js';\n\nexport type {\n AccountHardwareType,\n RequiredEventContextFromClient,\n CrossChainSwapsEventProperties,\n TradeData,\n RequestParams,\n RequestMetadata,\n TxStatusData,\n QuoteFetchData,\n InputPrimaryDenominationData,\n HashPresenceData,\n FailureTelemetryData,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from './utils/metrics/types.js';\n\nexport type { QuoteWarning } from './utils/quote-warnings/types.js';\nexport { hasSufficientGasForQuote } from './utils/quote-warnings/insufficient-gas-for-quote.js';\nexport { hasNetworkFee } from './utils/quote-warnings/network-fee-unavailable.js';\n\nexport {\n getAccountHardwareType,\n formatProviderLabel,\n getRequestParams,\n getSwapType,\n isHardwareWallet,\n isCustomSlippage,\n getQuotesReceivedProperties,\n} from './utils/metrics/properties.js';\n\nexport { getQuoteFetchErrorCode } from './utils/metrics/failure-telemetry.js';\n\nexport type {\n ChainConfiguration,\n L1GasFees,\n NonEvmFees,\n GasMultiplierByChainId,\n FeatureFlagResponse,\n GenericQuoteRequest,\n BatchSellTradesResponse,\n GaslessProperties,\n SimulatedGasFeeLimits,\n Step,\n RefuelData,\n FeeData,\n Intent,\n IntentOrderLike,\n BridgeControllerState,\n InputPrimaryDenomination,\n BridgeControllerAction,\n BridgeControllerActions,\n BridgeControllerEvents,\n BridgeControllerMessenger,\n FeatureFlagsPlatformConfig,\n TxFeeGasLimits,\n TokenFeature,\n QuoteStreamCompleteData,\n BridgeControllerGetStateAction,\n BridgeControllerStateChangeEvent,\n DeepPartial,\n} from './types.js';\n\nexport {\n type QuoteMetadata,\n type TokenAmountValues,\n QuoteMetadataMigrationPhase,\n} from './utils/quote-metadata/types.js';\nexport {\n validateQuoteResponseV1,\n QuoteResponseSchemaV1,\n type QuoteResponseV1,\n} from './validators/quote-response-v1.js';\nexport { mergeQuoteMetadata } from './utils/quote-metadata/merge.js';\n\nexport {\n AssetType,\n SortOrder,\n ChainId,\n RequestStatus,\n StatusTypes,\n} from './types.js';\n\nexport type {\n BridgeControllerUpdateBridgeQuoteRequestParamsAction,\n BridgeControllerFetchQuotesAction,\n BridgeControllerStopPollingForQuotesAction,\n BridgeControllerSetLocationAction,\n BridgeControllerGetLocationAction,\n BridgeControllerSetInputPrimaryDenominationAction,\n BridgeControllerResetStateAction,\n BridgeControllerSetChainIntervalLengthAction,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerUpdateBatchSellTradesAction,\n} from './bridge-controller-method-action-types.js';\n\nexport { AbortReason } from './utils/metrics/constants.js';\n\nexport type {\n TxData,\n BitcoinTradeData,\n TronTradeData,\n StellarTradeData,\n Trade,\n} from './validators/trade.js';\nexport {\n isBitcoinTrade,\n isTronTrade,\n isEvmTxData,\n isStellarTrade,\n} from './validators/trade.js';\nexport {\n validateQuoteResponse,\n type QuoteResponse,\n isQuoteResponseV2,\n} from './validators/quote-response.js';\nexport type { Quote } from './validators/quote.js';\nexport { FeeType, DiscountType } from './validators/quote.js';\nexport { ActionTypes } from './validators/step.js';\nexport { toQuoteResponseV1 } from './coercers/quote-response-v2-to-v1.js';\nexport { toQuoteResponseV2 } from './coercers/quote-response-v1-to-v2.js';\n\nexport { toQuoteMetadataV1 } from './utils/quote-metadata/to-quote-metadata-v1.js';\nexport { toQuoteMetadataV2 } from './utils/quote-metadata/to-quote-metadata-v2.js';\n\nexport {\n sumAmounts,\n calcAtomicTokenAmount,\n calcNormalizedTokenAmount,\n} from './utils/number-formatters.js';\nexport { assetIdsMatch } from './utils/assets.js';\n\nexport {\n validateQuoteStreamComplete,\n QuoteStreamCompleteReason,\n} from './validators/quote-stream-complete.js';\nexport { BatchSellTransactionType } from './validators/batch-sell.js';\nexport {\n AmountsAndAssetSchema,\n type AmountsAndAsset,\n} from './validators/amount-and-asset.js';\nexport { TokenFeatureType } from './validators/token-feature.js';\nexport type {\n BridgeAsset,\n BridgeAssetV2,\n MinimalAsset,\n} from './validators/bridge-asset.js';\nexport {\n BridgeAssetSchema,\n validateBridgeAsset,\n validateBridgeAssetV2,\n MinimalAssetSchema,\n BridgeAssetV2Schema,\n BridgeAssetSecurityDataType,\n} from './validators/bridge-asset.js';\nexport { FeatureId } from './validators/feature-flags.js';\nexport { toBridgeAssetV2 } from './coercers/quote-response-v1-to-v2.js';\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_UAT_API_BASE_URL,\n BRIDGE_PROD_API_BASE_URL,\n} from './constants/bridge.js';\n\nexport type { AllowedBridgeChainIds } from './constants/bridge.js';\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.js';\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.js';\n\nexport {\n MetricsActionType,\n MetricsSwapType,\n} from './utils/metrics/constants.js';\n\nexport {\n isEthUsdt,\n isNativeAddress,\n isSolanaChainId,\n isBitcoinChainId,\n isTronChainId,\n isStellarChainId,\n isNonEvmChainId,\n getNativeAssetForChainId,\n getDefaultBridgeControllerState,\n isCrossChain,\n} from './utils/bridge.js';\n\nexport {\n isValidQuoteRequest,\n isValidBatchSellQuoteRequest,\n} from './validators/quote-request.js';\n\nexport {\n calcSlippagePercentage,\n calcQuoteMetadata,\n} from './utils/quote-metadata/calculators.js';\n\nexport { calcLatestSrcBalance } from './utils/balance.js';\n\nexport {\n fetchBridgeTokens,\n getClientHeaders,\n fetchBridgeQuoteStream,\n} from './utils/fetch.js';\n\nexport { appendFeesToQuotes } from './utils/quote-fees.js';\n\nexport {\n formatChainIdToCaip,\n formatChainIdToHex,\n formatAddressToCaipReference,\n formatAddressToAssetId,\n formatChainIdToDec,\n} from './utils/caip-formatters.js';\n\nexport { extractTradeData } from './utils/trade-utils.js';\n\nexport {\n selectBridgeQuotes,\n selectBatchSellQuotes,\n selectBatchSellTrades,\n selectDefaultSlippagePercentage,\n type BridgeAppState,\n selectExchangeRateByAssetId,\n selectIsQuoteExpired,\n selectBridgeFeatureFlags,\n selectMinimumBalanceForRentExemptionInSOL,\n selectTokenWarnings,\n} from './selectors.js';\n\nexport { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge.js';\n\nexport { getBridgeFeatureFlags } from './utils/feature-flags.js';\n\nexport { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage.js';\n\nexport {\n isValidSwapsContractAddress,\n getSwapsContractAddress,\n fetchTokens,\n type SwapsToken,\n} from './utils/swaps.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,kCAAkC,EAClC,wBAAwB,EACxB,iBAAiB,EACjB,2BAA2B,EAC3B,aAAa,EACb,YAAY,EACZ,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AAsBtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sDAAsD,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAElF,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B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AkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAE/B,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,yCAAyC,EACzC,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,gCAAgC,EAChC,eAAe,IAAI,cAAc,GAClC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,GAEZ,MAAM,kBAAkB,CAAC","sourcesContent":["export { BridgeController } from './bridge-controller.js';\n\nexport {\n BatchSellMetricsEventName,\n UnifiedSwapBridgeEventName,\n BATCH_SELL_EVENT_CATEGORY,\n UNIFIED_SWAP_BRIDGE_EVENT_CATEGORY,\n BatchSellMetricsLocation,\n InputAmountPreset,\n MetaMetricsSwapsEventSource,\n PollingStatus,\n FailurePhase,\n SwapBridgeErrorCode,\n} from './utils/metrics/constants.js';\n\nexport type { BridgeControllerMetricsEventName } from './utils/metrics/constants.js';\nexport type { BridgeControllerMetricsLocation } from './utils/metrics/constants.js';\n\nexport type {\n AccountHardwareType,\n RequiredEventContextFromClient,\n CrossChainSwapsEventProperties,\n TradeData,\n RequestParams,\n RequestMetadata,\n TxStatusData,\n QuoteFetchData,\n InputPrimaryDenominationData,\n HashPresenceData,\n FailureTelemetryData,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from './utils/metrics/types.js';\n\nexport type { QuoteWarning } from './utils/quote-warnings/types.js';\nexport { hasSufficientGasForQuote } from './utils/quote-warnings/insufficient-gas-for-quote.js';\nexport { hasNetworkFee } from './utils/quote-warnings/network-fee-unavailable.js';\n\nexport {\n getAccountHardwareType,\n formatProviderLabel,\n getRequestParams,\n getSwapType,\n isHardwareWallet,\n isCustomSlippage,\n getQuotesReceivedProperties,\n} from './utils/metrics/properties.js';\n\nexport { getQuoteFetchErrorCode } from './utils/metrics/failure-telemetry.js';\n\nexport type {\n ChainConfiguration,\n L1GasFees,\n NonEvmFees,\n GasMultiplierByChainId,\n FeatureFlagResponse,\n GenericQuoteRequest,\n BatchSellTradesResponse,\n GaslessProperties,\n SimulatedGasFeeLimits,\n Step,\n RefuelData,\n FeeData,\n Intent,\n IntentOrderLike,\n BridgeControllerState,\n InputPrimaryDenomination,\n BridgeControllerAction,\n BridgeControllerActions,\n BridgeControllerEvents,\n BridgeControllerMessenger,\n FeatureFlagsPlatformConfig,\n TxFeeGasLimits,\n TokenFeature,\n QuoteStreamCompleteData,\n BridgeControllerGetStateAction,\n BridgeControllerStateChangeEvent,\n DeepPartial,\n SwapTraceRequest,\n SwapTraceFunction,\n SwapRelatedTraceName,\n} from './types.js';\n\nexport {\n type QuoteMetadata,\n type TokenAmountValues,\n QuoteMetadataMigrationPhase,\n} from './utils/quote-metadata/types.js';\nexport {\n validateQuoteResponseV1,\n QuoteResponseSchemaV1,\n type QuoteResponseV1,\n} from './validators/quote-response-v1.js';\nexport { mergeQuoteMetadata } from './utils/quote-metadata/merge.js';\n\nexport {\n AssetType,\n SortOrder,\n ChainId,\n RequestStatus,\n StatusTypes,\n} from './types.js';\n\nexport type {\n BridgeControllerUpdateBridgeQuoteRequestParamsAction,\n BridgeControllerFetchQuotesAction,\n BridgeControllerStopPollingForQuotesAction,\n BridgeControllerSetLocationAction,\n BridgeControllerGetLocationAction,\n BridgeControllerSetInputPrimaryDenominationAction,\n BridgeControllerResetStateAction,\n BridgeControllerSetChainIntervalLengthAction,\n BridgeControllerTrackUnifiedSwapBridgeEventAction,\n BridgeControllerUpdateBatchSellTradesAction,\n} from './bridge-controller-method-action-types.js';\n\nexport { AbortReason } from './utils/metrics/constants.js';\n\nexport type {\n TxData,\n BitcoinTradeData,\n TronTradeData,\n StellarTradeData,\n Trade,\n} from './validators/trade.js';\nexport {\n isBitcoinTrade,\n isTronTrade,\n isEvmTxData,\n isStellarTrade,\n} from './validators/trade.js';\nexport {\n validateQuoteResponse,\n type QuoteResponse,\n isQuoteResponseV2,\n} from './validators/quote-response.js';\nexport type { Quote } from './validators/quote.js';\nexport { FeeType, DiscountType } from './validators/quote.js';\nexport { ActionTypes } from './validators/step.js';\nexport { toQuoteResponseV1 } from './coercers/quote-response-v2-to-v1.js';\nexport { toQuoteResponseV2 } from './coercers/quote-response-v1-to-v2.js';\n\nexport { toQuoteMetadataV1 } from './utils/quote-metadata/to-quote-metadata-v1.js';\nexport { toQuoteMetadataV2 } from './utils/quote-metadata/to-quote-metadata-v2.js';\n\nexport {\n sumAmounts,\n calcAtomicTokenAmount,\n calcNormalizedTokenAmount,\n} from './utils/number-formatters.js';\nexport { assetIdsMatch } from './utils/assets.js';\n\nexport {\n validateQuoteStreamComplete,\n QuoteStreamCompleteReason,\n} from './validators/quote-stream-complete.js';\nexport { BatchSellTransactionType } from './validators/batch-sell.js';\nexport {\n AmountsAndAssetSchema,\n type AmountsAndAsset,\n} from './validators/amount-and-asset.js';\nexport { TokenFeatureType } from './validators/token-feature.js';\nexport type {\n BridgeAsset,\n BridgeAssetV2,\n MinimalAsset,\n} from './validators/bridge-asset.js';\nexport {\n BridgeAssetSchema,\n validateBridgeAsset,\n validateBridgeAssetV2,\n MinimalAssetSchema,\n BridgeAssetV2Schema,\n BridgeAssetSecurityDataType,\n} from './validators/bridge-asset.js';\nexport { FeatureId } from './validators/feature-flags.js';\nexport { toBridgeAssetV2 } from './coercers/quote-response-v1-to-v2.js';\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_UAT_API_BASE_URL,\n BRIDGE_PROD_API_BASE_URL,\n} from './constants/bridge.js';\n\nexport type { AllowedBridgeChainIds } from './constants/bridge.js';\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.js';\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.js';\n\nexport {\n MetricsActionType,\n MetricsSwapType,\n} from './utils/metrics/constants.js';\n\nexport {\n isEthUsdt,\n isNativeAddress,\n isSolanaChainId,\n isBitcoinChainId,\n isTronChainId,\n isStellarChainId,\n isNonEvmChainId,\n getNativeAssetForChainId,\n getDefaultBridgeControllerState,\n isCrossChain,\n} from './utils/bridge.js';\n\nexport {\n isValidQuoteRequest,\n isValidBatchSellQuoteRequest,\n} from './validators/quote-request.js';\n\nexport {\n calcSlippagePercentage,\n calcQuoteMetadata,\n} from './utils/quote-metadata/calculators.js';\n\nexport { calcLatestSrcBalance } from './utils/balance.js';\n\nexport {\n fetchBridgeTokens,\n getClientHeaders,\n fetchBridgeQuoteStream,\n} from './utils/fetch.js';\n\nexport { appendFeesToQuotes } from './utils/quote-fees.js';\n\nexport {\n formatChainIdToCaip,\n formatChainIdToHex,\n formatAddressToCaipReference,\n formatAddressToAssetId,\n formatChainIdToDec,\n} from './utils/caip-formatters.js';\n\nexport { extractTradeData } from './utils/trade-utils.js';\n\nexport {\n selectBridgeQuotes,\n selectBatchSellQuotes,\n selectBatchSellTrades,\n selectDefaultSlippagePercentage,\n type BridgeAppState,\n selectExchangeRateByAssetId,\n selectIsQuoteExpired,\n selectBridgeFeatureFlags,\n selectMinimumBalanceForRentExemptionInSOL,\n selectTokenWarnings,\n} from './selectors.js';\n\nexport {\n BRIDGE_FEATURE_ID_TO_FEATURE_TAG,\n TraceFeatureTag as SwapFeatureTag,\n} from './constants/traces.js';\n\nexport { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge.js';\n\nexport { getBridgeFeatureFlags } from './utils/feature-flags.js';\n\nexport { BRIDGE_DEFAULT_SLIPPAGE } from './utils/slippage.js';\n\nexport {\n isValidSwapsContractAddress,\n getSwapsContractAddress,\n fetchTokens,\n type SwapsToken,\n} from './utils/swaps.js';\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AccountsControllerGetAccountByAddressAction } from '@metamask/acco
|
|
|
2
2
|
import type { AssetsControllerGetExchangeRatesForBridgeAction } from '@metamask/assets-controller';
|
|
3
3
|
import type { CurrencyRateControllerGetStateAction } from '@metamask/assets-controllers';
|
|
4
4
|
import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
|
|
5
|
+
import type { TraceRequest } from '@metamask/controller-utils';
|
|
5
6
|
import type { Messenger } from '@metamask/messenger';
|
|
6
7
|
import type { NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller';
|
|
7
8
|
import type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';
|
|
@@ -12,6 +13,8 @@ import type { CaipAccountId, CaipAssetId, CaipAssetType, CaipChainId, Hex } from
|
|
|
12
13
|
import type { BridgeControllerMethodActions } from './bridge-controller-method-action-types.js';
|
|
13
14
|
import type { BridgeController } from './bridge-controller.js';
|
|
14
15
|
import type { BRIDGE_CONTROLLER_NAME } from './constants/bridge.js';
|
|
16
|
+
import { TraceFeatureTag } from './constants/traces.js';
|
|
17
|
+
import type { TraceOperation } from './constants/traces.js';
|
|
15
18
|
import type { SimulatedGasFeeLimitsSchema } from './validators/batch-sell.js';
|
|
16
19
|
import type { BatchSellTradesResponseSchema } from './validators/batch-sell.js';
|
|
17
20
|
import type { ChainConfigurationSchema, ChainRankingSchema, PlatformConfigSchema } from './validators/feature-flags.js';
|
|
@@ -24,6 +27,29 @@ import type { FeeDataSchema } from './validators/quote.js';
|
|
|
24
27
|
import type { GaslessPropertiesSchema } from './validators/quote.js';
|
|
25
28
|
import type { StepSchema } from './validators/step.js';
|
|
26
29
|
import type { TokenFeatureSchema } from './validators/token-feature.js';
|
|
30
|
+
/**
|
|
31
|
+
* Filters the client-supplied trace names to only include swap/bridge/batch sell related names
|
|
32
|
+
*/
|
|
33
|
+
export type SwapRelatedTraceName<TNameEnum extends string> = {
|
|
34
|
+
[TName in TNameEnum]: `${TName}` extends `${string}Swap${string}` | `${string}Bridge${string}` | `${string}Batch Sell${string}` ? TName : never;
|
|
35
|
+
}[TNameEnum];
|
|
36
|
+
/**
|
|
37
|
+
* Trace request type for swap/bridge traces
|
|
38
|
+
*/
|
|
39
|
+
export type SwapTraceRequest<TTraceName> = Omit<TraceRequest, 'name' | 'tags' | 'parentContext'> & {
|
|
40
|
+
name: TTraceName;
|
|
41
|
+
op?: TraceOperation;
|
|
42
|
+
tags: {
|
|
43
|
+
feature: TraceFeatureTag;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Generic trace function type that supports both mobile and extension interfaces
|
|
48
|
+
*/
|
|
49
|
+
export type SwapTraceFunction<TTraceName extends string> = {
|
|
50
|
+
<TResult>(request: SwapTraceRequest<TTraceName>, fn: (args?: unknown) => TResult): TResult;
|
|
51
|
+
(request: SwapTraceRequest<TTraceName>): unknown;
|
|
52
|
+
};
|
|
27
53
|
export type FetchFunction = (input: RequestInfo | URL | string, init?: RequestInit) => Promise<any>;
|
|
28
54
|
/**
|
|
29
55
|
* The types of assets that a user can send
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2CAA2C,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,KAAK,EAAE,+CAA+C,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,8BAA8B,CAAC;AACzF,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EACV,mDAAmD,EACnD,2CAA2C,EAC5C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,wCAAwC,CAAC;AAC3G,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,0CAA0C,CAAC;AAC1G,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,GAAG,EACJ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAChG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,6BAA6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dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmDA;;GAEG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,4DAA4D;IAC5D,8BAAiB,CAAA;IACjB,qBAAqB;IACrB,4BAAe,CAAA;IACf,kCAAkC;IAClC,wBAAW,CAAA;IACX;;;OAGG;IACH,gCAAmB,CAAA;AACrB,CAAC,EAZW,SAAS,KAAT,SAAS,QAYpB;AA2BD;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAmED,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAsDD,MAAM,CAAN,IAAY,OAqBX;AArBD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,8CAAa,CAAA;IACb,oCAAQ,CAAA;IACR,6CAAa,CAAA;IACb,2CAAY,CAAA;IACZ,wCAAW,CAAA;IACX,iDAAgB,CAAA;IAChB,mDAAiB,CAAA;IACjB,2CAAa,CAAA;IACb,wDAAyB,CAAA;IACzB,gDAAoB,CAAA;IACpB,4FAA4F;IAC5F,wDAAwB,CAAA;IACxB,6CAAgB,CAAA;IAChB,sCAAU,CAAA;IACV,yCAAW,CAAA;IACX,+CAAc,CAAA;IACd,8CAAc,CAAA;IACd,sCAAU,CAAA;IACV,kDAAgB,CAAA;AAClB,CAAC,EArBW,OAAO,KAAP,OAAO,QAqBlB;AAQD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,uDAAW,CAAA;IACX,mDAAS,CAAA;AACX,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type { AssetsControllerGetExchangeRatesForBridgeAction } from '@metamask/assets-controller';\nimport type { CurrencyRateControllerGetStateAction } from '@metamask/assets-controllers';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n CaipAccountId,\n CaipAssetId,\n CaipAssetType,\n CaipChainId,\n Hex,\n} from '@metamask/utils';\n\nimport type { BridgeControllerMethodActions } from './bridge-controller-method-action-types.js';\nimport type { BridgeController } from './bridge-controller.js';\nimport type { BRIDGE_CONTROLLER_NAME } from './constants/bridge.js';\nimport type { SimulatedGasFeeLimitsSchema } from './validators/batch-sell.js';\nimport type { BatchSellTradesResponseSchema } from './validators/batch-sell.js';\nimport type {\n ChainConfigurationSchema,\n ChainRankingSchema,\n PlatformConfigSchema,\n} from './validators/feature-flags.js';\nimport type { IntentSchema } from './validators/intent.js';\nimport type { QuoteResponseV1 } from './validators/quote-response-v1.js';\nimport type { QuoteResponse } from './validators/quote-response.js';\nimport type { QuoteStreamCompleteSchema } from './validators/quote-stream-complete.js';\nimport type { TxFeeGasLimitsSchema } from './validators/quote.js';\nimport type { FeeDataSchema } from './validators/quote.js';\nimport type { GaslessPropertiesSchema } from './validators/quote.js';\nimport type { StepSchema } from './validators/step.js';\nimport type { TokenFeatureSchema } from './validators/token-feature.js';\n\nexport type FetchFunction = (\n input: RequestInfo | URL | string,\n init?: RequestInit,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * The types of assets that a user can send\n */\nexport enum AssetType {\n /** The native asset for the current network, such as ETH */\n native = 'NATIVE',\n /** An ERC20 token */\n token = 'TOKEN',\n /** An ERC721 or ERC1155 token. */\n NFT = 'NFT',\n /**\n * A transaction interacting with a contract that isn't a token method\n * interaction will be marked as dealing with an unknown asset type.\n */\n unknown = 'UNKNOWN',\n}\n\nexport type ChainConfiguration = Infer<typeof ChainConfigurationSchema>;\n\nexport type ChainRanking = Infer<typeof ChainRankingSchema>;\n\n/**\n * @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead\n */\nexport type L1GasFees = {\n l1GasFeesInHexWei?: Hex; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees\n};\n\n/**\n * @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead\n */\nexport type NonEvmFees = {\n nonEvmFeesInNative?: string; // Non-EVM chain fees in native units (SOL for Solana, BTC for Bitcoin)\n};\n\nexport type InputPrimaryDenomination = 'token_amount' | 'fiat_value';\n\n/**\n * Asset exchange rate values for a given chain and address\n */\nexport type ExchangeRate = { exchangeRate?: string; usdExchangeRate?: string };\n\n/**\n * Sort order set by the user\n */\nexport enum SortOrder {\n COST_ASC = 'cost_ascending',\n ETA_ASC = 'time_descending',\n}\n\n/**\n * This is the interface for the token object used in the extension client\n * In addition to the {@link BridgeAsset} fields, it includes balance information\n */\nexport type BridgeToken = {\n address: string;\n symbol: string;\n image: string;\n decimals: number;\n chainId: number | Hex | ChainId | CaipChainId;\n balance: string; // raw balance\n // TODO deprecate this field and use balance instead\n string: string | undefined; // normalized balance as a stringified number\n tokenFiatAmount?: number | null;\n occurrences?: number;\n};\n\ntype DecimalChainId = string;\nexport type GasMultiplierByChainId = Record<DecimalChainId, number>;\n\nexport type FeatureFlagResponse = Infer<typeof PlatformConfigSchema>;\n\n// TODO move definition to validators.ts\n/**\n * This is the interface for the quote request sent to the bridge-api\n * and should only be used by the fetchBridgeQuotes utility function\n * Components and redux stores should use the {@link GenericQuoteRequest} type\n */\nexport type QuoteRequest<\n ChainIdType = ChainId | number,\n TokenAddressType = string,\n WalletAddressType = string,\n> = {\n walletAddress: WalletAddressType;\n destWalletAddress?: WalletAddressType;\n srcChainId: ChainIdType;\n destChainId: ChainIdType;\n srcTokenAddress: TokenAddressType;\n destTokenAddress: TokenAddressType;\n /**\n * This is the amount sent, in atomic amount\n */\n srcTokenAmount: string;\n slippage?: number;\n aggIds?: string[];\n bridgeIds?: string[];\n insufficientBal?: boolean;\n resetApproval?: boolean;\n refuel?: boolean;\n /**\n * Whether the response should include gasless swap quotes\n * This should be true if the user has opted in to STX on the client\n * and the current network has STX support\n */\n gasIncluded: boolean;\n /**\n * Whether to request quotes that use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: boolean;\n /**\n * The fee that will be charged by MetaMask\n */\n fee?: number;\n};\n\nexport enum StatusTypes {\n SUBMITTED = 'SUBMITTED',\n UNKNOWN = 'UNKNOWN',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n COMPLETE = 'COMPLETE',\n}\n\n/**\n * These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types.\n * Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes\n */\nexport type GenericQuoteRequest = QuoteRequest<\n Hex | CaipChainId | string | number, // chainIds\n Hex | CaipAssetId | string, // assetIds/addresses\n Hex | CaipAccountId | string // accountIds/addresses\n>;\n\nexport type Step = Infer<typeof StepSchema>;\n\nexport type RefuelData = Step;\n\nexport type FeeData = Infer<typeof FeeDataSchema>;\n\nexport type Intent = Infer<typeof IntentSchema>;\nexport type IntentOrderLike = Intent['order'];\n\nexport type BatchSellTradesRequest = {\n quotes: QuoteResponseV1[];\n stxEnabled: boolean;\n};\n\n/**\n * This is the bridge-api response for the obtainGaslessBatch method\n */\nexport type BatchSellTradesResponse = Infer<\n typeof BatchSellTradesResponseSchema\n>;\n\nexport type SimulatedGasFeeLimits = Infer<typeof SimulatedGasFeeLimitsSchema>;\nexport type TxFeeGasLimits = Infer<typeof TxFeeGasLimitsSchema>;\n\nexport type GaslessProperties = Infer<typeof GaslessPropertiesSchema>;\n\ntype DeepPartialValue<Type> =\n NonNullable<Type> extends (infer U)[]\n ? DeepPartial<U>[]\n : NonNullable<Type> extends readonly (infer U)[]\n ? readonly DeepPartial<U>[]\n : NonNullable<Type> extends object\n ? DeepPartial<NonNullable<Type>>\n : Type;\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [K in keyof Type]?: null extends Type[K]\n ? DeepPartialValue<Type[K]> | null\n : DeepPartialValue<Type[K]>;\n };\n\nexport enum ChainId {\n ETH = 1,\n OPTIMISM = 10,\n BSC = 56,\n POLYGON = 137,\n ZKSYNC = 324,\n BASE = 8453,\n ARBITRUM = 42161,\n AVALANCHE = 43114,\n LINEA = 59144,\n SOLANA = 1151111081099710,\n BTC = 20000000000001,\n /** Internal bridge / token-list id for Stellar pubnet (Token API chain: stellar:pubnet). */\n STELLAR = 20000000000002,\n TRON = 728126428,\n SEI = 1329,\n MONAD = 143,\n HYPEREVM = 999,\n MEGAETH = 4326,\n ARC = 5042,\n ROBINHOOD = 4663,\n}\n\nexport type FeatureFlagsPlatformConfig = Infer<typeof PlatformConfigSchema>;\n\nexport type TokenFeature = Infer<typeof TokenFeatureSchema>;\n\nexport type QuoteStreamCompleteData = Infer<typeof QuoteStreamCompleteSchema>;\n\nexport enum RequestStatus {\n LOADING = 0,\n FETCHED = 1,\n ERROR = 2,\n}\n\nexport type BridgeControllerState = {\n quoteRequest: Partial<GenericQuoteRequest>[];\n quotes: QuoteResponse[];\n /**\n * The time elapsed between the initial quote fetch and when the first valid quote was received\n */\n quotesInitialLoadTime: number | null;\n /**\n * The timestamp of when the latest quote fetch started\n */\n quotesLastFetched: number | null;\n /**\n * The status of the quote fetch, including fee calculations and validations\n * This is set to\n * - LOADING when the quote fetch starts\n * - FETCHED when the process completes successfully, including when quotes are empty\n * - ERROR when any errors occur\n *\n * When SSE is enabled, this is set to LOADING even when a quote is available. It is only\n * set to FETCHED when the stream is closed and all quotes have been received\n */\n quotesLoadingStatus: RequestStatus | null;\n quoteFetchError: string | null;\n /**\n * The number of times the quotes have been refreshed, starts at 0 and is\n * incremented at the end of each quote fetch\n */\n quotesRefreshCount: number;\n /**\n * Asset exchange rates for EVM and multichain assets that are not indexed by the assets controllers\n */\n assetExchangeRates: Record<CaipAssetType, ExchangeRate>;\n /**\n * When the src token is SOL, this needs to be subtracted from their balance to determine\n * the max amount that can be sent.\n */\n minimumBalanceForRentExemptionInLamports: string | null;\n /**\n * Security alerts for the destination token in the current quote request,\n * populated from `token_warning` SSE events.\n */\n tokenWarnings: TokenFeature[];\n /**\n * Client-supplied security classification for the destination token in the\n * current quote request, used as the `token_security_type_destination`\n * analytics property. Set via the `context` arg of\n * `updateBridgeQuoteRequestParams` and reset whenever the quote request is\n * reset. `null` when the client has no security data for the token.\n */\n tokenSecurityTypeDestination: string | null;\n /**\n * The denomination currently shown as the primary source amount input.\n * This is persisted as a user preference so returning to the flow restores\n * the last selected fiat/token display mode.\n */\n inputPrimaryDenomination: InputPrimaryDenomination;\n /**\n * Metadata about the completed quote stream, populated from the `complete` SSE event.\n * Set to null at the start of each fetch and updated when the complete event is received.\n */\n quoteStreamComplete: QuoteStreamCompleteData | null;\n /**\n * Contains gasless transaction data and fees for BatchSell quotes, provided by the obtainGaslessBatch API\n */\n batchSellTrades: BatchSellTradesResponse | null;\n /**\n * The status of the batch sell trades fetch, including fee calculations and validations\n */\n batchSellTradesLoadingStatus: RequestStatus | null;\n};\n\n/**\n * @deprecated Use the separate method action types (e.g.,\n * `BridgeControllerFetchQuotesAction`) instead.\n */\nexport type BridgeControllerAction<\n FunctionName extends keyof BridgeController,\n> = {\n type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeController[FunctionName];\n};\n\nexport type BridgeControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type BridgeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type BridgeControllerActions =\n | BridgeControllerGetStateAction\n | BridgeControllerMethodActions;\n\nexport type BridgeControllerEvents = BridgeControllerStateChangeEvent;\n\nexport type AllowedActions =\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | CurrencyRateControllerGetStateAction\n | SnapControllerHandleRequestAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | AssetsControllerGetExchangeRatesForBridgeAction;\nexport type AllowedEvents = never;\n\n/**\n * The messenger for the BridgeController.\n */\nexport type BridgeControllerMessenger = Messenger<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerActions | AllowedActions,\n BridgeControllerEvents | AllowedEvents\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyFA;;GAEG;AACH,MAAM,CAAN,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,4DAA4D;IAC5D,8BAAiB,CAAA;IACjB,qBAAqB;IACrB,4BAAe,CAAA;IACf,kCAAkC;IAClC,wBAAW,CAAA;IACX;;;OAGG;IACH,gCAAmB,CAAA;AACrB,CAAC,EAZW,SAAS,KAAT,SAAS,QAYpB;AA2BD;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAmED,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAsDD,MAAM,CAAN,IAAY,OAqBX;AArBD,WAAY,OAAO;IACjB,mCAAO,CAAA;IACP,8CAAa,CAAA;IACb,oCAAQ,CAAA;IACR,6CAAa,CAAA;IACb,2CAAY,CAAA;IACZ,wCAAW,CAAA;IACX,iDAAgB,CAAA;IAChB,mDAAiB,CAAA;IACjB,2CAAa,CAAA;IACb,wDAAyB,CAAA;IACzB,gDAAoB,CAAA;IACpB,4FAA4F;IAC5F,wDAAwB,CAAA;IACxB,6CAAgB,CAAA;IAChB,sCAAU,CAAA;IACV,yCAAW,CAAA;IACX,+CAAc,CAAA;IACd,8CAAc,CAAA;IACd,sCAAU,CAAA;IACV,kDAAgB,CAAA;AAClB,CAAC,EArBW,OAAO,KAAP,OAAO,QAqBlB;AAQD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,uDAAW,CAAA;IACX,mDAAS,CAAA;AACX,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { AccountsControllerGetAccountByAddressAction } from '@metamask/accounts-controller';\nimport type { AssetsControllerGetExchangeRatesForBridgeAction } from '@metamask/assets-controller';\nimport type { CurrencyRateControllerGetStateAction } from '@metamask/assets-controllers';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type { TraceRequest } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerGetNetworkClientByIdAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { SnapControllerHandleRequestAction } from '@metamask/snaps-controllers';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n CaipAccountId,\n CaipAssetId,\n CaipAssetType,\n CaipChainId,\n Hex,\n} from '@metamask/utils';\n\nimport type { BridgeControllerMethodActions } from './bridge-controller-method-action-types.js';\nimport type { BridgeController } from './bridge-controller.js';\nimport type { BRIDGE_CONTROLLER_NAME } from './constants/bridge.js';\nimport { TraceFeatureTag } from './constants/traces.js';\nimport type { TraceOperation } from './constants/traces.js';\nimport type { SimulatedGasFeeLimitsSchema } from './validators/batch-sell.js';\nimport type { BatchSellTradesResponseSchema } from './validators/batch-sell.js';\nimport type {\n ChainConfigurationSchema,\n ChainRankingSchema,\n PlatformConfigSchema,\n} from './validators/feature-flags.js';\nimport type { IntentSchema } from './validators/intent.js';\nimport type { QuoteResponseV1 } from './validators/quote-response-v1.js';\nimport type { QuoteResponse } from './validators/quote-response.js';\nimport type { QuoteStreamCompleteSchema } from './validators/quote-stream-complete.js';\nimport type { TxFeeGasLimitsSchema } from './validators/quote.js';\nimport type { FeeDataSchema } from './validators/quote.js';\nimport type { GaslessPropertiesSchema } from './validators/quote.js';\nimport type { StepSchema } from './validators/step.js';\nimport type { TokenFeatureSchema } from './validators/token-feature.js';\n\n/**\n * Filters the client-supplied trace names to only include swap/bridge/batch sell related names\n */\nexport type SwapRelatedTraceName<TNameEnum extends string> = {\n [TName in TNameEnum]: `${TName}` extends\n | `${string}Swap${string}`\n | `${string}Bridge${string}`\n | `${string}Batch Sell${string}`\n ? TName\n : never;\n}[TNameEnum];\n\n/**\n * Trace request type for swap/bridge traces\n */\nexport type SwapTraceRequest<TTraceName> = Omit<\n TraceRequest,\n 'name' | 'tags' | 'parentContext'\n> & {\n name: TTraceName;\n op?: TraceOperation;\n tags: { feature: TraceFeatureTag };\n};\n\n/**\n * Generic trace function type that supports both mobile and extension interfaces\n */\nexport type SwapTraceFunction<TTraceName extends string> = {\n <TResult>(\n request: SwapTraceRequest<TTraceName>,\n fn: (args?: unknown) => TResult,\n ): TResult;\n (request: SwapTraceRequest<TTraceName>): unknown;\n};\n\nexport type FetchFunction = (\n input: RequestInfo | URL | string,\n init?: RequestInit,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => Promise<any>;\n\n/**\n * The types of assets that a user can send\n */\nexport enum AssetType {\n /** The native asset for the current network, such as ETH */\n native = 'NATIVE',\n /** An ERC20 token */\n token = 'TOKEN',\n /** An ERC721 or ERC1155 token. */\n NFT = 'NFT',\n /**\n * A transaction interacting with a contract that isn't a token method\n * interaction will be marked as dealing with an unknown asset type.\n */\n unknown = 'UNKNOWN',\n}\n\nexport type ChainConfiguration = Infer<typeof ChainConfigurationSchema>;\n\nexport type ChainRanking = Infer<typeof ChainRankingSchema>;\n\n/**\n * @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead\n */\nexport type L1GasFees = {\n l1GasFeesInHexWei?: Hex; // l1 fees for approval and trade in hex wei, appended by BridgeController.#appendL1GasFees\n};\n\n/**\n * @deprecated Avoid introducing new usages and use the QuoteResponseV2 feeData.network value instead\n */\nexport type NonEvmFees = {\n nonEvmFeesInNative?: string; // Non-EVM chain fees in native units (SOL for Solana, BTC for Bitcoin)\n};\n\nexport type InputPrimaryDenomination = 'token_amount' | 'fiat_value';\n\n/**\n * Asset exchange rate values for a given chain and address\n */\nexport type ExchangeRate = { exchangeRate?: string; usdExchangeRate?: string };\n\n/**\n * Sort order set by the user\n */\nexport enum SortOrder {\n COST_ASC = 'cost_ascending',\n ETA_ASC = 'time_descending',\n}\n\n/**\n * This is the interface for the token object used in the extension client\n * In addition to the {@link BridgeAsset} fields, it includes balance information\n */\nexport type BridgeToken = {\n address: string;\n symbol: string;\n image: string;\n decimals: number;\n chainId: number | Hex | ChainId | CaipChainId;\n balance: string; // raw balance\n // TODO deprecate this field and use balance instead\n string: string | undefined; // normalized balance as a stringified number\n tokenFiatAmount?: number | null;\n occurrences?: number;\n};\n\ntype DecimalChainId = string;\nexport type GasMultiplierByChainId = Record<DecimalChainId, number>;\n\nexport type FeatureFlagResponse = Infer<typeof PlatformConfigSchema>;\n\n// TODO move definition to validators.ts\n/**\n * This is the interface for the quote request sent to the bridge-api\n * and should only be used by the fetchBridgeQuotes utility function\n * Components and redux stores should use the {@link GenericQuoteRequest} type\n */\nexport type QuoteRequest<\n ChainIdType = ChainId | number,\n TokenAddressType = string,\n WalletAddressType = string,\n> = {\n walletAddress: WalletAddressType;\n destWalletAddress?: WalletAddressType;\n srcChainId: ChainIdType;\n destChainId: ChainIdType;\n srcTokenAddress: TokenAddressType;\n destTokenAddress: TokenAddressType;\n /**\n * This is the amount sent, in atomic amount\n */\n srcTokenAmount: string;\n slippage?: number;\n aggIds?: string[];\n bridgeIds?: string[];\n insufficientBal?: boolean;\n resetApproval?: boolean;\n refuel?: boolean;\n /**\n * Whether the response should include gasless swap quotes\n * This should be true if the user has opted in to STX on the client\n * and the current network has STX support\n */\n gasIncluded: boolean;\n /**\n * Whether to request quotes that use EIP-7702 delegated gasless execution\n */\n gasIncluded7702: boolean;\n /**\n * The fee that will be charged by MetaMask\n */\n fee?: number;\n};\n\nexport enum StatusTypes {\n SUBMITTED = 'SUBMITTED',\n UNKNOWN = 'UNKNOWN',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n COMPLETE = 'COMPLETE',\n}\n\n/**\n * These are types that components pass in. Since data is a mix of types when coming from the redux store, we need to use a generic type that can cover all the types.\n * Payloads with this type are transformed into QuoteRequest by fetchBridgeQuotes right before fetching quotes\n */\nexport type GenericQuoteRequest = QuoteRequest<\n Hex | CaipChainId | string | number, // chainIds\n Hex | CaipAssetId | string, // assetIds/addresses\n Hex | CaipAccountId | string // accountIds/addresses\n>;\n\nexport type Step = Infer<typeof StepSchema>;\n\nexport type RefuelData = Step;\n\nexport type FeeData = Infer<typeof FeeDataSchema>;\n\nexport type Intent = Infer<typeof IntentSchema>;\nexport type IntentOrderLike = Intent['order'];\n\nexport type BatchSellTradesRequest = {\n quotes: QuoteResponseV1[];\n stxEnabled: boolean;\n};\n\n/**\n * This is the bridge-api response for the obtainGaslessBatch method\n */\nexport type BatchSellTradesResponse = Infer<\n typeof BatchSellTradesResponseSchema\n>;\n\nexport type SimulatedGasFeeLimits = Infer<typeof SimulatedGasFeeLimitsSchema>;\nexport type TxFeeGasLimits = Infer<typeof TxFeeGasLimitsSchema>;\n\nexport type GaslessProperties = Infer<typeof GaslessPropertiesSchema>;\n\ntype DeepPartialValue<Type> =\n NonNullable<Type> extends (infer U)[]\n ? DeepPartial<U>[]\n : NonNullable<Type> extends readonly (infer U)[]\n ? readonly DeepPartial<U>[]\n : NonNullable<Type> extends object\n ? DeepPartial<NonNullable<Type>>\n : Type;\nexport type DeepPartial<Type> = Type extends string\n ? Type\n : {\n [K in keyof Type]?: null extends Type[K]\n ? DeepPartialValue<Type[K]> | null\n : DeepPartialValue<Type[K]>;\n };\n\nexport enum ChainId {\n ETH = 1,\n OPTIMISM = 10,\n BSC = 56,\n POLYGON = 137,\n ZKSYNC = 324,\n BASE = 8453,\n ARBITRUM = 42161,\n AVALANCHE = 43114,\n LINEA = 59144,\n SOLANA = 1151111081099710,\n BTC = 20000000000001,\n /** Internal bridge / token-list id for Stellar pubnet (Token API chain: stellar:pubnet). */\n STELLAR = 20000000000002,\n TRON = 728126428,\n SEI = 1329,\n MONAD = 143,\n HYPEREVM = 999,\n MEGAETH = 4326,\n ARC = 5042,\n ROBINHOOD = 4663,\n}\n\nexport type FeatureFlagsPlatformConfig = Infer<typeof PlatformConfigSchema>;\n\nexport type TokenFeature = Infer<typeof TokenFeatureSchema>;\n\nexport type QuoteStreamCompleteData = Infer<typeof QuoteStreamCompleteSchema>;\n\nexport enum RequestStatus {\n LOADING = 0,\n FETCHED = 1,\n ERROR = 2,\n}\n\nexport type BridgeControllerState = {\n quoteRequest: Partial<GenericQuoteRequest>[];\n quotes: QuoteResponse[];\n /**\n * The time elapsed between the initial quote fetch and when the first valid quote was received\n */\n quotesInitialLoadTime: number | null;\n /**\n * The timestamp of when the latest quote fetch started\n */\n quotesLastFetched: number | null;\n /**\n * The status of the quote fetch, including fee calculations and validations\n * This is set to\n * - LOADING when the quote fetch starts\n * - FETCHED when the process completes successfully, including when quotes are empty\n * - ERROR when any errors occur\n *\n * When SSE is enabled, this is set to LOADING even when a quote is available. It is only\n * set to FETCHED when the stream is closed and all quotes have been received\n */\n quotesLoadingStatus: RequestStatus | null;\n quoteFetchError: string | null;\n /**\n * The number of times the quotes have been refreshed, starts at 0 and is\n * incremented at the end of each quote fetch\n */\n quotesRefreshCount: number;\n /**\n * Asset exchange rates for EVM and multichain assets that are not indexed by the assets controllers\n */\n assetExchangeRates: Record<CaipAssetType, ExchangeRate>;\n /**\n * When the src token is SOL, this needs to be subtracted from their balance to determine\n * the max amount that can be sent.\n */\n minimumBalanceForRentExemptionInLamports: string | null;\n /**\n * Security alerts for the destination token in the current quote request,\n * populated from `token_warning` SSE events.\n */\n tokenWarnings: TokenFeature[];\n /**\n * Client-supplied security classification for the destination token in the\n * current quote request, used as the `token_security_type_destination`\n * analytics property. Set via the `context` arg of\n * `updateBridgeQuoteRequestParams` and reset whenever the quote request is\n * reset. `null` when the client has no security data for the token.\n */\n tokenSecurityTypeDestination: string | null;\n /**\n * The denomination currently shown as the primary source amount input.\n * This is persisted as a user preference so returning to the flow restores\n * the last selected fiat/token display mode.\n */\n inputPrimaryDenomination: InputPrimaryDenomination;\n /**\n * Metadata about the completed quote stream, populated from the `complete` SSE event.\n * Set to null at the start of each fetch and updated when the complete event is received.\n */\n quoteStreamComplete: QuoteStreamCompleteData | null;\n /**\n * Contains gasless transaction data and fees for BatchSell quotes, provided by the obtainGaslessBatch API\n */\n batchSellTrades: BatchSellTradesResponse | null;\n /**\n * The status of the batch sell trades fetch, including fee calculations and validations\n */\n batchSellTradesLoadingStatus: RequestStatus | null;\n};\n\n/**\n * @deprecated Use the separate method action types (e.g.,\n * `BridgeControllerFetchQuotesAction`) instead.\n */\nexport type BridgeControllerAction<\n FunctionName extends keyof BridgeController,\n> = {\n type: `${typeof BRIDGE_CONTROLLER_NAME}:${FunctionName}`;\n handler: BridgeController[FunctionName];\n};\n\nexport type BridgeControllerGetStateAction = ControllerGetStateAction<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type BridgeControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerState\n>;\n\nexport type BridgeControllerActions =\n | BridgeControllerGetStateAction\n | BridgeControllerMethodActions;\n\nexport type BridgeControllerEvents = BridgeControllerStateChangeEvent;\n\nexport type AllowedActions =\n | AccountsControllerGetAccountByAddressAction\n | AuthenticationControllerGetBearerTokenAction\n | CurrencyRateControllerGetStateAction\n | SnapControllerHandleRequestAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | NetworkControllerGetNetworkClientByIdAction\n | RemoteFeatureFlagControllerGetStateAction\n | AssetsControllerGetExchangeRatesForBridgeAction;\nexport type AllowedEvents = never;\n\n/**\n * The messenger for the BridgeController.\n */\nexport type BridgeControllerMessenger = Messenger<\n typeof BRIDGE_CONTROLLER_NAME,\n BridgeControllerActions | AllowedActions,\n BridgeControllerEvents | AllowedEvents\n>;\n"]}
|
|
@@ -829,27 +829,17 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
829
829
|
nonEvmFeesInNative?: string | undefined;
|
|
830
830
|
l1GasFeesInHexWei?: `0x${string}` | undefined;
|
|
831
831
|
} & {
|
|
832
|
-
namespace: KnownCaipNamespace.
|
|
832
|
+
namespace: KnownCaipNamespace.Solana;
|
|
833
833
|
chainId: `${string}:${string}`;
|
|
834
|
-
trade:
|
|
835
|
-
raw_data_hex: string;
|
|
836
|
-
visible?: boolean | undefined;
|
|
837
|
-
raw_data?: {
|
|
838
|
-
contract?: {
|
|
839
|
-
type?: string | undefined;
|
|
840
|
-
}[] | undefined;
|
|
841
|
-
fee_limit?: number | undefined;
|
|
842
|
-
} | null | undefined;
|
|
843
|
-
};
|
|
834
|
+
trade: string;
|
|
844
835
|
approval?: {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
} | null | undefined;
|
|
836
|
+
chainId: number;
|
|
837
|
+
to: `0x${string}`;
|
|
838
|
+
from: `0x${string}`;
|
|
839
|
+
value: `0x${string}`;
|
|
840
|
+
data: `0x${string}`;
|
|
841
|
+
gasLimit: number | null;
|
|
842
|
+
effectiveGas?: number | undefined;
|
|
853
843
|
} | undefined;
|
|
854
844
|
}) | ({
|
|
855
845
|
quoteId?: string | undefined;
|
|
@@ -1250,17 +1240,27 @@ export declare const QuoteResponseSchemaV2: import("@metamask/superstruct").Stru
|
|
|
1250
1240
|
nonEvmFeesInNative?: string | undefined;
|
|
1251
1241
|
l1GasFeesInHexWei?: `0x${string}` | undefined;
|
|
1252
1242
|
} & {
|
|
1253
|
-
namespace: KnownCaipNamespace.
|
|
1243
|
+
namespace: KnownCaipNamespace.Tron;
|
|
1254
1244
|
chainId: `${string}:${string}`;
|
|
1255
|
-
trade:
|
|
1245
|
+
trade: {
|
|
1246
|
+
raw_data_hex: string;
|
|
1247
|
+
visible?: boolean | undefined;
|
|
1248
|
+
raw_data?: {
|
|
1249
|
+
contract?: {
|
|
1250
|
+
type?: string | undefined;
|
|
1251
|
+
}[] | undefined;
|
|
1252
|
+
fee_limit?: number | undefined;
|
|
1253
|
+
} | null | undefined;
|
|
1254
|
+
};
|
|
1256
1255
|
approval?: {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1256
|
+
raw_data_hex: string;
|
|
1257
|
+
visible?: boolean | undefined;
|
|
1258
|
+
raw_data?: {
|
|
1259
|
+
contract?: {
|
|
1260
|
+
type?: string | undefined;
|
|
1261
|
+
}[] | undefined;
|
|
1262
|
+
fee_limit?: number | undefined;
|
|
1263
|
+
} | null | undefined;
|
|
1264
1264
|
} | undefined;
|
|
1265
1265
|
}) | ({
|
|
1266
1266
|
quoteId?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/bridge-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "83.0.0-preview-a583980c5",
|
|
4
4
|
"description": "Manages bridge-related quote fetching functionality for MetaMask",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@ethersproject/providers": "^5.8.0",
|
|
58
58
|
"@metamask/accounts-controller": "^40.1.0",
|
|
59
59
|
"@metamask/assets-controller": "^19.1.0",
|
|
60
|
-
"@metamask/assets-controllers": "^112.1.
|
|
60
|
+
"@metamask/assets-controllers": "^112.1.3",
|
|
61
61
|
"@metamask/base-controller": "^10.1.0",
|
|
62
62
|
"@metamask/controller-utils": "^13.0.0",
|
|
63
63
|
"@metamask/gas-fee-controller": "^27.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"@metamask/multichain-network-controller": "^4.0.0",
|
|
68
68
|
"@metamask/network-controller": "^37.1.0",
|
|
69
69
|
"@metamask/polling-controller": "^17.0.0",
|
|
70
|
-
"@metamask/profile-sync-controller": "^
|
|
70
|
+
"@metamask/profile-sync-controller": "^35.0.0",
|
|
71
71
|
"@metamask/remote-feature-flag-controller": "^7.0.0",
|
|
72
72
|
"@metamask/snaps-controllers": "^19.0.1",
|
|
73
73
|
"@metamask/transaction-controller": "^72.2.1",
|