From 210156c5de96b31169873d14551058810599748f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 9 Feb 2023 17:27:34 +0100 Subject: [PATCH] rpc.sh: improve flags for curl wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- templates/rpc.sh.j2 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/rpc.sh.j2 b/templates/rpc.sh.j2 index e3277e2..e5a001f 100644 --- a/templates/rpc.sh.j2 +++ b/templates/rpc.sh.j2 @@ -6,6 +6,7 @@ URL="http://{{ geth_rpc_addr }}:{{ geth_rpc_port }}/" METHOD="$1" shift +PARAMS=("$@") if [[ -z "${METHOD}" ]]; then echo "No method specified!" >&2 @@ -25,8 +26,11 @@ PAYLOAD="{ \"params\": [${PARAMS}] }" -curl -s -X POST \ - -H "Content-type:application/json" \ +# The jq script checks if error exists and adjusts exit code. +curl --request POST \ + --silent \ + --fail-with-body \ + --header 'Content-type:application/json' \ --data "${PAYLOAD}" \ "${URL}" | \ jq -e '., if .error != null then null|halt_error(2) else halt end'