-
Notifications
You must be signed in to change notification settings - Fork 42
/
check_token.py
65 lines (54 loc) · 1.69 KB
/
check_token.py
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
57
58
59
60
61
62
63
64
65
import os
import time
import requests
base = os.path.join("icons", "multichain-tokens")
sleep_time = 0.5
eth_address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
sbtc_curve_address = "0xC25099792E9349C7DD09759744ea681C7de2cb66"
default_tokens = {
eth_address: {
"address": eth_address,
"name": "Ethereum",
"symbol": "ETH",
"decimals": "18",
"chainId": 1,
},
sbtc_curve_address: {
"address": sbtc_curve_address,
"name": "LP tBTC Curve",
"symbol": "TBTCCURVE",
"decimals": "18",
"chainId": 1,
},
}
ethplorer = os.environ.get("ETHPLORER_API_KEY")
required_files = ["logo.svg", "logo-32.png", "logo-128.png"]
def get_info(token):
if token in default_tokens:
return default_tokens[token]
try:
url = f"https://api.ethplorer.io/getTokenInfo/{token}?apiKey={ethplorer}"
r = requests.get(url)
return r.json()
except:
return None
def main():
ok = True
for chain in os.listdir(base):
root = os.path.join(base, chain)
for token in os.listdir(root):
for required in required_files:
required = os.path.join(root, token, required)
if not os.path.exists(required):
print(f"Error: {required} does not exist but it's required.")
ok = False
if ethplorer:
token_info = get_info(token)
if token_info is None:
print(f"Error: {token} could not be fetched.")
ok = False
time.sleep(sleep_time)
if not ok:
exit(1)
if __name__ == "__main__":
main()