diff --git a/indexer_app/utils.py b/indexer_app/utils.py index aaf6eb1..9dd1e9b 100644 --- a/indexer_app/utils.py +++ b/indexer_app/utils.py @@ -404,9 +404,9 @@ async def handle_list_update( ) - logger.info(f"updating list..... {data}") + logger.info(f"updating list from result..... {data}") - listObject = await List.objects.filter(on_chain_id=data["list_id"]).aupdate( + listObject = await List.objects.filter(on_chain_id=data["id"]).aupdate( owner_id=data["owner"], default_registration_status=data["default_registration_status"], name=data["name"], diff --git a/pots/serializers.py b/pots/serializers.py index 41b5d14..55c4837 100644 --- a/pots/serializers.py +++ b/pots/serializers.py @@ -1,6 +1,9 @@ +import requests from rest_framework import serializers from rest_framework.serializers import ModelSerializer +from django.conf import settings + from accounts.serializers import SIMPLE_ACCOUNT_EXAMPLE, AccountSerializer from base.serializers import TwoDecimalPlacesField from tokens.serializers import SIMPLE_TOKEN_EXAMPLE, TokenSerializer @@ -316,6 +319,24 @@ class MpdaoVoterSerializer(serializers.Serializer): locking_positions = LockingPositionSerializer(many=True) vote_positions = VotePositionSerializer(many=True) + staking_token_balance = serializers.SerializerMethodField() + + staking_token_id = serializers.SerializerMethodField() # mpdao is only available on mainnet, + + def get_staking_token_balance(self, obj): + voter_id = obj.get('voter_id') + url = f"https://rpc.web4.near.page/account/meta-pool.near/view/ft_balance_of?account_id={voter_id}" + response = requests.get(url) + if response.status_code == 200: + balance = response.json() + return balance + return "0" + + def get_staking_token_id(self, obj): + return "meta-pool.near" + + + class PaginatedMpdaoVotersResponseSerializer(serializers.Serializer): count = serializers.IntegerField()