mirror of
https://github.com/lnbits/lnbits.git
synced 2025-08-08 17:22:14 +02:00
fix: annotations for models.py (#2595)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
@@ -6,7 +8,7 @@ import time
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import Callable, Dict, List, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
from ecdsa import SECP256k1, SigningKey
|
from ecdsa import SECP256k1, SigningKey
|
||||||
from fastapi import Query
|
from fastapi import Query
|
||||||
@@ -62,7 +64,7 @@ class Wallet(BaseWallet):
|
|||||||
linking_key, curve=SECP256k1, hashfunc=hashlib.sha256
|
linking_key, curve=SECP256k1, hashfunc=hashlib.sha256
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_payment(self, payment_hash: str) -> Optional["Payment"]:
|
async def get_payment(self, payment_hash: str) -> Optional[Payment]:
|
||||||
from .crud import get_standalone_payment
|
from .crud import get_standalone_payment
|
||||||
|
|
||||||
return await get_standalone_payment(payment_hash)
|
return await get_standalone_payment(payment_hash)
|
||||||
@@ -132,8 +134,8 @@ class User(BaseModel):
|
|||||||
id: str
|
id: str
|
||||||
email: Optional[str] = None
|
email: Optional[str] = None
|
||||||
username: Optional[str] = None
|
username: Optional[str] = None
|
||||||
extensions: List[str] = []
|
extensions: list[str] = []
|
||||||
wallets: List[Wallet] = []
|
wallets: list[Wallet] = []
|
||||||
admin: bool = False
|
admin: bool = False
|
||||||
super_user: bool = False
|
super_user: bool = False
|
||||||
has_password: bool = False
|
has_password: bool = False
|
||||||
@@ -142,10 +144,10 @@ class User(BaseModel):
|
|||||||
updated_at: Optional[int] = None
|
updated_at: Optional[int] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wallet_ids(self) -> List[str]:
|
def wallet_ids(self) -> list[str]:
|
||||||
return [wallet.id for wallet in self.wallets]
|
return [wallet.id for wallet in self.wallets]
|
||||||
|
|
||||||
def get_wallet(self, wallet_id: str) -> Optional["Wallet"]:
|
def get_wallet(self, wallet_id: str) -> Optional[Wallet]:
|
||||||
w = [wallet for wallet in self.wallets if wallet.id == wallet_id]
|
w = [wallet for wallet in self.wallets if wallet.id == wallet_id]
|
||||||
return w[0] if w else None
|
return w[0] if w else None
|
||||||
|
|
||||||
@@ -208,7 +210,7 @@ class Payment(FromRowModel):
|
|||||||
preimage: str
|
preimage: str
|
||||||
payment_hash: str
|
payment_hash: str
|
||||||
expiry: Optional[float]
|
expiry: Optional[float]
|
||||||
extra: Dict = {}
|
extra: dict = {}
|
||||||
wallet_id: str
|
wallet_id: str
|
||||||
webhook: Optional[str]
|
webhook: Optional[str]
|
||||||
webhook_status: Optional[int]
|
webhook_status: Optional[int]
|
||||||
@@ -349,7 +351,7 @@ class PaymentFilters(FilterModel):
|
|||||||
preimage: str
|
preimage: str
|
||||||
payment_hash: str
|
payment_hash: str
|
||||||
expiry: Optional[datetime.datetime]
|
expiry: Optional[datetime.datetime]
|
||||||
extra: Dict = {}
|
extra: dict = {}
|
||||||
wallet_id: str
|
wallet_id: str
|
||||||
webhook: Optional[str]
|
webhook: Optional[str]
|
||||||
webhook_status: Optional[int]
|
webhook_status: Optional[int]
|
||||||
|
Reference in New Issue
Block a user