2021-03-19 11:52:00 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-03-25 12:56:04 +00:00
|
|
|
# vim: set ft=sh:
|
|
|
|
set -euo pipefail
|
2021-03-19 11:52:00 +00:00
|
|
|
|
2021-04-29 12:56:39 +00:00
|
|
|
URL="http://{{ geth_rpc_addr }}:{{ geth_rpc_port }}/"
|
2021-03-19 11:52:00 +00:00
|
|
|
|
|
|
|
METHOD="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
if [[ -z "${METHOD}" ]]; then
|
|
|
|
echo "No method specified!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-03-25 12:56:04 +00:00
|
|
|
if [[ -n "${@}" ]]; then
|
2021-05-11 09:20:47 +00:00
|
|
|
PARAMS=$(printf '%s,' "${@}")
|
|
|
|
PARAMS="${@%%,}"
|
2021-03-19 11:52:00 +00:00
|
|
|
else
|
2021-03-25 12:56:04 +00:00
|
|
|
PARAMS=''
|
2021-03-19 11:52:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
PAYLOAD="{
|
|
|
|
\"id\": 1,
|
|
|
|
\"jsonrpc\": \"2.0\",
|
|
|
|
\"method\": \"${METHOD}\",
|
2021-03-25 12:56:04 +00:00
|
|
|
\"params\": [${PARAMS}]
|
2021-03-19 11:52:00 +00:00
|
|
|
}"
|
|
|
|
|
|
|
|
curl -s -X POST \
|
|
|
|
-H "Content-type:application/json" \
|
|
|
|
--data "${PAYLOAD}" \
|
2021-03-25 12:56:04 +00:00
|
|
|
"${URL}" | \
|
|
|
|
jq -e '., if .error != null then null|halt_error(2) else halt end'
|