Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ format: prettier black ruff
check: mypy pyright checkblack checkruff checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write .
uv run ./node_modules/.bin/prettier --write .
pyright:
poetry run ./node_modules/.bin/pyright
uv run ./node_modules/.bin/pyright

mypy:
poetry run mypy .
uv run mypy .

black:
poetry run black .
uv run black .

ruff:
poetry run ruff check . --fix
uv run ruff check . --fix

checkruff:
poetry run ruff check .
uv run ruff check .

checkprettier:
poetry run ./node_modules/.bin/prettier --check .
uv run ./node_modules/.bin/prettier --check .

checkblack:
poetry run black --check .
uv run black --check .

checkeditorconfig:
editorconfig-checker

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry run pytest
uv run pytest
install-pre-commit-hook:
@echo "Installing pre-commit hook to git"
@echo "Uninstall the hook with poetry run pre-commit uninstall"
poetry run pre-commit install
@echo "Uninstall the hook with uv run pre-commit uninstall"
uv run pre-commit install

pre-commit:
poetry run pre-commit run --all-files
uv run pre-commit run --all-files


checkbundle:
Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "Stream Alerts",
"version": "1.1.0",
"short_description": "Bitcoin donations in stream alerts",
"tile": "/streamalerts/static/image/streamalerts.png",
"contributors": ["Fittiboy", "dni"],
"min_lnbits_version": "1.0.0",
"min_lnbits_version": "1.7.0-rc1",
"images": [],
"description_md": "https://raw.githubusercontent.com/lnbits/streamalerts/main/description.md",
"terms_and_conditions_md": "https://raw.githubusercontent.com/lnbits/streamalerts/main/toc.md",
Expand Down
14 changes: 6 additions & 8 deletions crud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import httpx
from lnbits.core.crud import get_wallet
from lnbits.db import Database
Expand All @@ -19,14 +17,14 @@ async def get_service_redirect_uri(request, service_id):


async def create_donation(
data: CreateDonation, wallet: str, amount: float, donation_id: Optional[str] = None
data: CreateDonation, wallet: str, amount: float, donation_id: str | None = None
) -> Donation:
"""Create a new Donation"""
donation = Donation(
id=donation_id or urlsafe_short_hash(),
amount=amount,
wallet=wallet,
**data.dict(),
**data.model_dump(),
)
await db.insert("streamalerts.donations", donation)
return donation
Expand Down Expand Up @@ -74,15 +72,15 @@ async def create_service(data: CreateService) -> Service:
service = Service(
id=urlsafe_short_hash(),
state=urlsafe_short_hash(),
**data.dict(),
**data.model_dump(),
)
await db.insert("streamalerts.services", service)
return service


async def get_service(
service_id: Optional[str] = None, by_state: Optional[str] = None
) -> Optional[Service]:
service_id: str | None = None, by_state: str | None = None
) -> Service | None:
"""Return a service either by ID or, available, by state

Each Service's donation page is reached through its "state" hash
Expand Down Expand Up @@ -177,7 +175,7 @@ async def delete_service(service_id: str) -> list[str]:
return donation_ids


async def get_donation(donation_id: str) -> Optional[Donation]:
async def get_donation(donation_id: str) -> Donation | None:
"""Return a Donation"""
return await db.fetchone(
"SELECT * FROM streamalerts.donations WHERE id = :id",
Expand Down
2 changes: 1 addition & 1 deletion helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def get_charge_status(charge_id: str, api_key: str) -> ChargeStatus:
headers=headers,
)
r.raise_for_status()
return ChargeStatus.parse_obj(r.json())
return ChargeStatus.model_validate(r.json())


async def delete_charge(charge_id: str, api_key: str):
Expand Down
8 changes: 3 additions & 5 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from fastapi import Query
from pydantic import BaseModel

Expand All @@ -10,7 +8,7 @@ class CreateService(BaseModel):
client_secret: str = Query(...)
wallet: str = Query(...)
servicename: str = Query(...)
onchain: str = Query(None)
onchain: str | None = Query(None)


class CreateDonation(BaseModel):
Expand Down Expand Up @@ -55,8 +53,8 @@ class Service(BaseModel):
wallet: str
servicename: str # Currently, this will just always be "Streamlabs"
authenticated: bool = False # Whether a token (see below) has been acquired yet
onchain: Optional[str] = None
token: Optional[str] = None # The token with which to authenticate requests
onchain: str | None = None
token: str | None = None # The token with which to authenticate requests


class ChargeStatus(BaseModel):
Expand Down
Loading
Loading