Skip to content

Commit e78bcd9

Browse files
authored
Merge pull request #169 from PotLock/dev
Dev -> Prod
2 parents ed1f920 + 0ee7b3d commit e78bcd9

File tree

8 files changed

+145
-14
lines changed

8 files changed

+145
-14
lines changed

api/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
AccountsListAPI,
1818
DonorsAPI,
1919
)
20-
from base.api import StatsAPI
20+
from base.api import StatsAPI, ReclaimProofRequestView
2121
from donations.api import DonationContractConfigAPI
2222
from grantpicks.api import AccountProjectListAPI, ProjectListAPI, ProjectRoundVotesAPI, ProjectStatsAPI, RoundApplicationsAPI, RoundDetailAPI, RoundsListAPI
2323
from lists.api import (
@@ -143,6 +143,7 @@
143143
),
144144
# stats
145145
path("v1/stats", StatsAPI.as_view(), name="stats_api"),
146+
path("v1/reclaim/generate-request", ReclaimProofRequestView.as_view(), name="stats_api"),
146147

147148
# grantpicks
148149
path("v1/rounds", RoundsListAPI.as_view(), name="rounds_api"),

base/api.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
from django.db.models import Count, Exists, OuterRef, Sum
2-
from django.utils import timezone
1+
from django.db.models import Sum
2+
from django.http import JsonResponse
33
from django.utils.decorators import method_decorator
44
from django.views.decorators.cache import cache_page
55
from drf_spectacular.utils import (
66
OpenApiExample,
7-
OpenApiParameter,
87
OpenApiResponse,
98
extend_schema,
109
)
10+
from django.conf import settings
11+
from asgiref.sync import async_to_sync
1112
from rest_framework import serializers
1213
from rest_framework.request import Request
1314
from rest_framework.response import Response
1415
from rest_framework.views import APIView
15-
16+
from reclaim_python_sdk import ReclaimProofRequest
1617
from accounts.models import Account
1718
from donations.models import Donation
1819
from pots.models import PotPayout
@@ -25,6 +26,8 @@ class StatsResponseSerializer(serializers.Serializer):
2526
total_donors_count = serializers.IntegerField()
2627
total_recipients_count = serializers.IntegerField()
2728

29+
class ReclaimProofRequestConfigSerializer(serializers.Serializer):
30+
reclaimProofRequestConfig = serializers.CharField()
2831

2932
class StatsAPI(APIView):
3033
def dispatch(self, request, *args, **kwargs):
@@ -87,3 +90,45 @@ def get(self, request: Request, *args, **kwargs):
8790
"total_recipients_count": total_recipients_count,
8891
}
8992
)
93+
94+
95+
class ReclaimProofRequestView(APIView):
96+
97+
@extend_schema(
98+
responses={
99+
200: OpenApiResponse(
100+
response=ReclaimProofRequestConfigSerializer,
101+
description="Returns Reclaim proof request configuration",
102+
examples=[
103+
OpenApiExample(
104+
"example-1",
105+
summary="Simple example",
106+
description="Example response for Reclaim proof request config",
107+
value={
108+
"reclaimProofRequestConfig": "{}"
109+
},
110+
response_only=True,
111+
),
112+
],
113+
),
114+
500: OpenApiResponse(description="Internal server error"),
115+
}
116+
)
117+
def post(self, request: Request, *args, **kwargs):
118+
APP_ID = settings.RECLAIM_APP_ID
119+
APP_SECRET = settings.RECLAIM_APP_SECRET
120+
PROVIDER_ID = settings.RECLAIM_TWITTER_PROVIDER_ID
121+
122+
platform = request.query_params.get("platform")
123+
handle = request.query_params.get("handle")
124+
125+
try:
126+
reclaim_proof_func = async_to_sync(ReclaimProofRequest.init)
127+
reclaim_proof_request = reclaim_proof_func(APP_ID, APP_SECRET, PROVIDER_ID, {"context": {"handle": handle}})
128+
# reclaim_proof_request.set_app_callback_url("https://your-backend.com/receive-proofs")
129+
reclaim_proof_request_config = reclaim_proof_request.to_json_string()
130+
131+
return JsonResponse({"reclaimProofRequestConfig": reclaim_proof_request_config})
132+
except Exception as error:
133+
print(f"Error generating request config: {error}")
134+
return JsonResponse({"error": "Failed to generate request config"}, status=500)

base/settings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@
5959
REDIS_HOST = os.environ.get("PL_REDIS_HOST", "localhost")
6060
REDIS_PORT = os.environ.get("PL_REDIS_PORT", 6379)
6161
SENTRY_DSN = os.environ.get("PL_SENTRY_DSN")
62+
RECLAIM_APP_ID = os.environ.get("PL_RECLAIM_APP_ID")
63+
RECLAIM_APP_SECRET = os.environ.get("PL_RECLAIM_APP_SECRET")
64+
RECLAIM_TWITTER_PROVIDER_ID = os.environ.get("PL_RECLAIM_TWITTER_PROVIDER_ID")
6265

6366
# POTLOCK_TLA = "potlock.testnet" if ENVIRONMENT == "testnet" else "potlock.near"
6467
POTLOCK_TLA = "potlock.testnet" if ENVIRONMENT == "testnet" else ("staging.potlock.near" if ENVIRONMENT == "dev" else "potlock.near")
6568
# NADABOT_TLA = "nadabot.testnet" if ENVIRONMENT == "testnet" else "nadabot.near"
6669
NADABOT_TLA = "nadabot.testnet" if ENVIRONMENT == "testnet" else ("staging.nadabot.near" if ENVIRONMENT == "dev" else "nadabot.near")
67-
STELLAR_CONTRACT_ID = "CBEW52FEWIFWK4LCSMX5FAAG2MYB36C2RLKS5YEIF5AOJEDMCGYU3ZGB" if ENVIRONMENT == "testnet" else ("" if ENVIRONMENT == "dev" else "")
68-
STELLAR_PROJECTS_REGISTRY_CONTRACT = "CBG2JAGBYUAM3YLQFNFR3ZSWVR7XR5BEQHQ6XGUA3HCWVCHWO3RS3YUD" if ENVIRONMENT == "testnet" else ("" if ENVIRONMENT == "dev" else "")
70+
STELLAR_CONTRACT_ID = "CA7A2776JYIOYXPAJFONDC7BVPDWWLZU524UTGIJIQH6HWWOR6LKYQQT" if ENVIRONMENT == "testnet" else ("" if ENVIRONMENT == "dev" else "")
71+
STELLAR_PROJECTS_REGISTRY_CONTRACT = "CA56XSY7YEZ7CJ5FYG7YODQIWE3JNRGZ5S7E7VJAQ675KDS4BLZJ5NJH" if ENVIRONMENT == "testnet" else ("" if ENVIRONMENT == "dev" else "")
6972
NEAR_SOCIAL_CONTRACT_ADDRESS = (
7073
"v1.social08.testnet" if ENVIRONMENT == "testnet" else "social.near"
7174
)
@@ -234,7 +237,9 @@
234237

235238
CORS_ALLOWED_ORIGIN_REGEXES = [
236239
"^https:\/\/potlock-next-[\w-]+-potlock\.vercel\.app\/?$",
237-
"^https?:\/\/.*\.?grantpicks\.com$"
240+
"^https?:\/\/.*\.?grantpicks\.com$",
241+
"^https:\/\/staging\.app\.potlock\.(org|io|xyz|app)\/?$",
242+
"^https:\/\/staging\.alpha\.potlock\.(org|io|xyz|app)\/?$"
238243
]
239244

240245
# REDIS / CACHE CONFIGS
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Generated by Django 5.0.6 on 2025-05-07 15:53
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("grantpicks", "0006_alter_round_compliance_period_ms_and_more"),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name="round",
15+
name="use_whitelist",
16+
),
17+
migrations.AddField(
18+
model_name="round",
19+
name="application_wl_list_id",
20+
field=models.IntegerField(
21+
help_text="list for applicants",
22+
null=True,
23+
verbose_name="list for applicants",
24+
),
25+
),
26+
migrations.AddField(
27+
model_name="round",
28+
name="use_whitelist_application",
29+
field=models.BooleanField(
30+
default=False,
31+
help_text="Use whitelist for application.",
32+
verbose_name="use whitelist",
33+
),
34+
preserve_default=False,
35+
),
36+
migrations.AddField(
37+
model_name="round",
38+
name="use_whitelist_voting",
39+
field=models.BooleanField(
40+
default=False,
41+
help_text="Use whitelist for voting.",
42+
verbose_name="use whitelist",
43+
),
44+
preserve_default=False,
45+
),
46+
migrations.AddField(
47+
model_name="round",
48+
name="voting_wl_list_id",
49+
field=models.IntegerField(
50+
help_text="list for voter whitelist",
51+
null=True,
52+
verbose_name="list for voter whitelist",
53+
),
54+
),
55+
]

grantpicks/models.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,25 @@ class Round(models.Model):
184184
null=False,
185185
help_text=_("Round voting end date."),
186186
)
187-
use_whitelist = models.BooleanField(
187+
use_whitelist_voting = models.BooleanField(
188188
_("use whitelist"),
189189
null=False,
190-
help_text=_("Use whitelist."),
190+
help_text=_("Use whitelist for voting."),
191+
)
192+
use_whitelist_application = models.BooleanField(
193+
_("use whitelist"),
194+
null=False,
195+
help_text=_("Use whitelist for application."),
196+
)
197+
application_wl_list_id = models.IntegerField(
198+
_("list for applicants"),
199+
null=True,
200+
help_text=_("list for applicants"),
201+
)
202+
voting_wl_list_id = models.IntegerField(
203+
_("list for voter whitelist"),
204+
null=True,
205+
help_text=_("list for voter whitelist"),
191206
)
192207
use_vault = models.BooleanField(
193208
_("use vault"),

grantpicks/serializers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ class Meta:
7777
"application_end",
7878
"voting_start",
7979
"voting_end",
80-
"use_whitelist",
80+
"use_whitelist_voting",
81+
"use_whitelist_voting",
82+
"application_wl_list_id",
83+
"voting_wl_list_id",
8184
"use_vault",
8285
"num_picks_per_voter",
8386
"max_participants",
@@ -190,7 +193,10 @@ class Meta:
190193
],
191194
"use_vault": True,
192195
"description": "This is a test round",
193-
"use_whitelist": False,
196+
"use_whitelist_voting": False,
197+
"use_whitelist_application": True,
198+
"application_wl_list_id": 1,
199+
"voting_wl_list_id": 2,
194200
"voting_start": "2024-06-25T00:00:00Z",
195201
"voting_end": "2024-06-30T00:00:00Z",
196202
"cooldown_end": None,

indexer_app/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,11 @@ def create_or_update_round(event_data, contract_id, timestamp, chain_id="stellar
16471647
'application_end': datetime.fromtimestamp(event_data.get('application_end_ms') / 1000) if event_data.get('application_end_ms') else None,
16481648
'voting_start': datetime.fromtimestamp(event_data.get('voting_start_ms') / 1000),
16491649
'voting_end': datetime.fromtimestamp(event_data.get('voting_end_ms') / 1000),
1650-
'use_whitelist': event_data.get('use_whitelist'),
1651-
'use_vault': use_vault,
1650+
'use_whitelist_voting': event_data.get('use_whitelist_voting', False),
1651+
'use_whitelist_application': event_data.get('use_whitelist_application', False),
1652+
'application_wl_list_id': event_data.get('application_wl_list_id'),
1653+
'voting_wl_list_id': event_data.get('voting_wl_list_id'),
1654+
'use_vault': use_vault or False,
16521655
'num_picks_per_voter': event_data.get('num_picks_per_voter'),
16531656
'max_participants': event_data.get('max_participants'),
16541657
'allow_applications': event_data.get('allow_applications'),

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ drf-spectacular = "^0.27.2"
2424
django-extensions = "^3.2.3"
2525
psutil = "^6.0.0"
2626
stellar-sdk = "^11.0.0"
27+
reclaim-python-sdk = "^0.2.1"
2728

2829
[tool.poetry.group.dev.dependencies]
2930
black = "^24.3.0"

0 commit comments

Comments
 (0)