whallets-cli.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. chain = input(tc._choose_chain())
  17. name = input(tc._prompt_name())
  18. address = input(tc._prompt_address())
  19. twtr = input(tc._prompt_twitter())
  20. ens = input(tc._prompt_ens())
  21. check_wallet(chain)
  22. def check_wallet(chain):
  23. """
  24. Scans through wallets to check if a new wallet is not already in the
  25. database"
  26. """
  27. i = _chain_index(chain)
  28. dict = get_wallets()[i]
  29. wallets = dict
  30. def get_wallets():
  31. ''' Gets the info from the dictionary '''
  32. filename = 'wallets_dict.json'
  33. with open(filename) as f:
  34. all_wallets = json.load(f)
  35. evm_wallets = all_wallets['evm_wallets']
  36. spl_wallets = all_wallets['spl_wallets']
  37. return evm_wallets, spl_wallets
  38. def display_wallets(chain):
  39. """Displays the wallets according the given chain"""
  40. # Chains available 'evm','spl'
  41. # evm shows all the forks
  42. i = _chain_index(chain)
  43. dict = get_wallets()[i]
  44. print(f"\n\n{chain.upper()} WALLETS:")
  45. for key, value in dict.items():
  46. user = key
  47. wallets = value['wallets']
  48. info = value['info']
  49. twitter = value['twitter']
  50. chains = []
  51. for key, value in wallets.items():
  52. chains.append(key)
  53. print(f"\nUser: {user}")
  54. print(f"Info: {info}")
  55. print(f"Twitter: {twitter}")
  56. print(f"Wallet address: {value}")
  57. print(f"Active networks: {chains}")
  58. def _chain_index(chain):
  59. '''Asigns an index based on given parameter of the chain'''
  60. if chain.lower() == 'evm':
  61. i = 0
  62. elif chain.lower() == 'spl':
  63. i = 1
  64. return i
  65. def display_all_wallets():
  66. display_wallets('evm')
  67. display_wallets('spl')
  68. display_all_wallets()