Skip to content

Commit

Permalink
change to bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjazper committed May 29, 2024
1 parent 1b7b9b8 commit ad08773
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 95 deletions.
59 changes: 0 additions & 59 deletions .github/scripts/update-token-list.py

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/update-token-list.yml

This file was deleted.

9 changes: 8 additions & 1 deletion chains/81457/token-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@
"tokenDecimals": 18,
"tokenCategory": "Stablecoin"
},
{
"tokenAddress": "0xdc60c24de182b07cb3f3a9269f120d8c15c4b381",
"tokenName": "Digital Art Movement",
"tokenSymbol": "DAM",
"tokenDecimals": 18,
"tokenCategory": "DeFi"
},
{
"tokenAddress": "0xe4796ccb6bb5de2290c417ac337f2b66ca2e770e",
"tokenName": "Staked FRAX",
Expand Down Expand Up @@ -440,4 +447,4 @@
"tokenDecimals": 18,
"tokenCategory": "Other"
}
]
]
60 changes: 60 additions & 0 deletions update_lish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

CHAINS_PATH="chains"
TOKEN_LIST_FILENAME="token-list.json"

process_chain() {
local chain_dir=$1
local assets_path="$chain_dir/assets"
local token_list_path="$chain_dir/$TOKEN_LIST_FILENAME"

echo "Processing chain directory: $chain_dir"

# Initialize token list array
local token_list="[]"

# Iterate over each subdirectory in the assets directory
for dir_name in "$assets_path"/*; do
if [ -d "$dir_name" ]; then
local token_info_path="$dir_name/token-info.json"
local token_logo_path="$dir_name/token-logo.svg"

if [ -f "$token_info_path" ] && [ -f "$token_logo_path" ]; then
local token_info=$(cat "$token_info_path")
token_list=$(echo "$token_list" | jq --argjson token_info "$token_info" '. + [$token_info]')
else
echo "token-info.json or token-logo.svg not found in $dir_name"
fi
fi
done

# Read existing token list if it exists
if [ -f "$token_list_path" ]; then
local existing_token_list=$(cat "$token_list_path")
else
local existing_token_list="[]"
fi

# Sort token list by tokenAddress
token_list=$(echo "$token_list" | jq 'sort_by(.tokenAddress)')

# Check if the new token list is different from the existing one
if [ "$token_list" != "$existing_token_list" ]; then
# Write updated token list to token-list.json
echo "$token_list" | jq '.' > "$token_list_path"
echo "Written updated token list to $token_list_path"
else
echo "No changes detected in $token_list_path, skipping write."
fi
}

# Iterate over each subdirectory in the chains directory
for chain_dir in "$CHAINS_PATH"/*; do
if [ -d "$chain_dir" ]; then
process_chain "$chain_dir"
else
echo "No directories found in $CHAINS_PATH"
fi
done

echo "All token lists updated."

0 comments on commit ad08773

Please sign in to comment.