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

wasmd query wasm contract-state all --DECODE flag #1550

Open
dzmitry-lahoda opened this issue Aug 10, 2023 · 4 comments
Open

wasmd query wasm contract-state all --DECODE flag #1550

dzmitry-lahoda opened this issue Aug 10, 2023 · 4 comments
Milestone

Comments

@dzmitry-lahoda
Copy link

Can we have query to dump all state and decode it?

No I need to write some bash/jq/xxd/base64 script loop or smart queries:

wasmd query wasm contract-state all $CONTRACT $NODE --output "json" | jq -r '.models[0].key' | xxd -r -ps
wasmd query wasm contract-state all $CONTRACT $NODE --output "json" | jq -r '.models[0].value' | base64 -d

So in my cases I just want dump state of contract and read it in my dev/debug loop, but decoded

Is this worth to add? My be such tools exists and I miss it.

@alpe
Copy link
Member

alpe commented Aug 17, 2023

Technically, it would not be hard to decode keys and values in the CLI but they can be anything. Not likely human readable or nice to render on the shell. What would be your preferred output format?

@dzmitry-lahoda
Copy link
Author

i saw that in our case, keys are glue of some readable and non redable parts, but part is readable is enough to identify what the key is. some attemp to decode to unicode ignoring non decodable parts is good enough. like some editors do when I open binary files, definitely i see some usefull text inside (e.g. open wasm binary and see strings here mixed with some binary bytes). so some unicode would be usefull.

Values are json in our case. I assume values most people write are json too. And that why base64 encoding. So unicode string output is okey.

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Aug 20, 2023

problem for me is, okey to map one key and value via xxd/base64, but when I just want to dump whatever in contract and see it snapshow state, i will have to build looping with jq. it seem to complicate for fast view of data in bash, defeats the purpose. and i write queries which just dump whole state. actually ideal solution for storage to have schema too kind of, which is query impl for all data.

but hack in cli is good enough, and will work with contracts without schema. if their key/values are pb encoding for example, one layer of encoding onion is removed. so cli decoding is sloppy, but good enough in most cases.

@webmaster128
Copy link
Member

webmaster128 commented Aug 29, 2023

Sounds plausible to me, especially if the goal is to improve the "dev/debug loop" where you can always dig deeper if you need more precise information but often don't.

I suggest an implementation equivalent to from_utf8_lossy but did not find a Go version for that easily.

@alpe alpe added this to the v0.44.0 milestone Oct 18, 2023
@alpe alpe modified the milestones: v0.44.0, v0.46 Nov 15, 2023
@hashedone hashedone modified the milestones: v0.46.0, v0.51 Dec 11, 2023
@chipshort chipshort modified the milestones: v0.51, v0.52 Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants