-
Notifications
You must be signed in to change notification settings - Fork 2
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
[Fix] wagmi switch chain claim error #41
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
connectionHasSwitchChain = !!currentConnection?.connector.switchChain | ||
} | ||
|
||
if (account.address && connectionHasSwitchChain) { | ||
address = account.address | ||
} else { | ||
onShowMetaMaskPopup?.() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed, but didn't want to slow down this PR. If MM ext sends a notification, the appropriate window will already be shown in the UI.
*/ | ||
let connectionHasSwitchChain = false | ||
if (config.state.current) { | ||
const currentConnection = config.state.connections.get( | ||
config.state.current | ||
) | ||
connectionHasSwitchChain = !!currentConnection?.connector.switchChain | ||
} | ||
|
||
if (account.address && connectionHasSwitchChain) { | ||
address = account.address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at their code, it looks like switchChain is not supported by all the connectors https://github.com/wevm/wagmi/blob/main/packages/core/src/connectors/createConnector.ts#L64
if that's the case, then we'd never enter this if clause
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it would always throw on line 249 then since we need switch chain to be present to proceed.
await switchChainAsync({ chainId: reward.chain_id })
If the connector didn't have switch chain, then another connect call would be performed to try and connect to the injected provider which does have switchChain
. This is our intended UX for now I believe.
see HyperPlay-Gaming/hyperplay-desktop-client#1185 and https://github.com/HyperPlay-Gaming/product-management/issues/801
Something about our client implemenation or a wagmi bug is causing the address to be set but no connection is established. It is stuck in
reconnecting
status, so perhaps it connects, get the address, and then loses the connection object but keeps the address on the config object.We can just make the same check that wagmi does in switch chain and call
connectAsync
if it fails to ensure the connection is made to wagmi