removed optional from block and adjusted tests
This commit is contained in:
parent
d9a73fee3a
commit
e04027237f
@ -7,7 +7,7 @@ from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifiedTrace,
|
||||
CallTrace,
|
||||
ClassifiedCallTrace,
|
||||
DecodedCallTrace,
|
||||
ClassifierSpec,
|
||||
)
|
||||
|
||||
@ -71,7 +71,7 @@ class TraceClassifier:
|
||||
signature, Classification.unknown
|
||||
)
|
||||
|
||||
return ClassifiedCallTrace(
|
||||
return DecodedCallTrace(
|
||||
**trace.dict(),
|
||||
trace_type=trace.type,
|
||||
classification=classification,
|
||||
|
@ -46,9 +46,9 @@ class TraceType(Enum):
|
||||
|
||||
class Trace(CamelModel):
|
||||
block_number: int
|
||||
block_hash: Optional[str]
|
||||
subtraces: Optional[int]
|
||||
action: Optional[dict]
|
||||
block_hash: str
|
||||
action: dict
|
||||
subtraces: int
|
||||
result: Optional[dict]
|
||||
trace_address: List[int]
|
||||
transaction_hash: Optional[str]
|
||||
|
@ -51,6 +51,9 @@ class ClassifiedTrace(Trace):
|
||||
inputs: Optional[Dict[str, Any]]
|
||||
abi_name: Optional[str]
|
||||
|
||||
class Config:
|
||||
validate_assignment = True
|
||||
|
||||
|
||||
class CallTrace(ClassifiedTrace):
|
||||
|
||||
@ -58,7 +61,7 @@ class CallTrace(ClassifiedTrace):
|
||||
from_address: str
|
||||
|
||||
|
||||
class ClassifiedCallTrace(CallTrace):
|
||||
class DecodedCallTrace(CallTrace):
|
||||
|
||||
inputs: Dict[str, Any]
|
||||
abi_name: str
|
||||
|
24
mev_inspect/schemas/swaps.py
Normal file
24
mev_inspect/schemas/swaps.py
Normal file
@ -0,0 +1,24 @@
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from mev_inspect.schemas.classified_traces import Protocol
|
||||
|
||||
|
||||
class Swap(BaseModel):
|
||||
|
||||
abi_name: str
|
||||
transaction_hash: str
|
||||
block_number: int
|
||||
trace_address: List[int]
|
||||
pool_address: str
|
||||
from_address: str
|
||||
to_address: str
|
||||
token_in_address: str
|
||||
token_in_amount: int
|
||||
token_out_address: str
|
||||
token_out_amount: int
|
||||
|
||||
# Optional
|
||||
protocol: Optional[Protocol]
|
||||
error: Optional[str]
|
@ -18,8 +18,7 @@ import click
|
||||
def inspect(block_number: str, rpc: str, cache: bool):
|
||||
check_call(
|
||||
[
|
||||
"docker",
|
||||
"compose",
|
||||
"docker-compose",
|
||||
"exec",
|
||||
"mev-inspect",
|
||||
"python",
|
||||
|
@ -5,7 +5,7 @@ from mev_inspect.schemas.classified_traces import (
|
||||
Classification,
|
||||
ClassifiedTrace,
|
||||
CallTrace,
|
||||
ClassifiedCallTrace,
|
||||
DecodedCallTrace,
|
||||
)
|
||||
|
||||
|
||||
@ -17,6 +17,8 @@ def make_transfer_trace(
|
||||
to_address: str,
|
||||
token_address: str,
|
||||
amount: int,
|
||||
action: dict = {},
|
||||
subtraces: int = 0,
|
||||
):
|
||||
return CallTrace(
|
||||
transaction_hash=transaction_hash,
|
||||
@ -30,6 +32,9 @@ def make_transfer_trace(
|
||||
"recipient": to_address,
|
||||
"amount": amount,
|
||||
},
|
||||
block_hash=str(block_number),
|
||||
action=action,
|
||||
subtraces=subtraces,
|
||||
)
|
||||
|
||||
|
||||
@ -42,8 +47,12 @@ def make_swap_trace(
|
||||
abi_name: str,
|
||||
recipient_address: str,
|
||||
recipient_input_key: str,
|
||||
action: dict = {},
|
||||
subtraces: int = 0,
|
||||
):
|
||||
return ClassifiedCallTrace(
|
||||
return DecodedCallTrace(
|
||||
action=action,
|
||||
subtraces=subtraces,
|
||||
transaction_hash=transaction_hash,
|
||||
block_number=block_number,
|
||||
type=TraceType.call,
|
||||
@ -53,27 +62,36 @@ def make_swap_trace(
|
||||
to_address=pool_address,
|
||||
inputs={recipient_input_key: recipient_address},
|
||||
abi_name=abi_name,
|
||||
block_hash=str(block_number),
|
||||
)
|
||||
|
||||
|
||||
def make_unknown_trace(
|
||||
block_number,
|
||||
transaction_hash,
|
||||
trace_address,
|
||||
block_number: int,
|
||||
transaction_hash: str,
|
||||
trace_address: List[int],
|
||||
action={},
|
||||
subtraces=0,
|
||||
):
|
||||
|
||||
return ClassifiedTrace(
|
||||
transaction_hash=transaction_hash,
|
||||
block_number=block_number,
|
||||
type=TraceType.call,
|
||||
transaction_hash=transaction_hash,
|
||||
trace_address=trace_address,
|
||||
action=action,
|
||||
subtraces=subtraces,
|
||||
block_hash=str(block_number),
|
||||
type=TraceType.call,
|
||||
classification=Classification.unknown,
|
||||
)
|
||||
|
||||
|
||||
def make_many_unknown_traces(
|
||||
block_number,
|
||||
transaction_hash,
|
||||
trace_addresses,
|
||||
block_number: int,
|
||||
transaction_hash: str,
|
||||
trace_addresses: List[List[int]],
|
||||
action: dict = {},
|
||||
subtraces: int = 0,
|
||||
) -> List[ClassifiedTrace]:
|
||||
|
||||
return [
|
||||
@ -81,6 +99,8 @@ def make_many_unknown_traces(
|
||||
block_number,
|
||||
transaction_hash,
|
||||
trace_address,
|
||||
action,
|
||||
subtraces,
|
||||
)
|
||||
for trace_address in trace_addresses
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user