Skip to content

Added ENS currency to ensnode-sdk#2017

Merged
Goader merged 6 commits intomainfrom
feat/ens-currency
May 1, 2026
Merged

Added ENS currency to ensnode-sdk#2017
Goader merged 6 commits intomainfrom
feat/ens-currency

Conversation

@Goader
Copy link
Copy Markdown
Member

@Goader Goader commented Apr 30, 2026

Added ENS currency to ensnode-sdk

closes: #1941

Summary

  • Added ENS currency types and helpers to ensnode-sdk

Why


Testing

  • Automatic CI
  • New tests

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)

@Goader Goader self-assigned this Apr 30, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 00:42
@Goader Goader requested a review from a team as a code owner April 30, 2026 00:42
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 8216c01

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

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

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

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 30, 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 May 1, 2026 11:18am
ensnode.io Ready Ready Preview, Comment May 1, 2026 11:18am
ensrainbow.io Ready Ready Preview, Comment May 1, 2026 11:18am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@Goader has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 49 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac32cb5a-b114-4ead-837c-34166428a1ab

📥 Commits

Reviewing files that changed from the base of the PR and between 7e77c5c and 8216c01.

📒 Files selected for processing (7)
  • .changeset/eager-otters-wave.md
  • packages/ensnode-sdk/src/shared/currencies.test.ts
  • packages/ensnode-sdk/src/shared/currencies.ts
  • packages/ensnode-sdk/src/shared/deserialize.ts
  • packages/ensnode-sdk/src/shared/serialize.ts
  • packages/ensnode-sdk/src/shared/zod-schemas.test.ts
  • packages/ensnode-sdk/src/shared/zod-schemas.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ens-currency

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
Review rate limit: 0/1 reviews remaining, refill in 50 minutes and 49 seconds.

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

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

Adds $ENS as a supported currency in @ensnode/ensnode-sdk, extending the shared currency model and related parsing/schema utilities so ENS-denominated prices can be represented consistently alongside ETH/USDC/DAI.

Changes:

  • Add CurrencyIds.ENS plus PriceEns/SerializedPriceEns, priceEns(), and parseEns() in shared currencies.
  • Extend Zod price parsing to accept the new ENS currency discriminator and add makePriceEnsSchema().
  • Add/extend tests for ENS currency handling and update the SDK changeset.

Reviewed changes

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

Show a summary per file
File Description
packages/ensnode-sdk/src/shared/currencies.ts Adds ENS currency ID, ENS price types, priceEns, and parseEns.
packages/ensnode-sdk/src/shared/currencies.test.ts Adds test coverage for ENS currency info, constructors, scaling, and parsing.
packages/ensnode-sdk/src/shared/zod-schemas.ts Extends makePriceSchema union and introduces makePriceEnsSchema.
packages/ensnode-sdk/src/shared/zod-schemas.test.ts Updates price schema parsing tests to include ENS and adjusts error expectation.
.changeset/eager-otters-wave.md Declares a minor release and summarizes the ENS currency additions.

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

Comment thread packages/ensnode-sdk/src/shared/currencies.ts Outdated
Comment thread .changeset/eager-otters-wave.md Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR adds ENS token ($ENS) as a supported currency in ensnode-sdk, following the exact same pattern already established for ETH, USDC, and DAI. It introduces CurrencyIds.ENSTokens, PriceEnsTokens/SerializedPriceEnsTokens types, and the priceEnsTokens, parseEnsTokens, serializePriceEnsTokens, and deserializePriceEnsTokens helpers, along with a matching Zod schema and comprehensive tests.

Confidence Score: 5/5

Safe to merge — clean, well-tested addition that follows the established currency pattern exactly.

All new code mirrors the existing ETH/DAI/USDC implementations without deviation. Types, schemas, serialization, deserialization, and parse helpers are complete and consistent. Tests cover integer/decimal parsing, precision, error cases, and type narrowing. No logic bugs or missing pieces found.

No files require special attention.

Important Files Changed

Filename Overview
packages/ensnode-sdk/src/shared/currencies.ts Adds ENSTokens currency id, PriceEnsTokens/SerializedPriceEnsTokens types, priceEnsTokens() factory, and parseEnsTokens() — all consistent with the existing ETH/DAI/USDC pattern.
packages/ensnode-sdk/src/shared/zod-schemas.ts Adds makePriceEnsTokensSchema and extends the discriminated-union makePriceSchema; error message already auto-generates from Object.values(CurrencyIds) so no hardcoded update needed.
packages/ensnode-sdk/src/shared/serialize.ts Adds serializePriceEnsTokens, consistent with existing serializers.
packages/ensnode-sdk/src/shared/deserialize.ts Adds deserializePriceEnsTokens using the new Zod schema, consistent with existing deserializers.
packages/ensnode-sdk/src/shared/currencies.test.ts Comprehensive tests covering getCurrencyInfo, priceEnsTokens, parseEnsTokens (integer, decimal, precision, error cases), and scalePrice type preservation — all values verified correct.
packages/ensnode-sdk/src/shared/zod-schemas.test.ts Updates makePriceSchema test to cover ENSTokens parsing and correct error message.
.changeset/eager-otters-wave.md Correct minor bump changeset for the new public API symbols.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["string input\n(e.g. '1.5')"] -->|parseEnsTokens| B["validateAmountToParse"]
    B -->|valid| C["getCurrencyInfo(ENSTokens)\n→ decimals: 18"]
    C --> D["parseUnits(value, 18)\nviem"]
    D --> E["priceEnsTokens(amount)\n→ PriceEnsTokens"]
    E -->|serializePriceEnsTokens| F["SerializedPriceEnsTokens\n{ currency: 'ENSTokens', amount: string }"]
    F -->|deserializePriceEnsTokens| G["makePriceEnsTokensSchema\nZod validation"]
    G -->|valid| E
    E --> H["Price union type\nPriceEth | PriceDai | PriceUsdc | PriceEnsTokens"]
    F --> I["SerializedPrice union type"]
Loading

Reviews (4): Last reviewed commit: "review" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

Missing serializePriceEns and deserializePriceEns functions in serialize.ts and deserialize.ts, even though PriceEns type exists and is part of the Price union

Fix on Vercel

Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@Goader Looks good! A few suggestions. Please take the lead to merge when ready 👍

ETH: "ETH",
USDC: "USDC",
DAI: "DAI",
ENS: "ENS",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
ENS: "ENS",
ENSTokens: "ENSTokens",

Goal: We have "ENS" in so many places all over, therefore trying to give this a more distinctive name, even if it means we aren't strictly following the same pattern for naming ENSTokens as we do for other currencies.

}

export type Price = PriceEth | PriceDai | PriceUsdc;
export interface PriceEns {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export interface PriceEns {
export interface PriceEnsTokens {

/**
* Serialized representation of {@link PriceEns}.
*/
export interface SerializedPriceEns extends Omit<PriceEns, "amount"> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export interface SerializedPriceEns extends Omit<PriceEns, "amount"> {
export interface SerializedPriceEnsTokens extends Omit<PriceEns, "amount"> {

},
[CurrencyIds.ENS]: {
id: CurrencyIds.ENS,
name: "Ethereum Name Service",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
name: "Ethereum Name Service",
name: "$ENS Tokens",

}

/**
* Create price in ENS for given amount.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* Create price in ENS for given amount.
* Create price in ENS Tokens for given amount.

return parsed.data;
}

export function deserializePriceEns(maybePrice: unknown, valueLabel?: string): PriceEns {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export function deserializePriceEns(maybePrice: unknown, valueLabel?: string): PriceEns {
export function deserializePriceEnsTokens(maybePrice: unknown, valueLabel?: string): PriceEns {

/**
* Serializes a {@link PriceEns} object.
*/
export function serializePriceEns(price: PriceEns): SerializedPriceEns {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export function serializePriceEns(price: PriceEns): SerializedPriceEns {
export function serializePriceEnsTokens(price: PriceEns): SerializedPriceEns {

Comment thread .changeset/eager-otters-wave.md Outdated
"@ensnode/ensnode-sdk": minor
---

Add `$ENS` as a supported currency in `@ensnode/ensnode-sdk`: `CurrencyIds.ENS`, `PriceEns`/`SerializedPriceEns` types, and the `priceEns`, `parseEns`, `serializePriceEns`, `deserializePriceEns` helpers.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please update the terminology here based on other feedback? Thanks!

/**
* Schema for {@link PriceEns} type.
*/
export const makePriceEnsSchema = (valueLabel: string = "Price ENS") =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export const makePriceEnsSchema = (valueLabel: string = "Price ENS") =>
export const makePriceEnsTokensSchema = (valueLabel: string = "Price ENS") =>

@@ -0,0 +1,5 @@
---
"@ensnode/ensnode-sdk": minor
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please create a new issue in the ENSAwards GitHub for "Upgrade to ENSNode v1.11.0" (our next coming release).

We'll use this issue to track special actions that should be taken on ENSAwards when it's upgraded to work with the next coming release.

For now, please begin this list of special actions to identify how the new ENS currency type should be used from ensnode-sdk.

Copilot AI review requested due to automatic review settings May 1, 2026 11:08
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

Adds support for representing ENS token-denominated prices in @ensnode/ensnode-sdk shared currency utilities, including Zod parsing/validation, (de)serialization helpers, and tests.

Changes:

  • Added CurrencyIds.ENSTokens plus PriceEnsTokens / SerializedPriceEnsTokens types and helpers (priceEnsTokens, parseEnsTokens).
  • Extended shared Zod schemas to accept/parse the new currency and added a dedicated makePriceEnsTokensSchema.
  • Added serialize/deserialize helpers for ENS-token prices and expanded unit tests for parsing and schema behavior.

Reviewed changes

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

Show a summary per file
File Description
packages/ensnode-sdk/src/shared/currencies.ts Introduces ENS-token currency ID/type and parsing/creation helpers.
packages/ensnode-sdk/src/shared/currencies.test.ts Adds unit tests for the new currency info, helpers, scaling behavior, and parsing.
packages/ensnode-sdk/src/shared/zod-schemas.ts Extends Price discriminated union + adds makePriceEnsTokensSchema.
packages/ensnode-sdk/src/shared/zod-schemas.test.ts Updates makePriceSchema tests to include the new currency and error message.
packages/ensnode-sdk/src/shared/serialize.ts Adds serializePriceEnsTokens.
packages/ensnode-sdk/src/shared/deserialize.ts Adds deserializePriceEnsTokens.
.changeset/eager-otters-wave.md Declares a minor version bump for the new currency support.

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

Comment thread packages/ensnode-sdk/src/shared/currencies.ts
Comment thread packages/ensnode-sdk/src/shared/zod-schemas.ts Outdated
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.

ensnode-sdk: Add $ENS to currencies

3 participants