Rebase conflicts
This commit is contained in:
parent
e04027237f
commit
2bcffc5ad1
57
mev_inspect/schemas/transfers.py
Normal file
57
mev_inspect/schemas/transfers.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
from typing import List, TypeVar
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from .classified_traces import Classification, ClassifiedTrace, Protocol
|
||||||
|
|
||||||
|
|
||||||
|
class Transfer(BaseModel):
|
||||||
|
transaction_hash: str
|
||||||
|
trace_address: List[int]
|
||||||
|
from_address: str
|
||||||
|
to_address: str
|
||||||
|
amount: int
|
||||||
|
|
||||||
|
|
||||||
|
# To preserve the specific Transfer type
|
||||||
|
TransferGeneric = TypeVar("TransferGeneric", bound="Transfer")
|
||||||
|
|
||||||
|
|
||||||
|
class EthTransfer(Transfer):
|
||||||
|
@classmethod
|
||||||
|
def from_trace(cls, trace: ClassifiedTrace) -> "EthTransfer":
|
||||||
|
return cls(
|
||||||
|
transaction_hash=trace.transaction_hash,
|
||||||
|
trace_address=trace.trace_address,
|
||||||
|
amount=trace.value,
|
||||||
|
to_address=trace.to_address,
|
||||||
|
from_address=trace.from_address,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ERC20Transfer(Transfer):
|
||||||
|
token_address: str
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_trace(cls, trace: ClassifiedTrace) -> "ERC20Transfer":
|
||||||
|
if trace.classification != Classification.transfer or trace.inputs is None:
|
||||||
|
raise ValueError("Invalid transfer")
|
||||||
|
|
||||||
|
if trace.protocol == Protocol.weth:
|
||||||
|
return cls(
|
||||||
|
transaction_hash=trace.transaction_hash,
|
||||||
|
trace_address=trace.trace_address,
|
||||||
|
amount=trace.inputs["wad"],
|
||||||
|
to_address=trace.inputs["dst"],
|
||||||
|
from_address=trace.from_address,
|
||||||
|
token_address=trace.to_address,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return cls(
|
||||||
|
transaction_hash=trace.transaction_hash,
|
||||||
|
trace_address=trace.trace_address,
|
||||||
|
amount=trace.inputs["amount"],
|
||||||
|
to_address=trace.inputs["recipient"],
|
||||||
|
from_address=trace.inputs.get("sender", trace.from_address),
|
||||||
|
token_address=trace.to_address,
|
||||||
|
)
|
@ -3,16 +3,12 @@ from typing import List, Optional
|
|||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
ClassifiedTrace,
|
ClassifiedTrace,
|
||||||
Classification,
|
Classification,
|
||||||
Swap,
|
|
||||||
Transfer,
|
|
||||||
)
|
)
|
||||||
<<<<<<< HEAD
|
|
||||||
from mev_inspect.schemas.swaps import Swap
|
from mev_inspect.schemas.swaps import Swap
|
||||||
from mev_inspect.schemas.transfers import ERC20Transfer
|
from mev_inspect.schemas.transfers import ERC20Transfer
|
||||||
from mev_inspect.traces import get_traces_by_transaction_hash
|
from mev_inspect.traces import get_traces_by_transaction_hash
|
||||||
=======
|
|
||||||
|
|
||||||
>>>>>>> Swamps, transfers, tests imp
|
|
||||||
from mev_inspect.transfers import (
|
from mev_inspect.transfers import (
|
||||||
get_child_transfers,
|
get_child_transfers,
|
||||||
filter_transfers,
|
filter_transfers,
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
from typing import Dict, List, Optional, Sequence
|
from typing import Dict, List, Optional, Sequence
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
from mev_inspect.schemas.classified_traces import Classification, ClassifiedTrace
|
|
||||||
from mev_inspect.schemas.transfers import ERC20Transfer, EthTransfer, TransferGeneric
|
from mev_inspect.schemas.transfers import ERC20Transfer, EthTransfer, TransferGeneric
|
||||||
=======
|
|
||||||
from mev_inspect.schemas.classified_traces import (
|
from mev_inspect.schemas.classified_traces import (
|
||||||
Classification,
|
Classification,
|
||||||
ClassifiedTrace,
|
ClassifiedTrace,
|
||||||
Transfer,
|
|
||||||
)
|
)
|
||||||
>>>>>>> Swamps, transfers, tests imp
|
|
||||||
from mev_inspect.traces import is_child_trace_address, get_child_traces
|
from mev_inspect.traces import is_child_trace_address, get_child_traces
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
from mev_inspect.schemas.transfers import ERC20Transfer
|
from mev_inspect.schemas.transfers import ERC20Transfer
|
||||||
=======
|
|
||||||
from mev_inspect.schemas.classified_traces import Transfer
|
|
||||||
>>>>>>> Swamps, transfers, tests imp
|
|
||||||
from mev_inspect.transfers import remove_child_transfers_of_transfers
|
from mev_inspect.transfers import remove_child_transfers_of_transfers
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user