Skip to content

Commit

Permalink
get voter's staking balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheo committed Dec 31, 2024
1 parent 76b466b commit 8c8ab90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions indexer_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
21 changes: 21 additions & 0 deletions pots/serializers.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 8c8ab90

Please sign in to comment.