Skip to content

Commit

Permalink
Merge pull request #143 from PotLock/dev
Browse files Browse the repository at this point in the history
Dev -> prod
  • Loading branch information
Prometheo authored Jan 3, 2025
2 parents 239cd28 + fbecb39 commit 22b78db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pots/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
PAGINATED_POT_EXAMPLE,
PAGINATED_POT_FACTORY_EXAMPLE,
SIMPLE_POT_EXAMPLE,
PaginatedMpdaoUsersSerializer,
PaginatedPotApplicationsResponseSerializer,
PaginatedPotFactoriesResponseSerializer,
PaginatedPotPayoutsResponseSerializer,
Expand All @@ -48,7 +49,7 @@
PotFactorySerializer,
PotPayoutSerializer,
PotSerializer,
MpdaoVoterSerializer,
MpdaoSnapshotSerializer,
)


Expand Down Expand Up @@ -360,7 +361,7 @@ class MpdaoUsers(APIView):
],
responses={
200: OpenApiResponse(
response=MpdaoVoterSerializer,
response=PaginatedMpdaoUsersSerializer,
description="Returns voter details or paginated list of all voters for mpdao round",
examples=[
OpenApiExample(
Expand Down Expand Up @@ -425,7 +426,7 @@ def get_all_voters(self, query_params):
voters_data.append({
"voter_id": voter_id,
"account_data": account_data,
"voter_data": MpdaoVoterSerializer(voter_data or {"voter_id": voter_id}).data
"voter_data": MpdaoSnapshotSerializer(voter_data or {"voter_id": voter_id}).data
})

base_url = self.request.build_absolute_uri().split('?')[0]
Expand Down Expand Up @@ -507,7 +508,7 @@ def get_single_voter(self, voter_id):

response_data = {
"account_data": account_data,
"voter_data": MpdaoVoterSerializer(voter_data or {"voter_id": voter_id}).data
"voter_data": MpdaoSnapshotSerializer(voter_data or {"voter_id": voter_id}).data
}

return Response(response_data)
Expand Down
16 changes: 14 additions & 2 deletions pots/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from django.conf import settings

from accounts.serializers import SIMPLE_ACCOUNT_EXAMPLE, AccountSerializer
from accounts.serializers import SIMPLE_ACCOUNT_EXAMPLE, AccountSerializer, NearSocialProfileDataSerializer
from base.serializers import TwoDecimalPlacesField
from tokens.serializers import SIMPLE_TOKEN_EXAMPLE, TokenSerializer

Expand Down Expand Up @@ -341,7 +341,7 @@ class VotePositionSerializer(serializers.Serializer):
voting_power = serializers.CharField()


class MpdaoVoterSerializer(serializers.Serializer):
class MpdaoSnapshotSerializer(serializers.Serializer):
voter_id = serializers.CharField()
balance_in_contract = serializers.CharField(allow_null=True)
voting_power = serializers.CharField(allow_null=True)
Expand All @@ -364,3 +364,15 @@ def get_staking_token_balance(self, obj):
def get_staking_token_id(self, obj):
return "meta-pool.near"


class MpdaoVoterItemSerializer(serializers.Serializer):
voter_id = serializers.CharField()
account_data = AccountSerializer(allow_null=True)
voter_data = MpdaoSnapshotSerializer()

class PaginatedMpdaoUsersSerializer(serializers.Serializer):
count = serializers.IntegerField()
next = serializers.URLField(allow_null=True)
previous = serializers.URLField(allow_null=True)
results = MpdaoVoterItemSerializer(many=True)

0 comments on commit 22b78db

Please sign in to comment.