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
2 changes: 1 addition & 1 deletion docs/2025-budget-withdrawals.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ This performs some validations
- has user manually confirm the addresses and the amount

```shell
./scripts/action-create.jsonld my-metadata.jsonld --withdraw-to-script --deposit-return-addr $DEPOSIT_RETURN_ADDR --withdrawal-addr $WITHDRAWAL_ADDR
./scripts/action-create-tw.sh my-metadata.jsonld --withdraw-to-script --deposit-return-addr $DEPOSIT_RETURN_ADDR --withdrawal-addr $WITHDRAWAL_ADDR
```

### 10. Share the action file
Expand Down
33 changes: 21 additions & 12 deletions scripts/author-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
INTERSECT_AUTHOR_PATH="https://raw.githubusercontent.com/IntersectMBO/governance-actions/b1c5603fb306623e0261c234312eb7e011ac3d38/intersect-author.json"
######################################################

# Colors
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-signer is installed
if ! command -v cardano-signer >/dev/null 2>&1; then
echo "Error: cardano-signer is not installed or not in your PATH." >&2
echo -e "${RED}Error: cardano-signer is not installed or not in your PATH.${NC}" >&2
exit 1
fi

Expand All @@ -26,15 +35,14 @@ input_path="$1"

# Check if the key input file exists
if [ ! -f "$input_path" ]; then
echo "Error: JSON file '$input_path' not found!"
echo -e "${RED}Error: JSON file '${YELLOW}$input_path${RED}' not found!${NC}"
exit 1
fi

# Get Intersect author public key
# echo " "
# echo "Fetching Intersect author public key from $INTERSECT_AUTHOR_PATH"
echo -e "${CYAN}Fetching Intersect author public key from ${YELLOW}$INTERSECT_AUTHOR_PATH${NC}"
intersect_author_key=$(curl -s "$INTERSECT_AUTHOR_PATH" | jq -r '.publicKey')
# echo " "
echo -e " "

# Use cardano-signer to verify author witnesses
# https://github.com/gitmachtl/cardano-signer?tab=readme-ov-file#verify-governance-metadata-and-the-authors-signatures
Expand All @@ -55,13 +63,14 @@ check_if_intersect_author() {
author_key=$(jq -r ".authors[$i].witness.publicKey" "$file")

if [ "$author_key" == "$intersect_author_key" ]; then
echo "Author public key matches Intersect's known public key."
echo -e "${GREEN}Author public key matches Intersect's known public key.${NC}"
else
echo "Warning: Author public key does NOT match Intersect's known public key."
echo "Author public key: $author_key"
echo "Intersect's known public key: $intersect_author_key"
echo -e " "
echo -e "${RED}Warning: Author public key does NOT match Intersect's known public key.${NC}"
echo -e "Author public key: ${YELLOW}$author_key${NC}"
echo -e "Intersect's known public key: ${YELLOW}$intersect_author_key${NC}"
fi
echo " "
echo -e " "
done
}

Expand All @@ -71,7 +80,7 @@ if [ -d "$input_path" ]; then
jsonld_files=("$input_path"/*.jsonld)
# check if any .jsonld files were found
if [ ${#jsonld_files[@]} -eq 0 ]; then
echo "Error: No .jsonld files found in directory '$input_path'."
echo -e "${RED}Error: No .jsonld files found in directory '${YELLOW}$input_path${RED}'.${NC}"
exit 1
fi
# for each .jsonld file in the directory, go over it
Expand All @@ -84,6 +93,6 @@ elif [ -f "$input_path" ]; then
verify_author_witness "$input_path"
check_if_intersect_author "$input_path"
else
echo "Error: '$input_path' is not a valid file or directory."
echo -e "${RED}Error: '${YELLOW}$input_path${RED}' is not a valid file or directory.${NC}"
exit 1
fi
45 changes: 26 additions & 19 deletions scripts/budget-metadata-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage() {
echo "Check "
echo " "
echo "Options:"
echo " <directory> Path to your metadata files."
echo " <directory> Path to your metadata files directory."
echo " --no-author Skip author witness checks (default check author: $AUTHOR_CHECK)"
echo " --no-ipfs Skip IPFS checks (default check ipfs: $AUTHOR_CHECK)"
echo " --deposit-return-addr <stake address> Stake address for deposit return (bech32)"
Expand Down Expand Up @@ -105,12 +105,16 @@ check_field() {
}

if [ -d "$input_path" ]; then
# get all .jsonld files in the directory
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 " "
echo -e "${RED}Error: No .jsonld files found in directory: ${YELLOW}$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 Expand Up @@ -228,7 +232,7 @@ if [ -d "$input_path" ]; then

# Check if deposit address is provided
# and if provided, check if it matches the one in the metadata
if [ ! -z "$deposit_return_address_input" ]; then
if [ -n "$deposit_return_address_input" ]; then
if [ "$deposit_return_address_input" != "$deposit_return" ]; then
echo -e "${RED}Error: Deposit return address does not match the one in the metadata!${NC}" >&2
echo -e "Provided deposit return address: ${YELLOW}$deposit_return_address_input${NC}"
Expand All @@ -241,7 +245,7 @@ if [ -d "$input_path" ]; then

# Check if withdrawal address is provided
# and if provided, check if it matches the one in the metadata
if [ ! -z "$withdrawal_address_input" ]; then
if [ -n "$withdrawal_address_input" ]; then
if [ "$withdrawal_address_input" != "$withdrawal_address" ]; then
echo -e "${RED}Error: Withdrawal address does not match the one in the metadata!${NC}" >&2
echo -e "Provided withdrawal address: ${YELLOW}$withdrawal_address_input${NC}"
Expand All @@ -253,19 +257,22 @@ if [ -d "$input_path" ]; then
fi

# Check all IPFS references are accessible
echo -e " "
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e " "
echo -e "${CYAN}Checking all IPFS references are accessible in: ${YELLOW}$file${NC}"
echo -e "Using ./scripts/ipfs-check.sh"
reference_uris=$(jq -r '.body.references[].uri' "$file")
for reference in $reference_uris; do
# if reference is a ipfs URI
if [[ "$reference" == ipfs://* ]]; then
ipfs_hash=$(echo "$reference" | cut -d '/' -f 3)
./scripts/ipfs-check.sh "$ipfs_hash"
fi
done

if [ "$check_ipfs" = "true" ]; then
echo -e " "
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e " "
echo -e "${CYAN}Checking all IPFS references are accessible in: ${YELLOW}$file${NC}"
echo -e "Using ./scripts/ipfs-check.sh"
reference_uris=$(jq -r '.body.references[].uri' "$file")
for reference in $reference_uris; do
# if reference is a ipfs URI
if [[ "$reference" == ipfs://* ]]; then
ipfs_hash=$(echo "$reference" | cut -d '/' -f 3)
./scripts/ipfs-check.sh "$ipfs_hash"
fi
done
fi
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e " "
echo -e "${GREEN}All checks passed for: ${YELLOW}$file${NC}"
Expand Down
27 changes: 27 additions & 0 deletions scripts/cardano-aspell-dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@ ROI
toolset
IOG
lovelace
Leios
AVS
LSM
KES
Roadmap
Mithril
backend
HD
codebase
onboarding
roadmap
scalable
zk
PSSCs
IOE
toolsets
mainnet
testnet
Expand Down Expand Up @@ -125,10 +139,14 @@ Solana
UTxO
ada
Assurer
modularity
blogpost
CDH
CSV
Dquadrant
Blockfrost
uptime
incentivized
Ekklesia
EOY
knowledgebase
Expand All @@ -141,6 +159,8 @@ TRSC
TxPipe
Xerberus
highlevel
PBT
tx
Intersect's
Cardano's
TRSC's
Expand All @@ -151,3 +171,10 @@ kwufaxa
lfy
phgh
ynwyrcsaxdcd
dluahrj
eq
fgf
gsa
lc
puhsxmzktna
zzc
30 changes: 28 additions & 2 deletions scripts/metadata-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ sed -E -i '' 's/\[\[([^]]+)\]\]\{\.([a-zA-Z0-9_-]+)\}/\1/g' "$TEMP_MD"
sed -E -i '' 's/\[([^]]+)\]\{\.([a-zA-Z0-9_-]+)\}/\1/g' "$TEMP_MD"
# Fix broken markdown-style links [[Label]](url) change to [Label](url)
sed -E -i '' 's/\[\[([^\]]+)\]\]\(([^)]+)\)/[\1](\2)/g' "$TEMP_MD"
# Fix links with style markup: [[url]{.mark}](url) change to [url](url)
sed -E -i '' 's/\[\[([^]]+)\]\{\.mark\}\]\(([^)]+)\)/[\1](\2)/g' "$TEMP_MD"
# Normalize ₳ formatting
sed -E -i '' 's/\[₳\]\{\.mark\}/₳/g' "$TEMP_MD"
sed -E -i '' 's/₳[[:space:]]*/₳/g' "$TEMP_MD"
Expand Down Expand Up @@ -140,7 +142,7 @@ get_section() {

get_section_last() {
local label="$1"
awk "/^${label}\$/,/^Authors\$/" "$TEMP_MD" | sed "1d" \
awk "/^${label}\$/,/^References\$/" "$TEMP_MD" | sed "1d" \
| awk 'BEGIN{ORS=""; RS=""} {gsub(/\n/, " "); print $0 "\n\n"}' \
| sed 's/[[:space:]]\+$//' \
| jq -Rs .
Expand Down Expand Up @@ -199,7 +201,7 @@ extract_references() {
# this search term can be changed to match the expected pattern
extract_withdrawal_address() {
local rationale_text="$1"
echo "$rationale_text" | jq -r . | grep -oE "With the confirmed withdrawal address being:\s*(stake_test1[a-zA-Z0-9]{53}|stake1[a-zA-Z0-9]{53})" | sed -E 's/.*being:\s*//'
echo "$rationale_text" | jq -r . | grep -oE "With the confirmed withdrawal address being:[[:space:]]*(stake_test1[a-zA-Z0-9]{53}|stake1[a-zA-Z0-9]{53})" | sed -E 's/.*being:[[:space:]]*//'
}

# use helper functions to extract sections
Expand Down Expand Up @@ -314,6 +316,30 @@ EOF
echo -e " "
echo -e "${CYAN}Cleaning up the formatting on the JSON output...${NC}"

# Clean up for markdown formatting already present within the .docx file
# replace \\*\\* with ** (remove escaped asterisks)
perl -i -pe 's/\\\\\*\\\\\*/\*\*/g' "$FINAL_OUTPUT_JSON"
# replace \\\" with "
perl -i -pe 's/\\\\\"/\"/g' "$FINAL_OUTPUT_JSON"
# replace \\\" with "
perl -i -pe 's/\\\\\"/\"/g' "$FINAL_OUTPUT_JSON"
# replace \\* with *
perl -i -pe 's/\\\\\*/\*/g' "$FINAL_OUTPUT_JSON"
# remove \n\n<!-- --> patterns
perl -i -pe 's/\\n\\n<!-- -->//g' "$FINAL_OUTPUT_JSON"
# replace \\' with '
perl -i -pe 's/\\\\\x27/\x27/g' "$FINAL_OUTPUT_JSON"
# replace \' with '
# give up on this one for now

# for debug
# echo "$(cat $TEMP_OUTPUT_JSON)"

# Use jq to format the JSON output
jq . "$TEMP_OUTPUT_JSON" > "$FINAL_OUTPUT_JSON"

# Clean up trailing \n\n from JSON string fields
echo -e "${CYAN}Removing trailing newlines from JSON fields...${NC}"
sed -i '' 's/\\n\\n"/"/g' "$FINAL_OUTPUT_JSON"

echo -e "${GREEN}JSONLD saved to $FINAL_OUTPUT_JSON${NC}"
2 changes: 1 addition & 1 deletion scripts/metadata-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ echo " "
echo "Validation complete."
echo " "

exit $AJV_EXIT_CODE
exit 0