From 64773a4db0f0d0b01d1191d0672d6400628ffc3f Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Wed, 14 Oct 2020 18:44:23 +0200
Subject: [PATCH] [mod] Introduce has_auth_method() used in `balance`

---
 silkaj/auth.py  | 10 ++++++++++
 silkaj/money.py |  9 ++-------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/silkaj/auth.py b/silkaj/auth.py
index 91ca04f3..2a4279ac 100644
--- a/silkaj/auth.py
+++ b/silkaj/auth.py
@@ -46,6 +46,16 @@ def auth_method(ctx):
         return auth_by_scrypt()
 
 
+@pass_context
+def has_auth_method(ctx):
+    return (
+        ctx.obj["AUTH_SCRYPT"]
+        or ctx.obj["AUTH_FILE"]
+        or ctx.obj["AUTH_SEED"]
+        or ctx.obj["AUTH_WIF"]
+    )
+
+
 @command("authfile", help="Generate authentication file")
 @option("--file", default="authfile", show_default=True, help="Path file")
 def generate_auth_file(file):
diff --git a/silkaj/money.py b/silkaj/money.py
index 7e124925..6d9930b3 100644
--- a/silkaj/money.py
+++ b/silkaj/money.py
@@ -21,7 +21,7 @@ from tabulate import tabulate
 from silkaj.network_tools import ClientInstance
 from silkaj.blockchain_tools import HeadBlock
 from silkaj.tools import CurrencySymbol, message_exit, coroutine
-from silkaj.auth import auth_method
+from silkaj.auth import auth_method, has_auth_method
 
 # had to import wot to prevent loop dependency. No use here.
 from silkaj import wot
@@ -38,12 +38,7 @@ from duniterpy.documents.transaction import InputSource
 @coroutine
 async def cmd_amount(ctx, pubkeys):
     client = ClientInstance().client
-    if not (
-        ctx.obj["AUTH_SCRYPT"]
-        or ctx.obj["AUTH_FILE"]
-        or ctx.obj["AUTH_SEED"]
-        or ctx.obj["AUTH_WIF"]
-    ):
+    if not has_auth_method():
         if not pubkeys:
             message_exit("You should specify one or many pubkeys")
         pubkey_list = list()
-- 
GitLab