Skip to content

fix: bump sdk with new .finance domain#212

Closed
alfetopito wants to merge 4 commits intomainfrom
fix/bump-sdk
Closed

fix: bump sdk with new .finance domain#212
alfetopito wants to merge 4 commits intomainfrom
fix/bump-sdk

Conversation

@alfetopito
Copy link
Copy Markdown
Collaborator

@alfetopito alfetopito commented Apr 15, 2026

Summary

Bump to latest cow-sdk which points to the new .finance domain

Summary by CodeRabbit

  • Chores
    • Migrated API and explorer service endpoints from the cow.fi domain to cow.finance
    • Updated cow-sdk dependency to version 8.1.0
    • Improved test environment variable handling for reliability

@alfetopito alfetopito requested a review from a team April 15, 2026 15:40
@alfetopito alfetopito self-assigned this Apr 15, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

This PR performs a domain migration from cow.fi to cow.finance across multiple services, updates test fixtures for environment variable isolation, and pins the @cowprotocol/cow-sdk dependency to a specific version.

Changes

Cohort / File(s) Summary
Domain Migration (Production)
apps/api/src/app/routes/proxies/socket/index.ts, apps/twap/src/app/utils/getApiBaseUrl.ts, libs/repositories/src/datasources/cowApi.ts, libs/shared/src/utils/format.ts
Updated hardcoded domain references from cow.fi to cow.finance for socket proxies, API base URLs, and explorer URLs.
Domain Migration (Documentation)
libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.ts, libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.spec.ts
Updated inline documentation and test annotations referencing api.cow.fi to api.cow.finance.
Test Updates
apps/notification-producer/src/sendPush.test.ts
Updated test payload URL from swap.cow.fi to swap.cow.finance.
Test Fixture Improvements
libs/repositories/src/datasources/coingecko.test.ts
Enhanced test isolation by snapshotting and restoring process.env.COINGECKO_API_KEY in beforeEach/afterAll hooks, and explicitly deleting the environment variable in the "API key not set" test case.
Dependencies
package.json
Pinned @cowprotocol/cow-sdk from ^8.0.0 to 8.1.0 and added trailing newline.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 The domain hops from .fi to .finance so grand,
Each URL neatly changed across the land,
Tests now properly clean their state with care,
SDK version locked with precision fair,
A migration smooth, from web to domain affairs! 🌐

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changeset: bumping the cow-sdk dependency to version 8.1.0 and updating domain references from .fi to .finance across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bump-sdk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​cowprotocol/​cow-sdk@​8.0.0 ⏵ 8.1.07910010099100

View full report

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.ts (1)

108-108: Fix minor typo in inline comment.

At Line 108, See See and tokens is look accidental. Small cleanup will improve readability.

✏️ Suggested wording
-// If tokens is not found, return null. See See https://api.cow.finance/mainnet/api/v1/token/this-is-not-a-token/native_price
+// If token is not found, return null. See https://api.cow.finance/mainnet/api/v1/token/this-is-not-a-token/native_price
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.ts` at line 108,
Fix the inline comment in UsdRepositoryCow.ts inside the error handling comment:
remove the duplicated "See" and correct "tokens is" to "token is" so the comment
reads like "If token is not found, return null. See
https://api.cow.finance/..."—update the comment near the token lookup logic in
the UsdRepositoryCow class/function accordingly.
libs/repositories/src/datasources/cowApi.ts (1)

3-4: Normalize the base URL before path concatenation.

Good domain migration. One small hardening: if COW_API_BASE_URL ends with /, Line 17 can produce a double slash.

💡 Suggested tweak
-const COW_API_BASE_URL =
-  process.env.COW_API_BASE_URL || 'https://api.cow.finance';
+const COW_API_BASE_URL = (
+  process.env.COW_API_BASE_URL || 'https://api.cow.finance'
+).replace(/\/+$/, '');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/repositories/src/datasources/cowApi.ts` around lines 3 - 4, Normalize
COW_API_BASE_URL to remove any trailing slash before concatenating paths: update
the COW_API_BASE_URL initialization (the constant named COW_API_BASE_URL) to
trim a trailing '/' (e.g., using .replace(/\/+$/, '') or new URL(base).origin)
so subsequent concatenations that build endpoints (where you currently append
paths to COW_API_BASE_URL) cannot produce a double slash; ensure all places that
build URLs from COW_API_BASE_URL use the normalized value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libs/repositories/src/datasources/coingecko.test.ts`:
- Line 4: The test restores COINGECKO_API_KEY by assigning
process.env.COINGECKO_API_KEY = originalApiKey which can set the literal string
"undefined"; instead, update the teardown/restore logic around the
originalApiKey variable so that if originalApiKey is undefined you delete
process.env.COINGECKO_API_KEY, otherwise set process.env.COINGECKO_API_KEY =
originalApiKey; locate the restoration code referencing originalApiKey and
process.env.COINGECKO_API_KEY in the test file and replace the direct assignment
with this conditional delete-or-assign behavior.

---

Nitpick comments:
In `@libs/repositories/src/datasources/cowApi.ts`:
- Around line 3-4: Normalize COW_API_BASE_URL to remove any trailing slash
before concatenating paths: update the COW_API_BASE_URL initialization (the
constant named COW_API_BASE_URL) to trim a trailing '/' (e.g., using
.replace(/\/+$/, '') or new URL(base).origin) so subsequent concatenations that
build endpoints (where you currently append paths to COW_API_BASE_URL) cannot
produce a double slash; ensure all places that build URLs from COW_API_BASE_URL
use the normalized value.

In `@libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.ts`:
- Line 108: Fix the inline comment in UsdRepositoryCow.ts inside the error
handling comment: remove the duplicated "See" and correct "tokens is" to "token
is" so the comment reads like "If token is not found, return null. See
https://api.cow.finance/..."—update the comment near the token lookup logic in
the UsdRepositoryCow class/function accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e36b0e06-5066-41be-89f4-2f6a28e10dab

📥 Commits

Reviewing files that changed from the base of the PR and between 07f7932 and 7570dce.

⛔ Files ignored due to path filters (2)
  • libs/repositories/src/gen/cow/cow-api-types.ts is excluded by !**/gen/**
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • apps/api/src/app/routes/proxies/socket/index.ts
  • apps/notification-producer/src/sendPush.test.ts
  • apps/twap/src/app/utils/getApiBaseUrl.ts
  • libs/repositories/src/datasources/coingecko.test.ts
  • libs/repositories/src/datasources/cowApi.ts
  • libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.spec.ts
  • libs/repositories/src/repos/UsdRepository/UsdRepositoryCow.ts
  • libs/shared/src/utils/format.ts
  • package.json

import { getCoingeckoProClient } from './coingecko';

describe('getCoingeckoProClient', () => {
const originalApiKey = process.env.COINGECKO_API_KEY;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Node.js, what happens when assigning process.env.MY_VAR = undefined? Does it delete the variable or set it to the string "undefined"?

💡 Result:

Assigning process.env.MY_VAR = undefined sets the value to the string "undefined", not deleting the variable. To delete it, use delete process.env.MY_VAR. This is the documented behavior in the official Node.js documentation (v25.9.0), which states: "Assigning a property on process.env will implicitly convert the value to a string... env.test = undefined; console.log(env.test); // => 'undefined'". This behavior is deprecated, and future versions may throw an error for non-string/number/boolean values, but currently, it converts undefined to "undefined". Confirmed in Node.js GitHub issues #48875 and #9248, where developers note that assignment always stringifies the value, and delete is required to unset.

Citations:


🏁 Script executed:

cat -n libs/repositories/src/datasources/coingecko.test.ts | head -50

Repository: cowprotocol/bff

Length of output: 1781


Avoid restoring env vars via direct undefined assignment.

At lines 9 and 13, restoring with direct assignment sets "undefined" (string) when originalApiKey is absent, polluting the environment for other tests. In Node.js, assigning undefined to process.env.* coerces to the string "undefined" rather than deleting it; use delete instead, as shown on line 34.

Suggested fix
 describe('getCoingeckoProClient', () => {
   const originalApiKey = process.env.COINGECKO_API_KEY;
+
+  const restoreApiKey = () => {
+    if (originalApiKey === undefined) {
+      delete process.env.COINGECKO_API_KEY;
+    } else {
+      process.env.COINGECKO_API_KEY = originalApiKey;
+    }
+  };

   beforeEach(() => {
     jest.resetModules();
     jest.clearAllMocks();
-    process.env.COINGECKO_API_KEY = originalApiKey;
+    restoreApiKey();
   });

   afterAll(() => {
-    process.env.COINGECKO_API_KEY = originalApiKey;
+    restoreApiKey();
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@libs/repositories/src/datasources/coingecko.test.ts` at line 4, The test
restores COINGECKO_API_KEY by assigning process.env.COINGECKO_API_KEY =
originalApiKey which can set the literal string "undefined"; instead, update the
teardown/restore logic around the originalApiKey variable so that if
originalApiKey is undefined you delete process.env.COINGECKO_API_KEY, otherwise
set process.env.COINGECKO_API_KEY = originalApiKey; locate the restoration code
referencing originalApiKey and process.env.COINGECKO_API_KEY in the test file
and replace the direct assignment with this conditional delete-or-assign
behavior.

@alfetopito
Copy link
Copy Markdown
Collaborator Author

Superseded by #213

@alfetopito alfetopito closed this Apr 16, 2026
@alfetopito alfetopito deleted the fix/bump-sdk branch April 16, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant