fix: use lnbits linting, change to uv (#9)
Some checks failed
/ release (push) Has been cancelled
Tests / test (push) Has been cancelled
/ pullrequest (push) Has been cancelled

* fix: use lnbits linting, change to uv

- formatting
- prettier
- pyright

* dont ignore packagejson

* readd poetry lock for integration tests

* fix pyright

* fix mypy

* fix test?

* fix lnbits version

* fixup tests

* fixup!
This commit is contained in:
dni ⚡ 2025-09-12 09:30:16 +02:00 • committed by GitHub
commit 603b345073
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 5059 additions and 2199 deletions

View file

@ -1,5 +1,4 @@
from http import HTTPStatus
from typing import Dict, List, Optional
import secp256k1
from fastapi import APIRouter, Depends, Request
@ -38,20 +37,18 @@ nwcprovider_api_router = APIRouter()
# Get supported permissions
@nwcprovider_api_router.get("/api/v1/permissions", status_code=HTTPStatus.OK)
async def api_get_permissions() -> Dict:
@nwcprovider_api_router.get("/api/v1/permissions")
async def api_get_permissions() -> dict:
return nwc_permissions
## Get nwc keys associated with the wallet
@nwcprovider_api_router.get(
"/api/v1/nwc", status_code=HTTPStatus.OK, response_model=List[NWCGetResponse]
)
@nwcprovider_api_router.get("/api/v1/nwc")
async def api_get_nwcs(
include_expired: bool = False,
calculate_spent_budget: bool = False,
wallet: WalletTypeInfo = Depends(require_admin_key),
):
) -> list[NWCGetResponse]:
wallet_id = wallet.wallet.id
# hardening #
@ -74,9 +71,7 @@ async def api_get_nwcs(
# Get a nwc key
@nwcprovider_api_router.get(
"/api/v1/nwc/{pubkey}", status_code=HTTPStatus.OK, response_model=NWCGetResponse
)
@nwcprovider_api_router.get("/api/v1/nwc/{pubkey}")
async def api_get_nwc(
pubkey: str,
include_expired: bool = False,
@ -102,22 +97,20 @@ async def api_get_nwc(
# Get pairing url for given secret
@nwcprovider_api_router.get(
"/api/v1/pairing/{secret}", status_code=HTTPStatus.OK, response_model=str
)
@nwcprovider_api_router.get("/api/v1/pairing/{secret}")
async def api_get_pairing_url(req: Request, secret: str) -> str:
# hardening #
assert_sane_string(secret)
# ## #
pprivkey: Optional[str] = await get_config_nwc("provider_key")
pprivkey: str | None = await get_config_nwc("provider_key")
if not pprivkey:
raise Exception("Extension is not configured")
relay = await get_config_nwc("relay")
if not relay:
raise Exception("Extension is not configured")
relay_alias: Optional[str] = await get_config_nwc("relay_alias")
relay_alias: str | None = await get_config_nwc("relay_alias")
if relay_alias:
relay = relay_alias
else:
@ -147,13 +140,12 @@ async def api_get_pairing_url(req: Request, secret: str) -> str:
@nwcprovider_api_router.put(
"/api/v1/nwc/{pubkey}",
status_code=HTTPStatus.CREATED,
response_model=NWCGetResponse,
)
async def api_register_nwc(
pubkey: str,
data: NWCRegistrationRequest,
wallet: WalletTypeInfo = Depends(require_admin_key),
):
) -> NWCGetResponse:
wallet_id = wallet.wallet.id
# hardening #
@ -177,7 +169,7 @@ async def api_register_nwc(
# Delete a nwc key
@nwcprovider_api_router.delete("/api/v1/nwc/{pubkey}", status_code=HTTPStatus.OK)
@nwcprovider_api_router.delete("/api/v1/nwc/{pubkey}")
async def api_delete_nwc(
pubkey: str, wallet: WalletTypeInfo = Depends(require_admin_key)
):
@ -193,9 +185,7 @@ async def api_delete_nwc(
# Get config
@nwcprovider_api_router.get(
"/api/v1/config", status_code=HTTPStatus.OK, dependencies=[Depends(check_admin)]
)
@nwcprovider_api_router.get("/api/v1/config", dependencies=[Depends(check_admin)])
async def api_get_all_config_nwc():
config = await get_all_config_nwc()
return config
@ -204,7 +194,6 @@ async def api_get_all_config_nwc():
# Get config
@nwcprovider_api_router.get(
"/api/v1/config/{key}",
status_code=HTTPStatus.OK,
dependencies=[Depends(check_admin)],
)
async def api_get_config_nwc(key: str):
@ -215,9 +204,7 @@ async def api_get_config_nwc(key: str):
# Set config
@nwcprovider_api_router.post(
"/api/v1/config", status_code=HTTPStatus.OK, dependencies=[Depends(check_admin)]
)
@nwcprovider_api_router.post("/api/v1/config", dependencies=[Depends(check_admin)])
async def api_set_config_nwc(req: Request):
data = await req.json()