From d7281b6d1477c25599e685c97893f0484ebd1601 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 20 Mar 2024 18:34:10 +0200 Subject: [PATCH 1/2] Icorrect response from getCode will set is_contract to zero. --- moonstreamapi/moonstreamapi/actions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/moonstreamapi/moonstreamapi/actions.py b/moonstreamapi/moonstreamapi/actions.py index af0f2c72..55c915e4 100644 --- a/moonstreamapi/moonstreamapi/actions.py +++ b/moonstreamapi/moonstreamapi/actions.py @@ -949,8 +949,15 @@ def check_if_smart_contract( web3_client = connect(blockchain_type, user_token=user_token) is_contract = False - - code = web3_client.eth.getCode(address) + breakpoint() + try: + code = web3_client.eth.getCode(address) + except Exception as e: + logger.error( + f"Error while getting code of address: {e} in blockchain: {blockchain_type}" + ) + code = b"" + if code != b"": is_contract = True From da0f089c0d605d93e46847eccb328f7ae90b09b0 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 20 Mar 2024 18:47:00 +0200 Subject: [PATCH 2/2] Replace to warning. --- moonstreamapi/moonstreamapi/actions.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/moonstreamapi/moonstreamapi/actions.py b/moonstreamapi/moonstreamapi/actions.py index 55c915e4..0dde7715 100644 --- a/moonstreamapi/moonstreamapi/actions.py +++ b/moonstreamapi/moonstreamapi/actions.py @@ -949,15 +949,14 @@ def check_if_smart_contract( web3_client = connect(blockchain_type, user_token=user_token) is_contract = False - breakpoint() try: code = web3_client.eth.getCode(address) except Exception as e: - logger.error( + logger.warning( f"Error while getting code of address: {e} in blockchain: {blockchain_type}" ) code = b"" - + if code != b"": is_contract = True