Skip to content

Refactor: Correct EIP-3085 network parameter shape, propagate wallet errors, and remove transient query clients - #7

Open
mertcano wants to merge 1 commit into
robinhoodmarkets:mainfrom
mertcano:mertcano-patch-1
Open

mertcano wants to merge 1 commit into
robinhoodmarkets:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Why

Catch blocks previously swallowed wallet failures, returning { address: null } or false which made user rejections, missing wallets, and RPC failures indistinguishable from successful control flow. The network addition hook supplied an extraneous address parameter alongside wallet_addEthereumChain, violating the EIP-3085 standard expecting a single parameter object. Transient QueryClient instances were being allocated on every render, causing unnecessary cache invalidations.

How

Updated useConnect and useAddToNetwork to throw explicit, typed Error instances upon wallet rejections, missing environments, or invalid responses so React Query can properly expose failure states. Refactored addToNetwork to send exactly one standardized chain parameter object (wallet_addEthereumChain), safely validating and normalizing RPC URLs and optional explorer links. Removed per-render query-client allocations and unneeded cache invalidations from both mutation hooks.

Security/Robustness changes

Ensures accurate observability of wallet integration errors and robust network switching behavior.

…errors, and remove transient query clients

Why

Catch blocks previously swallowed wallet failures, returning { address: null } or false which made user rejections, missing wallets, and RPC failures indistinguishable from successful control flow.  The network addition hook supplied an extraneous address parameter alongside wallet_addEthereumChain, violating the EIP-3085 standard expecting a single parameter object.  Transient QueryClient instances were being allocated on every render, causing unnecessary cache invalidations.  

How

Updated useConnect and useAddToNetwork to throw explicit, typed Error instances upon wallet rejections, missing environments, or invalid responses so React Query can properly expose failure states.  Refactored addToNetwork to send exactly one standardized chain parameter object (wallet_addEthereumChain), safely validating and normalizing RPC URLs and optional explorer links.  Removed per-render query-client allocations and unneeded cache invalidations from both mutation hooks.  

Security/Robustness changes

Ensures accurate observability of wallet integration errors and robust network switching behavior.
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.

1 participant