Skip to content

Commit

Permalink
Fixes for auto connect state (MystenLabs#15061)
Browse files Browse the repository at this point in the history
## Description 

While integrating the `useAutoConnectWallet` hook, I encountered two
issues, which this PR fixes:
- When using SSR, the initial state can disagree between with the client
render. This is easy to work around by forcing the initial state to be
`idle`.
- The `isDisconnected` condition in auto connect led to an issue, where
after _attempting_ to connect the first time, this would become false
(since we go from disconnected -> connecting). The query would then run
with a different query key but immediately return `attempted` since
`isDisconnected` is false. This would lead to the hook resolving to
`attempted` before the connection attempt was done (this could cause UIs
to churn if you depended on this hook result). ~~I opted to just remove
this entirely, although we could also update this to depend on
`isConnected` instead, if we want.~~ (**edit:** ended up adding
`isConnected` to the query key to work around some crazy edge cases)

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
Jordan-Mysten authored Nov 28, 2023
1 parent f7eb722 commit 367779e
Show file tree
Hide file tree
Showing 10 changed files with 328 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-emus-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/dapp-kit': patch
---

Improve the reliability of the `useAutoConnectWallet` hook.
Loading

0 comments on commit 367779e

Please sign in to comment.