lnbits-legend/lnbits/extensions/nostrnip5/models.py

47 lines
835 B
Python
Raw Normal View History

2022-12-20 06:28:43 -06:00
from enum import Enum
from sqlite3 import Row
from typing import List, Optional
from fastapi.param_functions import Query
from pydantic import BaseModel
2022-12-20 07:15:54 -06:00
2022-12-20 06:28:43 -06:00
class CreateAddressData(BaseModel):
domain_id: str
local_part: str
pubkey: str
active: bool = False
2022-12-20 07:15:54 -06:00
2022-12-20 06:28:43 -06:00
class CreateDomainData(BaseModel):
wallet: str
currency: str
amount: float = Query(..., ge=0.01)
domain: str
2022-12-20 07:15:54 -06:00
2022-12-20 06:28:43 -06:00
class Domain(BaseModel):
id: str
wallet: str
currency: str
amount: int
domain: str
time: int
@classmethod
def from_row(cls, row: Row) -> "Domain":
return cls(**dict(row))
2022-12-20 07:15:54 -06:00
2022-12-20 06:28:43 -06:00
class Address(BaseModel):
id: str
domain_id: str
local_part: str
pubkey: str
active: bool
time: int
@classmethod
def from_row(cls, row: Row) -> "Address":
2022-12-20 07:15:54 -06:00
return cls(**dict(row))