From cdd7873b07e4ad62e3ea8bfe23aeb845fd7ab29f Mon Sep 17 00:00:00 2001 From: 0xca11ab1e <105989135+ca11ab1e@users.noreply.github.com> Date: Thu, 2 Jun 2022 10:13:56 +0200 Subject: [PATCH 1/3] Reduce `subprocess` verbosity on call, or involke, error --- src/nile/core/call_or_invoke.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nile/core/call_or_invoke.py b/src/nile/core/call_or_invoke.py index 86a621f4..dc59a588 100644 --- a/src/nile/core/call_or_invoke.py +++ b/src/nile/core/call_or_invoke.py @@ -1,4 +1,5 @@ """Command to call or invoke StarkNet smart contracts.""" +import contextlib import os import subprocess @@ -37,4 +38,6 @@ def call_or_invoke(contract, type, method, params, network, signature=None): command.append("--signature") command.extend(signature) - return subprocess.check_output(command).strip().decode("utf-8") + with contextlib.suppress(subprocess.CalledProcessError): + return subprocess.check_output(command).strip().decode("utf-8") + return "" From 5969257affd23e5684997b97f3c1b71c7198da8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Thu, 4 Aug 2022 13:51:55 -0300 Subject: [PATCH 2/3] improve logging --- src/nile/core/call_or_invoke.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/nile/core/call_or_invoke.py b/src/nile/core/call_or_invoke.py index 60f94951..051743d7 100644 --- a/src/nile/core/call_or_invoke.py +++ b/src/nile/core/call_or_invoke.py @@ -1,5 +1,4 @@ """Command to call or invoke StarkNet smart contracts.""" -import contextlib import logging import os import subprocess @@ -48,9 +47,7 @@ def call_or_invoke( command.append("--no_wallet") try: - with contextlib.suppress(subprocess.CalledProcessError): - return subprocess.check_output(command).strip().decode("utf-8") - return "" + return subprocess.check_output(command).strip().decode("utf-8") except subprocess.CalledProcessError: p = subprocess.Popen(command, stderr=subprocess.PIPE) _, error = p.communicate() @@ -62,5 +59,6 @@ def call_or_invoke( --max_fee=`MAX_FEE` """ ) + return "" else: raise From 13f0e99a8a8b2d9ee993a260db63441de41ee1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Thu, 4 Aug 2022 23:29:51 -0300 Subject: [PATCH 3/3] improve logging --- src/nile/core/call_or_invoke.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/nile/core/call_or_invoke.py b/src/nile/core/call_or_invoke.py index 051743d7..c863c2bf 100644 --- a/src/nile/core/call_or_invoke.py +++ b/src/nile/core/call_or_invoke.py @@ -51,14 +51,19 @@ def call_or_invoke( except subprocess.CalledProcessError: p = subprocess.Popen(command, stderr=subprocess.PIPE) _, error = p.communicate() + err_msg = error.decode() - if "max_fee must be bigger than 0" in error.decode(): + if "max_fee must be bigger than 0" in err_msg: logging.error( """ \n😰 Whoops, looks like max fee is missing. Try with:\n --max_fee=`MAX_FEE` """ ) - return "" - else: - raise + elif "transactions should go through the __execute__ entrypoint." in err_msg: + logging.error( + "\n\n😰 Whoops, looks like you're not using an account. Try with:\n" + "\nnile send [OPTIONS] SIGNER CONTRACT_NAME METHOD [PARAMS]" + ) + + return ""