fix: resolve Web3Auth social login failure caused by unreliable default RPCs - #146
Conversation
🦋 Changeset detectedLatest commit: e0e9ab0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Code Review
This pull request fixes Web3Auth social login failures by replacing unreliable default RPCs with PublicNode RPCs for Ethereum and Polygon. It also corrects a bug where blockExplorerUrl was incorrectly indexed as a string and ensures the chainConfig is properly passed during initialization. Review feedback highlights unsafe type assertions on blockExplorerUrl; removing these assertions is recommended to allow the type system to correctly handle optional values.
| tickerName: defaultChain.nativeCurrency?.name, | ||
| ticker: defaultChain.nativeCurrency?.symbol, | ||
| blockExplorerUrl: defaultChain.blockExplorers?.default.url[0] as string, | ||
| blockExplorerUrl: defaultChain.blockExplorers?.default.url as string, |
There was a problem hiding this comment.
The as string type assertion is unsafe because blockExplorers is optional in the Chain type. If it is missing, blockExplorerUrl will be undefined. Since blockExplorerUrl is optional in the Web3Auth configuration, it is safer to remove the assertion to allow the type system to correctly handle the optionality.
| blockExplorerUrl: defaultChain.blockExplorers?.default.url as string, | |
| blockExplorerUrl: defaultChain.blockExplorers?.default.url, |
| tickerName: chain.nativeCurrency?.name, | ||
| ticker: chain.nativeCurrency?.symbol, | ||
| blockExplorerUrl: chain.blockExplorers?.default.url[0] as string, | ||
| blockExplorerUrl: chain.blockExplorers?.default.url as string, |
There was a problem hiding this comment.
The as string assertion is unsafe here as well. Removing it allows the type system to correctly handle the case where blockExplorers is missing, avoiding potential runtime issues if the value is undefined.
| blockExplorerUrl: chain.blockExplorers?.default.url as string, | |
| blockExplorerUrl: chain.blockExplorers?.default.url, |
…default RPCs Replace viem's default RPC endpoints (eth.merkle.io, polygon-rpc.com) with reliable PublicNode RPCs for Ethereum and Polygon. These defaults fail for eth_getBlockByNumber which Web3Auth's TransactionFormatter calls during provider setup after OAuth, causing social login to silently fail. Also fixes blockExplorerUrl bug where string indexing returned a single character instead of the full URL, and passes chainConfig to the Web3Auth constructor as required by the SDK.
f332d77 to
bf8e4cd
Compare
blockExplorers is optional on Chain type, so the `as string` assertion masks a potential undefined. Since Web3Auth's blockExplorerUrl config is also optional, let the type system handle it correctly.
Summary
eth.merkle.io,polygon-rpc.com) with reliable PublicNode RPCs for Ethereum and Polygon — these defaults fail foreth_getBlockByNumberwhich Web3Auth'sTransactionFormattercalls during provider setup after OAuth, causing social login to silently failblockExplorerUrlbug where.url[0]string indexing returned"h"instead of the full URLchainConfigto theWeb3Authconstructor as required by the SDKaddChaincalls inuse-web-3-auth.tsxfor multi-chain consistencyTest plan
eth_chainIdandeth_getBlockByNumbercloses https://github.com/EveripediaNetwork/issues/issues/4867