Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect wallet doesn't work if stored chain id doesn't exist #5115

Open
usame-algan opened this issue Feb 25, 2025 · 1 comment
Open

Connect wallet doesn't work if stored chain id doesn't exist #5115

usame-algan opened this issue Feb 25, 2025 · 1 comment

Comments

@usame-algan
Copy link
Member

Bug description

To initialize onboard we need to pass a chainId in order to decide which wallets to enable. This chainId comes from useChainId which in turn gets the chainId from different sources in the following order:

  • From the url e.g. ?chain=1
  • From local storage under session.lastChainId depending on the safe that was last opened
  • From the connected wallet -> This is undefined because a wallet can only be connected once onboard is ready
  • From the default chain id which is either mainnet (1) or sepolia on dev environments (11155111)

However there are issues in case the user has a chainId stored under session.lastChainId that doesn't exist anymore in the chains config. This can happen if:

  • Switching between staging and prod config (only an issue for users working in both environments)
  • Turning off a network (temporarily)

Environment

  • Browser: Any
  • Wallet: Any
  • Chain: Any

Steps to reproduce

  1. Go to app.safe.global and open a safe on a network that is not supported
  2. Observe the chainId of that network is stored in local storage under session.lastChainId
  3. Go to the welcome page
  4. Try to connect your wallet

Expected result

Different options:

  • Connect button should be disabled
  • There should be an error that the wallet could not be initialized (e.g. because the network detected can't be found) and an option to "reset" the network
  • ...

Obtained result

Nothing happens

@usame-algan usame-algan changed the title Onboard initialization doesn't work sometimes Connect wallet doesn't work if stored chain id doesn't exist Feb 25, 2025
@chiranjeev13
Copy link

Hey @usame-algan I m struggling to reproduce this i tried clearing my cookies aswell but connect wallet always pops up for me here is what i did ->

  • Opened app.safe.global
  • Connected to metamask with just zkSyncEra mainnet connected to it
  • Took me to the onboard page(https://app.safe.global/welcome/accounts)
  • Then i just returned back to the welcome page and disconnected metamask
  • but I was still able to connect my wallet again

Am I missing something would be really helpful if you can send a screen recording to reproduce

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

No branches or pull requests

2 participants