Remove unnecessary RPC call on Faucet Button#1047
Merged
Conversation
Member
|
Nice!! I made this change for the CTF https://github.com/carletex/ctf-devcon/pull/104/files and then I forget to make this improvement on SE-2 codebase :-/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While testing the BG RPC I did a SE-2 build where I wanted to remove all the "automatic" RPC calls and only trigger them when doing an action (e.g. clicking a button).
After deleting all the obvious (getting the ETH price, the Balance from the connected wallet, etc) I realized that a RPC call for getting the connected address balance was still happening.
Digging a bit, this was coming from the
FaucetButtoncomponent: even if the component doesn't show (it returnsnullif not in localhost) theuseWatchBalancehook is still being called.This PR adds a check so we don't render/execute the FaucetButton at all (following the same logic as the block explorer link in the footer)
You can test by pulling down https://github.com/scaffold-eth/scaffold-eth-2/tree/faucet-button--test, where all the RPC calls are removed (except the FaucetButton one), so you can add the fix from this PR and check.
PS. It might be a bit nitpicky (just saving an RPC call every X seconds) but since the fix is straight forward decided to go for it.
What do y'all think?