Skip to content

Comments

Remove unnecessary RPC call on Faucet Button#1047

Merged
carletex merged 1 commit intomainfrom
faucet-button
Jan 30, 2025
Merged

Remove unnecessary RPC call on Faucet Button#1047
carletex merged 1 commit intomainfrom
faucet-button

Conversation

@carletex
Copy link
Member

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 FaucetButton component: even if the component doesn't show (it returns null if not in localhost) the useWatchBalance hook 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?

@carletex carletex requested review from Pabl0cks and rin-st January 30, 2025 13:39
Copy link
Member

@rin-st rin-st left a comment

Choose a reason for hiding this comment

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

Good point! Lgtm!

@carletex carletex merged commit 90058a3 into main Jan 30, 2025
1 check passed
@carletex carletex deleted the faucet-button branch January 30, 2025 15:06
@damianmarti
Copy link
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 :-/

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