-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add queries to wasmd section #141
Open
pinosu
wants to merge
2
commits into
main
Choose a base branch
from
add_queries_to_wasmd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−4
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -514,9 +514,9 @@ sleep 6 | |||||
wasmd q tx $(echo "$RESP" | jq -r '.txhash') -o json | jq | ||||||
``` | ||||||
|
||||||
### Query contract state | ||||||
### Query Contract State All | ||||||
|
||||||
To query the state of a WASM contract, you can use the following command. | ||||||
To query the state of a WASM contract, you can use the following command: | ||||||
|
||||||
```sh | ||||||
wasmd query wasm contract-state all "$CONTRACT" -o json | ||||||
|
@@ -539,9 +539,10 @@ The output will look similar to this: | |||||
} | ||||||
``` | ||||||
|
||||||
`Models` are key-value pairs representing the state data of the contract base64-encoded. | ||||||
The `"models"` array contains key-value pairs representing the state data of the contract, with both | ||||||
keys and values base64-encoded. | ||||||
|
||||||
We can decode the contract state using the following command: | ||||||
You can decode the contract state using the following command: | ||||||
|
||||||
```sh | ||||||
wasmd query wasm contract-state all "$CONTRACT" -o json | jq -r '.models[0].value' | base64 -d | ||||||
|
@@ -557,6 +558,62 @@ The output will be similar to the following: | |||||
} | ||||||
``` | ||||||
|
||||||
### Query Contract State Raw | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
To query the state of a WASM contract for a specific key, you can use the following command: | ||||||
|
||||||
```sh | ||||||
# Set the state key you want to query | ||||||
KEY="636F6E666967" | ||||||
wasmd q wasm contract-state raw $CONTRACT $KEY -o json | ||||||
``` | ||||||
|
||||||
The output will look similar to this: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"data": "eyJ2ZXJpZmllciI6Indhc20xNzlhdnc5NmFheTcwcHM5OXVtdWFlc3h4Y3p3YzBxbTVnd3VmeGciLCJiZW5lZmljaWFyeSI6Indhc20xNDI3a3BxOW1tbmZwMG1hZGs1YXhoMnVrbWpncGZoNnNremR4a3UiLCJmdW5kZXIiOiJ3YXNtMTc5YXZ3OTZhYXk3MHBzOTl1bXVhZXN4eGN6d2MwcW01Z3d1ZnhnIn0=" | ||||||
} | ||||||
``` | ||||||
|
||||||
`"data"` represents the base64-encoded state data of the contract for the given key. | ||||||
|
||||||
You can decode the `data` field using the following command: | ||||||
|
||||||
```sh | ||||||
wasmd q wasm contract-state raw $CONTRACT $KEY -o json | jq -r '.data' | base64 -d | ||||||
``` | ||||||
|
||||||
The output will be similar to the following: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"verifier": "wasm1hvgm6p76gccgg4dl4caa8a7v03dsqww6r9sk4g", | ||||||
"beneficiary": "wasm1pa29lac5s85kgj7pn9z6gc0t4sqgzllcguhf24", | ||||||
"funder": "wasm1hvgm6p76gccgg4dl4caa8a7v03dsqww6r9sk4g" | ||||||
} | ||||||
``` | ||||||
|
||||||
### Query Contract State Smart | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
To query the state of a WASM contract for specific data, you can use the following command: | ||||||
chipshort marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
```sh | ||||||
# Set the query for the data you want to retrieve | ||||||
QUERY='{"verifier": {}}' | ||||||
wasmd q wasm contract-state smart $CONTRACT $QUERY -o json | ||||||
``` | ||||||
|
||||||
The output will look similar to this: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"data": { | ||||||
"verifier": "wasm179avw96aay70ps99umuaesxxczwc0qm5gwufxg" | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## Migration | ||||||
|
||||||
Migration is the process of upgrading an existing contract to a new version without changing its | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just feels a little easier to read when separated like that!