from typing import Optional

from pydantic import condecimal
from sqlalchemy.orm import declared_attr
from sqlmodel import Field, SQLModel


class Reward(SQLModel, table=True):
    tx_hash: Optional[str] = Field(primary_key=True)
    address: Optional[str] = Field(..., index=True)
    block: Optional[int]
    timestamp: Optional[int]

    # Come from Tx logs
    value: condecimal(max_digits=10, decimal_places=3) = None
    iscore: condecimal(max_digits=13, decimal_places=3) = None

    @declared_attr
    def __tablename__(cls) -> str:  # noqa: N805
        return "rewards"

pydantic.condecimal sqlmodel.Field
[((206, 229), 'sqlmodel.Field', 'Field', ([], {'primary_key': '(True)'}), '(primary_key=True)\n', (211, 229), False, 'from sqlmodel import Field, SQLModel\n'), ((259, 281), 'sqlmodel.Field', 'Field', (['...'], {'index': '(True)'}), '(..., index=True)\n', (264, 281), False, 'from sqlmodel import Field, SQLModel\n'), ((372, 415), 'pydantic.condecimal', 'condecimal', ([], {'max_digits': '(10)', 'decimal_places': '(3)'}), '(max_digits=10, decimal_places=3)\n', (382, 415), False, 'from pydantic import condecimal\n'), ((435, 478), 'pydantic.condecimal', 'condecimal', ([], {'max_digits': '(13)', 'decimal_places': '(3)'}), '(max_digits=13, decimal_places=3)\n', (445, 478), False, 'from pydantic import condecimal\n')]