Skip to content

Commit

Permalink
chore: move allow list endpoint (#618)
Browse files Browse the repository at this point in the history
* chore: move allow list endpoint

* chore: update auth to match customization
  • Loading branch information
tim-schultz authored Jun 19, 2024
1 parent 75b7455 commit 4fe178d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
24 changes: 23 additions & 1 deletion api/account/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
from typing import Dict, List, Optional, cast

import api_logging as logging
from account.models import Account, AccountAPIKey, Community, Nonce, Customization
from account.models import (
Account,
AccountAPIKey,
AddressList,
AddressListMember,
Community,
Nonce,
Customization,
)
from django.conf import settings
from django.contrib.auth import get_user_model
from django.http import HttpResponse
Expand Down Expand Up @@ -636,3 +644,17 @@ def get_account_customization(request, dashboard_path: str):

except Customization.DoesNotExist:
raise APIException("Customization not found", status.HTTP_404_NOT_FOUND)


@api.get("/allow-list/{str:list}/{str:address}", auth=None)
def check_on_allow_list(request, list: str, address: str):
"""
Check if an address is on the allow list for a specific round
"""
try:
is_member = AddressListMember.objects.filter(
list__name=list, address=address
).exists()
return {"is_member": is_member}
except AddressList.DoesNotExist:
return {"is_member": False}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ def test_successful_get_allow_list(self):
)

client = Client()
response = client.get(
f"/registry/allow-list/{list_name}/{user_address}",
)
response = client.get(f"/account/allow-list/{list_name}/{user_address}")
assert response.status_code == 200
assert response.json()["is_member"]

def test_unsuccessful_get_allow_list(self):
list_name = "test"
client = Client()
response = client.get(
f"/registry/allow-list/{list_name}/0x123",
)
response = client.get(f"/account/allow-list/{list_name}/0x123")
assert response.status_code == 200
assert not response.json()["is_member"]
16 changes: 0 additions & 16 deletions api/registry/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# --- Deduplication Modules
from account.models import (
Account,
AddressList,
AddressListMember,
Community,
Nonce,
Rules,
Expand Down Expand Up @@ -729,20 +727,6 @@ def stamp_display(request) -> List[StampDisplayResponse]:
return fetch_all_stamp_metadata()


@router.get("/allow-list/{str:list}/{str:address}")
def check_on_allow_list(request, list: str, address: str):
"""
Check if an address is on the allow list for a specific round
"""
try:
is_member = AddressListMember.objects.filter(
list__name=list, address=address
).exists()
return {"is_member": is_member}
except AddressList.DoesNotExist:
return {"is_member": False}


@router.get(
"/gtc-stake/{str:address}/{int:round_id}",
# auth=ApiKey(),
Expand Down

0 comments on commit 4fe178d

Please sign in to comment.