Review nostr tags

This commit is contained in:
koalasat 2024-08-07 22:49:16 +02:00
parent af3a03c891
commit 032a48a4b2
No known key found for this signature in database
GPG Key ID: 2F7F61C6146AB157

View File

@ -33,9 +33,7 @@ class Nostr:
event = ( event = (
EventBuilder( EventBuilder(
Kind(38383), Kind(38383), "", self.generate_tags(order, robot_name, currency)
"",
Tag.parse(self.generate_tags(order, robot_name, currency)),
) )
.custom_created_at(order.created_at.timestamp()) .custom_created_at(order.created_at.timestamp())
.to_event(keys) .to_event(keys)
@ -57,29 +55,33 @@ class Nostr:
).hexdigest() ).hexdigest()
tags = [ tags = [
["d", str(uuid.UUID(hashed_id))], Tag.parse(["d", str(uuid.UUID(hashed_id))]),
["name", robot_name], Tag.parse(["name", robot_name]),
["k", "sell" if order.type == Order.Types.SELL else "buy"], Tag.parse(["k", "sell" if order.type == Order.Types.SELL else "buy"]),
["f", currency], Tag.parse(["f", currency]),
["s", self.get_status_tag(order)], Tag.parse(["s", self.get_status_tag(order)]),
["amt", "0"], Tag.parse(["amt", "0"]),
["fa", str(order.amount)], Tag.parse(["fa", str(order.amount)]),
["pm"] + order.payment_method.split(" "), Tag.parse(["pm"] + order.payment_method.split(" ")),
["premium", str(order.premium)], Tag.parse(["premium", str(order.premium)]),
Tag.parse(
[ [
"source", "source",
f"http://{config("HOST_NAME")}/{config("COORDINATOR_ALIAS")}/order/{order.id}", f"http://{config("HOST_NAME")}/{config("COORDINATOR_ALIAS")}/order/{order.id}",
], ]
["expiration", int(order.expires_at.timestamp())], ),
["y", "robosats", config("COORDINATOR_ALIAS", cast=str)], Tag.parse(["expiration", int(order.expires_at.timestamp())]),
["n", str(config("NETWORK"))], Tag.parse(["y", "robosats", config("COORDINATOR_ALIAS", cast=str)]),
["layer"] + self.get_layer_tag(order), Tag.parse(["n", str(config("NETWORK"))]),
["bond", str(order.bond_size)], Tag.parse(["layer"] + self.get_layer_tag(order)),
["z", "order"], Tag.parse(["bond", str(order.bond_size)]),
Tag.parse(["z", "order"]),
] ]
print(tags) print(tags)
if order.latitude and order.longitude: if order.latitude and order.longitude:
tags.extend([["g", pygeohash.encode(order.latitude, order.longitude)]]) tags.extend(
[Tag.parse(["g", pygeohash.encode(order.latitude, order.longitude)])]
)
return tags return tags