serinko 4 gadi atpakaļ
vecāks
revīzija
21aad259d5
2 mainītis faili ar 71 papildinājumiem un 45 dzēšanām
  1. 22 4
      texts_cli.py
  2. 49 41
      whallets_cli.py

+ 22 - 4
texts_cli.py

@@ -63,9 +63,17 @@ def _choose_network():
     table = [ line_0, line, line_1, line_2, line_3]
     return table
 
-def _prompt_address():
+def _prompt_new_info(item):
     """Ask or the wallet address"""
-    msg = "\nEnter the wallet address:\n"
+    msg = f"\nEnter the wallet {item}:\n(if unknown press Enter)\n"
+    return msg
+
+def _ask_more_wallets():
+    """ask user if an account has more wallet addresses"""
+    msg = \
+        "\nDo you want to add another wallet to this username?" \
+        "\n1 - YES (add more wallets)\n2 - NO (continue)\n"
+
     return msg
 
 def _prompt_twitter():
@@ -93,10 +101,12 @@ def _display_wallet_check_result(y):
     """displays answer based on added data"""
     msg_0 = \
         f"{y.title()} already exists in your wallet dictionary."\
-        f"\nDo you want to continue?\n1 - YES\n2 - NO (change the item)"\
+        f"\nDo you want to continue?\n1 - YES (keep it duplicate)"\
+        f"\n2 - NO (change the item)"\
         f"{_menu_choice()}"
+
     msg_1 = \
-        f"This is your the wallet info:\n"
+        f"This is your the wallet info:\n(Press Enter to save, 'q' to cancell)"
     return (msg_0, msg_1)
 
 
@@ -128,6 +138,14 @@ def _save_wallet_confirm(ntw_i, name, addr, twtr, ens, inf):
         ]
     return table
 
+
+# def _display_wallets(chain, user):
+#     """Text template for table of wallet display function"""
+#     line_0 = ("*****",f"{chain.upper} WALLETS")
+#     line = ("=====================================================",)
+#     line_1 = ("Username:",f"{user}")
+
+
 def _return_network(ntw_i):
     """Return network based on index"""
     if ntw_i == 0:

+ 49 - 41
whallets_cli.py

@@ -70,18 +70,6 @@ def add_wallet():
 
 
 
-
-def _correct_item(y):
-    """Allows user to rewrite an exisitng item in the wallet"""
-    z = (input(tc._display_wallet_check_result(y)[0]))
-    if z =='1':
-        print(tc._display_wallet_check_result(y)[1])
-        return True
-
-    elif z == '2':
-        new_item = input(tc._enter_new_info(y))
-        return new_item
-
 def remove_wallet():
     """Removes wallet from the wallet dictionary"""
     # This function needs to be developped
@@ -89,6 +77,17 @@ def remove_wallet():
 def _get_inputs():
     """Get infor to add a new wallet"""
     ntw_i = _check_network()
+    items_str = ['username','twitter address','ENS','info/note','address']
+    wallet = []
+    adresses = []
+
+    for i,item in enumerate(items_str):
+        x = input(tc._prompt_info(item))
+        new_item = check_wallet_item(ntw_i,x)
+        if item == 'address':
+            
+
+
     name = input(tc._prompt_name())
     addr = input(tc._prompt_address())
     inf = input(tc._prompt_info())
@@ -107,47 +106,53 @@ def _check_network():
     else:
         return i
 
-def check_wallet(ntw_i,name, addr, twtr, ens, inf):
+def check_wallet_item(ntw_i,x):
     """
     Scans through wallets to check if a new wallet is not already in the
     database
     """
-    i = ntw_i
-
-    dict = get_wallets()[i]
+    dict = get_wallets()[ntw_i]
     for key, value in dict.items():
-        user = key
+        username = key
         wallets = value['wallets']
         info = value['info']
         twitter = value['twitter']
         ens_saved = value['ens']
-        if user == name:
-            x = [1,'name']
-        elif addr in wallets.values():
-            x = [2, 'address']
-        elif twtr == twitter:
-            x = [3, 'twitter']
-        elif ens == ens_saved:
-            x = [4, 'ENS']
-        else:
-            x = [5, "none"]
-
-    y = x[1]
-    x = x[0]
-
-    if x != 5:
-        new_item = _correct_item(y)
-    else:
-        print(tc._display_wallet_check_result(y)[1])
-        new_item = True
-
-    wlt = [ntw_i, name, addr, twtr, ens, inf]
 
-    if new_item != True:
-        wlt[x] = new_item
+        if x == username:
+            new_item = _correct_item(x,'username')
+        elif x in wallets.values():
+            new_item = _correct_item(x,'wallet address')
+        elif x == twitter:
+            new_item = _correct_item(x,'twitter address')
+        elif x == ens_saved:
+            new_item = _correct_item(x, 'ENS')
+        else:
+            new_item = x
+
+    return new_item
+
+    # else:
+    #     print(tc._display_wallet_check_result(y)[1])
+    #     new_item = True
+    #
+    # wlt = [ntw_i, name, addr, twtr, ens, inf]
+    #
+    # if new_item != True:
+    #     wlt[x] = new_item
+    #
+    # return wlt
+
+def _correct_item(x,z):
+    """Allows user to rewrite an exisitng item in the wallet"""
+    a = (input(tc._display_wallet_check_result(z)[0]))
 
-    return wlt
+    if a == '1':
+        new_item = x
 
+    elif a == '2':
+        new_item = input(tc._enter_new_info(z))
+        return new_item
 
 
 def get_wallets():
@@ -190,6 +195,9 @@ def display_wallets(chain):
             networks_str = ', '.join(networks)
             print(networks_str)
 
+
+
+
 def _chain_index(chain):
     """Asigns an index based on given parameter of the chain"""
     if chain.lower() == 'evm':