The backend component to interface with the smart contract.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

42 行
802 B

  1. from pydantic import BaseModel, computed_field, PrivateAttr
  2. class IssuePost(BaseModel):
  3. _id: bytes = PrivateAttr()
  4. title: str
  5. summary: str
  6. paragraph_count: int
  7. positive_votes: int
  8. negative_votes: int
  9. telegram_handle: str
  10. created_at: int
  11. def __init__(self, id: bytes, **data):
  12. super().__init__(**data)
  13. self._id = id
  14. @computed_field(return_type=str)
  15. @property
  16. def id(self) -> str:
  17. return self._id.hex()
  18. @id.setter
  19. def id(self, value: bytes) -> None:
  20. self._id = value
  21. class AddIssueRequest(BaseModel):
  22. session_id: str
  23. title: str
  24. paragraphs: list[str]
  25. class AddIssueResponse(BaseModel):
  26. result: bool
  27. class VoteIssueRequest(BaseModel):
  28. issue_id: str
  29. increase: bool
  30. decrease: bool