whallets-cli.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """CLI for users to manage the wallet database and run research functions"""
  2. #TODO:
  3. # 1) Interacting with APIs
  4. # 2) easy adding data to the wallets_dict.json
  5. # 3) Scanning through APIs based on given parameters
  6. # 4) Prints options for the user (-h)
  7. import json
  8. import texts_cli as tc
  9. def cli():
  10. """Main program for the cli"""
  11. print(tc.welcome_message())
  12. def main_menu():
  13. """main cli options"""
  14. def add_wallet():
  15. """A function to add wallet to the wallets_dict.json"""
  16. def get_wallets():
  17. ''' Gets the info from the dictionary '''
  18. filename = 'wallets_dict.json'
  19. with open(filename) as f:
  20. all_wallets = json.load(f)
  21. evm_wallets = all_wallets['evm_wallets']
  22. spl_wallets = all_wallets['spl_wallets']
  23. return evm_wallets, spl_wallets
  24. def display_wallets(chain):
  25. """Displays the wallets according the given chain"""
  26. # Chains available 'evm','spl'
  27. # evm shows all the forks
  28. i = _chain_index(chain)
  29. dict = get_wallets()[i]
  30. print(f"\n\n{chain.upper()} WALLETS:")
  31. def _chain_index(chain):
  32. '''Asigns an index based on given parameter of the chain'''
  33. if chain.lower() == 'evm':
  34. i = 0
  35. elif chain.lower() == 'spl':
  36. i = 1
  37. return i
  38. def display_all_wallets():
  39. display_wallets('evm')
  40. display_wallets('spl')