add rpc.sh script for easier JSON RPC calls
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
e00e1041d4
commit
338e74d6e6
|
@ -6,6 +6,7 @@ beacon_node_service_home: 'C:\Users\{{ beacon_node_service_user_name }}'
|
|||
beacon_node_service_path: '{{ beacon_node_service_home }}\{{ beacon_node_service_name }}'
|
||||
beacon_node_service_bin_path: '{{ beacon_node_service_path }}\bin'
|
||||
beacon_node_service_exe: '{{ beacon_node_service_bin_path }}\nimbus_beacon_node.exe'
|
||||
beacon_node_rpc_script_path: '{{ beacon_node_service_path }}\rpc.sh'
|
||||
|
||||
beacon_node_repo_url: 'https://github.com/status-im/nimbus-eth2.git'
|
||||
beacon_node_repo_branch: 'stable'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Create JSON RPC wrapper script
|
||||
win_template:
|
||||
src: 'rpc.sh.j2'
|
||||
dest: '{{ beacon_node_rpc_script_path }}'
|
|
@ -3,6 +3,7 @@
|
|||
- import_tasks: user.yml
|
||||
- import_tasks: install.yml
|
||||
- import_tasks: build.yml
|
||||
- import_tasks: config.yml
|
||||
- import_tasks: service.yml
|
||||
- import_tasks: validators.yml
|
||||
when: beacon_node_dist_validators_enabled
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bash
|
||||
# vim: set ft=sh:
|
||||
set -euo pipefail
|
||||
|
||||
URL="http://localhost:{{ beacon_node_rpc_port }}/"
|
||||
|
||||
METHOD="$1"
|
||||
shift
|
||||
|
||||
if [[ -z "${METHOD}" ]]; then
|
||||
echo "No method specified!" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "${@}" ]]; then
|
||||
PARAMS=$(printf '%s,' "${@}")
|
||||
PARAMS="${@%%,}\""
|
||||
else
|
||||
PARAMS=''
|
||||
fi
|
||||
|
||||
PAYLOAD="{
|
||||
\"id\": 1,
|
||||
\"jsonrpc\": \"2.0\",
|
||||
\"method\": \"${METHOD}\",
|
||||
\"params\": [${PARAMS}]
|
||||
}"
|
||||
|
||||
# The jq script checks if error exists and adjusts exit code.
|
||||
curl -s -X POST --max-time 10 \
|
||||
-H "Content-type:application/json" \
|
||||
--data "${PAYLOAD}" \
|
||||
"${URL}" | \
|
||||
jq -e '., if .error != null then null|halt_error(2) else halt end'
|
Loading…
Reference in New Issue