Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@shunkakinoki
Copy link
Contributor

@shunkakinoki shunkakinoki commented Feb 13, 2022

Added a resolveName hook to resolve ens to address

ref: https://docs.ens.domains/dapp-developer-guide/resolving-names

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2022

⚠️ No Changeset found

Latest commit: 1c702ed

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Feb 13, 2022

Someone is attempting to deploy a commit to a Personal Account owned by @tmm on Vercel.

@tmm first needs to authorize it.

@bpierre
Copy link
Contributor

bpierre commented Feb 13, 2022

Nice! 🙌 I didn’t realize useResolver() was not doing the actual resolving.

There are a few issues with this hook structure that got addressed by this PR: #135

In summary:

  • didCancel in the useEffect() doesn’t do anything (the condition will always be false since it happens right after the declaration) and can be safely removed.
  • resolveName is not captured by the useEffect() dependencies, which means that the useEffect() wouldn’t react to a change of provider (returned by useProvider() and used by resolveName()).
  • setState() is being called after an async operation (here and here) and will trigger warnings if the component has been rerendered / unmounted in the meantime. A didCancel flag (in a ref, outside of the useCallback()) would prevent this to happen.

@vercel
Copy link

vercel bot commented Feb 14, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/zoo/wagmi/6n8iVRL3Vuihp7efdHw8urY7qYZ4
✅ Preview: https://wagmi-git-fork-shunkakinoki-feat-ini-resolve-name-zoo.vercel.app

didCancel = true
}
}, [addressOrName, cacheBuster, skip, token])
return cancelQuery
Copy link
Member

Choose a reason for hiding this comment

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

Some carryover from #135

@tmm
Copy link
Member

tmm commented Feb 14, 2022

thanks @shunkakinoki! was meaning to add this one.

@bpierre made the updates from your comment.

resolveName is not captured by the useEffect() dependencies, which means that the useEffect() wouldn’t react to a change of provider (returned by useProvider() and used by resolveName()).

Used cacheBuster instead since it's further upsteam dep of provider. Also, update a few other hooks to use it. Another reason I didn't add actions to the useEffect deps was because I noticed a lot of unnecessary requests triggered when testing.

@tmm tmm merged commit 6105e2c into wevm:main Feb 14, 2022
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.

3 participants