@metamask/bridge-controller 73.2.1 → 75.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -1
- package/dist/bridge-controller.cjs +20 -21
- package/dist/bridge-controller.cjs.map +1 -1
- package/dist/bridge-controller.d.cts +9 -16
- package/dist/bridge-controller.d.cts.map +1 -1
- package/dist/bridge-controller.d.mts +9 -16
- package/dist/bridge-controller.d.mts.map +1 -1
- package/dist/bridge-controller.mjs +21 -22
- package/dist/bridge-controller.mjs.map +1 -1
- package/dist/constants/bridge.cjs +2 -0
- package/dist/constants/bridge.cjs.map +1 -1
- package/dist/constants/bridge.d.cts +4 -1
- package/dist/constants/bridge.d.cts.map +1 -1
- package/dist/constants/bridge.d.mts +4 -1
- package/dist/constants/bridge.d.mts.map +1 -1
- package/dist/constants/bridge.mjs +2 -0
- package/dist/constants/bridge.mjs.map +1 -1
- package/dist/constants/chains.cjs +4 -1
- package/dist/constants/chains.cjs.map +1 -1
- package/dist/constants/chains.d.cts +3 -0
- package/dist/constants/chains.d.cts.map +1 -1
- package/dist/constants/chains.d.mts +3 -0
- package/dist/constants/chains.d.mts.map +1 -1
- package/dist/constants/chains.mjs +3 -0
- package/dist/constants/chains.mjs.map +1 -1
- package/dist/constants/tokens.cjs +12 -0
- package/dist/constants/tokens.cjs.map +1 -1
- package/dist/constants/tokens.d.cts +7 -0
- package/dist/constants/tokens.d.cts.map +1 -1
- package/dist/constants/tokens.d.mts +7 -0
- package/dist/constants/tokens.d.mts.map +1 -1
- package/dist/constants/tokens.mjs +12 -0
- package/dist/constants/tokens.mjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.d.cts +143 -143
- package/dist/selectors.d.mts +143 -143
- package/dist/types.cjs +11 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +12 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +12 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +10 -0
- package/dist/types.mjs.map +1 -1
- package/dist/utils/feature-flags.d.cts +1 -1
- package/dist/utils/feature-flags.d.mts +1 -1
- package/dist/utils/fetch.cjs +8 -4
- package/dist/utils/fetch.cjs.map +1 -1
- package/dist/utils/fetch.d.cts +6 -5
- package/dist/utils/fetch.d.cts.map +1 -1
- package/dist/utils/fetch.d.mts +6 -5
- package/dist/utils/fetch.d.mts.map +1 -1
- package/dist/utils/fetch.mjs +8 -4
- package/dist/utils/fetch.mjs.map +1 -1
- package/dist/utils/metrics/properties.cjs +2 -0
- package/dist/utils/metrics/properties.cjs.map +1 -1
- package/dist/utils/metrics/properties.d.cts +2 -0
- package/dist/utils/metrics/properties.d.cts.map +1 -1
- package/dist/utils/metrics/properties.d.mts +2 -0
- package/dist/utils/metrics/properties.d.mts.map +1 -1
- package/dist/utils/metrics/properties.mjs +2 -0
- package/dist/utils/metrics/properties.mjs.map +1 -1
- package/dist/utils/metrics/types.cjs.map +1 -1
- package/dist/utils/metrics/types.d.cts +30 -17
- package/dist/utils/metrics/types.d.cts.map +1 -1
- package/dist/utils/metrics/types.d.mts +30 -17
- package/dist/utils/metrics/types.d.mts.map +1 -1
- package/dist/utils/metrics/types.mjs.map +1 -1
- package/dist/utils/quote.cjs +2 -2
- package/dist/utils/quote.cjs.map +1 -1
- package/dist/utils/quote.d.cts +1 -1
- package/dist/utils/quote.d.cts.map +1 -1
- package/dist/utils/quote.d.mts +1 -1
- package/dist/utils/quote.d.mts.map +1 -1
- package/dist/utils/quote.mjs +1 -1
- package/dist/utils/quote.mjs.map +1 -1
- package/dist/utils/validators.cjs +2 -9
- package/dist/utils/validators.cjs.map +1 -1
- package/dist/utils/validators.d.cts +3 -8
- package/dist/utils/validators.d.cts.map +1 -1
- package/dist/utils/validators.d.mts +3 -8
- package/dist/utils/validators.d.mts.map +1 -1
- package/dist/utils/validators.mjs +1 -8
- package/dist/utils/validators.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -2,11 +2,11 @@ import type { TraceCallback } from "@metamask/controller-utils";
|
|
|
2
2
|
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
3
|
import type { BridgeClientId } from "./constants/bridge.cjs";
|
|
4
4
|
import { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.cjs";
|
|
5
|
+
import { FeatureId } from "./types.cjs";
|
|
5
6
|
import type { L1GasFees, GenericQuoteRequest, NonEvmFees, QuoteResponse, BridgeControllerState, BridgeControllerMessenger, FetchFunction } from "./types.cjs";
|
|
6
7
|
import { AbortReason, MetaMetricsSwapsEventSource, UnifiedSwapBridgeEventName } from "./utils/metrics/constants.cjs";
|
|
7
8
|
import type { RequiredEventContextFromClient } from "./utils/metrics/types.cjs";
|
|
8
9
|
import type { CrossChainSwapsEventProperties } from "./utils/metrics/types.cjs";
|
|
9
|
-
import type { FeatureId } from "./utils/validators.cjs";
|
|
10
10
|
/**
|
|
11
11
|
* The input to start polling for the {@link BridgeController}
|
|
12
12
|
*
|
|
@@ -16,19 +16,11 @@ import type { FeatureId } from "./utils/validators.cjs";
|
|
|
16
16
|
*/
|
|
17
17
|
type BridgePollingInput = {
|
|
18
18
|
quoteRequests: GenericQuoteRequest[];
|
|
19
|
-
context:
|
|
20
|
-
/**
|
|
21
|
-
* Client-supplied security classification for the destination token
|
|
22
|
-
* (e.g. from token security/scanning data). Stored on the controller
|
|
23
|
-
* and merged into every analytics event that includes
|
|
24
|
-
* `token_address_destination`. Pass `null` when no security data is
|
|
25
|
-
* available for the selected destination token.
|
|
26
|
-
*/
|
|
27
|
-
Pick<RequiredEventContextFromClient[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched], 'token_security_type_destination'>;
|
|
19
|
+
context: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesError] & RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesRequested];
|
|
28
20
|
};
|
|
29
21
|
declare const BridgeController_base: (abstract new (...args: any[]) => {
|
|
30
|
-
readonly "__#
|
|
31
|
-
"__#
|
|
22
|
+
readonly "__#17@#intervalIds": Record<string, NodeJS.Timeout>;
|
|
23
|
+
"__#17@#intervalLength": number | undefined;
|
|
32
24
|
setIntervalLength(intervalLength: number): void;
|
|
33
25
|
getIntervalLength(): number | undefined;
|
|
34
26
|
_startPolling(input: BridgePollingInput): void;
|
|
@@ -80,19 +72,20 @@ export declare class BridgeController extends BridgeController_base<typeof BRIDG
|
|
|
80
72
|
* This method does not start polling for quotes and does not emit UnifiedSwapBridge events
|
|
81
73
|
*
|
|
82
74
|
* @param quoteRequest - The parameters for quote requests to fetch
|
|
83
|
-
* @param abortSignal - The abort signal to cancel all the requests
|
|
84
75
|
* @param featureId - The feature ID that maps to quoteParam overrides from LD
|
|
76
|
+
* @param abortSignal - The abort signal to cancel all the requests
|
|
85
77
|
* @returns A list of validated quotes
|
|
86
78
|
*/
|
|
87
|
-
fetchQuotes: (quoteRequest: GenericQuoteRequest,
|
|
79
|
+
fetchQuotes: (quoteRequest: GenericQuoteRequest, featureId: FeatureId, abortSignal?: AbortSignal | null) => Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]>;
|
|
88
80
|
/**
|
|
89
81
|
* Fetches gasless transaction data and fees for BatchSell quotes.
|
|
90
82
|
* To use this in the clients, add a listener for the recommendedQuotes and call
|
|
91
83
|
* this handler whenever they change.
|
|
92
84
|
*
|
|
93
85
|
* @param quotes - The quotes to fetch the gasless transaction data and fees for
|
|
86
|
+
* @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature.
|
|
94
87
|
*/
|
|
95
|
-
updateBatchSellTrades: (quotes: (QuoteResponse | null)[]) => Promise<void>;
|
|
88
|
+
updateBatchSellTrades: (quotes: (QuoteResponse | null)[], stxEnabled: boolean) => Promise<void>;
|
|
96
89
|
stopPollingForQuotes: (reason?: AbortReason, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
97
90
|
/**
|
|
98
91
|
* Sets the location/entry point for the current swap or bridge flow.
|
|
@@ -102,7 +95,7 @@ export declare class BridgeController extends BridgeController_base<typeof BRIDG
|
|
|
102
95
|
* @param location - The entry point from which the user initiated the flow
|
|
103
96
|
*/
|
|
104
97
|
setLocation: (location: MetaMetricsSwapsEventSource) => void;
|
|
105
|
-
resetState: (reason?: AbortReason, quoteRequestIndex?: number | null) => void;
|
|
98
|
+
resetState: (reason?: AbortReason, quoteRequestIndex?: number | null, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
106
99
|
/**
|
|
107
100
|
* Sets the interval length based on the source chain
|
|
108
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-controller.d.cts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAIhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yCAAyC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA2B;AACzD,OAAO,EACL,sBAAsB,EAKvB,+BAA2B;
|
|
1
|
+
{"version":3,"file":"bridge-controller.d.cts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAIhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yCAAyC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA2B;AACzD,OAAO,EACL,sBAAsB,EAKvB,+BAA2B;AAQ5B,OAAO,EAAE,SAAS,EAAiB,oBAAgB;AACnD,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EAEV,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACd,oBA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,YAAY,iBAAwB,kBAAkB,mBAEpD;IAEF;;;;;;;;OAQG;IACH,8BAA8B,mBACZ,QAAQ,mBAAmB,CAAC,GAAG;QAC7C,aAAa,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;KACrD,WACQ,kBAAkB,CAAC,SAAS,CAAC,sBACnB,MAAM,sBACN,MAAM,mBAgDzB;IAEF;;;;;;;;OAQG;IACH,WAAW,iBACK,mBAAmB,aACtB,SAAS,gBACP,WAAW,GAAG,IAAI,KAC9B,QAAQ,CAAC,aAAa,GAAG,SAAS,GAAG,UAAU,CAAC,EAAE,CAAC,CAiCpD;IAEF;;;;;;;OAOG;IACH,qBAAqB,WACX,CAAC,aAAa,GAAG,IAAI,CAAC,EAAE,cACpB,OAAO,KAClB,QAAQ,IAAI,CAAC,CAsDd;IA4LF,oBAAoB,YACT,WAAW,YACV,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,UAanF;IAEF;;;;;;OAMG;IACH,WAAW,aAAc,2BAA2B,UAElD;IAEF,UAAU,6CAEW,MAAM,GAAG,IAAI,YACtB,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,UAsCnF;IAEF;;OAEG;IACH,sBAAsB,aAYpB;IA+gBF;;;;;;;;;;OAUG;IACH,2BAA2B,6KASN,MAAM,UAgBzB;CA+BH"}
|
|
@@ -2,11 +2,11 @@ import type { TraceCallback } from "@metamask/controller-utils";
|
|
|
2
2
|
import type { TransactionController } from "@metamask/transaction-controller";
|
|
3
3
|
import type { BridgeClientId } from "./constants/bridge.mjs";
|
|
4
4
|
import { BRIDGE_CONTROLLER_NAME } from "./constants/bridge.mjs";
|
|
5
|
+
import { FeatureId } from "./types.mjs";
|
|
5
6
|
import type { L1GasFees, GenericQuoteRequest, NonEvmFees, QuoteResponse, BridgeControllerState, BridgeControllerMessenger, FetchFunction } from "./types.mjs";
|
|
6
7
|
import { AbortReason, MetaMetricsSwapsEventSource, UnifiedSwapBridgeEventName } from "./utils/metrics/constants.mjs";
|
|
7
8
|
import type { RequiredEventContextFromClient } from "./utils/metrics/types.mjs";
|
|
8
9
|
import type { CrossChainSwapsEventProperties } from "./utils/metrics/types.mjs";
|
|
9
|
-
import type { FeatureId } from "./utils/validators.mjs";
|
|
10
10
|
/**
|
|
11
11
|
* The input to start polling for the {@link BridgeController}
|
|
12
12
|
*
|
|
@@ -16,19 +16,11 @@ import type { FeatureId } from "./utils/validators.mjs";
|
|
|
16
16
|
*/
|
|
17
17
|
type BridgePollingInput = {
|
|
18
18
|
quoteRequests: GenericQuoteRequest[];
|
|
19
|
-
context:
|
|
20
|
-
/**
|
|
21
|
-
* Client-supplied security classification for the destination token
|
|
22
|
-
* (e.g. from token security/scanning data). Stored on the controller
|
|
23
|
-
* and merged into every analytics event that includes
|
|
24
|
-
* `token_address_destination`. Pass `null` when no security data is
|
|
25
|
-
* available for the selected destination token.
|
|
26
|
-
*/
|
|
27
|
-
Pick<RequiredEventContextFromClient[UnifiedSwapBridgeEventName.InputSourceDestinationSwitched], 'token_security_type_destination'>;
|
|
19
|
+
context: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesError] & RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesRequested];
|
|
28
20
|
};
|
|
29
21
|
declare const BridgeController_base: (abstract new (...args: any[]) => {
|
|
30
|
-
readonly "__#
|
|
31
|
-
"__#
|
|
22
|
+
readonly "__#17@#intervalIds": Record<string, NodeJS.Timeout>;
|
|
23
|
+
"__#17@#intervalLength": number | undefined;
|
|
32
24
|
setIntervalLength(intervalLength: number): void;
|
|
33
25
|
getIntervalLength(): number | undefined;
|
|
34
26
|
_startPolling(input: BridgePollingInput): void;
|
|
@@ -80,19 +72,20 @@ export declare class BridgeController extends BridgeController_base<typeof BRIDG
|
|
|
80
72
|
* This method does not start polling for quotes and does not emit UnifiedSwapBridge events
|
|
81
73
|
*
|
|
82
74
|
* @param quoteRequest - The parameters for quote requests to fetch
|
|
83
|
-
* @param abortSignal - The abort signal to cancel all the requests
|
|
84
75
|
* @param featureId - The feature ID that maps to quoteParam overrides from LD
|
|
76
|
+
* @param abortSignal - The abort signal to cancel all the requests
|
|
85
77
|
* @returns A list of validated quotes
|
|
86
78
|
*/
|
|
87
|
-
fetchQuotes: (quoteRequest: GenericQuoteRequest,
|
|
79
|
+
fetchQuotes: (quoteRequest: GenericQuoteRequest, featureId: FeatureId, abortSignal?: AbortSignal | null) => Promise<(QuoteResponse & L1GasFees & NonEvmFees)[]>;
|
|
88
80
|
/**
|
|
89
81
|
* Fetches gasless transaction data and fees for BatchSell quotes.
|
|
90
82
|
* To use this in the clients, add a listener for the recommendedQuotes and call
|
|
91
83
|
* this handler whenever they change.
|
|
92
84
|
*
|
|
93
85
|
* @param quotes - The quotes to fetch the gasless transaction data and fees for
|
|
86
|
+
* @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature.
|
|
94
87
|
*/
|
|
95
|
-
updateBatchSellTrades: (quotes: (QuoteResponse | null)[]) => Promise<void>;
|
|
88
|
+
updateBatchSellTrades: (quotes: (QuoteResponse | null)[], stxEnabled: boolean) => Promise<void>;
|
|
96
89
|
stopPollingForQuotes: (reason?: AbortReason, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
97
90
|
/**
|
|
98
91
|
* Sets the location/entry point for the current swap or bridge flow.
|
|
@@ -102,7 +95,7 @@ export declare class BridgeController extends BridgeController_base<typeof BRIDG
|
|
|
102
95
|
* @param location - The entry point from which the user initiated the flow
|
|
103
96
|
*/
|
|
104
97
|
setLocation: (location: MetaMetricsSwapsEventSource) => void;
|
|
105
|
-
resetState: (reason?: AbortReason, quoteRequestIndex?: number | null) => void;
|
|
98
|
+
resetState: (reason?: AbortReason, quoteRequestIndex?: number | null, context?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived]) => void;
|
|
106
99
|
/**
|
|
107
100
|
* Sets the interval length based on the source chain
|
|
108
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-controller.d.mts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAIhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yCAAyC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA2B;AACzD,OAAO,EACL,sBAAsB,EAKvB,+BAA2B;
|
|
1
|
+
{"version":3,"file":"bridge-controller.d.mts","sourceRoot":"","sources":["../src/bridge-controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAIhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,yCAAyC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,+BAA2B;AACzD,OAAO,EACL,sBAAsB,EAKvB,+BAA2B;AAQ5B,OAAO,EAAE,SAAS,EAAiB,oBAAgB;AACnD,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,UAAU,EAEV,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,EACd,oBAAgB;AAyBjB,OAAO,EACL,WAAW,EACX,2BAA2B,EAE3B,0BAA0B,EAC3B,sCAAkC;AAUnC,OAAO,KAAK,EAGV,8BAA8B,EAC/B,kCAA8B;AAC/B,OAAO,KAAK,EAAE,8BAA8B,EAAE,kCAA8B;AAgG5E;;;;;;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;;;;;;;;;;;;;;;;AAaF,qBAAa,gBAAiB,SAAQ,sBACpC,OAAO,sBAAsB,EAC7B,qBAAqB,EACrB,yBAAyB,CAC1B;;gBA4Ca,EACV,SAAS,EACT,KAAK,EACL,QAAQ,EACR,aAAa,EACb,eAAe,EACf,OAAO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AAC,UAanF;IAEF;;;;;;OAMG;IACH,WAAW,aAAc,2BAA2B,UAElD;IAEF,UAAU,6CAEW,MAAM,GAAG,IAAI,YACtB,8BAA8B,CAAC,2BAA2B,cAAc,CAAC,UAsCnF;IAEF;;OAEG;IACH,sBAAsB,aAYpB;IA+gBF;;;;;;;;;;OAUG;IACH,2BAA2B,6KASN,MAAM,UAgBzB;CA+BH"}
|
|
@@ -21,7 +21,7 @@ import { CHAIN_IDS } from "./constants/chains.mjs";
|
|
|
21
21
|
import { SWAPS_CONTRACT_ADDRESSES } from "./constants/swaps.mjs";
|
|
22
22
|
import { TraceName } from "./constants/traces.mjs";
|
|
23
23
|
import { selectIsAssetExchangeRateInState } from "./selectors.mjs";
|
|
24
|
-
import { RequestStatus } from "./types.mjs";
|
|
24
|
+
import { FeatureId, RequestStatus } from "./types.mjs";
|
|
25
25
|
import { getAssetIdsForToken, toExchangeRates } from "./utils/assets.mjs";
|
|
26
26
|
import { hasSufficientBalance } from "./utils/balance.mjs";
|
|
27
27
|
import { getDefaultBridgeControllerState, isCrossChain, isEthUsdt, isNonEvmChainId, isSolanaChainId } from "./utils/bridge.mjs";
|
|
@@ -181,7 +181,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
181
181
|
if (quoteRequestIndex >= quoteRequestCount) {
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
__classPrivateFieldGet(this, _BridgeController_trackInputChangedEvents, "f").call(this, paramsToUpdate, quoteRequestIndex);
|
|
184
|
+
__classPrivateFieldGet(this, _BridgeController_trackInputChangedEvents, "f").call(this, paramsToUpdate, context.feature_id, quoteRequestIndex);
|
|
185
185
|
this.resetState(AbortReason.QuoteRequestUpdated, quoteRequestIndex);
|
|
186
186
|
this.update((state) => {
|
|
187
187
|
// Update only the specified quote request and keep the rest of the quote requests unchanged
|
|
@@ -218,11 +218,11 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
218
218
|
* This method does not start polling for quotes and does not emit UnifiedSwapBridge events
|
|
219
219
|
*
|
|
220
220
|
* @param quoteRequest - The parameters for quote requests to fetch
|
|
221
|
-
* @param abortSignal - The abort signal to cancel all the requests
|
|
222
221
|
* @param featureId - The feature ID that maps to quoteParam overrides from LD
|
|
222
|
+
* @param abortSignal - The abort signal to cancel all the requests
|
|
223
223
|
* @returns A list of validated quotes
|
|
224
224
|
*/
|
|
225
|
-
this.fetchQuotes = async (quoteRequest,
|
|
225
|
+
this.fetchQuotes = async (quoteRequest, featureId, abortSignal = null) => {
|
|
226
226
|
const bridgeFeatureFlags = getBridgeFeatureFlags(this.messenger);
|
|
227
227
|
const jwt = await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this);
|
|
228
228
|
// If featureId is specified, retrieve the quoteRequestOverrides for that featureId
|
|
@@ -234,7 +234,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
234
234
|
const { quotes: baseQuotes, validationFailures } = await fetchBridgeQuotes(quoteRequestOverrides
|
|
235
235
|
? { ...quoteRequest, ...quoteRequestOverrides, resetApproval }
|
|
236
236
|
: { ...quoteRequest, resetApproval }, abortSignal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), jwt, __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, featureId, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
|
|
237
|
-
__classPrivateFieldGet(this, _BridgeController_trackQuoteValidationFailures, "f").call(this, validationFailures);
|
|
237
|
+
__classPrivateFieldGet(this, _BridgeController_trackQuoteValidationFailures, "f").call(this, validationFailures, featureId);
|
|
238
238
|
const quotesWithFees = await appendFeesToQuotes(baseQuotes, this.messenger, __classPrivateFieldGet(this, _BridgeController_getLayer1GasFee, "f"), __classPrivateFieldGet(this, _BridgeController_instances, "m", _BridgeController_getMultichainSelectedAccount).call(this, quoteRequest.walletAddress));
|
|
239
239
|
return sortQuotes(quotesWithFees, featureId);
|
|
240
240
|
};
|
|
@@ -244,8 +244,9 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
244
244
|
* this handler whenever they change.
|
|
245
245
|
*
|
|
246
246
|
* @param quotes - The quotes to fetch the gasless transaction data and fees for
|
|
247
|
+
* @param stxEnabled - Flag to estimate gas cost more precisely for the batch sell feature.
|
|
247
248
|
*/
|
|
248
|
-
this.updateBatchSellTrades = async (quotes) => {
|
|
249
|
+
this.updateBatchSellTrades = async (quotes, stxEnabled) => {
|
|
249
250
|
__classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f")?.abort(AbortReason.GaslessTxBatchFetched);
|
|
250
251
|
__classPrivateFieldSet(this, _BridgeController_batchSellTradesAbortController, new AbortController(), "f");
|
|
251
252
|
this.update((state) => {
|
|
@@ -253,7 +254,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
253
254
|
state.batchSellTradesLoadingStatus = RequestStatus.LOADING;
|
|
254
255
|
});
|
|
255
256
|
try {
|
|
256
|
-
const batchSellTradesResponse = await fetchBatchSellTrades(quotes, __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f").signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this), __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
|
|
257
|
+
const batchSellTradesResponse = await fetchBatchSellTrades(quotes, stxEnabled, __classPrivateFieldGet(this, _BridgeController_batchSellTradesAbortController, "f").signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), await __classPrivateFieldGet(this, _BridgeController_getJwt, "f").call(this), __classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, __classPrivateFieldGet(this, _BridgeController_clientVersion, "f"));
|
|
257
258
|
this.update((state) => {
|
|
258
259
|
state.batchSellTrades = batchSellTradesResponse;
|
|
259
260
|
state.batchSellTradesLoadingStatus = RequestStatus.FETCHED;
|
|
@@ -283,11 +284,12 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
283
284
|
console.log(`Failed to fetch batch sell trades`, error);
|
|
284
285
|
}
|
|
285
286
|
};
|
|
286
|
-
_BridgeController_trackQuoteValidationFailures.set(this, (validationFailures) => {
|
|
287
|
+
_BridgeController_trackQuoteValidationFailures.set(this, (validationFailures, featureId) => {
|
|
287
288
|
if (validationFailures.length === 0) {
|
|
288
289
|
return;
|
|
289
290
|
}
|
|
290
291
|
this.trackUnifiedSwapBridgeEvent(UnifiedSwapBridgeEventName.QuotesValidationFailed, {
|
|
292
|
+
feature_id: featureId,
|
|
291
293
|
failures: validationFailures,
|
|
292
294
|
location: __classPrivateFieldGet(this, _BridgeController_location, "f"),
|
|
293
295
|
});
|
|
@@ -318,12 +320,8 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
318
320
|
// Get unique assetIds for all quote requests
|
|
319
321
|
const assetIds = new Set(quoteRequests
|
|
320
322
|
.flatMap((quoteRequest) => [
|
|
321
|
-
quoteRequest.srcTokenAddress
|
|
322
|
-
|
|
323
|
-
: undefined,
|
|
324
|
-
quoteRequest.destTokenAddress && quoteRequest.destChainId
|
|
325
|
-
? getAssetIdsForToken(quoteRequest.destTokenAddress, quoteRequest.destChainId)
|
|
326
|
-
: undefined,
|
|
323
|
+
getAssetIdsForToken(quoteRequest.srcTokenAddress, quoteRequest.srcChainId),
|
|
324
|
+
getAssetIdsForToken(quoteRequest.destTokenAddress, quoteRequest.destChainId),
|
|
327
325
|
].flat())
|
|
328
326
|
.filter((assetId) => !selectIsAssetExchangeRateInState(exchangeRateSources, assetId)));
|
|
329
327
|
const currency = __classPrivateFieldGet(this, _BridgeController_getUseAssetsControllerForRates, "f").call(this)
|
|
@@ -437,8 +435,8 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
437
435
|
this.setLocation = (location) => {
|
|
438
436
|
__classPrivateFieldSet(this, _BridgeController_location, location, "f");
|
|
439
437
|
};
|
|
440
|
-
this.resetState = (reason = AbortReason.ResetState, quoteRequestIndex = null) => {
|
|
441
|
-
this.stopPollingForQuotes(reason);
|
|
438
|
+
this.resetState = (reason = AbortReason.ResetState, quoteRequestIndex = null, context) => {
|
|
439
|
+
this.stopPollingForQuotes(reason, context);
|
|
442
440
|
this.update((state) => {
|
|
443
441
|
// Cannot do direct assignment to state, i.e. state = {... }, need to manually assign each field
|
|
444
442
|
if (quoteRequestIndex === null) {
|
|
@@ -535,11 +533,11 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
535
533
|
__classPrivateFieldGet(this, _BridgeController_setMinimumBalanceForRentExemptionInLamports, "f").call(this, firstQuoteRequest.srcChainId, selectedAccount?.metadata?.snap?.id);
|
|
536
534
|
// Use SSE if enabled and return early
|
|
537
535
|
if (shouldStream || isBatchSellRequest) {
|
|
538
|
-
await __classPrivateFieldGet(this, _BridgeController_handleQuoteStreaming, "f").call(this, quoteRequests, jwt, selectedAccount);
|
|
536
|
+
await __classPrivateFieldGet(this, _BridgeController_handleQuoteStreaming, "f").call(this, quoteRequests, context.feature_id, jwt, selectedAccount);
|
|
539
537
|
return;
|
|
540
538
|
}
|
|
541
539
|
// Otherwise use regular fetch
|
|
542
|
-
const quotes = await this.fetchQuotes(firstQuoteRequest, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal);
|
|
540
|
+
const quotes = await this.fetchQuotes(firstQuoteRequest, context.feature_id, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal);
|
|
543
541
|
this.update((state) => {
|
|
544
542
|
// Set the initial load time if this is the first fetch
|
|
545
543
|
if (state.quotesRefreshCount ===
|
|
@@ -605,7 +603,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
605
603
|
this.stopAllPolling();
|
|
606
604
|
}
|
|
607
605
|
});
|
|
608
|
-
_BridgeController_handleQuoteStreaming.set(this, async (quoteRequests, jwt, selectedAccount) => {
|
|
606
|
+
_BridgeController_handleQuoteStreaming.set(this, async (quoteRequests, featureId, jwt, selectedAccount) => {
|
|
609
607
|
/**
|
|
610
608
|
* Tracks the number of valid quotes received from the current stream, which is used
|
|
611
609
|
* to determine when to clear the quotes list and set the initial load time
|
|
@@ -616,8 +614,8 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
616
614
|
* before setting quotesLoadingStatus to FETCHED
|
|
617
615
|
*/
|
|
618
616
|
const pendingFeeAppendPromises = new Set();
|
|
619
|
-
await fetchBridgeQuoteStream(__classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), quoteRequests, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), jwt, __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, {
|
|
620
|
-
onQuoteValidationFailure: __classPrivateFieldGet(this, _BridgeController_trackQuoteValidationFailures, "f"),
|
|
617
|
+
await fetchBridgeQuoteStream(__classPrivateFieldGet(this, _BridgeController_fetchFn, "f"), quoteRequests, __classPrivateFieldGet(this, _BridgeController_abortController, "f")?.signal, featureId, __classPrivateFieldGet(this, _BridgeController_clientId, "f"), jwt, __classPrivateFieldGet(this, _BridgeController_config, "f").customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL, {
|
|
618
|
+
onQuoteValidationFailure: (validationFailures) => __classPrivateFieldGet(this, _BridgeController_trackQuoteValidationFailures, "f").call(this, validationFailures, featureId),
|
|
621
619
|
onValidQuoteReceived: async (quote) => {
|
|
622
620
|
const feeAppendPromise = (async () => {
|
|
623
621
|
const quotesWithFees = await appendFeesToQuotes([quote], this.messenger, __classPrivateFieldGet(this, _BridgeController_getLayer1GasFee, "f"), selectedAccount);
|
|
@@ -814,7 +812,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
814
812
|
return baseProperties;
|
|
815
813
|
}
|
|
816
814
|
});
|
|
817
|
-
_BridgeController_trackInputChangedEvents.set(this, (paramsToUpdate, quoteRequestIndex = 0) => {
|
|
815
|
+
_BridgeController_trackInputChangedEvents.set(this, (paramsToUpdate, featureId, quoteRequestIndex = 0) => {
|
|
818
816
|
Object.entries(paramsToUpdate).forEach(([key, value]) => {
|
|
819
817
|
const inputKey = toInputChangedPropertyKey[key];
|
|
820
818
|
const inputValue = toInputChangedPropertyValue[key]?.(paramsToUpdate);
|
|
@@ -827,6 +825,7 @@ export class BridgeController extends StaticIntervalPollingController() {
|
|
|
827
825
|
input: inputKey,
|
|
828
826
|
input_value: inputValue,
|
|
829
827
|
location: __classPrivateFieldGet(this, _BridgeController_location, "f"),
|
|
828
|
+
feature_id: featureId,
|
|
830
829
|
});
|
|
831
830
|
}
|
|
832
831
|
});
|