Skip to content

Commit

Permalink
chore: Align with latest Tendermint RPC documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Aug 19, 2022
1 parent a682787 commit ab11959
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions scripts/get-flattened-publication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,35 @@ jq --version | awk '
'

# Make the abci_query request.
# cf. https://docs.tendermint.com/master/rpc/#/ABCI/abci_query
#
# {
# "jsonrpc": "2.0",
# "id": <integer>,
# "result": {
# "response": {
# "value": "<base64-encoded JSON text>",
# "height": "<decimal digits>",
# ...
# }
# }
# }
# cf. https://docs.tendermint.com/v0.34/rpc/
resp="$(
# Avoid the GET interface in case interpretation of `path` as JSON is ever fixed.
# https://github.com/tendermint/tendermint/issues/9164
# curl -sS "${URL_PREFIX%/}/abci_query?path=%22/custom/vstorage/data/$STORAGE_KEY%22" | \
curl -sS "$URL_PREFIX" --request POST --header 'Content-Type: application/json' --data "$(
printf '{
"jsonrpc": "2.0",
"id": -1,
"id": 1,
"method": "abci_query",
"params": { "path": "/custom/vstorage/data/%s" }
}' "$STORAGE_KEY"
)"
)"

# Decode the response
# Decode the response.
# cf. https://docs.tendermint.com/master/rpc/#/ABCI/abci_query
#
# {
# "jsonrpc": "2.0",
# "id": <integer>,
# "result": {
# "response": {
# "height": "<decimal digits>",
# "value": "<base64-encoded JSON text>",
# ...
# }
# }
# }
response_height_json="$(printf '%s' "$resp" | jq '.result.response.height?' | grep -E '^"[0-9]+"$')"
if [ ":$response_height_json" = : ]; then
printf 'Unable to read response block height:\n%s\n' "$resp" >&2
Expand Down

0 comments on commit ab11959

Please sign in to comment.