fix: inherit consumer transport + safer mainnet default#53
Draft
technophile-04 wants to merge 2 commits into
Draft
fix: inherit consumer transport + safer mainnet default#53technophile-04 wants to merge 2 commits into
technophile-04 wants to merge 2 commits into
Conversation
Address the mainnet burner CORS/429 issue reported in scaffold-eth/scaffold-eth-2#1265. New RPC resolution order in getProvider: 1. rpcUrls[chainId] (existing override) 2. config.transports[chainId] from the consumer's wagmi config (preserves fallback chains, Alchemy keys, etc.) — same pattern used by the official walletConnect connector via extractRpcUrls 3. Curated safer default for chains whose viem default is broken in production (just mainnet -> mainnet.rpc.buidlguidl.com for now) 4. chain.rpcUrls.default.http[0] (existing final fallback) Additive, no breaking changes. Example app updated to use the transports:{} form so inheritance is visible in the network tab.
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.
why
The cause is viem's
http()with no URL falls through tochain.rpcUrls.default.http[0]. For mainnet that'seth.merkle.io, which blocks cross-origin requests from most live domains and rate-limits hard.what changed
New resolution order for the burner's RPC in
burner.ts:rpcUrls[chainId]passed to the burner. Same as before.config.transports[chainId]from the consumer's wagmi config. Preserves fallback chains, Alchemy keys, anything else they configured. This is the same pattern the officialwalletConnectconnector uses viaextractRpcUrlsin@wagmi/core.mainnet → mainnet.rpc.buidlguidl.com. Easy to extend if other chains hit the same thing.chain.rpcUrls.default.http[0]. Existing final fallback.Also swapped the raw RPC passthrough from
getHttpRpcClient(url)topublicClient.request(...)so it works with any transport shape, including the consumer'sfallback([...])chain.All additive, no breaking changes. Anyone already using
rpcUrlskeeps the exact same behavior.what this doesn't fix
Consumers using the
client({ chain })factory form ofcreateConfig(SE-2's current pattern) won't see their transport inherited.config.transportsis undefined when the consumer usesclient(), and the wagmi connector surface does not expose the client factory to connectors. Step 3 covers SE-2 on mainnet directly, so the reported CORS issue is resolved out of the box. For other chains those consumers would still need to setrainbowkitBurnerWallet.rpcUrlsexplicitly, or switch their wagmi config to thetransports: {}form.test
The example app was updated to use
transports: {}so inheritance is visible in the network tab. Connect with the burner, watch the RPC calls go to whatever Alchemy URL you configured at the wagmi level. No second RPC config needed on the wallet side.refs
extractRpcUrls(the pattern this mirrors): https://github.com/wevm/wagmi/blob/main/packages/core/src/utils/extractRpcUrls.ts