Skip to content

Commit 6b91cc6

Browse files
authored
Merge pull request #1 from bitkarrot/cleanup
feat: cleanup code
2 parents 6e645f6 + 42b9093 commit 6b91cc6

23 files changed

Lines changed: 2795 additions & 387 deletions

.github/workflows/flake8.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
uses: lnbits/lnbits/.github/workflows/lint.yml@dev

.github/workflows/mypy.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/pylint.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/pyright.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: release github version
22
on:
33
push:
44
tags:
5-
- '[0-9]+.[0-9]+.[0-9]+'
5+
- 'v[0-9]+.[0-9]+.[0-9]+'
66
jobs:
77
build:
88
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
__pycache__
22
node_modules
33
.mypy_cache
4+
.venv
45
.DS_Store

Makefile

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
all: format check
22

3-
format: prettier isort black
3+
format: prettier black ruff
44

5-
check: pyright pylint flake8 checkisort checkblack checkprettier
5+
check: mypy pyright checkblack checkruff checkprettier
66

77
prettier:
8-
poetry run ./node_modules/.bin/prettier --write config.json manifest.json static templates
9-
8+
poetry run ./node_modules/.bin/prettier --write .
109
pyright:
1110
poetry run ./node_modules/.bin/pyright
1211

12+
mypy:
13+
poetry run mypy .
14+
1315
black:
1416
poetry run black .
1517

16-
flake8:
17-
poetry run flake8
18-
19-
mypy:
20-
poetry run mypy
18+
ruff:
19+
poetry run ruff check . --fix
2120

22-
isort:
23-
poetry run isort .
24-
25-
pylint:
26-
poetry run pylint *.py
21+
checkruff:
22+
poetry run ruff check .
2723

2824
checkprettier:
29-
poetry run ./node_modules/.bin/prettier --check config.json manifest.json static templates
25+
poetry run ./node_modules/.bin/prettier --check .
3026

3127
checkblack:
3228
poetry run black --check .
3329

34-
checkisort:
35-
poetry run isort --check-only .
30+
checkeditorconfig:
31+
editorconfig-checker
3632

3733
test:
3834
PYTHONUNBUFFERED=1 \
3935
DEBUG=true \
4036
poetry run pytest
37+
install-pre-commit-hook:
38+
@echo "Installing pre-commit hook to git"
39+
@echo "Uninstall the hook with poetry run pre-commit uninstall"
40+
poetry run pre-commit install
41+
42+
pre-commit:
43+
poetry run pre-commit run --all-files
44+
45+
46+
checkbundle:
47+
@echo "skipping checkbundle"

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
<h1>Decoder extension</h1>
22

3-
This is an extension to help decode invoices, lnurls and lightning addresses in [LNBits](https://lnbits.com).
3+
This is an extension to help decode invoices, lnurls and lightning addresses in [LNBits](https://lnbits.com).
44

5-
## Demo (Video)
5+
## Demo (Video)
66

77
https://github.com/bitkarrot/decoder/assets/73979971/9621f31f-052b-46e4-a294-8cd5a17c8d30
88

99
## Installation
10-
Install this extension using the manifest from this repository:
10+
11+
Install this extension using the manifest from this repository:
1112

1213
[https://raw.githubusercontent.com/bitkarrot/decoder/main/manifest.json](https://raw.githubusercontent.com/bitkarrot/decoder/main/manifest.json)
1314

14-
Add the above link to LNBits on the Admin Panel by Visiting: Manage Server -> Server -> Extension Sources
15+
Add the above link to LNBits on the Admin Panel by Visiting: Manage Server -> Server -> Extension Sources
1516

1617
<img width="480" alt="Screenshot 2024-01-08 at 3 37 25 PM" src="https://github.com/bitkarrot/decoder/assets/73979971/eb782af2-e4ae-4249-8f7d-ffa809693150">
1718

1819
## Example Usage
1920

2021
### Decode a BOLT11 invoice
22+
2123
<img width="620" alt="Screenshot 2024-01-08 at 3 31 09 PM" src="https://github.com/bitkarrot/decoder/assets/73979971/63f8e6e4-1594-4cc8-b277-8ef60d0df1a1">
2224

2325
### Decode a LNURL
@@ -28,7 +30,7 @@ Add the above link to LNBits on the Admin Panel by Visiting: Manage Server -> S
2830

2931
<img width="644" alt="Screenshot 2024-01-08 at 3 30 23 PM" src="https://github.com/bitkarrot/decoder/assets/73979971/8e14373b-842c-4529-86c0-50785347a4f0">
3032

31-
## Get Started
33+
## Get Started
3234

3335
Mininum poetry version has is ^1.2, but it is recommended to use latest poetry. (including OSX)
3436

__init__.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
1-
import asyncio
2-
31
from fastapi import APIRouter
42
from lnbits.db import Database
5-
from lnbits.helpers import template_renderer
6-
from lnbits.tasks import catch_everything_and_restart
3+
4+
from .views import decoder_generic_router
75

86
db = Database("ext_decoder")
97

108
decoder_ext: APIRouter = APIRouter(prefix="/decoder", tags=["decoder"])
9+
decoder_ext.include_router(decoder_generic_router)
1110

1211
decoder_static_files = [
1312
{
1413
"path": "/decoder/static",
1514
"name": "decoder_static",
1615
}
1716
]
18-
19-
20-
def decoder_renderer():
21-
return template_renderer(["decoder/templates"])
22-
23-
24-
from .tasks import wait_for_paid_invoices
25-
from .views import * # noqa: F401,F403
26-
from .views_api import * # noqa: F401,F403
27-
28-
29-
def decoder_start():
30-
loop = asyncio.get_event_loop()
31-
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))

0 commit comments

Comments
 (0)