-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstLink.sh_EXAMPLE
More file actions
executable file
·57 lines (41 loc) · 1.73 KB
/
stLink.sh_EXAMPLE
File metadata and controls
executable file
·57 lines (41 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
export RPC_URL="https://eth-mainnet.g.alchemy.com/v2/HIU????????????????????????"
export ETHERSCAN_API_KEY="?????????????????????????"
export USER_WALLET_ADDRESS="0x??????????????????????????"
#-- Optional --
#export GOOGLE_SHEET_URL="https://docs.google.com/spreadsheets/d/13GT?????????????????????"
#export GOOGLE_SHEET_TAB_NAME="stLink Data"
#export GCP_SERVICE_ACCOUNT_FILE="service-account-key.json"
# Check and rename block_timestamp_cache.db_tmp
if [ ! -f block_timestamp_cache.db ]; then
if [ -f block_timestamp_cache.db_tmp ]; then
mv block_timestamp_cache.db_tmp block_timestamp_cache.db
echo "Renamed block_timestamp_cache.db_tmp to block_timestamp_cache.db"
fi
fi
# Check and rename price_cache.db_tmp
if [ ! -f price_cache.db ]; then
if [ -f price_cache.db_tmp ]; then
mv price_cache.db_tmp price_cache.db
echo "Renamed price_cache.db_tmp to price_cache.db"
fi
fi
if [ -z "$GOOGLE_SHEET_URL" ]; then
python stLink.py --csv
else
echo "Finding the last entry date to fetch new data..."
LAST_DATE=$(python update_gsheet.py --get-last-date)
if [ -z "$LAST_DATE" ]; then
echo "No previous date found. Using a default start date."
echo "NOTE: THIS MAKE TAKE SOMETIME. This is to avoid rate limits."
python stLink.py --csv | python update_gsheet.py
else
echo "Last entry was on $LAST_DATE. Fetching new data since then..."
START_DATE=$(date -d "$LAST_DATE - 7 days" +%Y-%m-%d)
python stLink.py --csv --datefrom "$START_DATE" | python update_gsheet.py
fi
echo "Setting up the 'Monthly Report' tab..."
python update_gsheet.py --setup-report-tab
echo "NOTE: You may need to refresh your Google Sheet page"
fi