Skip to content

feat(swap-service): unified affiliate registration#42

Merged
kaladinlight merged 9 commits into
developfrom
feat/affiliate-register-with-code
May 28, 2026
Merged

feat(swap-service): unified affiliate registration#42
kaladinlight merged 9 commits into
developfrom
feat/affiliate-register-with-code

Conversation

@kaladinlight
Copy link
Copy Markdown
Member

Description

  • POST /v1/affiliate now requires partnerCode and bps and enforces RESERVED_PARTNER_CODES (previously bypassable via this endpoint).
  • POST /v1/affiliate/claim-code route and AffiliateService.claimPartnerCode are deleted. The matching dashboard/gateway changes ship in a separate web PR that must merge before this one (deploy order matters so the gateway never proxies to a 404).
  • PARTNER_CODE_REGEX tightened to /^[a-z0-9]{3,32}$/ — lowercase letters/digits only, no hyphens or mixed case.
  • New isReservedPartnerCode helper supports exact-match against a focused brand + env list and substring match for shapeshift (catches myshapeshift, shapeshift-airdrop, etc.).
  • Reserved-code rejection now returns 400 instead of 409 — a reserved code is a validation failure, not a resource conflict.
  • Unit tests added for AffiliateService.createAffiliate (happy path, duplicate wallet, reserved code, taken code).
  • Pre-existing affiliates with partner_code IS NULL are left as-is; no backfill, no admin claim path.

Testing

  • yarn workspace @shapeshift/swap-service test passes (4 new affiliate.service tests).
  • POST /v1/affiliate/claim-code returns 404.
  • POST /v1/affiliate missing partnerCode or bps returns 400 with class-validator messages.
  • Registering with a reserved code (e.g. admin, myshapeshift) returns 400 with "This partner code is reserved".
  • Registering an already-claimed code returns 409 with "Partner code already taken".
  • Re-registering the same wallet returns 409 with "Affiliate already registered".
  • Pre-existing affiliates with partner_code IS NULL are unaffected.

kaladinlight and others added 8 commits May 28, 2026 16:02
Aligns with the dashboard/public-api validation: lowercase a-z and
digits only, 3-32 characters, no hyphens or mixed case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds ShapeShift brand terms (shapeshift, shape, fox, shapeshiftdao)
and internal/technical reserved names (root, system, support, dev,
staging, prod, www, login, etc.) to prevent collision and
impersonation. Existing entries preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…lper

Drops the account-impersonation entries (login/signin/support/etc.)
that don't match the actual threat model — partner codes aren't shown
as a trust signal anywhere user-facing. Keeps brand short forms and
dev/protocol names. Adds an isReservedPartnerCode helper with a
substring match list seeded with "shapeshift" to block codes like
"myshapeshift" or "shapeshift-airdrop".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@kaladinlight, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 1 minute and 50 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f3c79aa-050d-4311-ad58-74cf6447d14a

📥 Commits

Reviewing files that changed from the base of the PR and between f53f99d and 3b751b0.

📒 Files selected for processing (5)
  • apps/swap-service/src/affiliate/__tests__/affiliate.service.test.ts
  • apps/swap-service/src/affiliate/affiliate.controller.ts
  • apps/swap-service/src/affiliate/affiliate.service.ts
  • apps/swap-service/src/affiliate/types.ts
  • apps/swap-service/src/affiliate/utils.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/affiliate-register-with-code

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.

Narrows the exact-match list to envs (dev/develop/staging? prod/production/release/qa? trimmed by user), brand short forms, and a few system terms. Substring list keeps "shapeshift".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kaladinlight kaladinlight force-pushed the feat/affiliate-register-with-code branch from 96d48fc to 3b751b0 Compare May 28, 2026 22:48
@kaladinlight kaladinlight enabled auto-merge (squash) May 28, 2026 22:48
@kaladinlight kaladinlight merged commit bca320a into develop May 28, 2026
2 checks passed
@kaladinlight kaladinlight deleted the feat/affiliate-register-with-code branch May 28, 2026 22:50
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