Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/2025-budget-withdrawals.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ source ./scripts/.env
Set some useful variables

```shell
export DEPOSIT_RETURN_ADDR=""
export WITHDRAWAL_ADDR=""
export DEPOSIT_RETURN_ADDR="stake1uyvjdz9rxsfsmv44rtk75k2rqyqskrga96dgdfrqjvjjpwsefcjnp"
export WITHDRAWAL_ADDR="stake17xzc8pt7fgf0lc0x7eq6z7z6puhsxmzktna7dluahrj6g6ghh5qjr"

export a="../governance-actions/mainnet/2025-07-13-budget-2025"
```

Make sure that `CARDANO_NODE_NETWORK_ID` and `CARDANO_NODE_SOCKET_PATH` are set.
Expand Down Expand Up @@ -75,7 +77,7 @@ We will pass `--no-author` as we know there is no author witness yet.
We will pass `--no-ipfs` as we know we didn't put it on ipfs yet.

```shell
./scripts/budget-metadata-validate.sh ./my-metadata-directory --no-author --no-ipfs --deposit-return-addr $DEPOSIT_RETURN_ADDR --withdrawal-addr $WITHDRAWAL_ADDR
./scripts/budget-metadata-validate.sh $a/EC --no-author --no-ipfs --deposit-return-addr $DEPOSIT_RETURN_ADDR --withdrawal-addr $WITHDRAWAL_ADDR
```

### 6. Sign with author's key
Expand Down
8 changes: 4 additions & 4 deletions scripts/action-create-tw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
##################################################

# Default configuration values
WITHDRAW_TO_SCRIPT="false"
WITHDRAW_TO_SCRIPT="true"

##################################################

Expand Down Expand Up @@ -36,9 +36,9 @@ fi
# Usage message

usage() {
echo "Usage: $0 <jsonld-file|directory> [--withdraw-to-script] [--deposit-return-addr <stake address>] [--withdrawal-addr <stake address>]"
echo "Usage: $0 <jsonld-file> [--withdraw-to-script] [--deposit-return-addr <stake address>] [--withdrawal-addr <stake address>]"
echo "Options:"
echo " <jsonld-file|directory> Path to the JSON-LD metadata file or directory containing metadata files"
echo " <jsonld-file> Path to the JSON-LD metadata file"
echo " --withdraw-to-script Check that the withdrawal address is a script-based address, exit otherwise"
echo " --deposit-return-addr <stake address> Check that metadata deposit return address matches provided one (Bech32)"
echo " --withdrawal-addr <stake address> Check that metadata withdrawal address matches provided one (Bech32)"
Expand Down Expand Up @@ -302,7 +302,7 @@ fi

is_stake_address_delegated_to_abstain_or_null() {
local address="$1"
vote_delegation=$(cardano-cli conway query stake-address-info --$protocol_magic --address "$address" | jq -r '.[0].voteDelegation')
vote_delegation=$(cardano-cli conway query stake-address-info --address "$address" | jq -r '.[0].voteDelegation')
if [ "$vote_delegation" = "alwaysAbstain" ] || [ "$vote_delegation" = "null" ] ; then
return 0
else
Expand Down
12 changes: 8 additions & 4 deletions scripts/author-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,19 @@ sign_file() {
# Use cardano-signer to sign author metadata

if [ -d "$input_path" ]; then
# If input is a directory: sign all .jsonld files
# If input is a directory: sign all .jsonld files (including subdirectories)
echo -e " "
echo -e "${CYAN}Processing directory: ${YELLOW}$input_path${NC}"

shopt -s nullglob
jsonld_files=("$input_path"/*.jsonld)
# Get all .jsonld files in the directory and subdirectories
jsonld_files=()
while IFS= read -r -d '' file; do
jsonld_files+=("$file")
done < <(find "$input_path" -type f -name "*.jsonld" -print0)

# check if any .jsonld files were found
if [ ${#jsonld_files[@]} -eq 0 ]; then
echo -e "${RED}Error: No .jsonld files found in directory '$input_path'.${NC}" >&2
echo -e "${RED}Error: No .jsonld files found in directory (including subdirectories): ${YELLOW}$input_path${NC}" >&2
exit 1
fi

Expand Down
14 changes: 12 additions & 2 deletions scripts/author-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,19 @@ echo -e " "
# https://github.com/gitmachtl/cardano-signer?tab=readme-ov-file#verify-governance-metadata-and-the-authors-signatures
verify_author_witness() {
local file="$1"
cardano-signer verify --cip100 \
local output
output=$(cardano-signer verify --cip100 \
--data-file "$file" \
--json-extended | jq '{workMode, result, errorMsg, authors, canonizedHash, fileHash}'
--json-extended | jq '{workMode, result, errorMsg, authors, canonizedHash, fileHash}')

echo "$output"

local result
result=$(echo "$output" | jq -r '.result')
if [ "$result" != "true" ]; then
echo -e "${RED}Error: Verification failed with result: ${YELLOW}$result${NC}" >&2
exit 1
fi
}

# Give the user a warning if the author isn't Intersect
Expand Down
186 changes: 186 additions & 0 deletions scripts/budget-action-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#!/bin/bash

##################################################

# some options maybe

##################################################

# Exit immediately if a command exits with a non-zero status,
# treat unset variables as an error, and fail if any command in a pipeline fails
set -euo pipefail

# Colors
#BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
BRIGHTWHITE='\033[0;37;1m'
NC='\033[0m'

# Check if cardano-cli is installed
if ! command -v cardano-cli >/dev/null 2>&1; then
echo "Error: cardano-cli is not installed or not in your PATH." >&2
exit 1
fi

# Check if ipfs cli is installed
if ! command -v ipfs >/dev/null 2>&1; then
echo "Error: ipfs cli is not installed or not in your PATH." >&2
exit 1
fi

# Usage message
usage() {
echo "Usage: $0 <directory> --deposit-return-addr <stake address> --withdrawal-addr <stake address> [--no-ipfs-pin]"
echo "Create treasury withdrawal governance actions from a directory of JSONLD metadata files and host the metadata on ipfs."
echo "Options:"
echo " <directory> Path to directory containing .jsonld files"
echo " --deposit-return-addr <stake address> Check that metadata deposit return address matches provided one (Bech32) [REQUIRED]"
echo " --withdrawal-addr <stake address> Check that metadata withdrawal address matches provided one (Bech32) [REQUIRED]"
echo " --no-ipfs-pin Skip IPFS pinning step"
echo " -h, --help Show this help message and exit"
exit 1
}

# Initialize variables with defaults
input_path=""
deposit_return_address_input=""
withdrawal_address_input=""
skip_ipfs_pin="false"

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--deposit-return-addr)
if [ -n "${2:-}" ]; then
deposit_return_address_input="$2"
shift 2
else
echo -e "${RED}Error: --deposit-return-addr requires a value${NC}" >&2
usage
fi
;;
--withdrawal-addr)
if [ -n "${2:-}" ]; then
withdrawal_address_input="$2"
shift 2
else
echo -e "${RED}Error: --withdrawal-addr requires a value${NC}" >&2
usage
fi
;;
--no-ipfs-pin)
skip_ipfs_pin="true"
shift
;;
-h|--help)
usage
;;
*)
if [ -z "$input_path" ]; then
input_path="$1"
fi
shift
;;
esac
done

# If no input path provided, show usage
if [ -z "$input_path" ]; then
echo -e "${RED}Error: No directory specified${NC}" >&2
usage
fi

# Check if required parameters are provided
if [ -z "$deposit_return_address_input" ]; then
echo -e "${RED}Error: --deposit-return-addr is required${NC}" >&2
usage
fi

if [ -z "$withdrawal_address_input" ]; then
echo -e "${RED}Error: --withdrawal-addr is required${NC}" >&2
usage
fi

# Check if input is a directory
if [ ! -d "$input_path" ]; then
echo -e "${RED}Error: Input is not a valid directory: ${YELLOW}$input_path${NC}" >&2
exit 1
fi

echo -e " "
echo -e "${YELLOW}Budget Action Creation Service${NC}"
echo -e "${CYAN}This script processes JSONLD files to create treasury withdrawal governance actions${NC}"
echo -e "${CYAN}It will host files on IPFS and create governance actions for each file${NC}"

# Get all .jsonld files in the directory and subdirectories
jsonld_files=()
while IFS= read -r -d '' file; do
jsonld_files+=("$file")
done < <(find "$input_path" -type f -name "*.jsonld" -print0)

# Check if any .jsonld files were found
if [ ${#jsonld_files[@]} -eq 0 ]; then
echo -e " "
echo -e "${RED}Error: No .jsonld files found in directory (including subdirectories): ${YELLOW}$input_path${NC}" >&2
exit 1
fi

echo -e " "
echo -e "${CYAN}Found ${YELLOW}${#jsonld_files[@]}${NC}${CYAN} .jsonld files to process${NC}"

for file in "${jsonld_files[@]}"; do
# Ask user if they want to continue with the next file
# Skip for the first file
if [ "$file" != "${jsonld_files[0]}" ]; then
echo -e " "
echo -e "${CYAN}The next file is: ${YELLOW}$file${NC}"
read -p "Do you want to continue with the next file? (y/n): " choice
case "$choice" in
y|Y ) echo -e "${GREEN}Continuing with the next file...${NC}";;
n|N ) echo -e "${YELLOW}Exiting...${NC}"; exit 0;;
* ) echo -e "${RED}Invalid choice, exiting...${NC}"; exit 1;;
esac
fi

if [ -f "$file" ]; then
echo -e " "
echo -e "${CYAN}Processing file: ${YELLOW}$file${NC}"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

if [ "$skip_ipfs_pin" = "false" ]; then
echo -e " "
echo -e "${CYAN}Hosting file on IPFS using ./ipfs-pin.sh${NC}"
./scripts/ipfs-pin.sh "$file"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
else
echo -e " "
echo -e "${YELLOW}Skipping IPFS pinning step${NC}"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
fi

echo -e " "
echo -e "${CYAN}Creating treasury governance action using ./action-create-tw.sh${NC}"

./scripts/action-create-tw.sh --deposit-return-addr "$deposit_return_address_input" \
--withdrawal-addr "$withdrawal_address_input" \
"$file"

echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e " "
echo -e "${GREEN}Successfully processed: ${YELLOW}$file${NC}"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

else
echo -e " "
echo -e "${RED}Error: file is not a valid file: ${YELLOW}$file${NC}" >&2
exit 1
fi
done

echo -e " "
echo -e "${GREEN}All files processed successfully!${NC}"
echo -e "${CYAN}Treasury withdrawal governance actions have been created for all JSONLD files${NC}"
13 changes: 12 additions & 1 deletion scripts/budget-metadata-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ if [ -d "$input_path" ]; then
check_field "title" "$title"
abstract=$(jq -r '.body.abstract' "$file")
check_field "abstract" "$abstract"
motivation=$(jq -r '.body.motivation' "$file")
check_field "motivation" "$motivation"
rationale=$(jq -r '.body.rationale' "$file")
check_field "rationale" "$rationale"
references=$(jq -r '.body.references' "$file")
check_field "references" "$references"
ga_type=$(jq -r '.body.onChain.governanceActionType' "$file")
Expand Down Expand Up @@ -201,8 +205,15 @@ if [ -d "$input_path" ]; then
echo "Title does not contain the term 'ada'"
fi

if [[ "$abstract" == *".mark"* ]] || [[ "$motivation" == *".mark"* ]] || [[ "$rationale" == *".mark"* ]]; then
echo -e "${RED}Error: The term '.mark' is not allowed in the title or abstract!" >&2
exit 1
else
echo "no Marks !!!"
fi

# ensure that title is less than 81 characters
if [ ${#title} -gt 81 ]; then
if [ ${#title} -gt 80 ]; then
echo -e "${RED}Error: Title is too long, must be less than 80 characters" >&2
exit 1
else
Expand Down
Loading