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

Cache clients created from a call to useClients #64

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

bigs
Copy link
Contributor

@bigs bigs commented Mar 9, 2023

Description

When a programmer passes CreateClientArgs to useClients, graz will create a client for the given chain, but will not cache it in the graz store, leading to strange issues where a client has been connected but cannot be retrieved via useClients calls with no arguments. This change stores the clients in the zustand store to avoid such issues.

Checklist

  • I have made sure the upstream branch for this PR is correct
  • I have made sure this PR is ready to merge
  • I have made sure that I have assigned reviewers related to this project

Changes

  • Added an onSuccess callback to the query in useClients that updates the zustand store with the newly created clients

Testing

To test this, I modified the example app to do the following:

  • Use a useClients call with chain info passed to it to create a client for a locally running chain without having to connect a wallet
  • Make a call with useQuerySmart to query a contract on that chain
  • Add logs to show that the query does not dispatch until the client is made, at which time it is successfully dispatched

When a programmer passes CreateClientArgs to useClients, graz will create a
client for the given chain, but will not cache it in the graz store, leading
to strange issues where a client has been connected but cannot be retrieved
via useClients calls with no arguments. This change stores the clients in the
zustand store to avoid such issues.
@bigs bigs requested review from codingki and grikomsn as code owners March 9, 2023 22:53
@vercel vercel bot temporarily deployed to Preview – graz-docs March 9, 2023 22:54 Inactive
@vercel vercel bot temporarily deployed to Preview – graz-example March 9, 2023 22:55 Inactive
Copy link
Member

@codingki codingki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! yeah this hook should update the store. I'll update the useSigningClients too.

@codingki codingki merged commit 9120eb3 into graz-sh:dev Mar 10, 2023
@codingki
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants