Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d56b414
add legacy register name functions
storywithoutend Dec 16, 2024
db176b4
fix and add tests
storywithoutend Dec 18, 2024
0aef6bf
add export code
storywithoutend Dec 18, 2024
d548d95
add prelease changeset
storywithoutend Dec 19, 2024
00e52b0
add minor changeset
storywithoutend Dec 20, 2024
78211a9
revert to before changeset pre enter command
storywithoutend Jan 7, 2025
f63d308
Revert "revert to before changeset pre enter command"
storywithoutend Jan 7, 2025
bcbdd64
revert changeset changes
storywithoutend Jan 7, 2025
d5615f5
revert changeset changes
storywithoutend Jan 7, 2025
8890de9
fix typo in release.yml
storywithoutend Jan 7, 2025
a9c1192
update release.yml for prerelease
storywithoutend Jan 7, 2025
688e6f0
v4.0.3-alpha.0
github-actions[bot] Jan 7, 2025
f530c91
add more abi snippet for ethcontroller and legacyethcontroller
storywithoutend Jan 9, 2025
984d63a
refactor and split out legacyregistration and legacyregistraionwithco…
storywithoutend Jan 10, 2025
9fc9aba
update legacyRegisterHelpers test
storywithoutend Jan 10, 2025
9e63758
fix lint error
storywithoutend Jan 10, 2025
951874e
v4.0.3-alpha.11
github-actions[bot] Jan 10, 2025
930cf26
refactor legacyRegisterName
storywithoutend Jan 13, 2025
5e345df
Merge branch 'add-register-commit-without-namewrapper' of https://git…
storywithoutend Jan 13, 2025
28c004b
fix typo in legacyEthEthRegistrarControllerNameRegisteredEventSnippet
storywithoutend Jan 13, 2025
ae1199f
Merge branch 'main' into add-register-commit-without-namewrapper
storywithoutend Jan 13, 2025
5397a10
v4.0.3-alpha.12
github-actions[bot] Jan 13, 2025
f1ccdf6
Merge branch 'v4.0.3-alpha.12-branch' into fix/update-with-other-bran…
storywithoutend Aug 19, 2025
6e28660
Add verbosity flag to CI test command for better debugging
storywithoutend Aug 19, 2025
bdc4b11
Test: Disable legacy name generator to isolate nonce issue
storywithoutend Aug 19, 2025
a31f3b2
Test: Force all transactions to use legacy generator
storywithoutend Aug 19, 2025
8433646
Fix nonce management timing in name generators
storywithoutend Aug 19, 2025
969a43a
Add nonce debug logging for legacy generator
storywithoutend Aug 19, 2025
6aca0a3
Add CI failure analysis and fix nonce management
storywithoutend Aug 19, 2025
4733950
Convert Promise.all to sequential for loop in commit phase
storywithoutend Aug 19, 2025
6297fe7
Convert Promise.all to sequential for loop in register phase
storywithoutend Aug 19, 2025
a463bbf
fix: resolve lint errors and warnings
storywithoutend Aug 19, 2025
8630c69
Add CLAUDE.md for Claude Code guidance
storywithoutend Aug 20, 2025
98e81e5
Update dependencies and contract addresses
storywithoutend Aug 20, 2025
7c07e86
Fix formatting in settings.local.json
storywithoutend Aug 20, 2025
2320b30
Restore tsconfig.node.json for tsn script functionality
storywithoutend Aug 20, 2025
a16cb1d
Remove prepack script from package.json
storywithoutend Aug 20, 2025
a36fbcd
Update release.yml
storywithoutend Aug 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Prerelease

on:
release:
types: [published]
jobs:
release:
name: Release
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

- uses: pnpm/action-setup@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- run: pnpm install --frozen-lockfile

- name: Set up git
run: |
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config --local user.name 'github-actions[bot]'

- name: Bump version to ${{ github.event.release.tag_name }}
run: |
pnpm -F @ensdomains/ensjs ver ${{ github.event.release.tag_name }}
git add .
git commit -m "${{ github.event.release.tag_name }}"

- name: Publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
pnpm config set //registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
pnpm -F @ensdomains/ensjs publish --tag next --no-git-checks

- name: Push changes
run: git push
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ jobs:
run: pnpm -F @ensdomains/ensjs build

- name: Run tests
run: pnpm -F @ensdomains/ensjs tenv start --extra-time 11368000
run: pnpm -F @ensdomains/ensjs tenv start --extra-time 11368000 --verbosity 1

- name: Publish to pkg.pr.new
run: pnpm dlx pkg-pr-new publish './packages/ensjs'

lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
147 changes: 147 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

ENSjs is the ultimate ENS JavaScript library for interacting with the Ethereum Name Service. It's built on top of viem and provides comprehensive functionality for ENS operations.

## Development Commands

### Setup and Installation
```bash
# Install dependencies (uses pnpm)
pnpm install
```

### Development Environment
```bash
# Start test environment with ENS contracts
pnpm tenv start

# Start development environment with extra time
pnpm denv

# Start Anvil without ENS node
pnpm anvil
```

### Testing
```bash
# Run all tests (no file parallelism)
pnpm test

# Watch mode for tests
pnpm test:watch

# Run specific test file
pnpm vitest src/functions/public/getOwner.test.ts
```

### Build and Lint
```bash
# Build the project
pnpm build

# Run linter (using Biome)
pnpm lint

# Clean build artifacts
pnpm clean
```

### Package Management
```bash
# Version management
pnpm ver

# Changeset commands
pnpm chgset:run
pnpm chgset:version
pnpm chgset:version:prerelease

# Local publishing for testing
pnpm publish:local:ensjs
pnpm publish:local:ens-test-env
```

## Architecture

### Monorepo Structure
- `packages/ensjs` - Main ENS library
- `packages/react` - React hooks for ENS
- `packages/ens-test-env` - Testing environment
- `packages/query-core` - Query functionality

### Client Types

ENSjs provides three specialized clients:

1. **Public Client** - Read-only blockchain operations
- Location: `src/clients/public.ts`
- Usage: `createEnsPublicClient({ chain, transport })`

2. **Wallet Client** - Write operations requiring signer
- Location: `src/clients/wallet.ts`
- Usage: `createEnsWalletClient({ chain, transport, account })`

3. **Subgraph Client** - Query ENS subgraph
- Location: `src/clients/subgraph.ts`
- Usage: Part of public client or standalone

### Code Organization

```
src/
├── clients/ # Client implementations
├── contracts/ # Contract definitions & addresses
├── functions/ # Core functionality
│ ├── public/ # Read operations
│ ├── wallet/ # Write operations
│ ├── subgraph/ # Subgraph queries
│ └── dns/ # DNS operations
├── utils/ # Utilities and helpers
└── errors/ # Error definitions
```

### Key Contracts

Contracts are defined in `src/contracts/consts.ts` for:
- Mainnet (chain ID: 1)
- Sepolia (chain ID: 11155111)
- Holesky (chain ID: 17000)

Main contracts:
- `ensRegistry` - Core ENS registry
- `ensPublicResolver` - Standard resolver
- `ensNameWrapper` - Name wrapper functionality
- `ensEthRegistrarController` - Name registration
- `ensUniversalResolver` - Batch operations

### Testing Patterns

- Tests use Vitest framework
- Test files are colocated with source (`.test.ts`)
- Uses `ens-test-env` for contract deployment
- No file parallelism to avoid conflicts

### Import Patterns

```typescript
// Main client
import { createEnsPublicClient } from '@ensdomains/ensjs'

// Specific modules
import { getOwner } from '@ensdomains/ensjs/public'
import { registerName } from '@ensdomains/ensjs/wallet'
import { getNamesForAddress } from '@ensdomains/ensjs/subgraph'
```

## Important Notes

- Always ensure tests pass before committing changes
- The library uses ESM modules (type: "module")
- Minimum Node.js version: 22
- Built with TypeScript for full type safety
- Supports tree-shaking for optimal bundle size
- Uses viem as the underlying Ethereum library
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"publish:local:ens-test-env": "yalc publish packages/ens-test-env --push --up",
"publish:local:ensjs": "yalc publish packages/ensjs --push --up",
"chgset:version": "changeset version && pnpm install",
"chgset:version:prerelease": "changeset pre enter next && pnpm chgset:version",
"chgset:run": "changeset",
"release": "pnpm publish -r --access public && changeset tag",
"chgset": "pnpm chgset:run && pnpm chgset:version",
Expand Down
16 changes: 16 additions & 0 deletions packages/ensjs/.claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"permissions": {
"allow": [
"mcp__github__search_pull_requests",
"mcp__github__get_pull_request_files",
"mcp__github__search_code",
"Bash(npm test:*)",
"Bash(npm --version)",
"Bash(git log:*)",
"Bash(find:*)",
"Bash(git add:*)",
"Bash(ls:*)"
],
"deny": []
}
}
114 changes: 58 additions & 56 deletions packages/ensjs/deploy/00_register_concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,37 @@ const func: DeployFunction = async (hre) => {
await network.provider.send('evm_setAutomine', [false])

// Commit
const commitTxs = await Promise.all(
names.map(
({
const commitTxs: Hash[] = []
for (const {
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
} of names) {
console.log(`Committing commitment for ${label}.eth...`)
let tx: Hash
if (type === 'legacy') {
tx = await legacyNameGenerator.commit({
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
}) => {
console.log(`Committing commitment for ${label}.eth...`)
if (type === 'legacy')
return legacyNameGenerator.commit({
label,
namedOwner,
namedAddr,
})
return wrappedNameGenerator.commit({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
},
),
)
namedAddr,
})
} else {
tx = await wrappedNameGenerator.commit({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
}
commitTxs.push(tx)
}

network.provider.send('evm_mine')
await Promise.all(
Expand All @@ -123,36 +124,37 @@ const func: DeployFunction = async (hre) => {
await network.provider.send('evm_mine')

// Register
const registerTxs = await Promise.all(
names.map(
({
const registerTxs: Hash[] = []
for (const {
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
} of names) {
let tx: Hash
if (type === 'legacy') {
tx = await legacyNameGenerator.register({
label,
type,
namedOwner,
namedAddr = namedOwner,
data = [],
reverseRecord = false,
fuses = 0,
duration = 31536000,
}) => {
if (type === 'legacy')
return legacyNameGenerator.register({
label,
namedOwner,
namedAddr,
duration,
})
return wrappedNameGenerator.register({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
},
),
)
namedAddr,
duration,
})
} else {
tx = await wrappedNameGenerator.register({
label,
namedOwner,
data,
reverseRecord,
fuses,
duration,
})
}
registerTxs.push(tx)
}

await network.provider.send('evm_mine')
await Promise.all(
Expand Down
5 changes: 2 additions & 3 deletions packages/ensjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ensdomains/ensjs",
"version": "4.0.2",
"version": "4.0.3-alpha.12",
"description": "ENS javascript library for contract interaction",
"type": "module",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -80,15 +80,14 @@
"build": "tsc --project tsconfig.build.json",
"tsn": "TS_NODE_PROJECT=tsconfig.node.json node --loader ts-node/esm",
"prepublish": "pnpm build && cp ../../README.md ../../LICENSE ./",
"prepack": "pnpm tsn ./scripts/prepack.ts",
"ver": "pnpm tsn ./scripts/updateVersion.ts",
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts",
"rcBranchVersion": "pnpm tsn ./scripts/rcBranchVersion.ts",
"hh": "NODE_OPTIONS='--experimental-loader ts-node/esm/transpile-only' hardhat"
},
"dependencies": {
"@adraffy/ens-normalize": "1.10.1",
"@ensdomains/address-encoder": "1.1.1",
"@ensdomains/address-encoder": "1.1.3",
"@ensdomains/content-hash": "3.1.0-rc.1",
"@ensdomains/dnsprovejs": "^0.5.1",
"abitype": "^1.0.0",
Expand Down
Loading