Skip to content
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

feat: Batch support for Basenames and ENS names #2102

Merged
merged 13 commits into from
Mar 11, 2025

Conversation

cpcramer
Copy link
Contributor

@cpcramer cpcramer commented Mar 7, 2025

What changed? Why?
Added identity resolution components for ENS and Basename support in OnchainKit. This includes:

  • useNames hook for resolving addresses to ENS/Basename names

  • Supporting utility function (getNames) with proper chain fallback logic

  • The implementation follows the chain fallback pattern where Base-specific resolution is attempted first, then falls back to mainnet ENS resolution when needed

  • React Query is used for efficient caching and data fetching

Notes to reviewers

How has it been tested?
Without batching. 48 requests:
Screenshot 2025-03-10 at 2 34 42 PM

With batching. 14 requests:
Screenshot 2025-03-10 at 2 38 46 PM

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 5:30pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 5:30pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 5:30pm

*/
export const useNames = (
{ addresses, chain = mainnet }: UseNamesOptions,
queryOptions?: UseQueryOptions,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, allow dev to pass through any query options that Tanstack supports - will make the hook a lot more useful to support specific use cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fast follow along with Avatars.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you expose gcTime instead of cacheTime so that when you switch to Tanstack query options it won't be a breaking change and we won't have to support both?

dschlabach
dschlabach previously approved these changes Mar 11, 2025
/** Array of Ethereum addresses to resolve names for */
addresses: Address[];
/** Optional chain for domain resolution */
chain?: typeof mainnet;
Copy link
Contributor

Choose a reason for hiding this comment

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

why wouldn't this be Chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be Chain, good catch

@cpcramer cpcramer merged commit c5ddbdf into main Mar 11, 2025
16 checks passed
@cpcramer cpcramer deleted the paul/feat-batch-ens-basenames branch March 11, 2025 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants