Skip to content

fix: resolve Web3Auth social login failure caused by unreliable default RPCs - #146

Merged
invisiblemask merged 3 commits into
mainfrom
fix/web3auth-social-login-rpc
May 5, 2026
Merged

fix: resolve Web3Auth social login failure caused by unreliable default RPCs#146
invisiblemask merged 3 commits into
mainfrom
fix/web3auth-social-login-rpc

Conversation

@invisiblemask

@invisiblemask invisiblemask commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 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
  • Fix blockExplorerUrl bug where .url[0] string indexing returned "h" instead of the full URL
  • Pass chainConfig to the Web3Auth constructor as required by the SDK
  • Apply the same PublicNode RPC override to addChain calls in use-web-3-auth.tsx for multi-chain consistency

Test plan

  • RPC connectivity tests confirm PublicNode endpoints respond correctly to eth_chainId and eth_getBlockByNumber
  • Build passes with no type errors
  • Manual test: Google social login works on iq-wiki with linked local package

closes https://github.com/EveripediaNetwork/issues/issues/4867

@changeset-bot

changeset-bot Bot commented May 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e0e9ab0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@everipedia/iq-login Patch

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/config/iq-login.config.ts Outdated
tickerName: defaultChain.nativeCurrency?.name,
ticker: defaultChain.nativeCurrency?.symbol,
blockExplorerUrl: defaultChain.blockExplorers?.default.url[0] as string,
blockExplorerUrl: defaultChain.blockExplorers?.default.url as string,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
blockExplorerUrl: defaultChain.blockExplorers?.default.url as string,
blockExplorerUrl: defaultChain.blockExplorers?.default.url,

Comment thread src/hooks/use-web-3-auth.tsx Outdated
tickerName: chain.nativeCurrency?.name,
ticker: chain.nativeCurrency?.symbol,
blockExplorerUrl: chain.blockExplorers?.default.url[0] as string,
blockExplorerUrl: chain.blockExplorers?.default.url as string,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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.
@invisiblemask
invisiblemask force-pushed the fix/web3auth-social-login-rpc branch from f332d77 to bf8e4cd Compare May 5, 2026 13:08
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.
@invisiblemask
invisiblemask merged commit 5bff5c2 into main May 5, 2026
1 check passed
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