Remove validation step

This commit is contained in:
Gui Heise 2021-11-24 12:23:32 -05:00
parent 8a555ea442
commit 9f860c118e

View File

@ -31,8 +31,6 @@ class ZeroExSwapClassifier(SwapClassifier):
child_transfers: List[Transfer],
) -> Optional[Swap]:
_validate_0x_swap(trace, child_transfers)
token_in_address, token_in_amount = _get_0x_token_in_data(
trace, child_transfers
)
@ -226,28 +224,15 @@ ZEROX_GENERIC_SPECS = [
ZEROX_CLASSIFIER_SPECS = ZEROX_CONTRACT_SPECS + ZEROX_GENERIC_SPECS
def _validate_0x_swap(
trace: DecodedCallTrace,
child_transfers: List[Transfer],
) -> None:
def _get_taker_token_in_amount(
taker_address: str, token_in_address: str, child_transfers: List[Transfer]
) -> int:
if len(child_transfers) != 2:
raise ValueError(
f"A settled order should consist of 2 child transfers, not {len(child_transfers)}."
)
if trace.function_signature not in (LIMIT_SIGNATURES + RFQ_SIGNATURES):
raise RuntimeError(
f"0x orderbook function {trace.function_signature} is not supported"
)
return None
def _get_taker_token_in_amount(
taker_address: str, token_in_address: str, child_transfers: List[Transfer]
) -> int:
if taker_address == ANY_TAKER_ADDRESS:
for transfer in child_transfers:
if transfer.token_address == token_in_address:
@ -272,6 +257,11 @@ def _get_0x_token_in_data(
elif trace.function_signature in LIMIT_SIGNATURES:
taker_address = order[6]
else:
raise RuntimeError(
f"0x orderbook function {trace.function_signature} is not supported"
)
token_in_amount = _get_taker_token_in_amount(
taker_address, token_in_address, child_transfers
)