Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
IPadawans committed Jul 3, 2024
1 parent e551e0e commit 1410988
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
msg: "File /home/{{ ansible_user }}/code/metagraph-l0/{{ staking_p12_file_name }} does not exist"
when: not (staking_p12_file_name is undefined or staking_p12_file_name == "") and not staking_file.stat.exists

- name: Fetch the latest combined snapshot
- name: Fetch the latest combined snapshot from global network
uri:
url: "http://{{ gl0_ip }}:{{ gl0_port }}/global-snapshots/latest/combined"
method: GET
Expand All @@ -90,17 +90,17 @@
register: latest_combined_snapshot_response
when: should_run_genesis or force_owner_message_bool or force_staking_message_bool

- name: Check if the fetch was successful
- name: Check if the snapshot fetch was successful
fail:
msg: "Error fetching the latest combined snapshot."
when: (should_run_genesis or force_owner_message_bool or force_staking_message_bool) and latest_combined_snapshot_response.status != 200

- name: Convert JSON response content to a fact
- name: Convert response to JSON
set_fact:
json_response: "{{ latest_combined_snapshot_response.content | from_json }}"
when: should_run_genesis or force_owner_message_bool or force_staking_message_bool

- name: Parse the response to extract the last messages
- name: Parse the response to extract the metagraph last messages
set_fact:
snapshot_fees_messages: "{{ json_response | json_query('[1].lastCurrencySnapshots.' ~ metagraph_id ~ '.Right[1].lastMessages') }}"
when: should_run_genesis or force_owner_message_bool or force_staking_message_bool
Expand Down
34 changes: 30 additions & 4 deletions scripts/hydra-operations/remote-snapshot-fee-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,41 @@ function fetch_latest_global_snapshot_metagraph_messages() {
if [ "$http_code" -ne 200 ]; then
echo_red "Failed to fetch data. HTTP Status Code: $http_code"
exit 1
else
else
last_messages=$(echo "$response" | jq -r ".[1].lastCurrencySnapshots.\"$metagraph_id\".Right[1].lastMessages")

if [ -z "$last_messages" ]; then
echo_red "Failed when extracting the fee configuration from global snapshot"
if [ -z "$last_messages" ] || [ "$last_messages" = "null" ]; then
echo_red "Failed when extracting the fee configuration from global snapshot. Be sure your metagraph have the fees messages configured"
exit 1
else
echo_green "Last messages extracted successfully:"
echo "$last_messages" | jq .

owner_address=$(echo "$last_messages" | jq -r .Owner.value.address)
owner_parent_ordinal=$(echo "$last_messages" | jq -r .Owner.value.parentOrdinal)
staking_address=$(echo "$last_messages" | jq -r .Staking.value.address)
staking_parent_ordinal=$(echo "$last_messages" | jq -r .Staking.value.parentOrdinal)

# Check if fields are empty or null and handle accordingly
if [ -z "$owner_address" ] || [ "$owner_address" = "null" ]; then
owner_address="N/A"
fi
if [ -z "$owner_parent_ordinal" ] || [ "$owner_parent_ordinal" = "null" ]; then
owner_parent_ordinal="N/A"
fi
if [ -z "$staking_address" ] || [ "$staking_address" = "null" ]; then
staking_address="N/A"
fi
if [ -z "$staking_parent_ordinal" ] || [ "$staking_parent_ordinal" = "null" ]; then
staking_parent_ordinal="N/A"
fi

echo_white "OWNER"
echo_url "Owner Address" "$owner_address"
echo_url "Owner Parent Ordinal" "$owner_parent_ordinal"
echo
echo_white "STAKING"
echo_url "Staking Address" "$staking_address"
echo_url "Staking Parent Ordinal" "$staking_parent_ordinal"
fi
fi

Expand Down

0 comments on commit 1410988

Please sign in to comment.