Skip to content

feat: add ens crate from foundry #2376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

abhijeetbhagat
Copy link

@abhijeetbhagat abhijeetbhagat commented May 1, 2025

Motivation

while working with ENS related stuff, you need utilities like namehash calculation, forward & reverse lookups. these utilities are part of foundry-common crate. developers using alloy-rs as a result require importing foundry-common crate alongside alloy-rs which doesn't make sense since foundry in turn uses alloy-rs as a dependency. (#2372)

Solution

we need to provide ENS utilities to developers using alloy-rs by copying the ens crate from foundry with little modifications:

  • fix the EnsResolverInstance type to reflect the latest version (foundry uses old version of alloy-sol-types crate)
  • remove the inspect_err call because it in turn calls sh_eprintln which belongs to the foundry-common crate.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

can we include this in the provider crate instead, I dont think we need an additional crate for this feature

@github-project-automation github-project-automation bot moved this to In Progress in Alloy May 1, 2025
@abhijeetbhagat
Copy link
Author

can we include this in the provider crate instead, I dont think we need an additional crate for this feature

problem is that the ens file needs the alloy-contract crate (because of the contracts defined using sol!) which in turn references the alloy-provider crate. so adding the ens file to the provider crate results in cyclic dependency.

@abhijeetbhagat
Copy link
Author

@mattsse hey! what do you think?

Comment on lines +26 to +31
alloy-contract.workspace = true
alloy-primitives.workspace = true
alloy-provider.workspace = true
alloy-sol-types.workspace = true
async-trait.workspace = true
thiserror.workspace = true
Copy link
Member

Choose a reason for hiding this comment

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

we can feature gate the async/provider/contract functionality to allow importing just for the utility functions like namehash

the feature should also be re-exported in the meta crate

Copy link
Member

Choose a reason for hiding this comment

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

let's add this to the meta crate crates/alloy

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod ens;
Copy link
Member

Choose a reason for hiding this comment

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

this is unnecessary, we can move everything into lib.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants