Skip to content

fix(affiliate): replace useWalletInfo chainId usage with useWalletCha…#7230

Merged
kernelwhisperer merged 3 commits intodevelopfrom
fix/affiliate-unsupported-network
Apr 6, 2026
Merged

fix(affiliate): replace useWalletInfo chainId usage with useWalletCha…#7230
kernelwhisperer merged 3 commits intodevelopfrom
fix/affiliate-unsupported-network

Conversation

@kernelwhisperer
Copy link
Copy Markdown
Contributor

@kernelwhisperer kernelwhisperer commented Mar 30, 2026

Summary

Fixes the unsupported network logic in affiliate: https://nomevlabs.slack.com/archives/C0361CDG8GP/p1774878380978359

To Test

  1. Connect wallet to a chain that cowfi does not support
  2. It should have the same behavior like network that cowfi supports, but affiliate doesn't: Sepolia

Summary by CodeRabbit

  • Refactor
    • Internal improvements to how wallet chain identification is handled across affiliate features to enhance code organization and maintainability.

@kernelwhisperer kernelwhisperer requested a review from a team March 30, 2026 14:13
@kernelwhisperer kernelwhisperer self-assigned this Mar 30, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cowfi Ready Ready Preview Apr 6, 2026 7:38am
explorer-dev Ready Ready Preview Apr 6, 2026 7:38am
swap-dev Ready Ready Preview Apr 6, 2026 7:38am
widget-configurator Ready Ready Preview Apr 6, 2026 7:38am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored Apr 6, 2026 7:38am
sdk-tools Ignored Ignored Preview Apr 6, 2026 7:38am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cb4493e9-0085-4050-a91b-a0d5d03d47b9

📥 Commits

Reviewing files that changed from the base of the PR and between f17e9bc and 6019151.

📒 Files selected for processing (6)
  • apps/cowswap-frontend/src/modules/affiliate/containers/AffiliatePartnerCodeCreation.tsx
  • apps/cowswap-frontend/src/modules/affiliate/containers/AffiliatePartnerOnboard.tsx
  • apps/cowswap-frontend/src/modules/affiliate/containers/AffiliateTraderModalCodeLinking.tsx
  • apps/cowswap-frontend/src/modules/affiliate/hooks/useAffiliateTraderWallet.ts
  • apps/cowswap-frontend/src/modules/affiliate/lib/affiliateProgramUtils.ts
  • apps/cowswap-frontend/src/pages/Account/AffiliatePartner.tsx

Walkthrough

The affiliate module's chain ID sourcing is refactored across containers, hooks, and page components from useWalletInfo() to a dedicated useWalletChainId() hook. Utility functions isSupportedPayoutsNetwork and isSupportedTradingNetwork are updated to accept optional chain IDs, handling undefined cases explicitly.

Changes

Cohort / File(s) Summary
Affiliate Containers (ChainId Sourcing)
apps/cowswap-frontend/src/modules/affiliate/containers/AffiliatePartnerCodeCreation.tsx, AffiliatePartnerOnboard.tsx, AffiliateTraderModalCodeLinking.tsx
Refactored to source chainId from useWalletChainId() instead of useWalletInfo(), while keeping account from useWalletInfo(). Network support checks now depend on the dedicated hook.
Affiliate Hook
apps/cowswap-frontend/src/modules/affiliate/hooks/useAffiliateTraderWallet.ts
Updated to derive chainId from useWalletChainId() instead of useWalletInfo(). Chain support validation continues to use computed chainId.
Utility Functions
apps/cowswap-frontend/src/modules/affiliate/lib/affiliateProgramUtils.ts
Function signatures updated: isSupportedPayoutsNetwork(chainId?: number) and isSupportedTradingNetwork(chainId?: number) now accept optional chainId with explicit undefined handling.
Account Page
apps/cowswap-frontend/src/pages/Account/AffiliatePartner.tsx
Refactored to obtain chainId via useWalletChainId() instead of useWalletInfo(), maintaining same conditional rendering logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop and a skip, the chainId's on a trip,
From useWalletInfo() to a hook more hip!
Optional now, it handles undefined with care,
Cleaner dependencies floating in the air! ✨

🚥 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
Title check ✅ Passed The title accurately summarizes the main change: replacing useWalletInfo chainId usage with useWalletChainId across affiliate modules.
Description check ✅ Passed The description includes a summary with issue reference and testing steps, but lacks detailed background information and screenshots. It covers the essential required sections.

✏️ 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/affiliate-unsupported-network

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.

Copy link
Copy Markdown
Contributor

@Danziger Danziger left a comment

Choose a reason for hiding this comment

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

Approved, but maybe we should look into this after the fix is merged?

TBH, it's not obvious the difference of behavior between useWalletInfo and useWalletChainId, so I'll try to make the former work like the latter and maybe even get rid of useWalletChainId if there's no need for it after the change.

In any case, because of the upcoming Viem migration, I would just create an issue to look at this later. @kernelwhisperer do you want to take care of it or should I assign it to myself?

@kernelwhisperer
Copy link
Copy Markdown
Contributor Author

Approved, but maybe we should look into this after the fix is merged?

TBH, it's not obvious the difference of behavior between useWalletInfo and useWalletChainId, so I'll try to make the former work like the latter and maybe even get rid of useWalletChainId if there's no need for it after the change.

In any case, because of the upcoming Viem migration, I would just create an issue to look at this later. @kernelwhisperer do you want to take care of it or should I assign it to myself?

I think it's the way it is because the app was "designed" with chainId being a requirement, e.g. disconnected wallet gives you chainId 1 so you can get a quote without a wallet

@Danziger
Copy link
Copy Markdown
Contributor

Danziger commented Mar 30, 2026

Approved, but maybe we should look into this after the fix is merged?
TBH, it's not obvious the difference of behavior between useWalletInfo and useWalletChainId, so I'll try to make the former work like the latter and maybe even get rid of useWalletChainId if there's no need for it after the change.
In any case, because of the upcoming Viem migration, I would just create an issue to look at this later. @kernelwhisperer do you want to take care of it or should I assign it to myself?

I think it's the way it is because the app was "designed" with chainId being a requirement, e.g. disconnected wallet gives you chainId 1 so you can get a quote without a wallet

Yep, what I suggest is to look into that to see how much work it is to make the hook return null or undefined and handle using a fallback value where needed in a more explicit way.

Copy link
Copy Markdown
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

Works as described.

I share Dani's concerns on the logic, as this is very easy to miss and revert to the previous pattern.
I also agree it's not blocking.

@kernelwhisperer kernelwhisperer enabled auto-merge (squash) April 6, 2026 07:35
@kernelwhisperer kernelwhisperer merged commit 85a7d06 into develop Apr 6, 2026
14 of 15 checks passed
@kernelwhisperer kernelwhisperer deleted the fix/affiliate-unsupported-network branch April 6, 2026 07:40
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2026
@elena-zh
Copy link
Copy Markdown
Contributor

elena-zh commented Apr 6, 2026

LGTM!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants