Better naming and bug fix

pull/154/head
yhtiyar 2021-08-24 15:05:17 +03:00
rodzic 3689a9a0bf
commit f0ae16b878
2 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -22,6 +22,7 @@ import boto3
import json
logger = logging.getLogger(__name__)
ETHERSCAN_SMARTCONTRACT_LABEL_NAME = "etherscan_smartcontract"
async def get_transaction_in_blocks(
@ -264,7 +265,7 @@ def parse_search_query_to_sqlalchemy_filters(q: str, allowed_addresses: List[str
return constructed_filters
def get_source_code(
def get_contract_source_info(
db_session: Session, contract_address: str
) -> Optional[data.EthereumSmartContractSourceInfo]:
query = db_session.query(EthereumAddress.id).filter(
@ -278,7 +279,7 @@ def get_source_code(
)
for label in labels:
if label.label == "etherscan_smartcontract":
if label.label == ETHERSCAN_SMARTCONTRACT_LABEL_NAME:
object_uri = label.label_data["object_uri"]
key = object_uri.split("s3://etherscan-smart-contracts/")[1]
s3 = boto3.client("s3")
@ -294,7 +295,7 @@ def get_source_code(
)
return contract_source_info
except:
logger.error(f"Failed to load smart contract {contract_address}")
logger.error(f"Failed to load smart contract {object_uri}")
return None

Wyświetl plik

@ -84,11 +84,13 @@ async def txinfo_ethereum_blockchain_handler(
if smart_contract is not None:
response.is_smart_contract_deployment = True
else:
response.smart_contract_info = actions.get_source_code(
source_info = actions.get_contract_source_info(
db_session, txinfo_request.tx.to_address
)
response.smart_contract_address = txinfo_request.tx.to_address
response.is_smart_contract_call = True
if source_info is not None:
response.smart_contract_info = source_info
response.smart_contract_address = txinfo_request.tx.to_address
response.is_smart_contract_call = True
return response