You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If that's what you mean, then no, it doesn't fix my issue. I tried it locally before opening this discussion because it seemed to be related to my issue, and now I've also pushed to prod so you can also give it a shot.
What works that before didn't:
My wallet is connected to optimism
I connect to the dapp
I see the list of proposals in the main page
In my wallet I change the network to Mainnet
I still see the list of proposals in the main page
What still does not work:
My wallet is connected to mainnet
I connect to the dapp
I don't see the list of proposals in the main page
Am I missing something obvious? Is my use of syncConnectedChain incorrect?
If I understand the documentation right (was not clear to me either), syncConnectedChain is keeping the viem state updated with the chain changes in the wallet so when you check the chainId in the account state it reflects the changes vs staying static.
My fix for a similar issue to yours was twofold.
Manually configure the desired chain in my application state and pass it into the hooks to enforce communication with the right chain.
Add a "chain is correct" validator before my writeContract calls and use swichChain(async) to trigger the chain switch if necessary.
@CuriouslyCory I was hoping to set the default chainId globally, but it seems that's not possible. Your idea to set the chainId manually in each hook seems the best solution so far. About notifying the user they are in the wrong chain, we are doing it already.
Will wait a bit to see if @tmm has any other suggestion, otherwise I'll mark your reply as the correct answer.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I’m noticing an issue with how our dApp handles chain switching, and I’d appreciate some guidance:
Our Wagmi config can be found here.
You can observe this behavior on our live site: https://propcorn.xyz.
How can we enforce that the transport always uses a specific chain (e.g., Optimism) regardless of the wallet’s connected chain?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions