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

[Eng 137] ENS publicClient async usage updates #2686

Merged
merged 14 commits into from
Jan 30, 2025

Conversation

Da-Colon
Copy link
Contributor

@Da-Colon Da-Colon commented Jan 23, 2025

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.

@Da-Colon Da-Colon self-assigned this Jan 23, 2025
Copy link

linear bot commented Jan 23, 2025

ENG-137 ENS updates

Copy link

cloudflare-workers-and-pages bot commented Jan 23, 2025

Deploying decent-interface with  Cloudflare Pages  Cloudflare Pages

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

View logs

…oved consistency and remove public client dependency
Copy link
Contributor Author

Choose a reason for hiding this comment

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

main update

Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Contributor Author

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

@Da-Colon Da-Colon marked this pull request as ready for review January 23, 2025 20:26
@Da-Colon Da-Colon marked this pull request as draft January 23, 2025 22:35
Comment on lines 45 to 68
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);
Copy link
Contributor Author

@Da-Colon Da-Colon Jan 23, 2025

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.

Copy link
Contributor

@DarksightKellar DarksightKellar left a 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
@Da-Colon Da-Colon marked this pull request as ready for review January 24, 2025 18:11
Copy link
Contributor

@DarksightKellar DarksightKellar left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

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.

Copy link
Member

@adamgall adamgall left a 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.

Base automatically changed from eng-137-ens-updates to develop January 30, 2025 17:27
@Da-Colon Da-Colon merged commit e187362 into develop Jan 30, 2025
4 checks passed
@Da-Colon Da-Colon deleted the eng-137-ens-updates-publicClient branch January 30, 2025 17:48
Copy link

sentry-io bot commented Feb 5, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: disallowed character: " "‎ {20} /create/* View Issue
  • ‼️ Error: disallowed character: " "‎ {20} /create/* View Issue

Did you find this useful? React with a 👍 or 👎

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