nostrrelay/models.py
dni ⚡ 35584a230f
Some checks failed
CI / lint (push) Has been cancelled
/ release (push) Has been cancelled
CI / tests (push) Has been cancelled
/ pullrequest (push) Has been cancelled
chore: add uv, linting, fixes (#39)
* chore: add uv, linting, fixes
2025-10-30 10:43:27 +01:00

45 lines
964 B
Python

from pydantic import BaseModel
class BuyOrder(BaseModel):
action: str
relay_id: str
pubkey: str
units_to_buy: int = 0
def is_valid_action(self) -> bool:
return self.action in ["join", "storage"]
class NostrPartialAccount(BaseModel):
relay_id: str
pubkey: str
allowed: bool | None = None
blocked: bool | None = None
class NostrAccount(BaseModel):
pubkey: str
relay_id: str
sats: int = 0
storage: int = 0
paid_to_join: bool = False
allowed: bool = False
blocked: bool = False
@property
def can_join(self):
"""If an account is explicitly allowed then it does not need to pay"""
return self.paid_to_join or self.allowed
@classmethod
def null_account(cls) -> "NostrAccount":
return NostrAccount(pubkey="", relay_id="")
class NostrEventTags(BaseModel):
relay_id: str
event_id: str
name: str
value: str
extra: str | None = None