texts_cli.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. """A module with all the display info for whallets-cli."""
  2. def _welcome_message():
  3. """welcoming message to the cli"""
  4. msg = \
  5. "\n=========================================\n"\
  6. "WELCOME TO WHALLETS CLI"\
  7. "\n========================================="
  8. return msg
  9. def _main_menu():
  10. """Displays the CLI main menu"""
  11. line_0 = ("**","MAIN MENU:")
  12. line = ("---","------------------------")
  13. line_1 = ("1 -","Add a wallet")
  14. # line_2 = ("2 -","Remove a wallet")
  15. line_3 = ("2 -","Display wallet database")
  16. line_4 = ("3 -","Display whale TXs on your EVM list (option not active yet)")
  17. # line_5 = ("5 -","Display whale TXs on your SPL list")
  18. line_6 = ("4 -","Export wallet database to csv")
  19. line_q = ("Q -","Quit!")
  20. table = [
  21. line_0,
  22. line,
  23. line_1,
  24. #line_2,
  25. line_3,
  26. line_4,
  27. line_6,
  28. line_q
  29. ]
  30. return table
  31. def _menu_choice():
  32. """Sentence asking user for the next step"""
  33. msg = "\nEnter number and press Enter: "
  34. return msg
  35. def _missing_operation():
  36. """Inform about non-existing users choice"""
  37. msg = "\nSorry, but you had either choosen an unexisting option, "\
  38. "or this operation has not been developped yet."
  39. return msg
  40. def _ask_new_choice():
  41. """Message offering a new choice or quit"""
  42. msg = \
  43. "\n\n=========================================\n"\
  44. "Do you have another choice?\n1 - YES\n2 - NO (quit)\n"
  45. return msg
  46. # Commentig out, simplified to ETH only
  47. # def _choose_network():
  48. # """Gives a choice of networks to work with"""
  49. # line_0 = ("**","Please chose the network for the wallet address:")
  50. # line = ("---", "---------------------------------",)
  51. # line_1 = ("1 -","EVM; Etherum main net and any forks (BSC, Poly..)")
  52. # line_2 = ("2 -","SPL; Solana Program Platform")
  53. # line_3 = ("3 -","BTC; Bitcoin")
  54. # table = [ line_0, line, line_1, line_2, line_3]
  55. # return table
  56. def _prompt_new_info(item):
  57. """Ask or the wallet address"""
  58. msg = f"\nEnter the wallet {item}:\n(if unknown press Enter)\n"
  59. return msg
  60. def _ask_more_wallets():
  61. """ask user if an account has more wallet addresses"""
  62. msg_0 = \
  63. "\nDo you want to add another address to this username?" \
  64. "\n1 - YES (add more wallets)\n2 - NO (continue)\n"
  65. msg_1 = "\nEnter another wallet address:\n"
  66. return msg_0, msg_1
  67. def _display_wallet_check_result(key):
  68. """displays answer based on added data"""
  69. msg_0 = \
  70. f"\nThis {key} already exists in your wallet dictionary."\
  71. f"\nDo you want to continue?\n1 - YES (keep it duplicate)"\
  72. f"\n2 - NO (change the item)"\
  73. f"{_menu_choice()}"
  74. msg_1 = \
  75. f"This is your the wallet info:\n(Press Enter to save, 'q' to cancell)"
  76. return (msg_0, msg_1)
  77. def _enter_new_info(key):
  78. """Asks user for a correct information"""
  79. msg = f"\nPlease write a correct {key}:\n\n"
  80. return msg
  81. def _save_wallet_confirm(addresses, new_wallet):
  82. """print wallet and ask user if to save it"""
  83. network = new_wallet["Network"]
  84. username = new_wallet["username"]
  85. twtr = new_wallet["twitter address"]
  86. ens = new_wallet["ENS"]
  87. info = new_wallet["info/note"]
  88. # addr = list(addresses)
  89. line_0 = ("****","Wallet to be saved:")
  90. line = ("-----","--------------------")
  91. line_1 = (f"Network:",f"{network}")
  92. line_2 = (f"Name:",f"{username}")
  93. line_3 = (f"Twitter:",f"{twtr}")
  94. line_4 = (f"ENS:",f"{ens}")
  95. line_5 = (f"Info:", f"{info}")
  96. table = [
  97. line_0,
  98. line,
  99. line_1,
  100. line_2,
  101. line_3,
  102. line_4,
  103. line_5,
  104. ]
  105. for i, address in enumerate(addresses):
  106. line = (f"Address_{i}:", f"{address}")
  107. table.append(line)
  108. return table
  109. def _confirm_entry():
  110. """Asks user to confirm the wallet saving or repeat"""
  111. msg_0 = \
  112. "\nDo you want to save the wallet to the database?"\
  113. "\n1 - YES\n2 - NO\n"
  114. msg_1 = "\nThe wallet was saved to your database."
  115. msg_2 = \
  116. "\nDo you want to add another wallet?"\
  117. "\n1 - YES\n2 - NO\n"
  118. return msg_0, msg_1, msg_2
  119. def _table_headers():
  120. """Text template for table of wallet display function"""
  121. line_0 = [
  122. "#", "USER", "ENS", "TWITTER", "INFO", "ADDRESSES", "NETWORKS"]
  123. line_ = ["==", "=========", "===========", "===========",
  124. "===========", "===========", "==========="]
  125. return line_0, line_
  126. def _csv_exported():
  127. """displays information about csv stored"""
  128. msg = "\nThe wallet database was exported to ~/whallets/data/whallets.csv."
  129. return msg
  130. def _return_network(ntw_i):
  131. """Return network based on index"""
  132. if ntw_i == 0:
  133. ntw = "EVM; ETH and forks (BSC, Poly..)"
  134. elif ntw_i == 1:
  135. ntw = "Solana Program Library"
  136. elif ntw_i == 2:
  137. ntw = "Bitcoin"
  138. else:
  139. ntw = None
  140. return ntw