Skip to content

Commit a62168b

Browse files
authored
fix: send Bungee affiliate header only for Bungee private endpoints (#494)
1 parent 6c68b97 commit a62168b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cowprotocol/cow-sdk",
3-
"version": "6.3.2",
3+
"version": "6.3.3",
44
"license": "(MIT OR Apache-2.0)",
55
"files": [
66
"/dist"

src/bridging/providers/bungee/BungeeApi.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export interface BungeeApiOptions {
5050
affiliate?: string
5151
}
5252

53+
type BungeeApiType = 'bungee' | 'events' | 'across' | 'bungee-manual'
54+
5355
interface IntermediateTokensParams {
5456
fromChainId: SupportedChainId
5557
toChainId: TargetChainId
@@ -362,8 +364,14 @@ export class BungeeApi {
362364
return bridges ?? this.options.includeBridges ?? SUPPORTED_BRIDGES
363365
}
364366

367+
private shouldAddAffiliate(apiType: BungeeApiType, baseUrl: string): boolean {
368+
const isBungeeApi = apiType === 'bungee' || apiType === 'bungee-manual'
369+
370+
return !baseUrl.includes(BUNGEE_BASE_URL) && isBungeeApi
371+
}
372+
365373
private async makeApiCall<T>(
366-
apiType: 'bungee' | 'events' | 'across' | 'bungee-manual',
374+
apiType: BungeeApiType,
367375
path: string,
368376
params: Record<string, string> | URLSearchParams,
369377
isValidResponse?: (response: unknown) => response is T,
@@ -379,7 +387,7 @@ export class BungeeApi {
379387
const url = `${baseUrl}${path}?${new URLSearchParams(params).toString()}`
380388
const headers: Record<string, string> = {}
381389

382-
if (this.options.affiliate && !baseUrl.includes(BUNGEE_BASE_URL)) {
390+
if (this.shouldAddAffiliate(apiType, baseUrl) && this.options.affiliate) {
383391
headers['affiliate'] = this.options.affiliate
384392
}
385393

0 commit comments

Comments
 (0)