From 5484560435fc73ccdb625c31f97d9a6b916917a4 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 28 Feb 2023 09:44:46 +0200 Subject: [PATCH] chore: code format --- README.md | 41 ++++++++++++++++++----------------------- tasks.py | 2 -- views.py | 3 +-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 88e796f..1cd1e04 100644 --- a/README.md +++ b/README.md @@ -6,24 +6,23 @@ In Diagon Alley, `merchant` and `customer` communicate via NOSTR relays, so loss of money, product information, and reputation become far less likely if attacked. -A `merchant` and `customer` both have a NOSTR key-pair that are used to sign notes and subscribe to events. +A `merchant` and `customer` both have a NOSTR key-pair that are used to sign notes and subscribe to events. #### For further information about NOSTR, see https://github.com/nostr-protocol/nostr - ## Terms -* `merchant` - seller of products with NOSTR key-pair -* `customer` - buyer of products with NOSTR key-pair -* `product` - item for sale by the `merchant` -* `stall` - list of products controlled by `merchant` (a `merchant` can have multiple stalls) -* `marketplace` - clientside software for searching `stalls` and purchasing `products` +- `merchant` - seller of products with NOSTR key-pair +- `customer` - buyer of products with NOSTR key-pair +- `product` - item for sale by the `merchant` +- `stall` - list of products controlled by `merchant` (a `merchant` can have multiple stalls) +- `marketplace` - clientside software for searching `stalls` and purchasing `products` ## Diagon Alley Clients ### Merchant admin -Where the `merchant` creates, updates and deletes `stalls` and `products`, as well as where they manage sales, payments and communication with `customers`. +Where the `merchant` creates, updates and deletes `stalls` and `products`, as well as where they manage sales, payments and communication with `customers`. The `merchant` admin software can be purely clientside, but for `convenience` and uptime, implementations will likely have a server listening for NOSTR events. @@ -39,14 +38,14 @@ The `merchant` event that publishes and updates product lists The below json goes in `content` of NIP-01. -Data from newer events should replace data from older events. +Data from newer events should replace data from older events. `action` types (used to indicate changes): -* `update` element has changed -* `delete` element should be deleted -* `suspend` element is suspended -* `unsuspend` element is unsuspended +- `update` element has changed +- `delete` element should be deleted +- `suspend` element is suspended +- `unsuspend` element is unsuspended ``` { @@ -175,7 +174,6 @@ As all elements are optional, an `update` `action` to a `product` `image`, may l ``` - ## Checkout events NIP-04 https://github.com/nostr-protocol/nips/blob/master/04.md, all checkout events are encrypted @@ -184,7 +182,6 @@ The below json goes in `content` of NIP-04. ### Step 1: `customer` order (event) - ``` { "id": , @@ -213,7 +210,7 @@ The below json goes in `content` of NIP-04. "quantity": , "message": } - + } ``` @@ -227,10 +224,11 @@ Sent back from the merchant for payment. Any payment option is valid that the me The below json goes in `content` of NIP-04. `payment_options`/`type` include: -* `url` URL to a payment page, stripe, paypal, btcpayserver, etc -* `btc` onchain bitcoin address -* `ln` bitcoin lightning invoice -* `lnurl` bitcoin lnurl-pay + +- `url` URL to a payment page, stripe, paypal, btcpayserver, etc +- `btc` onchain bitcoin address +- `ln` bitcoin lightning invoice +- `lnurl` bitcoin lnurl-pay ``` { @@ -276,6 +274,3 @@ Customer support is handle over whatever communication method was specified. If ## Additional Standard data models can be found here here - - - diff --git a/tasks.py b/tasks.py index c2a1abf..cbf1b74 100644 --- a/tasks.py +++ b/tasks.py @@ -11,7 +11,6 @@ from lnbits.helpers import url_for from lnbits.tasks import register_invoice_listener - async def wait_for_paid_invoices(): invoice_queue = asyncio.Queue() register_invoice_listener(invoice_queue) @@ -30,4 +29,3 @@ async def on_invoice_paid(payment: Payment) -> None: async def subscribe_nostrclient_ws(): print("### subscribe_nostrclient_ws") - diff --git a/views.py b/views.py index d836f29..ca8e1f7 100644 --- a/views.py +++ b/views.py @@ -2,16 +2,15 @@ import json from http import HTTPStatus from fastapi import Depends, Request -from starlette.responses import HTMLResponse from fastapi.templating import Jinja2Templates from loguru import logger +from starlette.responses import HTMLResponse from lnbits.core.models import User from lnbits.decorators import check_user_exists from . import nostrmarket_ext, nostrmarket_renderer - templates = Jinja2Templates(directory="templates")