The AI Works community logo The Blockchain Works community logo The Functional Works community logo The Golang Works community logo The Java Works community logo The JavaScript Works community logo The Python Works community logo The Remote Works community logo The WorksHub company logo

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to publish this job!

Login or register
to save this job!

Login or register
to save interesting jobs!

Login or register
to get access to all your job applications!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Login or register
to save articles!

Login to see the application

Engineers who find a new job through WorksHub average a 15% increase in salary 🚀

You will be redirected back to this page right after signin

Improve `query wasm contract-state` CLI syntax

Issue closed
Pull requests: 1
Contributors: 0
Level: Intermediate
  • Go
Issue closed
Pull requests: 1
Contributors: 0
Level: Intermediate
  • Go

On GitHub

Basic cosmos-sdk app with web assembly smart contracts
More info >

Issue posted by: 
ethanfrey's avatar

Ethan Frey

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 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
  • API

Use Open Source to hire or get hired

On GitHub

Basic cosmos-sdk app with web assembly smart contracts
More info >

Issue posted by: 
ethanfrey's avatar

Ethan Frey

Use Open Source to hire or get hired

Improve `query wasm contract-state` CLI syntax
View on GitHub