-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Eng 137]
ENS publicClient async usage updates
#2686
Conversation
…mproved network handling
…ith network handling
Deploying decent-interface with
|
Latest commit: |
bfa2e60
|
Status: | ✅ Deploy successful! |
Preview URL: | https://920f360f.decent-interface.pages.dev |
Branch Preview URL: | https://eng-137-ens-updates-publiccl.decent-interface.pages.dev |
…oved consistency and remove public client dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering, should we be using useEnsName
from wagmi
at all any more? My gut says no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main update
@@ -120,52 +121,50 @@ export function usePrepareFormData() { | |||
}: AzoriusERC20DAO<BigIntValuePair> & FreezeGuardConfigParam): Promise< | |||
AzoriusERC20DAO | undefined | |||
> => { | |||
if (publicClient) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This large section was just me removing this conditional
…move public client dependency
…etworks and improve address resolution logic
src/hooks/DAO/useSearchDao.ts
Outdated
const { resolvedAddress, isValid } = await resolveENSName(input); | ||
if (isValid) { | ||
await findSafes( | ||
supportedNetworks.map(network => ({ | ||
address: resolvedAddress, | ||
chainId: network.chain.id, | ||
})), | ||
); | ||
} else { | ||
const resolvedAddresses: Address[] = []; | ||
for (const chainId of supportedEnsNetworks) { | ||
const { resolvedAddress, isValid } = await resolveENSName(input, chainId); | ||
if (isValid) { | ||
resolvedAddresses.push(resolvedAddress); | ||
} | ||
} | ||
if (resolvedAddresses.length === 0) { | ||
setErrorMessage('Invalid search'); | ||
return; | ||
} | ||
|
||
const resolvedAddressesSet = new Set(resolvedAddresses); | ||
const mappedAddressesWithChainIds: ResolvedAddressWithChainId[] = []; | ||
for (const network of supportedNetworks) { | ||
for (const address of resolvedAddressesSet) { | ||
mappedAddressesWithChainIds.push({ address, chainId: network.chain.id }); | ||
} | ||
} | ||
|
||
await findSafes(mappedAddressesWithChainIds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of a refactor/update. So now it.
- attempts to resolve the address on supported ENS networks
- creates a Set of unique addresses to prevent repeated requests
- creates an array of addresses with chainIds by looping through supported networks and then the unique addresses to check each of the supported networks for each of the addresses for a safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A naming suggestion
…erface into eng-137-ens-updates-publicClient
…ied chain IDs and throw errors for unsupported chains
…rted ENS networks and enhance public client creation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering, should we be using useEnsName
from wagmi
at all any more? My gut says no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh i should have marked my last review as "Request changes". Doing that here. Please see my last couple sets of comments.
…lient creation logic
…plify client creation
- also moved loading state setter to start of
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Closes ENG-137.
So as this PR shows we have two different patterns in our app, not saying a bad thing but pointing it out.
We have a
hook
pattern, which on component mount the lookup is performed.And updated in this PR, we have the
async
pattern, where we need to make the call more explicitly either mostly in use in form validation and form submission preparation.This PR brings these 'async' instances to use the same function with the supported ens network used.