The backend component to interface with the smart contract.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

issue.py 802 B

2ヶ月前
1234567891011121314151617181920212223242526272829303132333435363738394041
  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