#!/bin/bash PROGRAM="$(basename $0)" source $AK_LIBDIR/_ak_ipfs time_started=$(date -u +%s.%N) ss=$(echo $time_started | cut -d '.' -f 1) nss=$(echo $time_started | cut -d '.' -f 2) # Check if there are enough arguments if [ $# -lt 1 ] then echo "Error: Not enough arguments provided" echo "Give a zblock's IPFS CID v0 as an argument" exit 1 fi if [ -n "$1" ] then TEST="$(echo -n "$1" | grep -v '^Qm[A-Za-z0-9]\{44\}$')" if [ -n "$TEST" ] then echo not ok exit 1 fi fi arg="$(mktemp)" ak-enter -l 1 "$1" | jq '.[]' > $arg ( \ # Create HTML document echo "" echo "" echo "" echo " Arching Kaos Chain Data" echo ' ' echo ' ' echo ' ' echo "" echo "" # Iterate through each argument and parse data if [ -f "$arg" ] then # Extract data from argument zblock=$(cat $arg | jq -r '.zblock') block=$(cat $arg | jq -r '.block') timestamp=$(cat $arg | jq -r '.timestamp') block_signature=$(cat $arg | jq -r '.block_signature') detach=$(cat $arg | jq -r '.detach') data=$(cat $arg | jq -r '.data') module=$(cat $arg | jq -r '.module') action=$(cat $arg | jq -r '.action') gpg=$(cat $arg | jq -r '.gpg') previous=$(cat $arg | jq -r '.previous') datablock=$(cat $arg | jq -r ".$data") # Output data in HTML format echo "

$PROGRAM

" echo "

🔎 $zblock

" if [ "$module" == "news" ] && [ "$action" == "add" ] then ak-news -x $zblock fi echo "

ℹī¸ $zblock

" echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo "
" echo "
đŸ“Ļ ZBLOCK
" echo "
" echo "
" echo " $zblock" echo "
$(_ak_ipfs_cat $zblock | jq)
" echo "
" echo "
" echo "
đŸ“Ļ BLOCK
" echo "
" echo "
" echo " $block" echo "
$(_ak_ipfs_cat $block | jq)
" echo "
" echo "
" echo "
🔏 BLOCK SIGNATURE
" echo "
" echo "
" echo " $block_signature" echo "
$(_ak_ipfs_cat $block_signature)
" echo "
" echo "
" echo "
⌚ TIMESTAMP
" echo "
" echo "

$timestamp

" echo "
" echo "
🔌 MODULE
" echo "
" echo "

$module

" echo "
" echo "
đŸĒ§ ACTION
" echo "
" echo "

$action

" echo "
" echo "
🔑 GPG
" echo "
" echo "
" echo " $gpg" echo "
$(_ak_ipfs_cat $gpg)
" echo "
" echo "
" echo "
đŸ“Ļ PREVIOUS
" echo "
" echo ' 🔗 '$previous'' echo "
" echo "
đŸ“Ļ DATA
" echo "
" echo "
" echo " $data" echo "
$datablock
" echo "
" echo "
" echo "
🔏 DATA_SIGNATURE
" echo "
" echo "
" echo " $detach" echo "
$(_ak_ipfs_cat $detach)
" echo "
" echo "
" echo "
📄 ipfs
" echo "
" echo ' '🔗 $(echo $datablock | jq -r '.ipfs')'' echo "
" echo "
🔏 detach
" echo "
" echo "
" echo " $(echo $datablock | jq -r '.detach')" echo "
$(_ak_ipfs_cat $(echo $datablock | jq -r '.detach'))
" echo "
" echo "
" echo "
📃 Rendered ZBLOCK
" echo "
$(cat $arg | jq)
" fi time_ended=$(date -u +%s.%N) se=$(echo $time_ended | cut -d '.' -f 1) nse=$(echo $time_ended | cut -d '.' -f 2) echo "
" echo -n " " else echo "$(( $nse - $(echo -n $nss|sed 's/^0*//') )) seconds" fi echo "" echo "" ) > zblock-$1.html rm $arg