Skip to content

Move the encoded referrer library module to @namehash/ens-referrals#1972

Open
tk-o wants to merge 14 commits intomainfrom
refactor/1927-move-encoded-referrer-to-ens-referrals
Open

Move the encoded referrer library module to @namehash/ens-referrals#1972
tk-o wants to merge 14 commits intomainfrom
refactor/1927-move-encoded-referrer-to-ens-referrals

Conversation

@tk-o
Copy link
Copy Markdown
Member

@tk-o tk-o commented Apr 21, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary


Why

  • PR Refactor/enssdk refactor continued #1908 review flagged that buildEncodedReferrer / decodeEncodedReferrer live in @ensnode/ensnode-sdk but are really community-facing utilities for the ENS Referral Program — they belong in @namehash/ens-referrals. Also: buildEncodedReferrer should accept Address (not NormalizedAddress) and normalize internally via toNormalizedAddress, which already throws on invalid input.

Testing


Notes for Reviewer (Optional)

  • Please review commit-by-commit.

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

tk-o added 8 commits April 21, 2026 17:15
Uses data model from `enssdk`. Also, as a workaround, defines an inline copy for the `decodeReferrer` function that cannot be imported from `@namehash/ens-referrals` package due to circular references issue.
@tk-o tk-o requested a review from a team as a code owner April 21, 2026 15:42
Copilot AI review requested due to automatic review settings April 21, 2026 15:42
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 21, 2026

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

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Apr 22, 2026 5:47am
ensnode.io Ready Ready Preview, Comment Apr 22, 2026 5:47am
ensrainbow.io Ready Ready Preview, Comment Apr 22, 2026 5:47am

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: 1c645e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@namehash/ens-referrals Major
@ensnode/ensnode-sdk Major
enssdk Major
ensapi Major
ensindexer Major
@namehash/namehash-ui Major
ensadmin Major
ensrainbow Major
fallback-ensapi Major
@ensnode/ensdb-sdk Major
@ensnode/ensnode-react Major
@ensnode/ensrainbow-sdk Major
@ensnode/integration-test-env Major
@ensnode/enskit-react-example Patch
enskit Major
@docs/ensnode Major
@docs/ensrainbow Major
enscli Major
ensskills Major
@ensnode/datasources Major
@ensnode/ponder-sdk Major
@ensnode/ponder-subgraph Major
@ensnode/shared-configs Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e57be7c2-4bbb-48b8-be97-1c7a95a286a5

📥 Commits

Reviewing files that changed from the base of the PR and between 425d2b3 and 1c645e4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • apps/ensindexer/src/plugins/registrars/shared/lib/universal-registrar-renewal-with-referrer-events.ts
  • packages/ensnode-sdk/src/registrars/zod-schemas.ts

📝 Walkthrough

Walkthrough

This PR moves referrer encode/decode utilities from @ensnode/ensnode-sdk into @namehash/ens-referrals, adds a raw Referrer type in enssdk, introduces a branded EncodedReferrer in ens-referrals, renames decodeEncodedReferrerdecodeReferrer, updates buildEncodedReferrer to accept Address (normalizing internally), and updates consumers/imports across indexer, API, UI, and schema packages.

Changes

Cohort / File(s) Summary
New type in enssdk
packages/enssdk/src/lib/types/evm.ts
Added exported Referrer alias (raw 32-byte hex).
Moved & branded utilities
packages/ens-referrals/src/encoded-referrer.ts, packages/ens-referrals/src/encoded-referrer.test.ts, packages/ens-referrals/src/index.ts
Moved runtime helpers into ens-referrals, introduced branded EncodedReferrer, renamed decoder to decodeReferrer, changed buildEncodedReferrer to accept Address and normalize internally, updated tests and re-exports.
Removed re-exports from ensnode-sdk
packages/ensnode-sdk/src/registrars/index.ts, packages/ensnode-sdk/src/registrars/registrar-action.ts
Removed encoded-referrer re-export; updated RegistrarAction referral field types to use Referrer and adjusted decodedReferrer typing.
Inlined decode logic
packages/ensnode-sdk/src/registrars/zod-schemas.ts
Inlined decode/validation constants and local decodeReferrer logic (offset, length, padding checks) to avoid runtime import.
Indexer & handler typing updates
apps/ensindexer/src/plugins/.../RegistrarController.ts, .../ETHRegistrar.ts, .../registrar-controller-events.ts, .../universal-registrar-renewal-with-referrer-events.ts
Re-typed referrer/encodedReferrer usages from EncodedReferrerReferrer and updated corresponding imports to enssdk.
Decode function migration in indexer
apps/ensindexer/src/plugins/registrars/ethnames/handlers/Ethnames_RegistrarController.ts, .../Ethnames_UniversalRegistrarRenewalWithReferrer.ts, apps/ensapi/src/lib/registrar-actions/find-registrar-actions.ts
Replaced calls/imports of decodeEncodedReferrer/ZERO_ENCODED_REFERRER from @ensnode/ensnode-sdk with decodeReferrer/ZERO_ENCODED_REFERRER from @namehash/ens-referrals.
DB schema & deps
packages/ensdb-sdk/src/ensindexer-abstract/ensv2.schema.ts, apps/ensindexer/package.json, packages/namehash-ui/package.json
Updated schema column types to Referrer and added @namehash/ens-referrals workspace dependency to indexer and UI packages.
UI import update
packages/namehash-ui/src/components/registrar-actions/RegistrarActionCard.tsx
Switched ZERO_ENCODED_REFERRER import source to @namehash/ens-referrals.
Docs & misc
packages/ens-referrals/README.md, packages/ens-referrals/src/api/zod-schemas.ts, .changeset/dirty-swans-arrive.md
Added README examples for building encoded referrers, minor zod-schemas loop refactor, and changeset documenting the move.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

ensnode-sdk

Poem

🐰 I hopped the bytes from one nest to three,
I normalized, branded, and set padding free,
Decode renamed, imports realigned,
Tiny hops in code — tidy trails behind,
Carrots for tests and a ribbon of glee! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main objective: moving the encoded referrer library module from @ensnode/ensnode-sdk to @namehash/ens-referrals.
Description check ✅ Passed The PR description follows the template and provides summary, rationale, testing approach, and notes. All required sections are present and adequately filled.
Linked Issues check ✅ Passed The changeset implements all core requirements from issue #1927: moved helpers to ens-referrals, hoisted Referrer to enssdk, branded EncodedReferrer, updated function signatures, inlined decode logic, updated consumer imports, and added documentation.
Out of Scope Changes check ✅ Passed All changes directly support the objectives of issue #1927. Minor refactoring in zod-schemas (loop syntax change) and README enhancements are consistent with the scope of this module reorganization.

✏️ 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 refactor/1927-move-encoded-referrer-to-ens-referrals

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR completes the migration of buildEncodedReferrer, decodeReferrer (renamed from decodeEncodedReferrer), EncodedReferrer, and ZERO_ENCODED_REFERRER from @ensnode/ensnode-sdk into @namehash/ens-referrals, and introduces a shared Referrer = Hex base type in enssdk. buildEncodedReferrer now accepts Address and normalizes internally via toNormalizedAddress, and EncodedReferrer is promoted to a branded subtype of Referrer to enforce construction through the validated builder. All previously flagged concerns have been addressed: the continue-skipping-i++ bug is fixed with entries(), and the local decodeReferrer copy in ensnode-sdk/zod-schemas.ts is a documented necessity to avoid a circular dependency.

Confidence Score: 5/5

Safe to merge — all P0/P1 findings from prior rounds are resolved, no new issues found.

All previously flagged issues (continue/i++ bug, decodeReferrer duplication explained by circular dependency) are resolved. The type changes are internally consistent: Referrer is the loose base for raw onchain bytes, EncodedReferrer is the branded validated subtype. Consumer sites are all updated. No remaining issues rise above P2.

No files require special attention.

Important Files Changed

Filename Overview
packages/ens-referrals/src/encoded-referrer.ts Core migration target — moves buildEncodedReferrer/decodeReferrer/EncodedReferrer/ZERO_ENCODED_REFERRER here; EncodedReferrer is now a branded subtype of Referrer; buildEncodedReferrer accepts Address and normalizes internally.
packages/enssdk/src/lib/types/evm.ts Adds Referrer = Hex as a shared base type for raw 32-byte onchain referrer values; clean addition.
packages/ensnode-sdk/src/registrars/zod-schemas.ts Inlines a local copy of decodeReferrer to avoid a circular dependency with ens-referrals; acknowledged trade-off, logic is identical to the canonical implementation in ens-referrals.
packages/ens-referrals/src/api/zod-schemas.ts Fixes previously-flagged bug where continue bypassed i++ by switching to items.entries(); no other issues.
packages/ensnode-sdk/src/registrars/registrar-action.ts Removes re-exports of moved symbols; RegistrarActionReferralAvailable.encodedReferrer now typed as Referrer (looser, but correct for raw onchain data); decodedReferrer tightened to NormalizedAddress.
packages/ens-referrals/src/encoded-referrer.test.ts Tests migrated from ensnode-sdk; decodeEncodedReferrer renamed to decodeReferrer; new test verifies buildEncodedReferrer throws on invalid address; buildEncodedReferrer test updated to accept Address directly.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph enssdk["enssdk"]
        Referrer["Referrer = Hex\n(raw 32-byte onchain value)"]
    end

    subgraph ens_referrals["@namehash/ens-referrals"]
        EncodedReferrer["EncodedReferrer\n(Referrer & branded)\nvalidly-encoded subset"]
        buildEncodedReferrer["buildEncodedReferrer(Address)\n→ EncodedReferrer"]
        decodeReferrer["decodeReferrer(Referrer)\n→ NormalizedAddress"]
        ZERO["ZERO_ENCODED_REFERRER"]
    end

    subgraph ensnode_sdk["@ensnode/ensnode-sdk"]
        RegistrarAction["RegistrarActionReferralAvailable\nencodedReferrer: Referrer\ndecodedReferrer: NormalizedAddress"]
        LocalDecodeReferrer["local decodeReferrer copy\n(circular dep workaround)"]
    end

    subgraph consumers["Consumers"]
        ensindexer["ensindexer"]
        ensapi["ensapi"]
        namehash_ui["namehash-ui"]
    end

    Referrer --> EncodedReferrer
    Referrer --> RegistrarAction
    EncodedReferrer --> buildEncodedReferrer
    EncodedReferrer --> ZERO
    buildEncodedReferrer --> decodeReferrer

    ens_referrals --> consumers
    ensnode_sdk --> consumers
    LocalDecodeReferrer -.->|"mirrors logic"| decodeReferrer
Loading

Reviews (2): Last reviewed commit: "Apply AI PR feedback" | Re-trigger Greptile

Comment thread packages/ens-referrals/src/api/zod-schemas.ts Outdated
Comment thread packages/ensnode-sdk/src/registrars/zod-schemas.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Moves the encoded referrer encode/decode utilities out of @ensnode/ensnode-sdk into the community-facing @namehash/ens-referrals, while hoisting the shared raw referrer type into enssdk to avoid dependency cycles.

Changes:

  • Added Referrer type to enssdk and updated downstream typing to use it for “raw bytes32 referrer” fields.
  • Introduced encoded-referrer module in @namehash/ens-referrals (branded EncodedReferrer, buildEncodedReferrer, decodeReferrer, constants) and ported tests/docs.
  • Removed encoded-referrer exports from @ensnode/ensnode-sdk registrars surface and inlined decode logic where needed (zod invariant), updating app/package callsites and deps.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds workspace links for @namehash/ens-referrals where newly depended upon.
packages/namehash-ui/src/components/registrar-actions/RegistrarActionCard.tsx Switches ZERO_ENCODED_REFERRER import to @namehash/ens-referrals.
packages/namehash-ui/package.json Adds dependency on @namehash/ens-referrals.
packages/enssdk/src/lib/types/evm.ts Introduces Referrer type alias.
packages/ensnode-sdk/src/registrars/zod-schemas.ts Inlines decodeReferrer + constants for zod invariant checks (no runtime import from ens-referrals).
packages/ensnode-sdk/src/registrars/registrar-action.ts Replaces EncodedReferrer with Referrer and tightens decodedReferrer to NormalizedAddress; removes re-exports.
packages/ensnode-sdk/src/registrars/index.ts Stops exporting the removed encoded-referrer module.
packages/ensdb-sdk/src/ensindexer-abstract/ensv2.schema.ts Updates schema typing from EncodedReferrer to Referrer.
packages/ens-referrals/src/index.ts Exports the new encoded-referrer module from the package root.
packages/ens-referrals/src/encoded-referrer.ts Implements branded EncodedReferrer, buildEncodedReferrer(Address), and decodeReferrer(Referrer).
packages/ens-referrals/src/encoded-referrer.test.ts Updates tests for renamed decoder and updated buildEncodedReferrer input type.
packages/ens-referrals/src/api/zod-schemas.ts Refactors edition config parsing loop (introduces an indexing bug; see PR comments).
packages/ens-referrals/README.md Documents buildEncodedReferrer under “Other Utilities”.
apps/ensindexer/src/plugins/registrars/shared/lib/universal-registrar-renewal-with-referrer-events.ts Updates referral typing from EncodedReferrer to Referrer.
apps/ensindexer/src/plugins/registrars/shared/lib/registrar-controller-events.ts Updates referral typing from EncodedReferrer to Referrer.
apps/ensindexer/src/plugins/registrars/ethnames/handlers/Ethnames_UniversalRegistrarRenewalWithReferrer.ts Switches decoding import/usage to decodeReferrer from @namehash/ens-referrals.
apps/ensindexer/src/plugins/registrars/ethnames/handlers/Ethnames_RegistrarController.ts Switches decoding import/usage to decodeReferrer from @namehash/ens-referrals.
apps/ensindexer/src/plugins/ensv2/handlers/ensv2/ETHRegistrar.ts Updates event arg typing from EncodedReferrer to Referrer.
apps/ensindexer/src/plugins/ensv2/handlers/ensv1/RegistrarController.ts Updates event arg typing from EncodedReferrer to Referrer.
apps/ensindexer/package.json Adds dependency on @namehash/ens-referrals.
apps/ensapi/src/lib/registrar-actions/find-registrar-actions.ts Switches ZERO_ENCODED_REFERRER import to @namehash/ens-referrals.
.changeset/dirty-swans-arrive.md Adds release notes + bumps for enssdk, @namehash/ens-referrals, and @ensnode/ensnode-sdk.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/enssdk/src/lib/types/evm.ts
Comment thread packages/ens-referrals/src/api/zod-schemas.ts Outdated
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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/ens-referrals/src/api/zod-schemas.ts (1)

342-372: ⚠️ Potential issue | 🔴 Critical

Bug: continue on line 358 skips i++, causing index drift in error paths.

With the index-based loop this refactor replaces, i++ ran in the loop header and always incremented — including after continue. In the new for...of form, the i++ has been moved to the end of the body (line 371), so the continue on line 358 bypasses it. As a result, once an unrecognized item fails base-parse validation, every subsequent item's re-emitted issues (and any later unrecognized-branch continue) will be reported under a stale/incorrect array index, misaligning issue paths with the original input.

🛠️ Proposed fix
-    let i = 0;
-
-    for (const item of items) {
+    for (const [i, item] of items.entries()) {
       if (knownAwardModels.includes(item.rules.awardModel)) {
         // Known award model — fully validate.
         const parsed = configSchema.safeParse(item);
         if (!parsed.success) {
           reemitIssues(ctx, parsed.error.issues, [i]);
         } else {
           result.push(parsed.data);
         }
       } else {
         // Unknown award model — preserve as ReferralProgramRulesUnrecognized using base fields.
         const parsed = unrecognizedBaseSchema.safeParse(item);
         if (!parsed.success) {
           reemitIssues(ctx, parsed.error.issues, [i]);
           continue;
         }

         result.push({
           ...parsed.data,
           rules: {
             ...parsed.data.rules,
             awardModel: ReferralProgramAwardModels.Unrecognized,
             originalAwardModel: item.rules.awardModel,
           } satisfies ReferralProgramRulesUnrecognized,
         });
       }
-
-      i++;
     }

Alternatively, move i++ before the if/else block (or use a try/finally-style guard) so it is unconditionally executed each iteration.

Note: this file's changes are unrelated to the PR's stated objective (moving encoded-referrer helpers). Consider whether this refactor belongs in a separate PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ens-referrals/src/api/zod-schemas.ts` around lines 342 - 372, The
loop's index variable i is incremented at the end of the for...of body, but a
continue in the unrecognized-item failure path skips i++, causing subsequent
error indices to be wrong; to fix, ensure i is incremented every iteration
regardless of control flow — e.g., increment i at the top of the loop (before
checking knownAwardModels) or restructure with a try/finally so i++ runs in
finally; adjust the block around items, knownAwardModels, configSchema,
unrecognizedBaseSchema, and reemitIssues so all paths (including the continue
after unrecognizedBaseSchema.safeParse failure) execute the unconditional i++
and keep the ReferralProgramAwardModels.Unrecognized/ originalAwardModel logic
unchanged.
packages/ens-referrals/README.md (1)

155-183: 🧹 Nitpick | 🔵 Trivial

Docs LGTM.

Two new subsections correctly document buildEnsReferralUrl and buildEncodedReferrer with accurate input/output examples. The intro sentence at Line 157 is a bit bare — optionally expand to mention both referral-link and encoded-referrer helpers for discoverability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ens-referrals/README.md` around lines 155 - 183, Update the brief
intro under "Other Utilities" to clearly mention both referral-link and
encoded-referrer helpers for discoverability: revise the sentence that currently
reads "The package also includes helpers." to explicitly reference the functions
buildEnsReferralUrl and buildEncodedReferrer and state that the section shows
how to build a referrer URL and an encoded referrer 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
`@apps/ensindexer/src/plugins/registrars/shared/lib/universal-registrar-renewal-with-referrer-events.ts`:
- Line 1: The local variable decodedReferrer (and any places around lines
~80-85) is widened to Address; update the import to bring in NormalizedAddress
from "enssdk" (replace Address with NormalizedAddress) and change the type
annotations for referral.decodedReferrer / decodedReferrer to NormalizedAddress
so the normalized invariant is preserved through the DB update path and matches
the treatment in registrar-controller-events.ts.

In `@packages/ens-referrals/src/encoded-referrer.ts`:
- Around line 67-76: Update the JSDoc grammar in the referrer decode docblock:
change the opening sentence from "Decode an {`@link` Referrer} value..." to
"Decode a {`@link` Referrer} value..." and similarly adjust the `@throws` lines to
use "Throws when ..." (e.g., "@throws when referrer value is not represented by
{`@link` ENCODED_REFERRER_BYTE_LENGTH} bytes." → "@throws when the referrer value
is not represented by {`@link` ENCODED_REFERRER_BYTE_LENGTH} bytes." and "@throws
when decodedReferrer is not a valid EVM address." → "@throws when the decoded
referrer is not a valid EVM address."); update the docblock that documents the
referrer decode function in encoded-referrer.ts accordingly.
- Around line 17-28: The JSDoc on ENCODED_REFERRER_BYTE_OFFSET (and the
accompanying encoded length constant) incorrectly links to Referrer instead of
the encoded representation; update the doc comments to reference EncodedReferrer
(and/or clarify "encoded referrer") and adjust wording to state these constants
describe the encoded layout (12-byte left padding, 32-byte total) rather than a
raw Referrer so the comments accurately refer to EncodedReferrer and the
encoding layout.

In `@packages/ensnode-sdk/src/registrars/zod-schemas.ts`:
- Around line 55-64: The JSDoc for the referrer decoding routine (describing
decoding a {`@link` Referrer} into a {`@link` NormalizedAddress} and referencing
{`@link` ENCODED_REFERRER_BYTE_LENGTH} and decodedReferrer) contains a redundant
`@returns` tag; remove that `@returns` line so the summary and return type alone
describe the returned decoded referrer address, leaving the rest of the comment
and exception tags intact.
- Around line 35-53: These SDK-local referrer layout constants
(ENCODED_REFERRER_BYTE_OFFSET, ENCODED_REFERRER_BYTE_LENGTH,
EXPECTED_ENCODED_REFERRER_PADDING) should be made private to the module: remove
the export keyword and keep them as internal constants (or prefix with an
underscore) so they are not exported from ensnode-sdk; update any internal
usages in this file to reference the now-non-exported symbols and do not
re-export them—if other packages need them, export from `@namehash/ens-referrals`
instead.

---

Outside diff comments:
In `@packages/ens-referrals/README.md`:
- Around line 155-183: Update the brief intro under "Other Utilities" to clearly
mention both referral-link and encoded-referrer helpers for discoverability:
revise the sentence that currently reads "The package also includes helpers." to
explicitly reference the functions buildEnsReferralUrl and buildEncodedReferrer
and state that the section shows how to build a referrer URL and an encoded
referrer value.

In `@packages/ens-referrals/src/api/zod-schemas.ts`:
- Around line 342-372: The loop's index variable i is incremented at the end of
the for...of body, but a continue in the unrecognized-item failure path skips
i++, causing subsequent error indices to be wrong; to fix, ensure i is
incremented every iteration regardless of control flow — e.g., increment i at
the top of the loop (before checking knownAwardModels) or restructure with a
try/finally so i++ runs in finally; adjust the block around items,
knownAwardModels, configSchema, unrecognizedBaseSchema, and reemitIssues so all
paths (including the continue after unrecognizedBaseSchema.safeParse failure)
execute the unconditional i++ and keep the
ReferralProgramAwardModels.Unrecognized/ originalAwardModel logic unchanged.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0829a18e-8243-4926-8c51-40ef32cf1516

📥 Commits

Reviewing files that changed from the base of the PR and between 3db8a27 and fcdb3d4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (21)
  • .changeset/dirty-swans-arrive.md
  • apps/ensapi/src/lib/registrar-actions/find-registrar-actions.ts
  • apps/ensindexer/package.json
  • apps/ensindexer/src/plugins/ensv2/handlers/ensv1/RegistrarController.ts
  • apps/ensindexer/src/plugins/ensv2/handlers/ensv2/ETHRegistrar.ts
  • apps/ensindexer/src/plugins/registrars/ethnames/handlers/Ethnames_RegistrarController.ts
  • apps/ensindexer/src/plugins/registrars/ethnames/handlers/Ethnames_UniversalRegistrarRenewalWithReferrer.ts
  • apps/ensindexer/src/plugins/registrars/shared/lib/registrar-controller-events.ts
  • apps/ensindexer/src/plugins/registrars/shared/lib/universal-registrar-renewal-with-referrer-events.ts
  • packages/ens-referrals/README.md
  • packages/ens-referrals/src/api/zod-schemas.ts
  • packages/ens-referrals/src/encoded-referrer.test.ts
  • packages/ens-referrals/src/encoded-referrer.ts
  • packages/ens-referrals/src/index.ts
  • packages/ensdb-sdk/src/ensindexer-abstract/ensv2.schema.ts
  • packages/ensnode-sdk/src/registrars/index.ts
  • packages/ensnode-sdk/src/registrars/registrar-action.ts
  • packages/ensnode-sdk/src/registrars/zod-schemas.ts
  • packages/enssdk/src/lib/types/evm.ts
  • packages/namehash-ui/package.json
  • packages/namehash-ui/src/components/registrar-actions/RegistrarActionCard.tsx
💤 Files with no reviewable changes (1)
  • packages/ensnode-sdk/src/registrars/index.ts

Comment thread packages/ens-referrals/src/encoded-referrer.ts
Comment thread packages/ensnode-sdk/src/registrars/zod-schemas.ts Outdated
Comment thread packages/ensnode-sdk/src/registrars/zod-schemas.ts
tk-o added 4 commits April 21, 2026 18:38
…in referrer bytes). Runtime helpers (`buildEncodedReferrer`, `decodeReferrer` — renamed from `decodeEncodedReferrer`, `ZERO_ENCODED_REFERRER`, and related constants) moved from `@ensnode/ensnode-sdk` to `@namehash/ens-referrals`, which now owns a branded `EncodedReferrer` type returned by `buildEncodedReferrer`. `buildEncodedReferrer` now accepts `Address` (previously `NormalizedAddress`) and normalizes internally.
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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ens-referrals/README.md (1)

7-9: ⚠️ Potential issue | 🟡 Minor

Include enssdk in the install command.

The new examples import Address from enssdk, but the installation step does not install it directly. This can fail for consumers using strict dependency resolution.

📝 Proposed docs fix
-npm install `@namehash/ens-referrals` viem
+npm install `@namehash/ens-referrals` enssdk viem

Also applies to: 161-183

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ens-referrals/README.md` around lines 7 - 9, Update the installation
instruction so consumers install the enssdk package alongside the other
dependencies: change the npm install command that currently references
"@namehash/ens-referrals viem" to also include "enssdk" because the examples
import Address from enssdk; ensure the README's install line (the code block
containing npm install `@namehash/ens-referrals` viem) is updated wherever it
appears (including the other occurrence around lines 161-183).
♻️ Duplicate comments (1)
packages/ensnode-sdk/src/registrars/zod-schemas.ts (1)

55-64: 🧹 Nitpick | 🔵 Trivial

Remove the redundant @returns tag.

Line 60 restates the function summary and return type; this was already flagged and still applies.

As per coding guidelines, “Do not add JSDoc @returns tags that merely restate the method summary; remove such redundancy during PR review”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ensnode-sdk/src/registrars/zod-schemas.ts` around lines 55 - 64, The
JSDoc block that begins "Decode a {`@link` Referrer} value into a {`@link`
NormalizedAddress}..." contains a redundant `@returns` tag that restates the
summary; remove that `@returns` tag from the referrer decoder JSDoc (the comment
attached to the referrer decoding function) so only the summary and throws tags
remain, leaving no duplicate return description.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/dirty-swans-arrive.md:
- Line 7: The changeset uses the non-hyphenated adjective "onchain"; change it
to the hyphenated form "on-chain" in the description so the sentence reads "raw
32-byte on-chain referrer bytes"; update the phrase within the same line that
mentions Referrer, buildEncodedReferrer, decodeReferrer, ZERO_ENCODED_REFERRER,
EncodedReferrer, Address and NormalizedAddress to use "on-chain" instead of
"onchain".

In `@packages/ens-referrals/src/encoded-referrer.ts`:
- Around line 67-76: Remove the redundant JSDoc `@returns` tag in the
decodeReferrer function's comment block (the block starting "Decode a {`@link`
Referrer} value into a {`@link` NormalizedAddress}") — delete the line that
restates the summary/return type and keep the other tags (`@param`, `@throws`)
intact so the documentation is not repetitive.

---

Outside diff comments:
In `@packages/ens-referrals/README.md`:
- Around line 7-9: Update the installation instruction so consumers install the
enssdk package alongside the other dependencies: change the npm install command
that currently references "@namehash/ens-referrals viem" to also include
"enssdk" because the examples import Address from enssdk; ensure the README's
install line (the code block containing npm install `@namehash/ens-referrals`
viem) is updated wherever it appears (including the other occurrence around
lines 161-183).

---

Duplicate comments:
In `@packages/ensnode-sdk/src/registrars/zod-schemas.ts`:
- Around line 55-64: The JSDoc block that begins "Decode a {`@link` Referrer}
value into a {`@link` NormalizedAddress}..." contains a redundant `@returns` tag
that restates the summary; remove that `@returns` tag from the referrer decoder
JSDoc (the comment attached to the referrer decoding function) so only the
summary and throws tags remain, leaving no duplicate return description.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a7a21eef-2f58-479d-b638-1d6d22612f30

📥 Commits

Reviewing files that changed from the base of the PR and between fcdb3d4 and 425d2b3.

📒 Files selected for processing (5)
  • .changeset/dirty-swans-arrive.md
  • packages/ens-referrals/README.md
  • packages/ens-referrals/src/api/zod-schemas.ts
  • packages/ens-referrals/src/encoded-referrer.ts
  • packages/ensnode-sdk/src/registrars/zod-schemas.ts

Comment thread .changeset/dirty-swans-arrive.md
Comment thread packages/ens-referrals/src/encoded-referrer.ts
Copy link
Copy Markdown
Member

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

Looking good and headed in the right direction.

@tk-o
Copy link
Copy Markdown
Member Author

tk-o commented Apr 22, 2026

@greptile review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR relocates encoded-referrer runtime helpers from @ensnode/ensnode-sdk into the community-facing @namehash/ens-referrals package, while hoisting the raw referrer bytes type into enssdk to avoid circular dependencies and keep SDK validation self-contained.

Changes:

  • Added Referrer type (Hex) to enssdk to represent raw on-chain bytes32 referrer values.
  • Moved/refactored runtime helpers into @namehash/ens-referrals (buildEncodedReferrer(Address), decodeReferrer(Referrer), constants, branded EncodedReferrer).
  • Updated SDK schemas and downstream apps/packages to use the new helper locations and the unbranded Referrer type where appropriate.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds workspace dependency entries for @namehash/ens-referrals where newly imported.
packages/namehash-ui/src/components/registrar-actions/RegistrarActionCard.tsx Switches ZERO_ENCODED_REFERRER import to @namehash/ens-referrals.
packages/namehash-ui/package.json Adds @namehash/ens-referrals dependency.
packages/enssdk/src/lib/types/evm.ts Introduces exported Referrer type alias.
packages/ensnode-sdk/src/registrars/zod-schemas.ts Inlines decodeReferrer logic for invariant checking without importing ens-referrals.
packages/ensnode-sdk/src/registrars/registrar-action.ts Updates referral field types: encodedReferrer: Referrer, decodedReferrer: NormalizedAddress; removes encoded-referrer re-exports.
packages/ensnode-sdk/src/registrars/index.ts Stops exporting removed encoded-referrer module.
packages/ensdb-sdk/src/ensindexer-abstract/ensv2.schema.ts Updates DB schema typing from EncodedReferrer to Referrer.
packages/ens-referrals/src/index.ts Exposes new encoded-referrer module from package root.
packages/ens-referrals/src/encoded-referrer.ts Adds branded EncodedReferrer + helpers/constants in ens-referrals.
packages/ens-referrals/src/encoded-referrer.test.ts Ports/updates tests for decodeReferrer and buildEncodedReferrer(Address) behavior.
packages/ens-referrals/src/api/zod-schemas.ts Minor loop refactor using items.entries().
packages/ens-referrals/README.md Documents buildEncodedReferrer usage from @namehash/ens-referrals.
apps/ensindexer/... Switches decoding to decodeReferrer from @namehash/ens-referrals and updates types to Referrer/NormalizedAddress.
apps/ensindexer/package.json Adds @namehash/ens-referrals dependency.
apps/ensapi/src/lib/registrar-actions/find-registrar-actions.ts Switches ZERO_ENCODED_REFERRER import to @namehash/ens-referrals.
.changeset/dirty-swans-arrive.md Declares minor bumps and describes the move/rename/type hoist.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

ens-referrals: move referrer encode/decode to ens-referrals

3 participants