Add maker_hash_id to book response

This commit is contained in:
Reckless_Satoshi 2023-11-28 11:13:40 +00:00
parent b62ace481d
commit 92b041cb31
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
5 changed files with 9 additions and 0 deletions

View File

@ -476,6 +476,7 @@ class OrderDetailSerializer(serializers.ModelSerializer):
class OrderPublicSerializer(serializers.ModelSerializer):
maker_nick = serializers.CharField(required=False)
maker_hash_id = serializers.CharField(required=False)
maker_status = serializers.CharField(
help_text='Status of the nick - "Active" or "Inactive"', required=False
)
@ -505,6 +506,7 @@ class OrderPublicSerializer(serializers.ModelSerializer):
"satoshis",
"maker",
"maker_nick",
"maker_hash_id",
"maker_status",
"price",
"escrow_duration",

View File

@ -708,6 +708,7 @@ class BookView(ListAPIView):
for order in queryset:
data = ListOrderSerializer(order).data
data["maker_nick"] = str(order.maker)
data["maker_hash_id"] = str(order.maker.robot.hash_id)
data["satoshis_now"] = Logics.satoshis_now(order)
# Compute current premium for those orders that are explicitly priced.

View File

@ -1554,6 +1554,8 @@ components:
nullable: true
maker_nick:
type: string
maker_hash_id:
type: string
maker_status:
type: string
description: Status of the nick - "Active" or "Inactive"

View File

@ -137,6 +137,9 @@ class RobotTokenSHA256AuthenticationMiddleWare:
user = User.objects.create_user(username=nickname, password=None)
# Store hash_id
user.robot.hash_id = hash
# Django rest_framework authtokens are limited to 40 characters.
# We use base91 so we can store the full entropy in the field.
Token.objects.create(key=token_sha256_b91, user=user)

View File

@ -831,6 +831,7 @@ class TradeTest(BaseAPITestCase):
self.assertIsInstance(datetime.fromisoformat(data[0]["created_at"]), datetime)
self.assertIsInstance(datetime.fromisoformat(data[0]["expires_at"]), datetime)
self.assertIsHash(data[0]["maker_hash_id"])
self.assertIsNone(data[0]["amount"])
self.assertAlmostEqual(
float(data[0]["min_amount"]), trade.maker_form["min_amount"]