mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 16:53:16 +00:00
Add robot hash ids to order details and robot view
This commit is contained in:
@ -432,6 +432,10 @@ class RobotViewSchema:
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Username generated (Robot name)",
|
"description": "Username generated (Robot name)",
|
||||||
},
|
},
|
||||||
|
"hash_id": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The hash identity of the robot, it is used to deterministically generate the avatar and the nicknames. It is the second sha256() of the token.",
|
||||||
|
},
|
||||||
"public_key": {
|
"public_key": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Armored ASCII PGP public key block",
|
"description": "Armored ASCII PGP public key block",
|
||||||
|
@ -254,8 +254,14 @@ class OrderDetailSerializer(serializers.ModelSerializer):
|
|||||||
maker_nick = serializers.CharField(
|
maker_nick = serializers.CharField(
|
||||||
required=False, help_text="Nickname (Robot name) of the maker"
|
required=False, help_text="Nickname (Robot name) of the maker"
|
||||||
)
|
)
|
||||||
|
maker_hash_id = serializers.CharField(
|
||||||
|
required=False, help_text="The maker's robot hash"
|
||||||
|
)
|
||||||
taker_nick = serializers.CharField(
|
taker_nick = serializers.CharField(
|
||||||
required=False, help_text="Nickname (Robot name) of the taker"
|
required=False, help_text="The taker's robot hash"
|
||||||
|
)
|
||||||
|
taker_hash_id = serializers.CharField(
|
||||||
|
required=False, help_text="The taker's robot hash"
|
||||||
)
|
)
|
||||||
status_message = serializers.CharField(
|
status_message = serializers.CharField(
|
||||||
required=False,
|
required=False,
|
||||||
@ -268,7 +274,6 @@ class OrderDetailSerializer(serializers.ModelSerializer):
|
|||||||
required=False, help_text="Whether or not the counterparty raised a dispute"
|
required=False, help_text="Whether or not the counterparty raised a dispute"
|
||||||
)
|
)
|
||||||
ur_nick = serializers.CharField(required=False, help_text="Your Nickname")
|
ur_nick = serializers.CharField(required=False, help_text="Your Nickname")
|
||||||
ur_nick = serializers.CharField(required=False, help_text="Your Nick")
|
|
||||||
maker_locked = serializers.BooleanField(
|
maker_locked = serializers.BooleanField(
|
||||||
required=False, help_text="True if maker bond is locked, False otherwise"
|
required=False, help_text="True if maker bond is locked, False otherwise"
|
||||||
)
|
)
|
||||||
@ -428,7 +433,9 @@ class OrderDetailSerializer(serializers.ModelSerializer):
|
|||||||
"is_buyer",
|
"is_buyer",
|
||||||
"is_seller",
|
"is_seller",
|
||||||
"maker_nick",
|
"maker_nick",
|
||||||
|
"maker_hash_id",
|
||||||
"taker_nick",
|
"taker_nick",
|
||||||
|
"taker_hash_id",
|
||||||
"status_message",
|
"status_message",
|
||||||
"is_fiat_sent",
|
"is_fiat_sent",
|
||||||
"is_disputed",
|
"is_disputed",
|
||||||
|
@ -244,6 +244,7 @@ class OrderView(viewsets.ViewSet):
|
|||||||
)
|
)
|
||||||
|
|
||||||
data["maker_nick"] = str(order.maker)
|
data["maker_nick"] = str(order.maker)
|
||||||
|
data["maker_hash_id"] = str(order.maker.robot.hash_id)
|
||||||
|
|
||||||
# Add activity status of participants based on last_seen
|
# Add activity status of participants based on last_seen
|
||||||
data["maker_status"] = Logics.user_activity_status(order.maker.last_login)
|
data["maker_status"] = Logics.user_activity_status(order.maker.last_login)
|
||||||
@ -278,6 +279,8 @@ class OrderView(viewsets.ViewSet):
|
|||||||
data["is_buyer"] = Logics.is_buyer(order, request.user)
|
data["is_buyer"] = Logics.is_buyer(order, request.user)
|
||||||
data["is_seller"] = Logics.is_seller(order, request.user)
|
data["is_seller"] = Logics.is_seller(order, request.user)
|
||||||
data["taker_nick"] = str(order.taker)
|
data["taker_nick"] = str(order.taker)
|
||||||
|
if order.taker:
|
||||||
|
data["taker_hash_id"] = str(order.taker.robot.hash_id)
|
||||||
data["status_message"] = Order.Status(order.status).label
|
data["status_message"] = Order.Status(order.status).label
|
||||||
data["is_fiat_sent"] = order.is_fiat_sent
|
data["is_fiat_sent"] = order.is_fiat_sent
|
||||||
data["latitude"] = order.latitude
|
data["latitude"] = order.latitude
|
||||||
@ -648,6 +651,7 @@ class RobotView(APIView):
|
|||||||
user = request.user
|
user = request.user
|
||||||
context = {}
|
context = {}
|
||||||
context["nickname"] = user.username
|
context["nickname"] = user.username
|
||||||
|
context["hash_id"] = user.robot.hash_id
|
||||||
context["public_key"] = user.robot.public_key
|
context["public_key"] = user.robot.public_key
|
||||||
context["encrypted_private_key"] = user.robot.encrypted_private_key
|
context["encrypted_private_key"] = user.robot.encrypted_private_key
|
||||||
context["earned_rewards"] = user.robot.earned_rewards
|
context["earned_rewards"] = user.robot.earned_rewards
|
||||||
|
@ -770,6 +770,11 @@ paths:
|
|||||||
nickname:
|
nickname:
|
||||||
type: string
|
type: string
|
||||||
description: Username generated (Robot name)
|
description: Username generated (Robot name)
|
||||||
|
hash_id:
|
||||||
|
type: string
|
||||||
|
description: The hash identity of the robot, it is used to deterministically
|
||||||
|
generate the avatar and the nicknames. It is the second sha256()
|
||||||
|
of the token.
|
||||||
public_key:
|
public_key:
|
||||||
type: string
|
type: string
|
||||||
description: Armored ASCII PGP public key block
|
description: Armored ASCII PGP public key block
|
||||||
@ -1375,9 +1380,15 @@ components:
|
|||||||
maker_nick:
|
maker_nick:
|
||||||
type: string
|
type: string
|
||||||
description: Nickname (Robot name) of the maker
|
description: Nickname (Robot name) of the maker
|
||||||
|
maker_hash_id:
|
||||||
|
type: string
|
||||||
|
description: The maker's robot hash
|
||||||
taker_nick:
|
taker_nick:
|
||||||
type: string
|
type: string
|
||||||
description: Nickname (Robot name) of the taker
|
description: The taker's robot hash
|
||||||
|
taker_hash_id:
|
||||||
|
type: string
|
||||||
|
description: The taker's robot hash
|
||||||
status_message:
|
status_message:
|
||||||
type: string
|
type: string
|
||||||
description: The current status of the order corresponding to the `status`
|
description: The current status of the order corresponding to the `status`
|
||||||
@ -1389,7 +1400,7 @@ components:
|
|||||||
description: Whether or not the counterparty raised a dispute
|
description: Whether or not the counterparty raised a dispute
|
||||||
ur_nick:
|
ur_nick:
|
||||||
type: string
|
type: string
|
||||||
description: Your Nick
|
description: Your Nickname
|
||||||
maker_locked:
|
maker_locked:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: True if maker bond is locked, False otherwise
|
description: True if maker bond is locked, False otherwise
|
||||||
|
@ -257,6 +257,10 @@ class TradeTest(BaseAPITestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
data["ur_nick"], read_file(f"tests/robots/{robot_index}/nickname")
|
data["ur_nick"], read_file(f"tests/robots/{robot_index}/nickname")
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
data["maker_nick"], read_file(f"tests/robots/{robot_index}/nickname")
|
||||||
|
)
|
||||||
|
self.assertIsHash(data["maker_hash_id"])
|
||||||
self.assertIsInstance(data["satoshis_now"], int)
|
self.assertIsInstance(data["satoshis_now"], int)
|
||||||
self.assertFalse(data["maker_locked"])
|
self.assertFalse(data["maker_locked"])
|
||||||
self.assertFalse(data["taker_locked"])
|
self.assertFalse(data["taker_locked"])
|
||||||
@ -342,6 +346,8 @@ class TradeTest(BaseAPITestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
data["maker_nick"], read_file(f"tests/robots/{trade.maker_index}/nickname")
|
data["maker_nick"], read_file(f"tests/robots/{trade.maker_index}/nickname")
|
||||||
)
|
)
|
||||||
|
self.assertIsHash(data["maker_hash_id"])
|
||||||
|
self.assertIsHash(data["taker_hash_id"])
|
||||||
self.assertEqual(data["maker_status"], "Active")
|
self.assertEqual(data["maker_status"], "Active")
|
||||||
self.assertEqual(data["taker_status"], "Active")
|
self.assertEqual(data["taker_status"], "Active")
|
||||||
self.assertFalse(data["is_maker"])
|
self.assertFalse(data["is_maker"])
|
||||||
|
Reference in New Issue
Block a user