Description
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 thequery
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 inhex
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