-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
35 lines (31 loc) · 1.13 KB
/
main.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
from operator import itemgetter
from substrateinterface import SubstrateInterface
try:
substrate = SubstrateInterface(
url="wss://zeitgeist.api.onfinality.io/public-ws"
)
except ConnectionRefusedError:
print("⚠️ Remote RPC server didn't respond")
exit()
collator_size = substrate.query(
module='ParachainStaking',
storage_function='TotalSelected'
)
collators = substrate.query(
module='ParachainStaking',
storage_function='CandidatePool'
)
chain_symbol = str(substrate.get_constant('Currency','GetNativeCurrencyId')).upper()
chain_decimals = substrate.token_decimals
print("%s Collator stats:" % (substrate.name))
print("=========================")
collator_set = []
for collator in collators:
amount = float(collator["amount"]) / 10**chain_decimals
collator_set.append({"amount": amount,"owner": collator["owner"]})
count = 0
for collator in sorted(collator_set,key=itemgetter('amount'),reverse=True):
print("%.0f %s delegated to %s" % (collator['amount'], chain_symbol, collator['owner']))
count += 1
if count == collator_size:
print("----- (Outside of selected collators) -----")