-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy path_fetch-cbridge-tokens.py
41 lines (38 loc) · 2.11 KB
/
_fetch-cbridge-tokens.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
#!/usr/bin/env python3
"""
Retrieves all of the Celer cBridge tokens to/from Oasis Sapphire mainnet
"""
import json
from urllib.request import urlopen
def format_result(data):
chains = {}
for c in data["chains"]:
chains[c["id"]] = c
for p in data['pegged_pair_configs']:
org_chain = chains[p['org_chain_id']]
pegged_chain = chains[p['pegged_chain_id']]
org_chain_is_sapph = p['org_chain_id'] in [0x5afe,0x5aff]
pegged_chain_is_sapph = p['pegged_chain_id'] in [0x5afe,0x5aff]
chain_is_not_deprecated = (p['org_chain_id'] not in [0x5, 0x13881] and
p['pegged_chain_id'] not in [0x5, 0x13881])
if (org_chain_is_sapph or pegged_chain_is_sapph) and chain_is_not_deprecated:
src_url = org_chain['explore_url'] + 'address/' + p["org_token"]["token"]["address"]
dest_url = pegged_chain['explore_url'] + 'address/' + p["pegged_token"]["token"]["address"]
print(f'| {org_chain["name"]} ({org_chain["id"]}) | {p["org_token"]["token"]["symbol"]} | [`{p["org_token"]["token"]["address"]}`]({src_url}) | {pegged_chain["name"]} ({pegged_chain["id"]}) | [`{p["pegged_token"]["token"]["address"]}`]({dest_url}) |')
print('## Celer cBridge Tokens (Mainnet)')
print("""<!-- NOTE: this is generated using `_fetch-cbridge-tokens.py` -->
<!-- WARNING: please don't manually update the table! -->
| Source Chain | Token Name | Source Address | Dest. Chain | Dest Address |
| ------------ | ---------- | -------------- | ----------- | ------------ |""")
with urlopen('https://cbridge-prod2.celer.app/v1/getTransferConfigs') as h:
data = json.load(h)
format_result(data)
print()
print('## Celer cBridge Tokens (Testnet)')
print("""<!-- NOTE: this is generated using `_fetch-cbridge-tokens.py` -->
<!-- WARNING: please don't manually update the table! -->
| Source Chain | Token Name | Source Address | Dest. Chain | Dest Address |
| ------------ | ---------- | -------------- | ----------- | ------------ |""")
with urlopen('https://cbridge-v2-test.celer.network/v1/getTransferConfigs') as h:
data = json.load(h)
format_result(data)