Files
wtf-indexer/src/core/events.py
T

19 lines
608 B
Python

from pydantic import BaseModel, Field
from typing import Dict, Any, Optional
class NormalizedEvent(BaseModel):
"""跨链与跨合约的标准归一化事件 (Layer 2)"""
chain_id: int
block_number: int
tx_hash: str
log_index: int
event_type: str = Field(description="e.g. MARKET_CREATED, MINT_COLLATERAL, REDEEM_OT, RESOLVE_OUTCOME, CLAIM")
contract_address: str
payload: Dict[str, Any]
timestamp: int
@property
def event_id(self) -> str:
"""全局唯一幂等标识 (Idempotency Key)"""
return f"{self.chain_id}:{self.tx_hash}:{self.log_index}"