-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[bug] Account hook rpc not update on chain switch #365
Comments
@jxom , I followed exactly example in above link. I did a console.log printout and I can see the chainId being updated. But the problem is the Account hook didn't take the updated RPC URL. I need to manually refresh the browser in order to get the updated RPC URL. Based on the screenshot below, it show that chainId auto updated "4" and the url is Rinkeby. But when I check the Account hook data, the"rpc" still under Mainnet. ( Always need to manual trigger refresh browser.) This issue happened to Coinbase Wallet too. |
Basically when ever the network change, it didn't notify all the hook. When I tried to call the mint function it hit the wrong provider RPC URL. |
What exactly are you using the WalletConnect The data you're seeing there is stale (we need to fix this), however, internally you should automatically be connected to Rinkeby and the hooks should update to reflect that (and use the rinkeby RPC URLs). If you are seeing otherwise, can you provide an example of your code? Thanks. |
@jxom Below is my code. Basically click the button, to call the "onMintPressed", and it will call the contract mint function. App.js
Minter.js
|
Ah yep! I can reproduce now, thanks! This is a bug on our end. Having a look into it. |
Hopefully can be fixed ASAP. I have switched my project to Wagmi and this is the show stopper to my project. |
May I know when will this fix release to npm? |
Probably will need to investigate this one a bit further as it is not a simple fix, so I can't give you a timeframe right now. For the meantime, maybe specify an RPC URL map to the Wallet Connect connector: new WalletConnectConnector({
chains,
options: {
rpc: {
[chain.mainnet.id]: `${chain.mainnet.rpcUrls.alchemy}/${alchemyId}`,
[chain.rinkeby.id]: `${chain.rinkeby.rpcUrls.alchemy}/${alchemyId}`
}
}
}) |
I have followed your suggested method. But couldn't solved the issue. When I trigger mint, it will trigger the mainnet URL instead of the actual wallet connected network. Unless I do a manual refresh. For the testing work around, I will manual refresh. In production anyway only mainnet is allow. |
Not sure if this is related, but thought I'd ask before opening a new issue. I am seeing behavior where calling a contract with the provider/signer from wagmi seems to have missing RPC data. Does this look like the same thing? (JSON error above is misleading because the I have tried:
No luck so far! |
After stepping through all of my previous attempts, I think I figured out what was going on: My code looked something like this (including the export const connectors = {
injected: new InjectedConnector(),
qrcode: new WalletConnectConnector({
options: {
qrcode: false,
rpc: {
[chain.mainnet.id]: `${chain.mainnet.rpcUrls.alchemy}/${alchemyId}`,
[chain.rinkeby.id]: `${chain.rinkeby.rpcUrls.alchemy}/${alchemyId}`,
},
},
}),
mobile: new WalletConnectConnector({
options: {},
}),
};
export const client = createClient({
autoConnect: true,
connectors: Object.values(connectors),
}); (The map of connectors is used later to render custom display depending on the connector + screen size. Curious if there's a better approach!) I think the issue stems from both Ultimately my goal here is to use the default WalletConnect modal/UI when connecting on mobile screens, but on desktop the modal is replaced by a custom QR code display (similar to how Shields did their mint). Aside from |
This use case sounds like a perfect fit for this proposed EIP, your feedback is greatly appreciated! https://ethereum-magicians.org/t/eip-wallet-switchactiverpcprovider-rpc-method-for-supporting-aa-custom-rpc-methods-more/9142 |
@jxom , When I tried to tigger contract write function, it show below error. I think it tried to use the "http" instead of the custom url. |
@bryantoh – you are probably experiencing this because you are connected to mainnet and do not have an RPC URL defined for it on the new WalletConnectConnector({
chains,
options: {
rpc: {
[chain.mainnet.id]: `${chain.mainnet.rpcUrls.alchemy}/${alchemyId}`,
[chain.rinkeby.id]: `${chain.rinkeby.rpcUrls.alchemy}/${alchemyId}`
}
}
}) |
I have follow about method, at least now can show proper mainnet URL. I did choose Rinkeby when connecting to the wallet, but it still show mainnet URL. The screenshot below it show connected to Rinkeby. I need to manual browser refresh in order to solve this issue. |
This issue seems only happened on WalletConnect( tested on Rainbow and Metamask mobile wallet). |
Did you try setting the new WalletConnectConnector({
options: {
qrcode: true,
chainId,
rpc: {
[chain.mainnet.id]: `${chain.mainnet.rpcUrls.alchemy}/${alchemyId}`,
[chain.rinkeby.id]: `${chain.rinkeby.rpcUrls.alchemy}/${alchemyId}`,
},
},
}); |
Still the same issue. Only manual refresh will help. |
#408 should fix the issues seen here. |
just adding a comment to say that i get the same thing. connect wallet via wallet connect -> select rinkeby in wallet -> app uses mainnet -> manual refresh -> app uses rinkeby @jxom when will that be released? or is it already released? |
@outdoteth will be released once #445 is merged in. (You can subscribe to the PR if you want to get notified.) |
Even with this issue I still able release my app to production. Just add logic to enforce user connect to mainnet otherwise show "switch network" button to switch to mainnet. |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion. |
Is there an existing issue for this?
Package Version
0.3.0
Current Behavior
After I connect to the Rainbow wallet on Rinkeby chain, the Account hook, didn't automatically change the rpc to Rinkeby, instead it still showing Mainnet
Expected Behavior
It should auto update the rpc on network switch from wallet.
Steps To Reproduce
No response
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: