Skip to content

Commit ad08773

Browse files
committed
change to bash script
1 parent 1b7b9b8 commit ad08773

File tree

4 files changed

+68
-95
lines changed

4 files changed

+68
-95
lines changed

.github/scripts/update-token-list.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/update-token-list.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

chains/81457/token-list.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,13 @@
405405
"tokenDecimals": 18,
406406
"tokenCategory": "Stablecoin"
407407
},
408+
{
409+
"tokenAddress": "0xdc60c24de182b07cb3f3a9269f120d8c15c4b381",
410+
"tokenName": "Digital Art Movement",
411+
"tokenSymbol": "DAM",
412+
"tokenDecimals": 18,
413+
"tokenCategory": "DeFi"
414+
},
408415
{
409416
"tokenAddress": "0xe4796ccb6bb5de2290c417ac337f2b66ca2e770e",
410417
"tokenName": "Staked FRAX",
@@ -440,4 +447,4 @@
440447
"tokenDecimals": 18,
441448
"tokenCategory": "Other"
442449
}
443-
]
450+
]

update_lish.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
CHAINS_PATH="chains"
4+
TOKEN_LIST_FILENAME="token-list.json"
5+
6+
process_chain() {
7+
local chain_dir=$1
8+
local assets_path="$chain_dir/assets"
9+
local token_list_path="$chain_dir/$TOKEN_LIST_FILENAME"
10+
11+
echo "Processing chain directory: $chain_dir"
12+
13+
# Initialize token list array
14+
local token_list="[]"
15+
16+
# Iterate over each subdirectory in the assets directory
17+
for dir_name in "$assets_path"/*; do
18+
if [ -d "$dir_name" ]; then
19+
local token_info_path="$dir_name/token-info.json"
20+
local token_logo_path="$dir_name/token-logo.svg"
21+
22+
if [ -f "$token_info_path" ] && [ -f "$token_logo_path" ]; then
23+
local token_info=$(cat "$token_info_path")
24+
token_list=$(echo "$token_list" | jq --argjson token_info "$token_info" '. + [$token_info]')
25+
else
26+
echo "token-info.json or token-logo.svg not found in $dir_name"
27+
fi
28+
fi
29+
done
30+
31+
# Read existing token list if it exists
32+
if [ -f "$token_list_path" ]; then
33+
local existing_token_list=$(cat "$token_list_path")
34+
else
35+
local existing_token_list="[]"
36+
fi
37+
38+
# Sort token list by tokenAddress
39+
token_list=$(echo "$token_list" | jq 'sort_by(.tokenAddress)')
40+
41+
# Check if the new token list is different from the existing one
42+
if [ "$token_list" != "$existing_token_list" ]; then
43+
# Write updated token list to token-list.json
44+
echo "$token_list" | jq '.' > "$token_list_path"
45+
echo "Written updated token list to $token_list_path"
46+
else
47+
echo "No changes detected in $token_list_path, skipping write."
48+
fi
49+
}
50+
51+
# Iterate over each subdirectory in the chains directory
52+
for chain_dir in "$CHAINS_PATH"/*; do
53+
if [ -d "$chain_dir" ]; then
54+
process_chain "$chain_dir"
55+
else
56+
echo "No directories found in $CHAINS_PATH"
57+
fi
58+
done
59+
60+
echo "All token lists updated."

0 commit comments

Comments
 (0)