Skip to content

Commit 448977d

Browse files
committed
Move the "clientVersion" param as the last one
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
1 parent 57abdba commit 448977d

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

packages/bridge-controller/src/bridge-controller.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ describe('BridgeController', function () {
429429
mockFetchFn,
430430
BRIDGE_PROD_API_BASE_URL,
431431
null,
432+
'1.0.0',
432433
);
433434
expect(bridgeController.state.quotesLastFetched).toBeNull();
434435

@@ -2558,6 +2559,7 @@ describe('BridgeController', function () {
25582559
[Function],
25592560
"https://bridge.api.cx.metamask.io",
25602561
"perps",
2562+
"1.0.0",
25612563
],
25622564
]
25632565
`);
@@ -2619,6 +2621,7 @@ describe('BridgeController', function () {
26192621
[Function],
26202622
"https://bridge.api.cx.metamask.io",
26212623
"perps",
2624+
"1.0.0",
26222625
],
26232626
]
26242627
`);
@@ -2670,6 +2673,7 @@ describe('BridgeController', function () {
26702673
[Function],
26712674
"https://bridge.api.cx.metamask.io",
26722675
null,
2676+
"1.0.0",
26732677
],
26742678
]
26752679
`);

packages/bridge-controller/src/bridge-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ export class BridgeController extends StaticIntervalPollingController<BridgePoll
373373
: quoteRequest,
374374
abortSignal,
375375
this.#clientId,
376-
this.#clientVersion,
377376
this.#fetchFn,
378377
this.#config.customBridgeApiBaseUrl ?? BRIDGE_PROD_API_BASE_URL,
379378
featureId,
379+
this.#clientVersion,
380380
);
381381

382382
this.#trackResponseValidationFailures(validationFailures);

packages/bridge-controller/src/utils/__snapshots__/fetch.test.ts.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
exports[`fetch fetchBridgeQuotes should filter out malformed bridge quotes 2`] = `
44
Array [
5+
Array [
6+
"Quote validation failed",
7+
Array [
8+
"lifi|approval",
9+
"socket|trade",
10+
],
11+
],
512
Array [
613
"Quote validation failed",
714
Array [

packages/bridge-controller/src/utils/fetch.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ describe('fetch', () => {
7979
const result = await fetchBridgeTokens(
8080
'0xa',
8181
BridgeClientId.EXTENSION,
82-
'1.0.0',
8382
mockFetchFn,
8483
BRIDGE_PROD_API_BASE_URL,
84+
'1.0.0',
8585
);
8686

8787
expect(mockFetchFn).toHaveBeenCalledWith(
@@ -144,9 +144,9 @@ describe('fetch', () => {
144144
fetchBridgeTokens(
145145
'0xa',
146146
BridgeClientId.EXTENSION,
147-
'1.0.0',
148147
mockFetchFn,
149148
BRIDGE_PROD_API_BASE_URL,
149+
'1.0.0',
150150
),
151151
).rejects.toThrow(mockError);
152152
});
@@ -174,10 +174,10 @@ describe('fetch', () => {
174174
},
175175
signal,
176176
BridgeClientId.EXTENSION,
177-
'1.0.0',
178177
mockFetchFn,
179178
BRIDGE_PROD_API_BASE_URL,
180179
null,
180+
'1.0.0',
181181
);
182182

183183
expect(mockFetchFn).toHaveBeenCalledWith(
@@ -187,7 +187,7 @@ describe('fetch', () => {
187187
cacheRefreshTime: 0,
188188
},
189189
functionName: 'fetchBridgeQuotes',
190-
headers: { 'X-Client-Id': 'extension' },
190+
headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' },
191191
signal,
192192
},
193193
);
@@ -235,10 +235,10 @@ describe('fetch', () => {
235235
},
236236
signal,
237237
BridgeClientId.EXTENSION,
238-
'1.0.0',
239238
mockFetchFn,
240239
BRIDGE_PROD_API_BASE_URL,
241240
null,
241+
'1.0.0',
242242
);
243243

244244
expect(mockFetchFn).toHaveBeenCalledWith(
@@ -248,7 +248,7 @@ describe('fetch', () => {
248248
cacheRefreshTime: 0,
249249
},
250250
functionName: 'fetchBridgeQuotes',
251-
headers: { 'X-Client-Id': 'extension' },
251+
headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' },
252252
signal,
253253
},
254254
);
@@ -314,10 +314,10 @@ describe('fetch', () => {
314314
},
315315
signal,
316316
BridgeClientId.EXTENSION,
317-
'1.0.0',
318317
mockFetchFn,
319318
BRIDGE_PROD_API_BASE_URL,
320319
null,
320+
'1.0.0',
321321
);
322322

323323
expect(mockFetchFn).toHaveBeenCalledWith(
@@ -327,7 +327,7 @@ describe('fetch', () => {
327327
cacheRefreshTime: 0,
328328
},
329329
functionName: 'fetchBridgeQuotes',
330-
headers: { 'X-Client-Id': 'extension' },
330+
headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' },
331331
signal,
332332
},
333333
);
@@ -388,10 +388,10 @@ describe('fetch', () => {
388388
},
389389
signal,
390390
BridgeClientId.EXTENSION,
391-
'1.0.0',
392391
mockFetchFn,
393392
BRIDGE_PROD_API_BASE_URL,
394393
FeatureId.PERPS,
394+
'1.0.0',
395395
);
396396

397397
expect(mockFetchFn).toHaveBeenCalledWith(
@@ -401,7 +401,7 @@ describe('fetch', () => {
401401
cacheRefreshTime: 0,
402402
},
403403
functionName: 'fetchBridgeQuotes',
404-
headers: { 'X-Client-Id': 'extension' },
404+
headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' },
405405
signal,
406406
},
407407
);
@@ -466,15 +466,15 @@ describe('fetch', () => {
466466
expect(mockFetchFn).toHaveBeenCalledWith(
467467
'https://price.api.cx.metamask.io/v3/spot-prices?assetIds=eip155%3A1%2Ferc20%3A0x123%2Ceip155%3A1%2Ferc20%3A0x456&vsCurrency=USD',
468468
{
469-
headers: { 'X-Client-Id': 'test' },
469+
headers: { 'X-Client-Id': 'test', 'Client-Version': '1.0.0' },
470470
cacheOptions: { cacheRefreshTime: 30000 },
471471
functionName: 'fetchAssetExchangeRates',
472472
},
473473
);
474474
expect(mockFetchFn).toHaveBeenCalledWith(
475475
'https://price.api.cx.metamask.io/v3/spot-prices?assetIds=eip155%3A1%2Ferc20%3A0x123%2Ceip155%3A1%2Ferc20%3A0x456&vsCurrency=EUR',
476476
{
477-
headers: { 'X-Client-Id': 'test' },
477+
headers: { 'X-Client-Id': 'test', 'Client-Version': '1.0.0' },
478478
cacheOptions: { cacheRefreshTime: 30000 },
479479
functionName: 'fetchAssetExchangeRates',
480480
},

packages/bridge-controller/src/utils/fetch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ export const getClientHeaders = (clientId: string, clientVersion?: string) => ({
3333
*
3434
* @param chainId - The chain ID to fetch tokens for
3535
* @param clientId - The client ID for metrics
36-
* @param clientVersion - The client version for metrics (optional)
3736
* @param fetchFn - The fetch function to use
3837
* @param bridgeApiBaseUrl - The base URL for the bridge API
38+
* @param clientVersion - The client version for metrics (optional)
3939
* @returns A list of enabled (unblocked) tokens
4040
*/
4141
export async function fetchBridgeTokens(
4242
chainId: Hex | CaipChainId,
4343
clientId: string,
44-
clientVersion: string | undefined,
4544
fetchFn: FetchFunction,
4645
bridgeApiBaseUrl: string,
46+
clientVersion?: string,
4747
): Promise<Record<string, BridgeAsset>> {
4848
// TODO make token api v2 call
4949
const url = `${bridgeApiBaseUrl}/getTokens?chainId=${formatChainIdToDec(chainId)}`;
@@ -73,20 +73,20 @@ export async function fetchBridgeTokens(
7373
* @param request - The quote request
7474
* @param signal - The abort signal
7575
* @param clientId - The client ID for metrics
76-
* @param clientVersion - The client version for metrics (optional)
7776
* @param fetchFn - The fetch function to use
7877
* @param bridgeApiBaseUrl - The base URL for the bridge API
7978
* @param featureId - The feature ID to append to each quote
79+
* @param clientVersion - The client version for metrics (optional)
8080
* @returns A list of bridge tx quotes
8181
*/
8282
export async function fetchBridgeQuotes(
8383
request: GenericQuoteRequest,
8484
signal: AbortSignal | null,
8585
clientId: string,
86-
clientVersion: string | undefined,
8786
fetchFn: FetchFunction,
8887
bridgeApiBaseUrl: string,
8988
featureId: FeatureId | null,
89+
clientVersion?: string,
9090
): Promise<{
9191
quotes: QuoteResponse[];
9292
validationFailures: string[];

0 commit comments

Comments
 (0)