kopia lustrzana https://github.com/bugout-dev/moonstream
Better naming and bug fix
rodzic
3689a9a0bf
commit
f0ae16b878
|
@ -22,6 +22,7 @@ import boto3
|
||||||
import json
|
import json
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
ETHERSCAN_SMARTCONTRACT_LABEL_NAME = "etherscan_smartcontract"
|
||||||
|
|
||||||
|
|
||||||
async def get_transaction_in_blocks(
|
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
|
return constructed_filters
|
||||||
|
|
||||||
|
|
||||||
def get_source_code(
|
def get_contract_source_info(
|
||||||
db_session: Session, contract_address: str
|
db_session: Session, contract_address: str
|
||||||
) -> Optional[data.EthereumSmartContractSourceInfo]:
|
) -> Optional[data.EthereumSmartContractSourceInfo]:
|
||||||
query = db_session.query(EthereumAddress.id).filter(
|
query = db_session.query(EthereumAddress.id).filter(
|
||||||
|
@ -278,7 +279,7 @@ def get_source_code(
|
||||||
)
|
)
|
||||||
|
|
||||||
for label in labels:
|
for label in labels:
|
||||||
if label.label == "etherscan_smartcontract":
|
if label.label == ETHERSCAN_SMARTCONTRACT_LABEL_NAME:
|
||||||
object_uri = label.label_data["object_uri"]
|
object_uri = label.label_data["object_uri"]
|
||||||
key = object_uri.split("s3://etherscan-smart-contracts/")[1]
|
key = object_uri.split("s3://etherscan-smart-contracts/")[1]
|
||||||
s3 = boto3.client("s3")
|
s3 = boto3.client("s3")
|
||||||
|
@ -294,7 +295,7 @@ def get_source_code(
|
||||||
)
|
)
|
||||||
return contract_source_info
|
return contract_source_info
|
||||||
except:
|
except:
|
||||||
logger.error(f"Failed to load smart contract {contract_address}")
|
logger.error(f"Failed to load smart contract {object_uri}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,13 @@ async def txinfo_ethereum_blockchain_handler(
|
||||||
if smart_contract is not None:
|
if smart_contract is not None:
|
||||||
response.is_smart_contract_deployment = True
|
response.is_smart_contract_deployment = True
|
||||||
else:
|
else:
|
||||||
response.smart_contract_info = actions.get_source_code(
|
source_info = actions.get_contract_source_info(
|
||||||
db_session, txinfo_request.tx.to_address
|
db_session, txinfo_request.tx.to_address
|
||||||
)
|
)
|
||||||
response.smart_contract_address = txinfo_request.tx.to_address
|
if source_info is not None:
|
||||||
response.is_smart_contract_call = True
|
response.smart_contract_info = source_info
|
||||||
|
response.smart_contract_address = txinfo_request.tx.to_address
|
||||||
|
response.is_smart_contract_call = True
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue