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

fix eth_accounts calls on localNetwork #454

Merged
merged 3 commits into from
Jul 27, 2023
Merged

Conversation

technophile-04
Copy link
Collaborator

Description

Since we have localWalletClient as use effect dependency we get lot of eth_accounts because of this line :

const accounts = await localWalletClient.getAddresses();

You can easily notice lot of eth_accounts while using SE-2 through CLI but for some reason on main it sometimes doesn't happens directly and if you add console.log("This is localWalletClient", localWalletClient) below the above permalink it will start making eth_accounts (😅 even I am confused about this behavior on main but I noticed on it on main)

Nevertheless, I think it makes sense not to pass objects as dependency to useEffect

Solution :

Move localWalletClient outside of the component this we don't need to pass it as a dependency.

JSON.stringify doesn't work because uid is changing in localWalletClient

{"chain" :  ........... "uid":"0f45556b091"}

@rin-st
Copy link
Member

rin-st commented Jul 27, 2023

Good job! 👍
Please do the same for <FaucetButton /> or use the same wallet client if possible

@technophile-04
Copy link
Collaborator Author

Please do the same for or use the same wallet client if possible

I think we are not using useEffect in FaucetButton 😅 but moved localWalletClient outside the component at 9426ba2 🙌

@rin-st
Copy link
Member

rin-st commented Jul 27, 2023

yes, but it created new client on every render :)

@carletex
Copy link
Member

This fixes it! Since createWalletClient is not a hook I guess we are not supposed to use it as a dep because it changes every render.

Thank all!

@carletex carletex merged commit 03d4c34 into main Jul 27, 2023
1 check passed
@carletex carletex deleted the fix/eth_account-calls branch July 27, 2023 08:43
@Pabl0cks
Copy link
Collaborator

Tested in the branch I noticed it yesterday, and fixed it. Nice job all! 🙌

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.

4 participants