Skip to content

Commit a3f030b

Browse files
talvasconcelosdni
andauthored
Fix UV and LNURL (#17)
Co-authored-by: dni ⚡ <office@dnilabs.com>
1 parent e08f1ea commit a3f030b

15 files changed

Lines changed: 2340 additions & 3740 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
release:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- name: Create github release
1212
env:
1313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -19,7 +19,7 @@ jobs:
1919
needs: [release]
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
with:
2424
token: ${{ secrets.EXT_GITHUB }}
2525
repository: lnbits/lnbits-extensions

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ format: prettier black ruff
55
check: mypy pyright checkblack checkruff checkprettier
66

77
prettier:
8-
poetry run ./node_modules/.bin/prettier --write .
8+
uv run ./node_modules/.bin/prettier --write .
99
pyright:
10-
poetry run ./node_modules/.bin/pyright
10+
uv run ./node_modules/.bin/pyright
1111

1212
mypy:
13-
poetry run mypy .
13+
uv run mypy .
1414

1515
black:
16-
poetry run black .
16+
uv run black .
1717

1818
ruff:
19-
poetry run ruff check . --fix
19+
uv run ruff check . --fix
2020

2121
checkruff:
22-
poetry run ruff check .
22+
uv run ruff check .
2323

2424
checkprettier:
25-
poetry run ./node_modules/.bin/prettier --check .
25+
uv run ./node_modules/.bin/prettier --check .
2626

2727
checkblack:
28-
poetry run black --check .
28+
uv run black --check .
2929

3030
checkeditorconfig:
3131
editorconfig-checker
3232

3333
test:
3434
PYTHONUNBUFFERED=1 \
3535
DEBUG=true \
36-
poetry run pytest
36+
uv run pytest
3737
install-pre-commit-hook:
3838
@echo "Installing pre-commit hook to git"
39-
@echo "Uninstall the hook with poetry run pre-commit uninstall"
40-
poetry run pre-commit install
39+
@echo "Uninstall the hook with uv run pre-commit uninstall"
40+
uv run pre-commit install
4141

4242
pre-commit:
43-
poetry run pre-commit run --all-files
43+
uv run pre-commit run --all-files
4444

4545

4646
checkbundle:

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
offlineshop_ext.include_router(offlineshop_api_router)
1818
offlineshop_ext.include_router(offlineshop_lnurl_router)
1919

20-
__all__ = ["offlineshop_ext", "offlineshop_static_files", "db"]
20+
__all__ = ["db", "offlineshop_ext", "offlineshop_static_files"]

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "OfflineShop",
33
"short_description": "Receive payments for products offline!",
44
"tile": "/offlineshop/static/image/offlineshop.png",
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"min_lnbits_version": "1.3.0",
77
"contributors": [
88
{

crud.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
from lnbits.db import Database
42
from lnbits.helpers import urlsafe_short_hash
53

@@ -16,15 +14,15 @@ async def create_shop(data: CreateShop) -> Shop:
1614
return shop
1715

1816

19-
async def get_shop(shop_id: str) -> Optional[Shop]:
17+
async def get_shop(shop_id: str) -> Shop | None:
2018
return await db.fetchone(
2119
"SELECT * FROM offlineshop.shops WHERE id = :id",
2220
{"id": shop_id},
2321
Shop,
2422
)
2523

2624

27-
async def get_or_create_shop_by_wallet(wallet: str) -> Optional[Shop]:
25+
async def get_or_create_shop_by_wallet(wallet: str) -> Shop | None:
2826
shop = await db.fetchone(
2927
"SELECT * FROM offlineshop.shops WHERE wallet = :wallet",
3028
{"wallet": wallet},
@@ -52,7 +50,7 @@ async def update_item(item: Item) -> Item:
5250
return item
5351

5452

55-
async def get_item(item_id: str) -> Optional[Item]:
53+
async def get_item(item_id: str) -> Item | None:
5654
return await db.fetchone(
5755
"SELECT * FROM offlineshop.items WHERE id = :id LIMIT 1",
5856
{"id": item_id},

models.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import hashlib
33
import json
44
from collections import OrderedDict
5-
from typing import Optional
65

7-
from lnurl import encode as lnurl_encode
6+
from fastapi import Request
87
from lnurl.types import LnurlPayMetadata
98
from pydantic import BaseModel
10-
from starlette.requests import Request
119

1210
from .helpers import totp
1311

@@ -58,8 +56,8 @@ def get_word(self, payment_hash):
5856

5957
class CreateShop(BaseModel):
6058
wallet: str
61-
method: Optional[str] = "wordlist"
62-
wordlist: Optional[str] = None
59+
method: str | None = "wordlist"
60+
wordlist: str | None = None
6361

6462

6563
class Shop(BaseModel):
@@ -90,21 +88,14 @@ class Item(BaseModel):
9088
id: str
9189
name: str
9290
description: str
93-
image: Optional[str]
94-
enabled: Optional[bool] = True
91+
image: str | None = None
92+
enabled: bool | None = True
9593
price: float
9694
unit: str
9795

98-
def lnurl(self, req: Request) -> str:
99-
return lnurl_encode(
100-
str(req.url_for("offlineshop.lnurl_response", item_id=self.id))
101-
)
102-
10396
def values(self, req: Request):
10497
values = self.dict()
105-
values["lnurl"] = lnurl_encode(
106-
str(req.url_for("offlineshop.lnurl_response", item_id=self.id))
107-
)
98+
values["url"] = str(req.url_for("offlineshop.lnurl_response", item_id=self.id))
10899
return values
109100

110101
@property
@@ -127,4 +118,4 @@ class CreateItem(BaseModel):
127118
description: str
128119
price: float
129120
unit: str
130-
image: Optional[str] = None
121+
image: str | None = None

0 commit comments

Comments
 (0)