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

Use standard clients for queries #63

Merged
merged 1 commit into from
Mar 3, 2023

Conversation

bigs
Copy link
Contributor

@bigs bigs commented Mar 2, 2023

Description

This PR relaxes the smart contract query hooks requirements from a signing CosmWasm client to a standard CosmWasm client. This makes it possible to use the hooks when an application has not connected a wallet or otherwise created a signing client.

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

  • Changed destructuring of the graz store to pull out the standard clients object rather than the signing clients object and subsequently use it to execute CosmWasm queries when a CosmWasm client is present.

Testing

  • Create a sample application that instantiates clients via useClients
  • Query a smart contract on the target chain with one of the useQuerySmart or useQueryRaw hooks
  • Verify that a result was returned without need for a signing client.

@bigs bigs requested review from codingki and grikomsn as code owners March 2, 2023 20:51
@vercel vercel bot temporarily deployed to Preview – graz-example March 2, 2023 20:53 Inactive
@vercel vercel bot temporarily deployed to Preview – graz-docs March 2, 2023 20:53 Inactive
@codingki
Copy link
Member

codingki commented Mar 2, 2023

@bigs I think we should remove address from react query hook options (enabled) because if it's not connected this hook won't run
https://github.com/strangelove-ventures/graz/blob/dev/packages/graz/src/hooks/methods.ts#L269
https://github.com/strangelove-ventures/graz/blob/dev/packages/graz/src/hooks/methods.ts#L292

@bigs
Copy link
Contributor Author

bigs commented Mar 2, 2023

@bigs I think we should remove address from react query hook options (enabled) because if it's not connected this hook won't run https://github.com/strangelove-ventures/graz/blob/dev/packages/graz/src/hooks/methods.ts#L269 https://github.com/strangelove-ventures/graz/blob/dev/packages/graz/src/hooks/methods.ts#L292

I'm not 100% sure I'm reading you right, but the reason we made address optional in the hook arguments, but required in the "action" (and present in the enabled flag) was to account for cases where the contract address was not known at first component load. A simple example of this from a product we are building is a contract representing a community that has a reference to the contract address of a corresponding membership/seat/token contract. So we have dependent queries—first we must query the community contract and get the contract address for the membership contract, at which point we can query the membership contract for information.

Does that address your concern? I may be misunderstanding!

@codingki
Copy link
Member

codingki commented Mar 3, 2023

Oh yea I got your point. My mistake I thought that address coming from user wallet

@codingki codingki merged commit 181526f into graz-sh:dev Mar 3, 2023
@bigs
Copy link
Contributor Author

bigs commented Mar 3, 2023

Awesome, thank you! :)

@codingki
Copy link
Member

codingki commented Mar 3, 2023

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