-
Notifications
You must be signed in to change notification settings - Fork 7
/
configs.py
31 lines (26 loc) · 1.14 KB
/
configs.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
import json
import urllib3
def load_version():
package = json.load(open("package.json"))
return package.get("name") + " v" + package.get("version")
def load_dfe_config(path):
try:
if path.startswith("http"):
http = urllib3.PoolManager(timeout=3.0)
response = http.request('GET', path)
config = json.loads(response.data.decode('utf-8'))
else:
config = json.load(open(path))
except Exception as ex:
print(f"Fatal exception when trying to read triggering conditions from {path}:\n=> {ex}")
exit(1)
return config
def get_network_config(config, network_name):
chain_name = network_name.split('.')[0]
return config.get("chains").get(chain_name).get("networks").get(network_name)
def get_currency_symbol(config, currency):
return config.get("currencies").get(currency, "")
def get_price_feed_config(config, network_name, caption, param, default):
network_config = get_network_config(config, network_name)
value = network_config.get('feeds', {}).get(caption, {}).get(param, None) or config['conditions'].get(caption, {}).get(param, None) or config['conditions']['default'].get(param, default)
return value