Conversation
📝 WalkthroughWalkthroughIntroduces proxy support to JupiterClient by adding an optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
sdk/src/jupiter/jupiterClient.ts (2)
342-347: UnnecessaryfetchOptionsconditional — simplify to always pass headers.
fetchaccepts an empty headers object without issue, so the guard on line 342 adds complexity with no benefit. It also creates an inconsistency withgetSwap, which always passes headers directly.♻️ Proposed simplification
- const fetchOptions = - Object.keys(headers).length > 0 ? { headers } : {}; const quote = await ( await fetch( `${baseUrl}${apiVersionParam}/quote?${params.toString()}`, - fetchOptions + { headers } ) ).json();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sdk/src/jupiter/jupiterClient.ts` around lines 342 - 347, The fetchOptions conditional is unnecessary; remove the fetchOptions variable and always pass the headers directly to fetch (i.e., replace usage of fetchOptions with { headers }) so the call in the quote retrieval uses fetch(`${baseUrl}${apiVersionParam}/quote?${params.toString()}`, { headers }); also update any related local references in jupiterClient.ts and keep consistent with getSwap which already passes headers directly.
337-340: Extract the duplicatedapiVersionParamlogic into a private helper.The identical expression for
apiVersionParamis copy-pasted verbatim in bothgetQuote(lines 337-340) andgetSwap(lines 373-376). Extract it to keep the logic in one place.♻️ Proposed refactor — add a `getApiVersionParam()` helper
+ private getApiVersionParam(): string { + return !this.proxyUrl && + (this.url === RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API) + ? RECOMMENDED_JUPITER_API_VERSION + : ''; + }Then replace both sites:
- const apiVersionParam = - !this.proxyUrl && (this.url === RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API) - ? RECOMMENDED_JUPITER_API_VERSION - : ''; + const apiVersionParam = this.getApiVersionParam();Also applies to: 373-376
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@sdk/src/jupiter/jupiterClient.ts` around lines 337 - 340, The duplicated computation of apiVersionParam used in getQuote and getSwap should be extracted into a single private helper: add a private getApiVersionParam() method that returns the current expression (!this.proxyUrl && (this.url === RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API) ? RECOMMENDED_JUPITER_API_VERSION : ''), then replace the inline apiVersionParam assignments in getQuote and getSwap with calls to this.getApiVersionParam(); ensure the helper is used wherever that same logic appears to avoid future divergence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@sdk/src/jupiter/jupiterClient.ts`:
- Around line 342-347: The fetchOptions conditional is unnecessary; remove the
fetchOptions variable and always pass the headers directly to fetch (i.e.,
replace usage of fetchOptions with { headers }) so the call in the quote
retrieval uses fetch(`${baseUrl}${apiVersionParam}/quote?${params.toString()}`,
{ headers }); also update any related local references in jupiterClient.ts and
keep consistent with getSwap which already passes headers directly.
- Around line 337-340: The duplicated computation of apiVersionParam used in
getQuote and getSwap should be extracted into a single private helper: add a
private getApiVersionParam() method that returns the current expression
(!this.proxyUrl && (this.url === RECOMMENDED_JUPITER_API || this.url ===
LEGACY_JUPITER_API) ? RECOMMENDED_JUPITER_API_VERSION : ''), then replace the
inline apiVersionParam assignments in getQuote and getSwap with calls to
this.getApiVersionParam(); ensure the helper is used wherever that same logic
appears to avoid future divergence.
Summary by CodeRabbit