Skip to content

Commit

Permalink
Review nostr tags
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Aug 7, 2024
1 parent af3a03c commit 032a48a
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions api/nostr.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ async def send_order_event(self, order):

event = (
EventBuilder(
Kind(38383),
"",
Tag.parse(self.generate_tags(order, robot_name, currency)),
Kind(38383), "", self.generate_tags(order, robot_name, currency)
)
.custom_created_at(order.created_at.timestamp())
.to_event(keys)
Expand All @@ -57,29 +55,33 @@ def generate_tags(self, order, robot_name, currency):
).hexdigest()

tags = [
["d", str(uuid.UUID(hashed_id))],
["name", robot_name],
["k", "sell" if order.type == Order.Types.SELL else "buy"],
["f", currency],
["s", self.get_status_tag(order)],
["amt", "0"],
["fa", str(order.amount)],
["pm"] + order.payment_method.split(" "),
["premium", str(order.premium)],
[
"source",
f"http://{config("HOST_NAME")}/{config("COORDINATOR_ALIAS")}/order/{order.id}",
],
["expiration", int(order.expires_at.timestamp())],
["y", "robosats", config("COORDINATOR_ALIAS", cast=str)],
["n", str(config("NETWORK"))],
["layer"] + self.get_layer_tag(order),
["bond", str(order.bond_size)],
["z", "order"],
Tag.parse(["d", str(uuid.UUID(hashed_id))]),
Tag.parse(["name", robot_name]),
Tag.parse(["k", "sell" if order.type == Order.Types.SELL else "buy"]),
Tag.parse(["f", currency]),
Tag.parse(["s", self.get_status_tag(order)]),
Tag.parse(["amt", "0"]),
Tag.parse(["fa", str(order.amount)]),
Tag.parse(["pm"] + order.payment_method.split(" ")),
Tag.parse(["premium", str(order.premium)]),
Tag.parse(
[
"source",
f"http://{config("HOST_NAME")}/{config("COORDINATOR_ALIAS")}/order/{order.id}",
]
),
Tag.parse(["expiration", int(order.expires_at.timestamp())]),
Tag.parse(["y", "robosats", config("COORDINATOR_ALIAS", cast=str)]),
Tag.parse(["n", str(config("NETWORK"))]),
Tag.parse(["layer"] + self.get_layer_tag(order)),
Tag.parse(["bond", str(order.bond_size)]),
Tag.parse(["z", "order"]),
]
print(tags)
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

Expand Down

0 comments on commit 032a48a

Please sign in to comment.