-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.py
31 lines (27 loc) · 1.27 KB
/
data.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 importlib
def main(blockchains):
for blockchain in blockchains:
# Dynamically import the module based on the blockchain name
module_name = f'chains.{blockchain}'
try:
module = importlib.import_module(module_name)
except ImportError:
print(f"Failed to import {module_name}")
continue # Skip to the next blockchain if import fails
# Assume the class is named the same as the blockchain, but capitalized
class_name = blockchain.capitalize()
blockchain_class = getattr(module, class_name, None)
if blockchain_class is None:
print(f"Failed to find class {class_name} in {module_name}")
continue # Skip to the next blockchain if class is not found
# Call the get_validators classmethod
validators = blockchain_class.get_validators()
if validators is not None:
print(f'Validators for {blockchain}:')
print(validators)
else:
print(f'Failed to retrieve validators for {blockchain}')
if __name__ == '__main__':
# List of blockchain names
blockchains = ['aptos', 'axelar', 'bnb', 'celestia', 'celo', 'cosmos', 'injective', 'osmosis', 'polygon', 'sui']
main(blockchains)