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

fix useChain #361

Open
Sen-Com opened this issue Nov 7, 2023 · 6 comments
Open

fix useChain #361

Sen-Com opened this issue Nov 7, 2023 · 6 comments

Comments

@Sen-Com
Copy link

Sen-Com commented Nov 7, 2023

useChain is not correctly picking up all events.

Consider

....
const {address} = useChain("cosmosHub")
return

{address}

....

If I connect and change accounts, it works.
If I then re-connect and change accounts it does not pick up any account changes, i.e. I change account and the address does not change.

The bug is also in production, i.e. Osmosis frontend.
even forcefully refreshing the component a la

useEffect(() => () => setRefreshKey(refreshKey + 1), [chain, chainName])

is not working

@Sen-Com
Copy link
Author

Sen-Com commented Nov 7, 2023

local storage items are also not correct updated (i.e. no change) on account change

@Sen-Com
Copy link
Author

Sen-Com commented Nov 7, 2023

interestingly, useChainWallet does not suffer from the same issue and always picks up account changes correctly. That's a clear indication that the useChain hook is broken

@liujun93
Copy link
Contributor

@Sen-Com What did you do to cause re-connect? Usually Reconnect button shows up when you failed to connect, i.e. connection rejected by wallet. I tries this and reconnect, switch account still works. Is this not the re-connect you mentioned? can you list the exact steps so that we can reproduce the issue?

@Sen-Com
Copy link
Author

Sen-Com commented Nov 16, 2023

I tried countless things to make this work and all lead to the same issue: the useChain hook is not registering account changes correctly.

  1. connect wallet
  2. switch account -> registered
  3. disconnect wallet
  4. connect wallet
  5. switch account -> not registered

@liujun93
Copy link
Contributor

I still cannot reproduce it. Are you using the latest version of CosmosKit?

Maybe you can also try these steps in our doc site. https://docs.cosmoskit.com/#try-it-out

I'm using Keplr extension to test and everything works fine.

Or, can you make a simple example repo to reproduce it?

@bongdungyeuem27
Copy link

I tried countless things to make this work and all lead to the same issue: the useChain hook is not registering account changes correctly.

  1. connect wallet
  2. switch account -> registered
  3. disconnect wallet
  4. connect wallet
  5. switch account -> not registered

Yes, I have the same issue with nextjs page. And It even can not track when i use dynamic import

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

3 participants