Skip to content

Commit

Permalink
Merge pull request #1 from bitkarrot/cleanup
Browse files Browse the repository at this point in the history
feat: cleanup code
  • Loading branch information
bitkarrot authored Jul 25, 2024
2 parents 6e645f6 + 42b9093 commit 6b91cc6
Show file tree
Hide file tree
Showing 23 changed files with 2,795 additions and 387 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/flake8.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: lint
on:
push:
branches:
- main
pull_request:

jobs:
lint:
uses: lnbits/lnbits/.github/workflows/lint.yml@dev
27 changes: 0 additions & 27 deletions .github/workflows/mypy.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/pylint.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/pyright.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release github version
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__pycache__
node_modules
.mypy_cache
.venv
.DS_Store
41 changes: 24 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
all: format check

format: prettier isort black
format: prettier black ruff

check: pyright pylint flake8 checkisort checkblack checkprettier
check: mypy pyright checkblack checkruff checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write config.json manifest.json static templates

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

mypy:
poetry run mypy .

black:
poetry run black .

flake8:
poetry run flake8

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

isort:
poetry run isort .

pylint:
poetry run pylint *.py
checkruff:
poetry run ruff check .

checkprettier:
poetry run ./node_modules/.bin/prettier --check config.json manifest.json static templates
poetry run ./node_modules/.bin/prettier --check .

checkblack:
poetry run black --check .

checkisort:
poetry run isort --check-only .
checkeditorconfig:
editorconfig-checker

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry 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

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


checkbundle:
@echo "skipping checkbundle"
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<h1>Decoder extension</h1>

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

## Demo (Video)
## Demo (Video)

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

## Installation
Install this extension using the manifest from this repository:

Install this extension using the manifest from this repository:

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

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

<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">

## Example Usage

### Decode a BOLT11 invoice

<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">

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

<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">

## Get Started
## Get Started

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

Expand Down
21 changes: 3 additions & 18 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import asyncio

from fastapi import APIRouter
from lnbits.db import Database
from lnbits.helpers import template_renderer
from lnbits.tasks import catch_everything_and_restart

from .views import decoder_generic_router

db = Database("ext_decoder")

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

decoder_static_files = [
{
"path": "/decoder/static",
"name": "decoder_static",
}
]


def decoder_renderer():
return template_renderer(["decoder/templates"])


from .tasks import wait_for_paid_invoices
from .views import * # noqa: F401,F403
from .views_api import * # noqa: F401,F403


def decoder_start():
loop = asyncio.get_event_loop()
loop.create_task(catch_everything_and_restart(wait_for_paid_invoices))
5 changes: 0 additions & 5 deletions crud.py

This file was deleted.

5 changes: 0 additions & 5 deletions models.py

This file was deleted.

41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "decoder",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"prettier": "^2.8.7",
"pyright": "^1.1.303"
"prettier": "^3.2.5",
"pyright": "^1.1.358"
}
}
Loading

0 comments on commit 6b91cc6

Please sign in to comment.