rpc.sh: improve flags for curl wrapper

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-02-09 17:27:34 +01:00
parent f8f2e33772
commit 210156c5de
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 6 additions and 2 deletions

View File

@ -6,6 +6,7 @@ URL="http://{{ geth_rpc_addr }}:{{ geth_rpc_port }}/"
METHOD="$1" METHOD="$1"
shift shift
PARAMS=("$@")
if [[ -z "${METHOD}" ]]; then if [[ -z "${METHOD}" ]]; then
echo "No method specified!" >&2 echo "No method specified!" >&2
@ -25,8 +26,11 @@ PAYLOAD="{
\"params\": [${PARAMS}] \"params\": [${PARAMS}]
}" }"
curl -s -X POST \ # The jq script checks if error exists and adjusts exit code.
-H "Content-type:application/json" \ curl --request POST \
--silent \
--fail-with-body \
--header 'Content-type:application/json' \
--data "${PAYLOAD}" \ --data "${PAYLOAD}" \
"${URL}" | \ "${URL}" | \
jq -e '., if .error != null then null|halt_error(2) else halt end' jq -e '., if .error != null then null|halt_error(2) else halt end'