feat: add linters and ci (#28)
* feat: introduce linting and ci * add locks * prettier * black and sorting * f405 missing imports * E902 * mypy * renderer * circular imports * check comment * add exports * add lnurlerrorhandler only on lnurl routes * add test case
This commit is contained in:
parent
b5b5abd776
commit
a44820f61f
23 changed files with 2934 additions and 145 deletions
29
models.py
29
models.py
|
|
@ -1,10 +1,9 @@
|
|||
import shortuuid
|
||||
from fastapi import Query
|
||||
from fastapi import Query, Request
|
||||
from lnurl import Lnurl, LnurlWithdrawResponse
|
||||
from lnurl import encode as lnurl_encode
|
||||
from lnurl.models import ClearnetUrl, MilliSatoshi
|
||||
from lnurl.types import ClearnetUrl, MilliSatoshi
|
||||
from pydantic import BaseModel
|
||||
from starlette.requests import Request
|
||||
|
||||
|
||||
class CreateWithdrawData(BaseModel):
|
||||
|
|
@ -49,24 +48,24 @@ class WithdrawLink(BaseModel):
|
|||
usescssv = self.usescsv.split(",")
|
||||
tohash = self.id + self.unique_hash + usescssv[self.number]
|
||||
multihash = shortuuid.uuid(name=tohash)
|
||||
url = str(req.url_for(
|
||||
"withdraw.api_lnurl_multi_response",
|
||||
unique_hash=self.unique_hash,
|
||||
id_unique_hash=multihash,
|
||||
))
|
||||
url = str(
|
||||
req.url_for(
|
||||
"withdraw.api_lnurl_multi_response",
|
||||
unique_hash=self.unique_hash,
|
||||
id_unique_hash=multihash,
|
||||
)
|
||||
)
|
||||
else:
|
||||
url = str(req.url_for(
|
||||
"withdraw.api_lnurl_response", unique_hash=self.unique_hash
|
||||
))
|
||||
url = str(
|
||||
req.url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash)
|
||||
)
|
||||
|
||||
return lnurl_encode(url)
|
||||
|
||||
def lnurl_response(self, req: Request) -> LnurlWithdrawResponse:
|
||||
url = str(req.url_for(
|
||||
name="withdraw.api_lnurl_callback", unique_hash=self.unique_hash
|
||||
))
|
||||
url = req.url_for("withdraw.api_lnurl_callback", unique_hash=self.unique_hash)
|
||||
return LnurlWithdrawResponse(
|
||||
callback=ClearnetUrl(url, scheme="https"),
|
||||
callback=ClearnetUrl(url, scheme="https"), # type: ignore
|
||||
k1=self.k1,
|
||||
minWithdrawable=MilliSatoshi(self.min_withdrawable * 1000),
|
||||
maxWithdrawable=MilliSatoshi(self.max_withdrawable * 1000),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue