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

Improve query wasm contract-state CLI syntax #12

Closed
7 tasks
ethanfrey opened this issue Jan 10, 2020 · 2 comments · Fixed by #22
Closed
7 tasks

Improve query wasm contract-state CLI syntax #12

ethanfrey opened this issue Jan 10, 2020 · 2 comments · Fixed by #22
Assignees
Labels
API Fixes to the external client api

Comments

@ethanfrey
Copy link
Member

Summary

There is a comment on https://www.cosmwasm.com/docs/getting-started/first-demo that this command must be improved. Furthermore, we will soon have binary keys. Let's clean this up.

Problem Definition

There is a cli command: wasmcli query wasm contract-state $CONTRACT that dumps the entire contract state. This will quickly become unusable for all but the most simple cases. We also need to make sure the queries work well for the rest API.

Proposal

The following subcommands, each can be done as a separate PR:

  • wasmcli query wasm contract-state raw $CONTRACT $KEY - this will make access the given key inside the contracts store and return the value verbatum.
  • wasmcli query wasm contract-state smart $CONTRACT $QUERY - this will make a call to the given contract via the query handler (to be added in 0.6), and passes in $QUERY as the user message
  • wasmcli query wasm contract-state all $CONTRACT - behaves as the current one, but we need to add pagination to it. It should output (key, value) pairs (the above only output values), and should encode the key in hex format in all cases.

Encoding formats:

At least with 0.6, we will be dealing with []byte that may be ascii or may or may not be binary. Until there are major changes in cosmwasm, we can assume that the value is always valid utf-8 encoded json and just wrap this as json.RawMessage.

The key can be anything. To clarify this, we will add three flags, of which only one can be set. If none is set, we assume ascii for $QUERY and hex for $KEY. Queries are generally assumed to be json (ascii), while almost all keys will have non-ascii characters (when using prefixstore in cw-erc20 contract or cw-storage):

  • --ascii flag that will force decoding $KEY/$QUERY as ascii, eg. just cast to []byte
  • --hex flag that will force decoding $KEY/$QUERY as hex (with or without the 0x prefix)
  • --b64 flag that will force decoding $KEY/$QUERY as base64

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@ethanfrey ethanfrey added the API Fixes to the external client api label Jan 10, 2020
@workshub
Copy link

workshub bot commented Jan 13, 2020

This issue is now published on WorksHub. If you would like to work on this issue you can
start work on the WorksHub Issue Details page.

@ethanfrey
Copy link
Member Author

Closed by #22

Will need some updates with 0.6 support, but all functionality present, and tested

loloicci pushed a commit to loloicci/wasmd that referenced this issue Apr 19, 2023
* fix:wrong wasmplus amino codec register

* test: add test for getSignBytes of wasmplus

* chore: add changelog

* chore: change import order

* test: add maximum and minimum test case
NoahSaso pushed a commit to NoahSaso/wasmd that referenced this issue Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Fixes to the external client api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants