Black formatting for abi_decoder.py

pull/18/head
Neeraj Kashyap 2021-07-28 10:22:16 -07:00
rodzic 7cb6131a88
commit fcd373905c
1 zmienionych plików z 17 dodań i 5 usunięć

Wyświetl plik

@ -24,8 +24,12 @@ def query_for_text_signatures(
text_signatures.append(el.text_signature) text_signatures.append(el.text_signature)
return text_signatures return text_signatures
def decode_signatures( def decode_signatures(
session: Session, hex_signatures: List[str], data_model: Union[Type[EVMEventSignature], Type[EVMFunctionSignature]], db_model: Union[ESDEventSignature, ESDFunctionSignature] session: Session,
hex_signatures: List[str],
data_model: Union[Type[EVMEventSignature], Type[EVMFunctionSignature]],
db_model: Union[ESDEventSignature, ESDFunctionSignature],
) -> List[Union[EVMEventSignature, EVMFunctionSignature]]: ) -> List[Union[EVMEventSignature, EVMFunctionSignature]]:
decoded_signatures = [] decoded_signatures = []
for hex_signature in hex_signatures: for hex_signature in hex_signatures:
@ -36,6 +40,7 @@ def decode_signatures(
decoded_signatures.append(signature) decoded_signatures.append(signature)
return decoded_signatures return decoded_signatures
def decode_abi(source: str) -> ContractABI: def decode_abi(source: str) -> ContractABI:
disassembled = pyevmasm.disassemble_all(binascii.unhexlify(source)) disassembled = pyevmasm.disassemble_all(binascii.unhexlify(source))
function_hex_signatures = [] function_hex_signatures = []
@ -52,8 +57,15 @@ def decode_abi(source: str) -> ContractABI:
event_hex_signatures.append(hex_signature) event_hex_signatures.append(hex_signature)
with yield_db_session_ctx() as session: with yield_db_session_ctx() as session:
function_signatures = decode_signatures(session, function_hex_signatures, EVMFunctionSignature, ESDFunctionSignature) function_signatures = decode_signatures(
event_signatures = decode_signatures(session, event_hex_signatures, EVMEventSignature, ESDEventSignature) session, function_hex_signatures, EVMFunctionSignature, ESDFunctionSignature
)
abi = ContractABI(functions=cast(EVMFunctionSignature, function_signatures), events=cast(EVMEventSignature, event_signatures)) event_signatures = decode_signatures(
session, event_hex_signatures, EVMEventSignature, ESDEventSignature
)
abi = ContractABI(
functions=cast(EVMFunctionSignature, function_signatures),
events=cast(EVMEventSignature, event_signatures),
)
return abi return abi