From 442a50395403ad5762f4995c922109810ea07c69 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Wed, 11 Oct 2023 01:04:14 +0200 Subject: [PATCH 01/21] ad --- .../0018_userprofile_is_temporary.py | 18 +++++++++++++ ..._temporary_userprofile_is_new_by_wallet.py | 18 +++++++++++++ ...020_remove_userprofile_is_new_by_wallet.py | 17 +++++++++++++ authentication/models.py | 2 -- .../migrations/0032_linearaffleentries.py | 24 ++++++++++++++++++ prizetap/models.py | 10 ++++++++ prizetap/serializers.py | 6 +++++ prizetap/urls.py | 5 ++++ prizetap/views.py | 25 +++++++++++++++++-- 9 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 authentication/migrations/0018_userprofile_is_temporary.py create mode 100644 authentication/migrations/0019_rename_is_temporary_userprofile_is_new_by_wallet.py create mode 100644 authentication/migrations/0020_remove_userprofile_is_new_by_wallet.py create mode 100644 prizetap/migrations/0032_linearaffleentries.py diff --git a/authentication/migrations/0018_userprofile_is_temporary.py b/authentication/migrations/0018_userprofile_is_temporary.py new file mode 100644 index 00000000..c25036ef --- /dev/null +++ b/authentication/migrations/0018_userprofile_is_temporary.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.4 on 2023-10-10 11:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0017_alter_userprofile_username'), + ] + + operations = [ + migrations.AddField( + model_name='userprofile', + name='is_temporary', + field=models.BooleanField(default=False), + ), + ] diff --git a/authentication/migrations/0019_rename_is_temporary_userprofile_is_new_by_wallet.py b/authentication/migrations/0019_rename_is_temporary_userprofile_is_new_by_wallet.py new file mode 100644 index 00000000..e2f75b11 --- /dev/null +++ b/authentication/migrations/0019_rename_is_temporary_userprofile_is_new_by_wallet.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.4 on 2023-10-10 17:38 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0018_userprofile_is_temporary'), + ] + + operations = [ + migrations.RenameField( + model_name='userprofile', + old_name='is_temporary', + new_name='is_new_by_wallet', + ), + ] diff --git a/authentication/migrations/0020_remove_userprofile_is_new_by_wallet.py b/authentication/migrations/0020_remove_userprofile_is_new_by_wallet.py new file mode 100644 index 00000000..1cfb4514 --- /dev/null +++ b/authentication/migrations/0020_remove_userprofile_is_new_by_wallet.py @@ -0,0 +1,17 @@ +# Generated by Django 4.0.4 on 2023-10-10 23:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0019_rename_is_temporary_userprofile_is_new_by_wallet'), + ] + + operations = [ + migrations.RemoveField( + model_name='userprofile', + name='is_new_by_wallet', + ), + ] diff --git a/authentication/models.py b/authentication/models.py index d8ee7cdb..77c3653e 100644 --- a/authentication/models.py +++ b/authentication/models.py @@ -13,8 +13,6 @@ def get_or_create(self, first_context_id): except UserProfile.DoesNotExist: _user = User.objects.create_user(username=first_context_id) _profile = UserProfile(user=_user, initial_context_id=first_context_id) - # _profile.is_aura_verified - # _profile.is_meet_verified _profile.save() return _profile diff --git a/prizetap/migrations/0032_linearaffleentries.py b/prizetap/migrations/0032_linearaffleentries.py new file mode 100644 index 00000000..bc2378bf --- /dev/null +++ b/prizetap/migrations/0032_linearaffleentries.py @@ -0,0 +1,24 @@ +# Generated by Django 4.0.4 on 2023-10-10 23:03 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('prizetap', '0031_alter_constraint_name'), + ] + + operations = [ + migrations.CreateModel( + name='LineaRaffleEntries', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('wallet_address', models.CharField(max_length=255)), + ('is_winner', models.BooleanField(blank=True, default=False)), + ('claim_tx', models.CharField(blank=True, max_length=255, null=True)), + ('raffle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='linear_entries', to='prizetap.raffle')), + ], + ), + ] diff --git a/prizetap/models.py b/prizetap/models.py index c49e43b9..e41d780b 100644 --- a/prizetap/models.py +++ b/prizetap/models.py @@ -168,3 +168,13 @@ def save(self, *args, **kwargs): pass super().save(*args, **kwargs) + + +class LineaRaffleEntries(models.Model): + wallet_address = models.CharField(max_length=255) + raffle = models.ForeignKey(Raffle, on_delete=models.CASCADE, related_name="linear_entries") + is_winner = models.BooleanField(blank=True, default=False) + claim_tx = models.CharField(max_length=255, blank=True, null=True) + + def __str__(self): + return str(self.wallet_address) \ No newline at end of file diff --git a/prizetap/serializers.py b/prizetap/serializers.py index 28daad04..897136ca 100644 --- a/prizetap/serializers.py +++ b/prizetap/serializers.py @@ -184,3 +184,9 @@ def get_user_entry(self, raffle: Raffle): ).data except RaffleEntry.DoesNotExist: return None + + +class LineaRaffleEntrySerializer(serializers.ModelSerializer): + class Meta: + model = LineaRaffleEntries + fields = "__all__" \ No newline at end of file diff --git a/prizetap/urls.py b/prizetap/urls.py index 48c60d6f..927c5af4 100644 --- a/prizetap/urls.py +++ b/prizetap/urls.py @@ -56,5 +56,10 @@ "set-raffle-tx//", SetRaffleTXView.as_view(), name="set-raffle-tx", + ), + path( + "get-linea-entries/", + LineaRaffleView.as_view(), + name="get-linea-entries", ) ] diff --git a/prizetap/views.py b/prizetap/views.py index 3c697686..552c697c 100644 --- a/prizetap/views.py +++ b/prizetap/views.py @@ -8,12 +8,13 @@ from faucet.models import Chain from faucet.serializers import SmallChainSerializer from faucet.constraints import * -from .models import Raffle, RaffleEntry, Constraint +from .models import Raffle, RaffleEntry, Constraint, LineaRaffleEntries from .serializers import ( RaffleSerializer, RaffleEntrySerializer, ConstraintSerializer, - CreateRaffleSerializer + CreateRaffleSerializer, + LineaRaffleEntrySerializer ) from .validators import ( RaffleEnrollmentValidator, @@ -250,3 +251,23 @@ class ConstraintsListView(ListAPIView): queryset = Constraint.objects.all() serializer_class = ConstraintSerializer + +class LineaRaffleView(ListAPIView): + serializer_class = LineaRaffleEntrySerializer + + def get_queryset(self): + return LineaRaffleEntries.objects.all() + + +class SetLineaTxHashView(CreateAPIView): + + def post(self, request, *args, **kwargs): + pk = self.kwargs.get('pk') + tx_hash = request.data.get('tx_hash') + raffle_entry = get_object_or_404(LineaRaffleEntries, pk=pk) + raffle_entry.claim_tx = tx_hash + raffle_entry.save() + return Response({ + 'success': True, + 'data': LineaRaffleEntrySerializer(raffle_entry).data + }) \ No newline at end of file From 236cada43e7755090ae9c25fbea6772f90e957a4 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Wed, 11 Oct 2023 01:08:14 +0200 Subject: [PATCH 02/21] ad --- prizetap/admin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/prizetap/admin.py b/prizetap/admin.py index 550d7b8d..3a1eddad 100644 --- a/prizetap/admin.py +++ b/prizetap/admin.py @@ -18,7 +18,16 @@ class RaffleٍEntryAdmin(admin.ModelAdmin): def get_wallet(self, obj): return obj.user_profile.wallets.get(wallet_type=NetworkTypes.EVM).address +class LineaRaffleEntriesAdmin(admin.ModelAdmin): + list_display = [ + "pk", + "wallet_address", + "is_winner" + ] + + admin.site.register(Raffle, RaffleAdmin) admin.site.register(RaffleEntry, RaffleٍEntryAdmin) admin.site.register(Constraint, UserConstraintBaseAdmin) +admin.site.register(LineaRaffleEntries, LineaRaffleEntriesAdmin) From 9cbc8bb8c81799f52fc7cbd88d013bfb03b5bf11 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Wed, 11 Oct 2023 01:09:00 +0200 Subject: [PATCH 03/21] ad --- prizetap/urls.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prizetap/urls.py b/prizetap/urls.py index 927c5af4..7734e038 100644 --- a/prizetap/urls.py +++ b/prizetap/urls.py @@ -61,5 +61,10 @@ "get-linea-entries/", LineaRaffleView.as_view(), name="get-linea-entries", + ), + path( + "set-linea-hash//", + SetLineaTxHashView.as_view(), + name="set-linea-hash", ) ] From 0f8127d49bc4277fa7b56e085bee2c271b63fccf Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Wed, 11 Oct 2023 02:04:05 +0200 Subject: [PATCH 04/21] add dbdata.json to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a612cc10..f35b2e3e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ __pycache__/ *.so tmp.py +dbdata.json # Distribution / packaging .Python From be494fd66dee2bd8c24e77773cb9a79727d5a4ba Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Fri, 13 Oct 2023 13:59:17 +0200 Subject: [PATCH 05/21] change github workflow --- .github/workflows/django.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 184d6bd8..36684efb 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -24,8 +24,6 @@ jobs: run: python -m pip install --upgrade pip - name: Install requests run: pip install requests - - name: Install lnpay - run: pip install lnpay-py - name: Install Dependencies run: pip install -r requirements.txt - name: Run Tests From 0f28db2f9f0f30ae7062ac669408a8b4b27dcb28 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Sat, 14 Oct 2023 11:48:21 +0200 Subject: [PATCH 06/21] change order of raffles --- prizetap/views.py | 145 +++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 79 deletions(-) diff --git a/prizetap/views.py b/prizetap/views.py index 552c697c..3d0fdfaf 100644 --- a/prizetap/views.py +++ b/prizetap/views.py @@ -10,51 +10,51 @@ from faucet.constraints import * from .models import Raffle, RaffleEntry, Constraint, LineaRaffleEntries from .serializers import ( - RaffleSerializer, + RaffleSerializer, RaffleEntrySerializer, ConstraintSerializer, CreateRaffleSerializer, - LineaRaffleEntrySerializer + LineaRaffleEntrySerializer, ) from .validators import ( RaffleEnrollmentValidator, SetRaffleEntryTxValidator, SetClaimingPrizeTxValidator, - SetRaffleTxValidator + SetRaffleTxValidator, ) from .constraints import * from .constants import CONTRACT_ADDRESSES class RaffleListView(ListAPIView): - queryset = Raffle.objects.filter(is_active=True).order_by("pk") + queryset = Raffle.objects.filter(is_active=True).order_by("-pk") serializer_class = RaffleSerializer def get(self, request): queryset = self.get_queryset() - serializer = RaffleSerializer(queryset, many=True, context={ - 'user': request.user.profile if request.user.is_authenticated else None - }) + serializer = RaffleSerializer( + queryset, + many=True, + context={ + "user": request.user.profile if request.user.is_authenticated else None + }, + ) return Response(serializer.data) + class RaffleEnrollmentView(CreateAPIView): permission_classes = [IsAuthenticated] def post(self, request, pk): user_profile = request.user.profile raffle = get_object_or_404(Raffle, pk=pk) - - validator = RaffleEnrollmentValidator( - user_profile=user_profile, - raffle=raffle - ) - + + validator = RaffleEnrollmentValidator(user_profile=user_profile, raffle=raffle) + validator.is_valid(self.request.data) try: - raffle_entry = raffle.entries.get( - user_profile=user_profile - ) + raffle_entry = raffle.entries.get(user_profile=user_profile) except RaffleEntry.DoesNotExist: raffle_entry = RaffleEntry.objects.create( user_profile=user_profile, @@ -69,7 +69,8 @@ def post(self, request, pk): }, status=200, ) - + + class SetEnrollmentTxView(APIView): permission_classes = [IsAuthenticated] @@ -78,12 +79,11 @@ def post(self, request, pk): raffle_entry = get_object_or_404(RaffleEntry, pk=pk) validator = SetRaffleEntryTxValidator( - user_profile=user_profile, - raffle_entry=raffle_entry + user_profile=user_profile, raffle_entry=raffle_entry ) - + validator.is_valid(self.request.data) - + tx_hash = self.request.data.get("tx_hash", None) raffle_entry.tx_hash = tx_hash raffle_entry.save() @@ -92,11 +92,12 @@ def post(self, request, pk): { "detail": "Raffle entry updated successfully", "success": True, - "entry": RaffleEntrySerializer(raffle_entry).data + "entry": RaffleEntrySerializer(raffle_entry).data, }, status=200, ) - + + class SetClaimingPrizeTxView(APIView): permission_classes = [IsAuthenticated] @@ -104,13 +105,13 @@ def post(self, request, pk): user_profile = request.user.profile raffle = get_object_or_404(Raffle, pk=pk) raffle_entry = get_object_or_404( - RaffleEntry, raffle=raffle, user_profile=user_profile) + RaffleEntry, raffle=raffle, user_profile=user_profile + ) validator = SetClaimingPrizeTxValidator( - user_profile=user_profile, - raffle_entry=raffle_entry + user_profile=user_profile, raffle_entry=raffle_entry ) - + validator.is_valid(self.request.data) tx_hash = self.request.data.get("tx_hash", None) @@ -121,23 +122,22 @@ def post(self, request, pk): { "detail": "Raffle entry updated successfully", "success": True, - "entry": RaffleEntrySerializer(raffle_entry).data + "entry": RaffleEntrySerializer(raffle_entry).data, }, status=200, ) + class GetRaffleEntryView(APIView): def get(self, request, pk): raffle_entry = get_object_or_404(RaffleEntry, pk=pk) return Response( - { - "success": True, - "entry": RaffleEntrySerializer(raffle_entry).data - }, + {"success": True, "entry": RaffleEntrySerializer(raffle_entry).data}, status=200, ) + class GetRaffleConstraintsView(APIView): permission_classes = [IsAuthenticated] @@ -161,33 +161,26 @@ def get(self, request, raffle_pk): is_verified = False if constraint.is_observed(): is_verified = True - response_constraints.append({ - **ConstraintSerializer(c).data, - "is_verified": is_verified - }) - + response_constraints.append( + {**ConstraintSerializer(c).data, "is_verified": is_verified} + ) + return Response( - { - "success": True, - "constraints": response_constraints - }, - status=200 + {"success": True, "constraints": response_constraints}, status=200 ) + class CreateRaffleView(CreateAPIView): permission_classes = [IsAuthenticated] serializer_class = CreateRaffleSerializer def post(self, request: Request): - serializer: CreateRaffleSerializer = self.get_serializer(data=request.data, context={ - 'user_profile': request.user.profile - }) + serializer: CreateRaffleSerializer = self.get_serializer( + data=request.data, context={"user_profile": request.user.profile} + ) serializer.is_valid(raise_exception=True) serializer.save() - return Response({ - 'success': True, - "data": serializer.data - }) + return Response({"success": True, "data": serializer.data}) class SetRaffleTXView(APIView): @@ -197,13 +190,10 @@ def post(self, request, pk): user_profile = request.user.profile raffle = get_object_or_404(Raffle, pk=pk) - validator = SetRaffleTxValidator( - user_profile=user_profile, - raffle=raffle - ) - + validator = SetRaffleTxValidator(user_profile=user_profile, raffle=raffle) + validator.is_valid(self.request.data) - + tx_hash = self.request.data.get("tx_hash", None) raffle.tx_hash = tx_hash raffle.save() @@ -212,13 +202,14 @@ def post(self, request, pk): { "detail": "Raffle updated successfully", "success": True, - "raffle": RaffleSerializer(raffle, context={ - 'user': request.user.profile - }).data + "raffle": RaffleSerializer( + raffle, context={"user": request.user.profile} + ).data, }, status=200, ) + class ValidChainsView(ListAPIView): queryset = Chain.objects.filter(chain_id__in=list(CONTRACT_ADDRESSES.keys())) serializer_class = SmallChainSerializer @@ -228,25 +219,23 @@ def get(self, request): serializer = SmallChainSerializer(queryset, many=True) response = [] for chain in serializer.data: - response.append({ - **chain, - **CONTRACT_ADDRESSES[chain['chain_id']] - }) - return Response({ - "success": True, - "data": response - }) + response.append({**chain, **CONTRACT_ADDRESSES[chain["chain_id"]]}) + return Response({"success": True, "data": response}) + class UserRafflesListView(ListAPIView): - permission_classes=[IsAuthenticated] + permission_classes = [IsAuthenticated] def get(self, request): - queryset = Raffle.objects.filter(creator_profile=request.user.profile).order_by("pk") - serializer = RaffleSerializer(queryset, many=True, context={ - 'user': request.user.profile - }) + queryset = Raffle.objects.filter(creator_profile=request.user.profile).order_by( + "pk" + ) + serializer = RaffleSerializer( + queryset, many=True, context={"user": request.user.profile} + ) return Response(serializer.data) + class ConstraintsListView(ListAPIView): queryset = Constraint.objects.all() serializer_class = ConstraintSerializer @@ -257,17 +246,15 @@ class LineaRaffleView(ListAPIView): def get_queryset(self): return LineaRaffleEntries.objects.all() - -class SetLineaTxHashView(CreateAPIView): +class SetLineaTxHashView(CreateAPIView): def post(self, request, *args, **kwargs): - pk = self.kwargs.get('pk') - tx_hash = request.data.get('tx_hash') + pk = self.kwargs.get("pk") + tx_hash = request.data.get("tx_hash") raffle_entry = get_object_or_404(LineaRaffleEntries, pk=pk) raffle_entry.claim_tx = tx_hash raffle_entry.save() - return Response({ - 'success': True, - 'data': LineaRaffleEntrySerializer(raffle_entry).data - }) \ No newline at end of file + return Response( + {"success": True, "data": LineaRaffleEntrySerializer(raffle_entry).data} + ) From 6baf4f671fbc7e31d3f132a79aa3c78d06b1d276 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Sat, 14 Oct 2023 12:04:08 +0200 Subject: [PATCH 07/21] import OptimismClaimingGasConstraint to prizetap validators --- prizetap/validators.py | 75 ++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/prizetap/validators.py b/prizetap/validators.py index 7b9c998f..e2883086 100644 --- a/prizetap/validators.py +++ b/prizetap/validators.py @@ -4,18 +4,18 @@ from authentication.models import UserProfile from .models import RaffleEntry, Raffle from .constraints import * +from faucet.constraints import OptimismClaimingGasConstraint + class RaffleEnrollmentValidator: def __init__(self, *args, **kwargs): - self.user_profile: UserProfile = kwargs['user_profile'] - self.raffle: Raffle = kwargs['raffle'] + self.user_profile: UserProfile = kwargs["user_profile"] + self.raffle: Raffle = kwargs["raffle"] def can_enroll_in_raffle(self): if not self.raffle.is_claimable: - raise PermissionDenied( - "Can't enroll in this raffle" - ) - + raise PermissionDenied("Can't enroll in this raffle") + def check_user_constraints(self): try: param_values = json.loads(self.raffle.constraint_params) @@ -29,13 +29,12 @@ def check_user_constraints(self): except KeyError: pass if not constraint.is_observed(): - raise PermissionDenied( - constraint.response - ) + raise PermissionDenied(constraint.response) def check_user_has_wallet(self): if not self.user_profile.wallets.filter( - wallet_type=self.raffle.chain.chain_type).exists(): + wallet_type=self.raffle.chain.chain_type + ).exists(): raise PermissionDenied( f"You have not connected an {self.raffle.chain.chain_type} wallet to your account" ) @@ -47,23 +46,21 @@ def is_valid(self, data): self.check_user_has_wallet() + class SetRaffleEntryTxValidator: - def __init__(self, *args, **kwargs): - self.user_profile: UserProfile = kwargs['user_profile'] - self.raffle_entry: RaffleEntry = kwargs['raffle_entry'] + self.user_profile: UserProfile = kwargs["user_profile"] + self.raffle_entry: RaffleEntry = kwargs["raffle_entry"] def is_owner_of_raffle_entry(self): if not self.raffle_entry.user_profile == self.user_profile: raise PermissionDenied( "You don't have permission to update this raffle entry" ) - + def is_tx_empty(self): if self.raffle_entry.tx_hash: - raise PermissionDenied( - "This raffle entry is already updated" - ) + raise PermissionDenied("This raffle entry is already updated") def is_valid(self, data): self.is_owner_of_raffle_entry() @@ -71,26 +68,20 @@ def is_valid(self, data): tx_hash = data.get("tx_hash", None) if not tx_hash or len(tx_hash) != 66: - raise PermissionDenied( - "Tx hash is not valid" - ) + raise PermissionDenied("Tx hash is not valid") + class SetClaimingPrizeTxValidator: - def __init__(self, *args, **kwargs): - self.raffle_entry: RaffleEntry = kwargs['raffle_entry'] - + self.raffle_entry: RaffleEntry = kwargs["raffle_entry"] + def is_winner(self): if not self.raffle_entry.is_winner: - raise PermissionDenied( - "You are not the raffle winner" - ) - + raise PermissionDenied("You are not the raffle winner") + def is_tx_empty(self): if self.raffle_entry.claiming_prize_tx: - raise PermissionDenied( - "The tx_hash is already set" - ) + raise PermissionDenied("The tx_hash is already set") def is_valid(self, data): self.is_winner() @@ -98,27 +89,21 @@ def is_valid(self, data): tx_hash = data.get("tx_hash", None) if not tx_hash or len(tx_hash) != 66: - raise PermissionDenied( - "Tx hash is not valid" - ) + raise PermissionDenied("Tx hash is not valid") + class SetRaffleTxValidator: - def __init__(self, *args, **kwargs): - self.user_profile: UserProfile = kwargs['user_profile'] - self.raffle: Raffle = kwargs['raffle'] + self.user_profile: UserProfile = kwargs["user_profile"] + self.raffle: Raffle = kwargs["raffle"] def is_owner_of_raffle(self): if not self.raffle.creator_profile == self.user_profile: - raise PermissionDenied( - "You don't have permission to update this raffle" - ) - + raise PermissionDenied("You don't have permission to update this raffle") + def is_tx_empty(self): if self.raffle.tx_hash: - raise PermissionDenied( - "This raffle is already updated" - ) + raise PermissionDenied("This raffle is already updated") def is_valid(self, data): self.is_owner_of_raffle() @@ -126,6 +111,4 @@ def is_valid(self, data): tx_hash = data.get("tx_hash", None) if not tx_hash or len(tx_hash) != 66: - raise PermissionDenied( - "Tx hash is not valid" - ) \ No newline at end of file + raise PermissionDenied("Tx hash is not valid") From be98fd18ac1c9b190c3611d96bd93e14c3960dd3 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 01:29:50 +0330 Subject: [PATCH 08/21] Linea prizetap auto tasks --- brightIDfaucet/celery.py | 12 + prizetap/constants.py | 1687 +++++++++++++++++ .../0033_alter_linearaffleentries_raffle.py | 19 + ..._raffle_vrf_tx_hash_alter_raffle_status.py | 23 + .../migrations/0035_alter_raffle_status.py | 18 + prizetap/models.py | 4 +- prizetap/tasks.py | 131 +- prizetap/utils.py | 41 +- 8 files changed, 1929 insertions(+), 6 deletions(-) create mode 100644 prizetap/migrations/0033_alter_linearaffleentries_raffle.py create mode 100644 prizetap/migrations/0034_raffle_vrf_tx_hash_alter_raffle_status.py create mode 100644 prizetap/migrations/0035_alter_raffle_status.py diff --git a/brightIDfaucet/celery.py b/brightIDfaucet/celery.py index 3ccc9c45..64248d22 100644 --- a/brightIDfaucet/celery.py +++ b/brightIDfaucet/celery.py @@ -53,6 +53,18 @@ "set-raffle-winner": { "task": "prizetap.tasks.set_the_winner_of_raffles", "schedule": 300 + }, + "request-random-words-for-linea-raffles": { + "task": "prizetap.tasks.request_random_words_for_expired_linea_raffles", + "schedule": 60 + }, + "draw-linea-raffles": { + "task": "prizetap.tasks.draw_expired_linea_raffles", + "schedule": 60 + }, + "set-linea-raffle-winners": { + "task": "prizetap.tasks.set_the_winner_of_linea_raffles", + "schedule": 60 } } diff --git a/prizetap/constants.py b/prizetap/constants.py index a0957a6b..840296da 100644 --- a/prizetap/constants.py +++ b/prizetap/constants.py @@ -2802,6 +2802,1693 @@ } ] +VRF_CLIENT_ABI = [ + { + "inputs": [ + { + "internalType": "address", + "name": "_chainlinkVRFCoordinator", + "type": "address" + }, + { + "internalType": "uint64", + "name": "_chainlinkVRFSubscriptionId", + "type": "uint64" + }, + { + "internalType": "bytes32", + "name": "_chainlinkKeyHash", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_admin", + "type": "address" + }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "have", + "type": "address" + }, + { + "internalType": "address", + "name": "want", + "type": "address" + } + ], + "name": "OnlyCoordinatorCanFulfill", + "type": "error" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": True, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": True, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "requestId", + "type": "uint256" + }, + { + "indexed": False, + "internalType": "uint256[]", + "name": "randomWords", + "type": "uint256[]" + } + ], + "name": "VRFRequestFulfilled", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "uint256", + "name": "requestId", + "type": "uint256" + } + ], + "name": "VRFRequestSent", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OPERATOR_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "callbackGasLimit", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainlinkKeyHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "chainlinkVrfSubscriptionId", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "requestId", + "type": "uint256" + } + ], + "name": "getRandomWords", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastRequestId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "requestId", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "randomWords", + "type": "uint256[]" + } + ], + "name": "rawFulfillRandomWords", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "numWords", + "type": "uint32" + } + ], + "name": "requestRandomWords", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "gaslimit", + "type": "uint32" + } + ], + "name": "setCallbackGasLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "period", + "type": "uint256" + } + ], + "name": "setValidityPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "keyHash", + "type": "bytes32" + } + ], + "name": "setVrfKeyHash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "count", + "type": "uint16" + } + ], + "name": "setVrfRequestConfirmations", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "id", + "type": "uint64" + } + ], + "name": "setVrfSubscriptionId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "validityPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vrfRequestConfirmations", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "vrfRequests", + "outputs": [ + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "numWords", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] + +LINEA_PRIZETAP_ABI = [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "_muonAppId", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "parity", + "type": "uint8" + } + ], + "internalType": "struct IMuonClient.PublicKey", + "name": "_muonPublicKey", + "type": "tuple" + }, + { + "internalType": "address", + "name": "_muon", + "type": "address" + }, + { + "internalType": "address", + "name": "_muonValidGateway", + "type": "address" + }, + { + "internalType": "address", + "name": "_admin", + "type": "address" + }, + { + "internalType": "address", + "name": "_operator", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": False, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "indexed": False, + "internalType": "uint256", + "name": "multiplier", + "type": "uint256" + } + ], + "name": "Participate", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "indexed": True, + "internalType": "address", + "name": "winner", + "type": "address" + } + ], + "name": "PrizeClaimed", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "PrizeRefunded", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "indexed": False, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "RaffleCreated", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "indexed": True, + "internalType": "address", + "name": "rejector", + "type": "address" + } + ], + "name": "RaffleRejected", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": True, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": True, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": True, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": False, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": False, + "inputs": [ + { + "indexed": True, + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "indexed": True, + "internalType": "address[]", + "name": "winner", + "type": "address[]" + } + ], + "name": "WinnersSpecified", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_NUM_WINNERS", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OPERATOR_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_ERC721_RECEIVED", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_raffleId", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "_participants", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_multipliers", + "type": "uint256[]" + } + ], + "name": "addParticipants", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "claimPrize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maxParticipants", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "winnersCount", + "type": "uint32" + }, + { + "internalType": "bytes32", + "name": "requirementsHash", + "type": "bytes32" + } + ], + "name": "createRaffle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "randomNumbers", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "reqId", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "signature", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "nonce", + "type": "address" + } + ], + "internalType": "struct IMuonClient.SchnorrSign", + "name": "signature", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "gatewaySignature", + "type": "bytes" + } + ], + "name": "drawRaffle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "getParticipants", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "getWinners", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "isParticipated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isWinner", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isWinnerClaimed", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastRaffleId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "muon", + "outputs": [ + { + "internalType": "contract IMuonClient", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "muonAppId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "muonPublicKey", + "outputs": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "parity", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "muonValidGateway", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "participantPositions", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "multiplier", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "reqId", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "signature", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "nonce", + "type": "address" + } + ], + "internalType": "struct IMuonClient.SchnorrSign", + "name": "signature", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "gatewaySignature", + "type": "bytes" + } + ], + "name": "participateInRaffle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "raffles", + "outputs": [ + { + "internalType": "address", + "name": "initiator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "maxParticipants", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "participantsCount", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "winnersCount", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "exists", + "type": "bool" + }, + { + "internalType": "enum AbstractPrizetapRaffle.Status", + "name": "status", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "requirementsHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "refundPrize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + } + ], + "name": "rejectRaffle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_muonAddress", + "type": "address" + } + ], + "name": "setMuonAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_muonAppId", + "type": "uint256" + } + ], + "name": "setMuonAppId", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_gatewayAddress", + "type": "address" + } + ], + "name": "setMuonGateway", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "x", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "parity", + "type": "uint8" + } + ], + "internalType": "struct IMuonClient.PublicKey", + "name": "_muonPublicKey", + "type": "tuple" + } + ], + "name": "setMuonPublicKey", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "periodSeconds", + "type": "uint256" + } + ], + "name": "setValidationPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "validationPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "raffleId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "multiplier", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "reqId", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "signature", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "nonce", + "type": "address" + } + ], + "internalType": "struct IMuonClient.SchnorrSign", + "name": "sign", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "gatewaySignature", + "type": "bytes" + } + ], + "name": "verifyParticipationSig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "expirationTime", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "randomNumbers", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "reqId", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "signature", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "nonce", + "type": "address" + } + ], + "internalType": "struct IMuonClient.SchnorrSign", + "name": "sign", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "gatewaySignature", + "type": "bytes" + } + ], + "name": "verifyRandomNumberSig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] + +VRF_CLIENT_POLYGON_ADDRESS = "0xD1E7877A1C3F782dec76FB58C2B926365433d46F" + CONTRACT_ADDRESSES = { '137': { 'erc20_prizetap_addr': "0xB521C36F76d28Edb287346C9D649Fa1A60754f04", diff --git a/prizetap/migrations/0033_alter_linearaffleentries_raffle.py b/prizetap/migrations/0033_alter_linearaffleentries_raffle.py new file mode 100644 index 00000000..7c9e12ca --- /dev/null +++ b/prizetap/migrations/0033_alter_linearaffleentries_raffle.py @@ -0,0 +1,19 @@ +# Generated by Django 4.0.4 on 2023-10-16 07:44 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('prizetap', '0032_linearaffleentries'), + ] + + operations = [ + migrations.AlterField( + model_name='linearaffleentries', + name='raffle', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='linea_entries', to='prizetap.raffle'), + ), + ] diff --git a/prizetap/migrations/0034_raffle_vrf_tx_hash_alter_raffle_status.py b/prizetap/migrations/0034_raffle_vrf_tx_hash_alter_raffle_status.py new file mode 100644 index 00000000..05d6c7cc --- /dev/null +++ b/prizetap/migrations/0034_raffle_vrf_tx_hash_alter_raffle_status.py @@ -0,0 +1,23 @@ +# Generated by Django 4.0.4 on 2023-10-16 08:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('prizetap', '0033_alter_linearaffleentries_raffle'), + ] + + operations = [ + migrations.AddField( + model_name='raffle', + name='vrf_tx_hash', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AlterField( + model_name='raffle', + name='status', + field=models.CharField(choices=[('PENDING', 'Pending'), ('REJECTED', 'Rejected'), ('VERIFIED', 'Verified'), ('CLOSED', 'Closed'), ('WS', 'Winner is set')], default='PENDING', max_length=10), + ), + ] diff --git a/prizetap/migrations/0035_alter_raffle_status.py b/prizetap/migrations/0035_alter_raffle_status.py new file mode 100644 index 00000000..78ca13b3 --- /dev/null +++ b/prizetap/migrations/0035_alter_raffle_status.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.4 on 2023-10-16 21:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('prizetap', '0034_raffle_vrf_tx_hash_alter_raffle_status'), + ] + + operations = [ + migrations.AlterField( + model_name='raffle', + name='status', + field=models.CharField(choices=[('PENDING', 'Pending'), ('REJECTED', 'Rejected'), ('VERIFIED', 'Verified'), ('HELD', 'Held'), ('CLOSED', 'Closed'), ('WS', 'Winner is set')], default='PENDING', max_length=10), + ), + ] diff --git a/prizetap/models.py b/prizetap/models.py index e41d780b..3082e0e4 100644 --- a/prizetap/models.py +++ b/prizetap/models.py @@ -26,6 +26,7 @@ class Status(models.TextChoices): REJECTED = "REJECTED", _("Rejected") VERIFIED = "VERIFIED", _("Verified") HELD = "HELD", _("Held") + CLOSED = "CLOSED", _("Closed") WINNER_SET = "WS", _("Winner is set") class Meta: @@ -71,6 +72,7 @@ class Meta: ) rejection_reason = models.TextField(null=True, blank=True) tx_hash = models.CharField(max_length=255, blank=True, null=True) + vrf_tx_hash = models.CharField(max_length=255, blank=True, null=True) is_active = models.BooleanField(default=True) @property @@ -172,7 +174,7 @@ def save(self, *args, **kwargs): class LineaRaffleEntries(models.Model): wallet_address = models.CharField(max_length=255) - raffle = models.ForeignKey(Raffle, on_delete=models.CASCADE, related_name="linear_entries") + raffle = models.ForeignKey(Raffle, on_delete=models.CASCADE, related_name="linea_entries") is_winner = models.BooleanField(blank=True, default=False) claim_tx = models.CharField(max_length=255, blank=True, null=True) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 09c9fc20..55b9bfba 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -1,8 +1,13 @@ +import requests from celery import shared_task from django.utils import timezone from core.helpers import memcache_lock -from .models import Raffle -from .utils import PrizetapContractClient +from .models import Raffle, Chain +from .utils import ( + PrizetapContractClient, + VRFClientContractClient, + LineaPrizetapContractClient +) @shared_task(bind=True) @@ -64,3 +69,125 @@ def set_the_winner_of_raffles(self): except Exception as e: print(e) pass + +@shared_task(bind=True) +def request_random_words_for_expired_linea_raffles(self): + + id = f"{self.name}-LOCK" + + with memcache_lock(id, self.app.oid) as acquired: + if not acquired: + print(f"Could not acquire process lock at {self.name}") + return + + raffles_queryset = ( + Raffle.objects + .filter(deadline__lt=timezone.now()) + .filter(chain__chain_id=59140) + .filter(status=Raffle.Status.PENDING) + .filter(vrf_tx_hash__isnull=True) + ) + if raffles_queryset.count() > 0: + for raffle in raffles_queryset: + if raffle.linea_entries.count() > 0: + print(f"Request a random number for the Linea raffle {raffle.name}") + request_random_words_for_linea_raffle(raffle) + +def request_random_words_for_linea_raffle(raffle: Raffle): + chain = Chain.objects.get(chain_id=80001) + vrf_client = VRFClientContractClient(chain) + raffle_client = LineaPrizetapContractClient(raffle) + winners_count = raffle_client.get_raffle_winners_count() + tx_hash = vrf_client.request_random_words(winners_count) + receipt = raffle_client.wait_for_transaction_receipt(tx_hash) + if receipt['status'] == 1: + raffle.vrf_tx_hash = tx_hash + raffle.save() + +@shared_task(bind=True) +def draw_expired_linea_raffles(self): + + id = f"{self.name}-LOCK" + + with memcache_lock(id, self.app.oid) as acquired: + if not acquired: + print(f"Could not acquire process lock at {self.name}") + return + + raffles_queryset = ( + Raffle.objects + .filter(deadline__lt=timezone.now()) + .filter(chain__chain_id=59140) + .filter(status=Raffle.Status.PENDING) + .filter(vrf_tx_hash__isnull=False) + ) + if raffles_queryset.count() > 0: + for raffle in raffles_queryset: + if raffle.linea_entries.count() > 0: + print(f"Drawing the Linea raffle {raffle.name}") + draw_linea_raffle(raffle) + + +def draw_linea_raffle(raffle: Raffle): + muon_response = requests.get( + f"https://shield.unitap.app/v1/?app=stage_unitap&method=random-words¶ms[chainId]={raffle.chain.chain_id}¶ms[prizetapRaffle]={raffle.contract}¶ms[raffleId]={raffle.raffleId}" + ) + muon_response = muon_response.json() + print(muon_response) + if muon_response['success']: + muon_response = muon_response['result'] + muon_data = muon_response['data']['result'] + raffle_client = LineaPrizetapContractClient(raffle) + tx_hash = raffle_client.draw_raffle( + muon_data['expirationTime'], + muon_data['randomWords'], + muon_response['reqId'], + ( + muon_response['signatures'][0]['signature'], + muon_response['signatures'][0]['owner'], + muon_data['init']['nonceAddress'] + ), + muon_response['shieldSignature'] + ) + receipt = raffle_client.wait_for_transaction_receipt( + tx_hash) + if receipt['status'] == 1: + raffle.status = Raffle.Status.CLOSED + raffle.save() + + +@shared_task(bind=True) +def set_the_winner_of_linea_raffles(self): + + id = f"{self.name}-LOCK" + + with memcache_lock(id, self.app.oid) as acquired: + if not acquired: + print(f"Could not acquire process lock at {self.name}") + return + + raffles_queryset = ( + Raffle.objects + .filter(deadline__lt=timezone.now()) + .filter(chain__chain_id=59140) + .filter(status=Raffle.Status.CLOSED) + ) + if raffles_queryset.count() > 0: + for raffle in raffles_queryset: + print(f"Setting the winners of Linea raffle {raffle.name}") + set_the_winners_of_linea_raffle(raffle) + + +def set_the_winners_of_linea_raffle(raffle: Raffle): + raffle_client = LineaPrizetapContractClient(raffle) + winner_addresses = raffle_client.get_raffle_winners() + for address in winner_addresses: + try: + winner_entry = raffle.linea_entries.filter(wallet_address=address).get() + winner_entry.is_winner = True + winner_entry.save() + except Exception as e: + print(e) + pass + raffle.status = Raffle.Status.WINNER_SET + raffle.save() \ No newline at end of file diff --git a/prizetap/utils.py b/prizetap/utils.py index 25d9bfca..e49cb0f3 100644 --- a/prizetap/utils.py +++ b/prizetap/utils.py @@ -3,7 +3,10 @@ from .constants import ( PRIZETAP_ERC20_ABI, PRIZETAP_ERC721_ABI, - UNITAP_PASS_ABI + UNITAP_PASS_ABI, + VRF_CLIENT_ABI, + VRF_CLIENT_POLYGON_ADDRESS, + LINEA_PRIZETAP_ABI ) @@ -15,14 +18,46 @@ def __init__(self, raffle) -> None: self.set_contract(self.raffle.contract, abi) self.set_account(self.raffle.chain.wallet.private_key) - def draw_raffle(self): - func = self.contract.functions.heldRaffle(self.raffle.raffleId) + def draw_raffle(self, expiration_time, random_words, reqId, muon_sig, gateway_sig): + func = self.contract.functions.drawRaffle( + self.raffle.raffleId, + expiration_time, + random_words, + reqId, + muon_sig, + gateway_sig + ) return self.contract_txn(func) def get_raffle_winner(self): func = self.contract.functions.raffles(self.raffle.raffleId) raffle = self.contract_call(func) return raffle[8] + +class LineaPrizetapContractClient(PrizetapContractClient): + def __init__(self, raffle) -> None: + super().__init__(raffle) + abi = LINEA_PRIZETAP_ABI + self.set_contract(self.raffle.contract, abi) + + def get_raffle_winners(self): + func = self.contract.functions.getWinners(self.raffle.raffleId) + return self.contract_call(func) + + def get_raffle_winners_count(self): + func = self.contract.functions.raffles(self.raffle.raffleId) + raffle = self.contract_call(func) + return raffle[6] + +class VRFClientContractClient(Web3Utils): + def __init__(self, chain) -> None: + super().__init__(chain.rpc_url_private, chain.poa) + self.set_contract(VRF_CLIENT_POLYGON_ADDRESS, VRF_CLIENT_ABI) + self.set_account(chain.wallet.private_key) + + def request_random_words(self, num_words): + func = self.contract.functions.requestRandomWords(num_words) + return self.contract_txn(func) class UnitapPassClient(Web3Utils): From cf799ccee06df8930da3bfc79de0c699865e3478 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Tue, 17 Oct 2023 00:16:50 +0200 Subject: [PATCH 09/21] change tmp.py --- lin.csv | 492 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tmp.py | 147 ++++++----------- 2 files changed, 544 insertions(+), 95 deletions(-) create mode 100644 lin.csv diff --git a/lin.csv b/lin.csv new file mode 100644 index 00000000..1bcfd94f --- /dev/null +++ b/lin.csv @@ -0,0 +1,492 @@ +1,0xc54e79ab3322216f84c47885786af7b5ebde353a,9,√ +2,0x933a0162cc104364b1f7544e50056c151d08b706,5,√ +3,0x480fdac187f65a80d2559f2bdf7f5db9b8e36d2a,4,√ +4,0x55a1438b4b666c4359909ac902c41be09c3b821a,6,√ +5,0xf9178e809CEFaF2b219787336650A31552e52d5f,6,√ +6,0xc65feeddccdda21a6b35d3590f16e89857e792c3,1,√ +7,0xd454ed303748bb5a433388f9508433ba5d507030,5,√ +8,0x51d648f5f66652097d793235ebd6e774f6a77af6,1,√ +9,0x82b97fe157c390fd334c1aaebc767113cafa2154,1,√ +10,0xe6c789b1fb47dbbdcdc5ba643d698f575c598178,2,√ +11,0xca024cc7c74d0de58c0def263fdc5c9cef45351e,5,√ +12,0x5725a458b319d73b8ec84c47de80620e7b191b0c,3,√ +13,0x0b5b6aeb1ed0a30813a366effde5771539b032ec,1,√ +14,0xa3a527d1a247d9c69f7ad2c9842cdf6989b7b75a,4,√ +15,0xb1abd733f367137667460eb821989beb77d60939,10,√ +16,0x6fb5bb4aedd3f7e9c6be2fc93f1b27b74993f194,3,√ +17,0xd5b224f44d6421058ab43af63add9af0eff9896e,10,√ +18,0x610fb99011cef57175aadcefda0086822e0d5e2d,4,√ +19,0x99cb34e4291e16bc625b14332d45edfb475abb60,1,√ +20,0xcd0d4cdb238eec15fcf4ff9d13d5a59051e507d7,5,√ +21,0x08a9b4221a84bb39faa7d6fe0f7664efec9511ac,6,√ +22,0x795a5a6ed365111a62b0d8db7125d8ff95ba0310,1,√ +23,0x9b19bb1fbe8978d8a2454cc3b812dbf1341e03b3,7,√ +24,0x8481764c17e00ca9efc68d3fd33028027561f96b,3,√ +25,0xd72ae62719c453a12401136f59d4ce69d2dcc0bb,4,√ +26,0x432c53218a11bed08d238cf84ff547ce4fe933ab,2,√ +27,0x821fa4e5fcb337ce72e02f9fcdfbd9bfafe5abb0,3,√ +28,0xe77ad9c5af60332d24e5531b51a6b7f61d0b8703,3,√ +29,0x08da5f03faf97f20b695673f5c1ffadebf1c6a82,3,√ +30,0x526f6be87e77f1ad9de00d138e6feae8a4b58f00,9,√ +31,0xd8f2d20ec356402f7ddda59b6e85dfd08733c43a,1,√ +32,0x9c7430afc305b1bde1e40875cc508de0824a0463,2,√ +33,0x1b7ebd42d4869cd7865e2f939add07854c5466c3,1,√ +34,0xfd7ec5aa742f32300bebcf44855275ba3d737c94,9,√ +35,0x2badda496553efb501c702128f1e109dbc37659c,3,√ +36,0x3587f95530ed2fc300dfd4006642722a718a179e,8,√ +37,0xb3389f3edacdfd48603f2f06895a2b2a8a96952f,4,√ +38,0x321C3619eFDBc801319A81930DB65b7A8DbC4c2e,3,√ +39,0x3228ff4efd0a4722621e433844ade296f6af6c75,2,√ +40,0xe442145711bf3c56452f0dcc730f3ad65ce230cc,9,√ +41,0x0d8106d2ba1173043d800185fba525763f364fd0,8,√ +42,0x7f719246437b7cd8470ef384cfd381397d60f374,8,√ +43,0x3246f672b3cd58c81e7af53b186f810595b30df1,9,√ +44,0xdb76028d7e75c696b0079c7bd49830b879aa4ae5,6,√ +45,0x9624ed3d583db65042d124338e1310776a528452,2,√ +46,0x4b6c5a6d7682cb28441352c65384d5904f75068b,8,√ +47,0xa231a5ae629a0f15e1c1eb3ffbf813589e206926,3,√ +48,0xf9dff5d16439b7a24419be1484abd50e2c60e620,3,√ +49,0xfb37feebfc1d441901f57e59a59e77b8e28906ae,1,√ +50,0x98d082408944eb222d8ba1ec356f125181eaabe5,6,√ +51,0x435143cc1ad24f23167ba06531f4669a375179a0,6,√ +52,0x9fed7df317a107861571cc782a4ddd704c5df160,1,√ +53,0x8cfd6d77e5d698025bb04dfc3e02a09e657ce615,2,√ +54,0xe1983f009f3717e2d8397b28378b695fb1672e9e,2,√ +55,0x7c23a81ed302f026b53d74c881088a04a6fe121e,2,√ +56,0x5414952ef2231e41fd4912f5121946a683749eee,2,√ +57,0xef5e7cd8e6ef8726904cfc24f3af5061f051d045,11,√ +58,0x76f34d1a4535241ec054b49d969bdb37f444eb38,2,√ +59,0x44a9f89a67f5fc14761d1bf43a387124dc1beba7,3,√ +60,0xae4779f1ccbe0a43d86738be7631f6c20583a359,2,√ +61,0x2599a97701c87f6d598c816ea786ed5413a5ff54,1,√ +62,0x2c35259b8b9de17b1a90101d130c7bec9a5a4d11,1,√ +63,0x42f36d45381e3f5d9443e872b6192aaf0db55b53,2,√ +64,0x6ad28cfb274d8061d0bf28e59fe9b5c4c7a17627,1,√ +65,0x857c26509ce7c28757ea562813f2ae3ad3aafbac,2,√ +66,0xf0b8bcd1921d37bf83d71ccee40d55a13b98f3c5,2,√ +67,0xadfc6ab71e54413c3cef23d118ec3d9a09022f54,3,√ +68,0x2e98abd5bcca35abe2d203dde8a8354c841c108b,1,√ +69,0x2138da688c9de36875d57083be16066784ef3e1b,2,√ +70,0x5eedfe452b64fef64ee42309815611b66be37c14,1,√ +71,0x8b29f9a03af3037f58fb09fd96a05f8d4531606f,1,√ +72,0x6b4a7550b6ca8e3f36ec8df17951de7634345678,1,√ +73,0x49cc048d0cd136d28d6ca929a6a55e45fb4ecf84,1,√ +74,0x097e0c384d04c4da75bbd72c2fc7f75484f899d2,4,√ +75,0x0865178eb2b06f96df651edaa251580612e9e166,2,√ +76,0x84123d32f75647d149d62fa043b1bdb86f8e62cc,1,√ +77,0xf0b92d25a6bd33064651a03cf859c8231aa38567,1,√ +78,0xdb8014c3fb0c3a65250bf1e79839250b975e8164,1,√ +79,0xc1f1bc2c47c7eb066013fe66b4b6c1c1b30b936a,1,√ +80,0x197008a1d3e26a97a19f46c121482969cef95b7d,1,√ +81,0x42d1e1778b2f7b600065f618cdb502e3d2cc162b,1,√ +82,0xe5959222c16a4344fc6ae47da612cc42fe94ccf5,2,√ +83,0x49a5492fdfe5acc966dd5f41310dfdfe8daa349c,1,√ +84,0x10546b8246ee5a4c292eaf3e4a218cc87c5af431,1,√ +85,0x86486335295f0df2e4f1c93fa3cc352c5ea2340a,1,√ +86,0x6f78715467183fca5173efd6c2e1fee8d2e1f248,1,√ +87,0x99c623e30ad1765bfa92e29445da9bcb6213ba6d,3,√ +88,0x4fc2b7aec73366c728c4bb41ab11277519add014,1,√ +89,0x7cb0f1f5ec42cbab659d176a20d5d99c87bf7f0d,1,√ +90,0x9bf5a9f13c35890bcbe71c60b0d2cefbcf30c653,1,√ +91,0xa63adcafb1a6a4229916fbee82d50095a3635f3f,1,√ +92,0x8889c9285d57a818c17ddf9525aa6c4a98ae53e2,1,√ +93,0xe4f6b9ae129e976578a595107edd580921820de6,1,√ +94,0xa70a251b011e421520247bce1ffcd622e696704b,1,√ +95,0x6d3fb03cc874155ea1844052efc2def432c84ca5,1,√ +96,0x4d11aaa69158595085d13d5e1a2b22c1d0d5f348,1,√ +97,0x44125f8934a24664937a0f62ff3b3680d5dc6417,1,√ +98,0xb3bfdca6815ebe466c071ba251bbc33d8b6f4350,1,√ +99,0xa8aaa9d10356a64239a0b18ea33337af15b1cf49,2,√ +100,0x4dea13f204d4908f794acc2564a725b23b9b9b86,1,√ +101,0xbd7af60770a461f4d4e848e63dc32e8c9450a3fc,1,√ +102,0xac94f5c17e4999a023e6e961130497c299e77148,1,√ +103,0x42b40c18fd55822c03d7966146f0305fdffec556,1,√ +104,0x5a641c6fd5a473395355816ebc757b067ccaabe5,2,√ +105,0x4b42391baa84d0d412c2c89ba78d05304a7d679b,3,√ +106,0x290d4d08a8bcdbb1e66f24eefae3e7a14e332f6d,4,√ +107,0x2121E20910814cF0182de1247ae690Bc76b30343,4,√ +108,0x8ce01cf638681e12affd10e2feb1e7e3c50b7509,2,√ +109,0x6b65cf52669c1d70f05ee4d2bbf3d5236ab54355,3,√ +110,0x7bda0cd1e189c13c5e0b3f304c8f328615abc397,4,√ +111,0xe0783bfc4206268946381cef85b74eac51597987,4,√ +112,0x8763cfe56b224fba5125ec2a1b2ccfde43c2af6b,4,√ +113,0xf613bdee12ebf8b204d21c4ab57793f0ad47c607,1,√ +114,0xb248140d89ee4a1feabdd28f2f3ef23e2bd4b469,1,√ +115,0x4c76f8890fe5158f510fd720067a693970441518,1,√ +116,0x16e3adf898d69724e1ed0769a6c556497f0046ad,2,√ +117,0x150751baca3b90354c8bcd056aa1d826f365c68c,1,√ +118,0x714816133d78372a8759a9e9cb6b75d2596f045e,1,√ +119,0x9f6e94e4fe7a0526b27552e7fe051db63886a441,5,√ +120,0x27ba37d658c9c1e7f3175d662fdb21f0ae347871,1,√ +121,0x84242d32386ae16ac01af6087acb2877f0b92278,1,√ +122,0xcEC723d63930BF094E6960a186eFa951A5eDE7E9,1,√ +123,0x8a0df28f173103e20de05093aa6e27829715c9db,1,√ +124,0xb6e5781c9505491cf593301c0e3fa5273dc69ec2,1,√ +125,0x8434e528c3e22eecd1df0a8bbd5ca2832d170a1f,5,√ +126,0x414af1e885e8c98f4a73c3fa694bfcc5ec29e5f5,1,√ +127,0x18e3258fbdb8895b145fc6e25b42d6402b734f1e,2,√ +128,0xe27d9e71a92eb928d033194987be22998b336068,4,√ +129,0x41bf30492bf4dcded6bc73641c7e1a14ce0a6ead,1,√ +130,0xb58f75cf1ced668cfdf7ce5001b54abf55f7053c,1,√ +131,0xbb4463a404e360f24a8facb12cda772b27f5ad9f,1,√ +132,0x3999699dBB4DB7b89f5F91DBCc4189B348a65453,3,√ +133,0x39bb1652551c0de130a97026ff39cd48964863e4,4,√ +134,0x41e683ae2f9f7293f0706bdb276e22abbbd167a9,4,√ +135,0x105886b69a309b3872df39997977151662e88572,4,√ +136,0x2bd9fe75a7d355359c9450b025ccd20abda8a3ad,3,√ +137,0x4b6f4fc90a5988a5793c20f6d7be8f0f984bbdbe,3,√ +138,0x8ba1f30aa7e5763baf157f2821776fc5bf78ae69,3,√ +139,0x1c03eff3d2a35df54f243eecfe491288df64af20,1,√ +140,0xe4d47beedb5e6f5de24619789634b85d0073cd14,3,√ +141,0x627b63da1391deac116397a09a6efc644375709e,4,√ +142,0x5b56c36848372fb8d260aa364fcdbe62ed924463,1,√ +143,0x69e8e23eb2e61bc8449e02ced7075186dafbcfc1,1,√ +144,0x99f8783d24f5a5ffb76ae8882228f038fb6c8460,1,√ +145,0xcb436c31cfbf853e142701f9638be0dbf9665b6f,5,√ +146,0xa315ba6bbe97d685208a5e5254a141d9760868e5,3,√ +147,0x62287e52b4facd95b024032665a23092a05ff8c6,3,√ +148,0xc1123a379399e2a07fba2b965ab42a8e7500dc77,1,√ +149,0x17938c048abd322a7931ffadc65b1170859e5e48,1,√ +150,0x916e5bdd46b956ae076756f767091df0b052deba,1,√ +151,0xd5543aa4d2489f90e0b41dd172cbc16b25ff62e2,1,√ +152,0xe718bdb66bfab462728ea47fbe8f93c92b480a06,1,√ +153,0x9c17fe923220d0aebfc779ce4d24b465e4080bf7,1,√ +154,0x344e0e699837a361eb3fb0e203f1bed2c42e1496,1,√ +155,0x1277d142847aa24421e77caa04e6169b7a7a669e,1,√ +156,0x491cf7629a2397eb738a120fb13fa44bdbdc0e44,1,√ +157,0x5638dafaa7839c558fcc1b630966c41369370e25,1,√ +158,0x9ec793ef913211fbe875dbd8ed3227d94d9d1e5d,1,√ +159,0x2dd43dc631109f1c22c837f2dade18c0b343dd8d,1,√ +160,0x7b86b43CC1E2d568398ceEd8fC74338Dc9F9d193,2,√ +161,0xd02e3550604e86c42d806f24af3968a55e37d18b,1,√ +162,0xdfe0646b483404c3c391cd37b1c6a50b194ecbbb,4,√ +163,0x10fdc636697403f7db3ad215e1433b116921a2f0,2,√ +164,0x30a3c45ef11a652304b0f40c9af148707a0eddbf,1,√ +165,0x7f9105f6d78d2496a9063b26f6e36fb27972cf2e,3,√ +166,0x69638ff61918420b0246ac418f6335a7cf86241d,1,√ +167,0x152FA38FfA947a7FE081A8a7D80d7Cc402b5BF9e,2,√ +168,0xa198b9ba9d019d1dccb5474a38d402dfdff0d306,1,√ +169,0xf3fe547d0369e29272f7b19fa08f7fd750956978,2,√ +170,0xd2b58d79e27c3db00ad11547043da2fb6840594d,1,√ +171,0xc0a5ead2345513253ff72da4c682887106592255,1,√ +172,0x9310a32f12a28f9f4fb54d60a41eb3bfbd86a16a,1,√ +173,0xd1a42fe4871f99b219859b812e7ebaa311149074,1,√ +174,0x03fcbb331a5ad59d3f700910805e464b544546e2,1,√ +175,0xeb40e3a6296cba7b7155e53a5f3ad3c2df2cbf79,8,√ +176,0xeb082e96ddef1ac34cd6558c6ee363f1727d3c27,1,√ +177,0x554461cbb2591a421be1a0e1cdd7824d1b94b5df,8,√ +178,0x9a1a9c42a9d87adb7b74ddd3a82e851ab322fef1,1,√ +179,0x1dcfb0db0d1a774da525f1200e2c549bf8a9dc70,2,√ +180,0x03aadaf335f64ed0bd690b0bd10fca5dafb98e52,1,√ +181,0xb9d2f66a518a3b1cba00a626f82a91c4991cba45,1,√ +182,0x0ef0866e92da4f8712aaf2b503c434cdf192f3f0,8,√ +183,0x76c644460410070f7293c1f83da81c1389a6efe6,1,√ +184,0xcea0378b24a1c7cea48d5df77d2900fb1898fb4e,2,√ +185,0xf3b6b0bd6d014e9b3a11e2ca7d185d034d20e05f,1,√ +186,0x77c7a5ba71e5ae050790943345120d565004a79e,1,√ +187,0x36e1fa6d72d3072776c211d2b34ce6f6834e08d3,1,√ +188,0x37838b2e65552c6e15fa8e3639163a50b1bcdde3,8,√ +189,0xc4cdbc2a3459f5971ca9967413f724bb88c8b268,8,√ +190,0xf64d0d344a25b8b2b566c32e0849d84db00a21ee,1,√ +191,0x130ff451e0b3c595e18877b6c8b97d60bce86001,6,√ +192,0x61add079a871b0a5fbff1e356f03c2fe35dbcb85,1,√ +193,0xf9ce4b2a782810d3cbf202a8b63fa7e07ffb1f9c,1,√ +194,0x83ead847cc4bdd3d479207ecfe0d276c2d26f06c,6,√ +195,0xf402a34a0ef0132a9cbe3c91a22f8ca1062c7a8c,1,√ +196,0xe80c3c5792d3752d9405ee360080febc856edf3f,1,√ +197,0x0a15B25fe9ecfA9ba98a9b07FaBC9594B184E5eD,1,√ +198,0x65e91f3cf0c8be36734a752c6a3d1733ca02a7fb,2,√ +199,0xffb8c9ec9951b1d22ae0676a8965de43412ceb7d,2,√ +200,0xd1875347f9061e5a17bd97ccbb5b9c5ad33daf18,5,√ +201,0xa971305b99ed4f6869f98135979206b8dc1f0eda,5,√ +202,0x8da135fefbfe1454dbcb1024acbaf9587c62992b,1,√ +203,0xb7025E51a5DCcA0cb1C03f66fE31F5dCFfd599aa,2,√ +204,0xD4D66ACc07318b5B20cb46e684CDC7f5F1C148B0,3,√ +205,0x6ec8d5bea08437d12813c5f7663da4df843a4eec,5,√ +206,0x3299c2ef65235927aec9c0a26a8d76387f7a0231,1,√ +207,0xbcab8a3b2ae7a3953d0995192d63cbb8c5c53f79,5,√ +208,0x9e0eb4505d0658f97c1f77e844cad5c8bc3a525d,5,√ +209,0x6911df6ce619b47a7d36a8d91b799076c08d82ef,1,√ +210,0xad2f020669fcbbdb44516f9f25c7185cb063a10b,1,√ +211,0x7cc596b05acb9a7a3088be3bf89fef5a91b4ca7a,1,√ +212,0x5e1583d7e1ebb0cb9d1b0b15a554ddebe2a80573,8,√ +213,0x1db7373b68b09a319ce16874860026ce9dba3845,1,√ +214,0xffc0eae95b6963549ce550ef7efd9c9493ffd4dd,6,√ +215,0x19c11b8efa985eca9665b9d56cdea7990677ed34,1,√ +216,0x1e2e9110082882898b7313c5462725e6311b025f,1,√ +217,0x02b0a1ed34e91e1e2b4322407f3260971748c747,1,√ +218,0x592f7e24a9d08467a75cb63a7ecb3076d986063f,1,√ +219,0xb46678b08c889e546f0ba3bb2fe54ab852f1195d,1,√ +220,0x4b131a3fd68e7087ce0b428c68f615287784e3d3,1,√ +221,0xc14addf3c940760d213bb5cfa668d6ab1a1ad7ca,1,√ +222,0x9c85edf33057ef557bac8ad51f5c137690f41c76,1,√ +223,0x3a6aa5a709998be75b72b6e8a5cab3877620cccc,7,√ +224,0x66eeeeb9da8867a765bb147bf3240fc7215d8f96,5,√ +225,0x90b29018b0f2798925aa50e5bcbdc490d6b14dc6,5,√ +226,0x88c98b3947a862e0686008ccdb0aa1d71033f0c0,1,√ +227,0x45a7b69a522c5ecff77ad3540b901af59af12f3d,2,√ +228,0x99ffc9ff211704c2b7f3fd10f0cefa956310dd9c,1,√ +229,0x8924ce3dbf4c8c45828f1c50b5eb60ec22d69b4c,1,√ +230,0xda0f4b7c7e77d34190a22ea2574d60fa0633e8c7,1,√ +231,0x85e0d9e73c12efe889750f44422a77b544d48d17,2,√ +232,0x08cb134613707ba5e0dc8e95bc4a469cf5aafe99,1,√ +233,0xb2df04f4536b99666e3968d14761bb890d002df3,1,√ +234,0x7decc05384062a182a00dcf049e553bc0ecb4630,4,√ +235,0x8e6db1ffbb82c1e148dcf8865e8f491816065dc3,1,√ +236,0xc86c44d09099d0bf9826693a8a274a50ad4870c2,3,√ +237,0x96e54d07b631a40c3cafac9dfbbd4c3b71f0ab2b,3,√ +238,0x68c81fdf2c21b333495408b83514f4006f6768c4,1,√ +239,0x5868435a55cb2d5f30eb0c1223a1cb9c351fc6e2,2,√ +240,0x4047045179a6838572a990ea00e38508f4843d51,2,√ +241,0x2C21DC4fe422fBAdd7DC1edA8AC4D10a8D9fFa2e,2,√ +242,0x97c7890c4a5598ac136adb5e13f8ee669ee7dc1b,1,√ +243,0x67db769b0036f53b5e7257fad3031fa0ee62da43,1,√ +244,0xe5b479c0315f6ebe7e61272caffe54210fdc7671,1,√ +245,0x31ea2730a76c7d480bba0267eb91d02a3087ea88,1,√ +246,0xe098f7f5f299c88385f8f0003a1232dff5d77ece,1,√ +247,0xa2a38893672a8eefe0626ea1b131fe8534d8c228,1,√ +248,0x6d57c4f7b0c902c37dc495f173c886d0b5ac9752,1,√ +249,0x989b1a61b4796151f51852efa1f128a02c5e3a32,2,√ +250,0x86d6c1cc9baf0e561be2e01f83a75beaf09be19b,1,√ +251,0x6f0d30ee2bc8d381eefc23d5149fc9eee268321b,1,√ +252,0x54f7783b7ce0939deb74ea704a8e5a0468862823,2,√ +253,0xf9506e0bd0d1f41e32b94dc2ba6918d85955641e,1,√ +254,0x6fc86f522c064722a138f91256fe96b8174ec82b,1,√ +255,0x76bbc5f8dfa8c07b7e35d5b533612df5c413c39c,2,√ +256,0x9333c471fb0abb0a189189933bfc0d1a4584c9f7,1,√ +257,0xe92bc099698687f7a32cd68577611b1beae5d401,1,√ +258,0x0f3f321e87799fe8f27439b52c8d7b6bdcf5feb6,1,√ +259,0x4c9679cec05499e40652b3a82a2fdfceff2b3635,1,√ +260,0x8f3cef0c996a6e13c33cf26e1c447faa7acdf8dd,1,√ +261,0xbcbd8834fbf90e9918f71141df222dd5ccaf9672,1,√ +262,0x490e63cc011b64d3ff4f9c15e44e26514c2ad275,1,√ +263,0x234d871cb302b94a72a5273ca337dc7972c33888,1,√ +264,0xeb03f5356bbf9db94a166137aa06689d8f80628b,1,√ +265,0x724aa571841dadbafbd5a2c34a7cf94e182be5ec,1,√ +266,0xb6bd1b9b3e6e3512bb354789289f6d8fbc0f65bc,1,√ +267,0x56d79fe635196e734ce29d7a8ccd8014865e790c,2,√ +268,0x0185c555216bbd14f138a92730682a8e9fbc9e00,1,√ +269,0x3090a8da23358422a98a0cc2ddeda51ebdeb27d0,2,√ +270,0x64efa181839274ddd6f330ed40059974089343eb,1,√ +271,0xb63689c89fc7f1089e02708b0483e71c56f7ce86,2,√ +272,0xf245acfab1c10978a3eb507d5a57f2b2b3ebb972,1,√ +273,0x8a40435c3e62a8cb15570fa4e5587471f6b1b9f4,2,√ +274,0x6640693e331ce34a21292bebddd60639b2b6e5ce,1,√ +275,0xa68176387a8a58814b780529df1d164d0904c9ec,1,√ +276,0x04400db7f33d5330f62c8dbd4840920adc273615,1,√ +277,0x9bbca2632dfcaa1962b18275086338fc8ac47da2,1,√ +278,0xa38bfd31532a1ce791c13bbb5b7b03725d11a5e6,1,√ +279,0xfca9895a7dd0545c3d648f7ef235e546053946ca,1,√ +280,0x2f7a85b46ea05ba250b0c4043493b5a57025f0a7,1,√ +281,0x7bfadf96d112918e10314f94f6c990f150f0e0b1,1,√ +282,0xe476c3a18fb117ecb16c986dcb09630bb3abe854,1,√ +283,0x465b1E44b9a346240Ebdd64101E93d8275EE4446,1,√ +284,0x5334aea575c8bccfea58e489d9117ebdfbcea64e,1,√ +285,0x91c2232f8eab20b21aa95c325aaf9aad639ff486,1,√ +286,0x6e61526b020096e1f2aed74fdaf0e66247b6ff49,1,√ +287,0xcf0fb4d249b8c2f17dd805ac2b6f28ffc3d0049c,1,√ +288,0xc6f5f0f619148317025ee9527384971b2e61b377,1,√ +289,0x903b473899b9868801f6b8b893aef02a01445e7b,1,√ +290,0xd6a5b356b4e25ca1064f7417f02ab671b21f443c,1,√ +291,0x488a14b1490313e966229dea4f106f6c60f74c66,1,√ +292,0xd364055a2b9df6ca96970cbd6827991d741ee66a,1,√ +293,0x7cdded391cef865b7f03905b0c29da129b308e4e,3,√ +294,0xe0a35b164f5c5e44e26d357e4ac88e1b8714090f,1,√ +295,0xe58ac6b0572166e5a3815f24e5a715c5587ada6c,1,√ +296,0x867e29c16a1b921676c0c201e1dce6626609cbf6,1,√ +297,0x5213d8675879791e542e1f10f5e400dc6ce94aae,1,√ +298,0x7a3a6fe2bde4ae601804bbf951912e51c82060c4,1,√ +299,0x29054af0bc244f8801a6f073c56aa7d926511efe,1,√ +300,0x522a8a49d5016ef63e269f48b42201a87761b96c,1,√ +301,0xc6d4a1faaefb4d2661f3d235995f1b78b46bf9de,1,√ +302,0x94F98fE46b3c96C77EAcF297E86c8d47e5442eE7,1,√ +303,0xf666b915c7073dd6642f3a3b8f77b029ceee19ee,1,√ +304,0x507551ae8f089d459322f4c7e67d1567b4fc9e12,1,√ +305,0xad33d7e203441180e5cf5b98b8de1c00e9cd07a8,1,√ +306,0x658191594cda88744d8158813029420dcf137a32,1,√ +307,0x1690a5a4830ec4d9dafca3769dadd7472abbd153,1,√ +308,0x6e795320564c979c67de09970519c45eebfa76fa,1,√ +309,0x460635d1edaf3d25b419e3c4aace5c296e4ec02f,1,√ +310,0x2208f3bd3c17e085c073b09376cbe98a7c402a83,1,√ +311,0xcf8eb16da771566c53ceab68de7f83ac296e25b6,1,√ +312,0x68e6d415646fbdd290aa3d36157082ac162118e1,1,√ +313,0x28b8fbcebdc3114dd7ce20eb0642015ea3a21718,1,√ +314,0xae7e2aa76f463ca04812906f9c8c3d870704bd8d,1,√ +315,0x72430cfc6cbead96b2ef218ce6791a394fb50bbe,1,√ +316,0x8d3ec18dc2c96dafcd0924afe7273892bf4c1652,1,√ +317,0x9c2decdbd8e27717012a4401f0eeebdaf5591e15,1,√ +318,0xddc78a3f6a609283e9fd74eecefb2cbfb0064548,1,√ +319,0xffab351a80cbf8c4f1d378d17d21d10670e2a1d7,2,√ +320,0xb2993f007d2abaecbb7c3529d78c5de0f1214888,1,√ +321,0xe758683cA38Eb92191B1d5218c91c23D736D30b9,1,√ +322,0x02e4cc9fff7566563618fb21b3bb10eab4b3d726,1,√ +323,0x3fbcec42405391b1fb377664daa5ae7bc9ba7bf5,1,√ +324,0x39cbf1e004edbd43920832e829e837735997cb03,1,√ +325,0x18921682e62eb36c6391be33bec86e9266a13ad5,1,√ +326,0xad6da122085704f07f2669f109a06aa685311107,1,√ +327,0x4c4361a6852231e891fd124c287f53aeb24f539d,1,√ +328,0xecb968a79ae396a681fc5633dc1e783b61b47ad8,1,√ +329,0x5cd1669ba7bb15ec06f22064c0c5423b1b7f6ba2,1,√ +330,0x939fbd2c0e92625ac070da8d159de77991b53036,1,√ +331,0x9bff95797b327b33de106563d3b70f209d650f9b,1,√ +332,0x04Ca76Cd80705829aC6d21D5Af780B6fED6aB2D2,1,√ +333,0x244cf975996fa8ea19cab33706d4e0aec97b2ad3,1,√ +334,0x1dcf3a9fb8e66983c021e33a9f6664f8179b8ca7,1,√ +335,0x233ed7e3201808f96c8fe909cbaa8466ae893352,1,√ +336,0x33a559b6ed251d9f5208bdbefb092b5068923c4d,1,√ +337,0x5e9744aea7f43ec462db8edda1817c0e97c79f38,2,√ +338,0xc05ed8f3adbc1007d9d8debc21a721aa951fad50,1,√ +339,0x45638c0561fdfea7bf7f498e960e63f340180376,1,√ +340,0xfb6e85d852ccb8dd4632ada0dfab13b0eb8d84fd,1,√ +341,0xcab1294b8712d5f3223e9738f9d7e1070b736af6,1,√ +342,0xc5a1b9bfb4eff5ba4b0bd9eab6c27c625997cf4c,1,√ +343,0xc9bf08f3bdb14644ef4a2b7d855d427d8e77514d,1,√ +344,0x3e516b6d229bf935f1b6bf4a0c2531ddab48cf1b,1,√ +345,0xbac79de245633fcc4fb32c19bc0ac93f406c9950,1,√ +346,0x700b8e6df0cb64249dfb73e7125097b503131dc1,1,√ +347,0x6cd27a36d36b86343bd9c562f48d9583ab6efa4b,1,√ +348,0x89d70e2da19ed3ccdd9317ac1bf4e08a5bdcc4bf,1,√ +349,0x7bfee9c4239d220335749601738be5906e324bc0,1,√ +350,0xec126f4c4261690ba958195925c232ca80e8a862,1,√ +351,0x0415c0066dd7962fdd02efc8bce921b18ea5dadd,1,√ +352,0xfdea1f79a25a1455ebf9709afc6e1f074d98c71f,1,√ +353,0x16021a584b2db7b99db5368ab66031961fa8cd13,2,√ +354,0x2710bf3d6a6418c1ef990bba818a62c4e1f3e4da,1,√ +355,0x776f013a773bec54bfd022b3c64870806697ceeb,1,√ +356,0x6898428535A3DeEB400B2278dE7412beC7f49Af9,1,√ +357,0x2c64a1d5d602e7fb6d21da6211dcecc6e17a0649,1,√ +358,0xdcb6e52c0802186de2505a98ffb3add79f6aa711,2,√ +359,0x246b51cfbcb4584e7036ce99fc2702de27a77b31,1,√ +360,0x1e023ab3e41dec18e418dd8d4ae94670e8a28406,1,√ +361,0x58321ff4351f35e6627b147f0ab3907f05c619b5,1,√ +362,0x588cb3bf5d29bb318bde3479b8b5748e761c84e3,1,√ +363,0xf6e5adf2ffeefdbc2d62e10dc3629b211f464ce6,1,√ +364,0x86808475137bb59824701fda29600fdd16cec55f,1,√ +365,0x30ec257db9e920d991b3fc1aba391ee31dc259d3,2,√ +366,0xa80d509e9e62cd2358c404ae08acb008e1493622,2,√ +367,0x79227ac2ee8a2855c0ef97cb736ec3d529e55658,1,√ +368,0x8309ea203ebf8a2dab5b550b9c612337be942cca,1,√ +369,0xca9a7197777194ca44e23de6d906daa666ed20a4,1,√ +370,0x72678034ceb50c11fb599f850ed3dfa55edc78bb,1,√ +371,0xe9ad3a680b4cd89f13484a22fd1823922d64eb1a,1,√ +372,0x2fa055d703552b62a3f81e85c03e2ef936dfdfce,1,√ +373,0xf6ac07f237313f3fc3a1a2b37e279e3ad1c76f4f,1,√ +374,0x82137c29c76e8483a010ee2334ab5c448b55cfda,1,√ +375,0x3c9f12fd8edee2a9054af33259362d14685b8666,1,√ +376,0x72fcb7a980c2ca19ce937ce5a1ea00f6bb7aae30,1,√ +377,0xc079171b5fc4f53233cdd4801b032d0860f4e406,1,√ +378,0x6710447707295209d4b3ce160c19f62b2472d06c,1,√ +379,0x4e36e298808813a0a4b6ae3a97a945e62912327e,1,√ +380,0xb7b9e3b018745252a2ad0717f5af3906ef442d01,1,√ +381,0x00435c7f34759ca0ed9285191f18b9fdf71c5d5e,1,√ +382,0x79de9c5898adf164ec1708aaa4246a54183ec094,1,√ +383,0xa7b11111e9720F4cb50F7Cf1b9fD9bd8Cea88740,1,√ +384,0xb0b9cbd9b3b10fbec20aaf819dfc29c9936089e4,1,√ +385,0x98ee5f130b19109e4670f3bdc38c48533b3f32b4,1,√ +386,0xa955d9922e77ebff1ce1aa53d161be96d598003b,2,√ +387,0x0c4f890a7b98486ded2b80510a2656a9ae778a1d,2,√ +388,0xe5e853f567a6c4824dd98c366aa9f9f0ca8365c6,2,√ +389,0x9a9bf95c4bbe82705151879fab44c29a3d126acf,1,√ +390,0xbc88d0d62565f097f53f3f20a9c498228cf9c55b,1,√ +391,0x76e31a629b238d9eab3d51292878dab5ee8934b4,1,√ +392,0xe8a9b606383c49cd5c44a14cc6104f51b9dbc656,1,√ +393,0xb81e22951441cd373cd4372e122b952ba13d3ca6,1,√ +394,0xe23f2a21e74d801e9c2548f94a643e4290eba8e3,1,√ +395,0x79561c854fcb4c0bdad72d679c965328c988fb08,1,√ +396,0xd5aaed284113441a776b83da03f04aca1be92a94,1,√ +397,0xdc9519240d06ad8779454d1080e1a6ec85cc51f2,1,√ +398,0x26b20c710982af2e1de4116a0e4613e4ab21662a,1,√ +399,0xeea49acf54f7e7b35d9a42927b0727702986665b,1,√ +400,0xc973d75f5ee3daa9faffb3243b71a4681978e9cb,1,√ +401,0x76506fe76f6ecb4741041394d25b3b1e61a7bf64,1,√ +402,0x382e7a1b49e4dc529f4898ab472a5fb17315dcee,1,√ +403,0x9724245fa0792210977eeffe35efbeb24ac0a776,1,√ +404,0xa6d1150ee0c99d3a3451b44f3a0127d74bd8ec4d,1,√ +405,0xff4fee58df0504671e1007f6504e261dda19e9b0,1,√ +406,0x02ee8d6841204e59ef40effc8a7c7a2fc43a1ef1,1,√ +407,0x873b19b372f0035bc4a9d2e90a68f71cb15bc00f,1,√ +408,0xb1596fc0b02d38b7f0eede49f13b22d0693fa2cb,1,√ +409,0x6b71ceee84e439c38f84a90efa2b65db21cddad8,1,√ +410,0x72ddda4d86a3f4d15dbc23089274131b8e867513,1,√ +411,0x55eeddc3971f4756a463c5a66ac79474bd0f9ba6,1,√ +412,0x1e8488567d670242844d1bb0937e9283cb564204,1,√ +413,0xef7fd42ba4e0255d42bdd3c8febb2d18c86c326f,1,√ +414,0x74d297a917bdc5b9827786231a06305dfcf7a25d,1,√ +415,0xf42b7a30cca2627b26e3167cff1d9282213c5a04,1,√ +416,0x030bf6f4a27570e82477eb8a52f33fc3a9011bf9,1,√ +417,0xfded82a1077ae64bc2c03f6551e9d4e9f492589e,1,√ +418,0x25369343846e3626ba2bfbc31073a65ea023b73a,1,√ +419,0x8e5b87e44f62f5e977911836216e5a0d866e4983,1,√ +420,0x3a56e263bee3fbce4f30daceb2e12fbbc84b0c7a,1,√ +421,0xba2ab615960ff39e4ad42394111f36e99891dc84,2,√ +422,0x88add5a1abe02b492a3b6e639863614cefc6374a,2,√ +423,0x58061eb855bca35978564ae9355cbefd7e4c0a74,1,√ +424,0x9d28dc122a0f84c0ee2d855a956c58ad6be0479e,1,√ +425,0xfac4c7b47ef570029a8ead7af45e763e52a4a2a3,1,√ +426,0xb85c3f7e9fdf09514a51a65d11f7005028c70780,1,√ +427,0x18c60a8e9a4149c5d8e9a7b60c78a81ffd72c1ff,1,√ +428,0x4cf53a1c57abc6ad011ff833bef33b37075d7fa7,1,√ +429,0x6b76ddf79484ec1f991b524a9c8f54b78ec80c62,1,√ +430,0x06d618e1b16e351ab6c99fa9c7991ac6753cd26c,1,√ +431,0xea5f533e7758e3d7d5730249462e308eb7e3d2e3,1,√ +432,0x8c1035f8116346856d9e8505832d69e80762994c,1,√ +433,0x1d6bbcee4c8ca1a5ba6af7d84e923e60bb3e1dbd,1,√ +434,0x180790192bcb702cde25715c79c01ac482f92e6d,1,√ +435,0x0a1a8a13fd2c3094b8f563b4944db4e18bfcf90c,1,√ +436,0x73068056a48903a1a271522b90afa419fae8d5f6,1,√ +437,0xc73ea81b3ef46c1e1f0d52713c6c9c40f16891ac,1,√ +438,0x13ade8d33ab7e066f54975d3c13a862becb07112,1,√ +439,0xe784d8f448f1d68e9fa18f25085f17500e9956f6,2,√ +440,0x8293370091efa2f56cc398b05d04eb6c5e35a541,2,√ +441,0xfba18bcea6d16a00b3ed43850482da21b895b81a,1,√ +442,0xd01a0c7992a7e48525e803dc978ead130bc2d8f7,1,√ +443,0xcc964f965160ee3217eb682646c29755f2bab5a2,1,√ +444,0x5bcf13cf8c2bcd82b13ad606c344a3737cc587f0,2,√ +445,0x885aa02959db62e9dc6a63329ee60510bb0aee58,1,√ +446,0x5f220af537876200e780692ae7db3bf87b3186f6,1,√ +447,0x493a91a299c7d0dfed26ed84bc2184c6016ed60f,2,√ +448,0xff9e8003458ccbe0f5d950f858b273b55d473a31,1,√ +449,0x5725e585cc133bf19f8b58d731826a2d442b1f87,1,√ +450,0xf2b9d00e6208ec1e27da00a7deba73bc105056aa,1,√ +451,0xf348d71730a16892ce864f5d72aa4470bf03e938,1,√ +452,0xb047f100961f80eee43fece53990bcbad313a2af,1,√ +453,0x2028dc49e366e94e3db1fb3f38f6ee83a6904cb5,1,√ +454,0x0f2044b68e6bd206c89d1a166e2447a3332e98b8,1,√ +455,0x98da9663906dfaf452b38567b3bd4234a946c026,1,√ +456,0xd5e23c650758a077cc96060718bbe631585c2c95,1,√ +457,0x9df39a21aa6580a6f265d994bd381fdee10071e3,1,√ +458,0xae4dc5cebd9608e9d663cc0c847dac9f847b92b2,1,√ +459,0x74ed728016046fea7e5e2d530a16007fb451db3c,1,√ +460,0xc7d64b978c9cfa6c02c44cc9af444f98e2797ec2,1,√ +461,0x3c800eb80dcc3bd8217f73771e92064016e16f9c,1,√ +462,0x0b817a4cc314f7a645dc0caa83653a33755442ac,2,√ +463,0xd57ea3f20e30dc54beb7bdb9c1c2532ed9c73915,1,√ +464,0x7ba1cbe79c811ee2ae33a9207240376f2ccaad9f,1,√ +465,0xda0a4a7b33d99fa767fba10035bb0a58ef6d5a1b,1,√ +466,0x98915d11a1fd3fe57c7c385013e987e8ca20ec6e,1,√ +467,0x0e7589922bc280169f2f755475212561a191027f,1,√ +468,0x99144a12d5400b8839cbce0bbbeeba139fcb7ee6,1,√ +469,0xfd14485d12333c41710a7988aabcac3af3501aef,1,√ +470,0x43f03c2e0e4f2512bcd4d8ad2a8d74308adb59a5,1,√ +471,0x3f9fdbfa44737edf9c1752ce4e747df83943e46f,1,√ +472,0xf5e36df4569e21c5d8d7f6fd1b6cc5674772c466,1,√ +473,0x50693e63a0abb825b1ba99564954d45b6e45a632,1,√ +474,0x13fc26809DB5fb84fCb45A3008B0C33F182B3C22,1,√ +475,0x39888cc1f82eab6daa53dd91e57a1439561ce1f8,1,√ +476,0x302d7dea9b11db0b66ce00ff77ab1b8533dc011d,1,√ +477,0x27013d4758f4cb3f6a9c2bbe4d8ca55d4c09dfa4,1,√ +478,0xe813eca6798d42c5da06aa4b6506f4569d990eae,2,√ +479,0x1e6b5ebdd97ad37644b0d8e11ad55c48e6c38b43,1,√ +480,0x00e855e13ccde7f02ccbbeaea75550b7156b505c,1,√ +481,0xdf4f68fef95c1327cc067156625007c304ec3110,1,√ +482,0x5ba2e191642376aca7119d38b7752067f1ff9de7,1,√ +483,0x35fc079276eaa9b80a834b03c35bc5535f77af55,1,√ +484,0xa3d684198b8ec7e5a5d6246407be3350a608986f,1,√ +485,0x6f454fa5c8c9dc56209f6f5d4c7df32c735c4946,1,√ +486,0xe083c1b3a66c56547064d16bc39413c17296c0f3,1,√ +487,0xbbc06ecd1741c88ccb6ba83e8a2699346a50cbf9,1,√ +488,0x16b658270ac50c0063940ed287c401b3df7ccf70,1,√ +489,0xa2dd202debab968ee2b76be79f13748d2c1d5975,1,√ +490,0x17a7394ea7c2bb18084746c1601c90b99998f7a9,1,√ +491,0x05a9b6d8df2088e825b2055d72f8f3243ae30417,1,√ +492,0xda60386f1862ab6ae91183229a206d936aa5b8e4,1,√ diff --git a/tmp.py b/tmp.py index c26b7a44..26ec2bee 100644 --- a/tmp.py +++ b/tmp.py @@ -1,95 +1,52 @@ -{ - "detail": "Signature Created Successfully", - "signature": { - "id": 1, - "token_distribution": OrderedDict( - [ - ("id", 2), - ("name", "Test Distribution"), - ("distributor", "Test distributor"), - ("distributor_url", "https://example.com/distributor"), - ("discord_url", "https://discord.com/example"), - ("twitter_url", "https://twitter.com/example"), - ("image_url", "https://example.com/image.png"), - ("token", "TEST"), - ("token_address", "0x83ff60e2f93f8edd0637ef669c69d5fb4f64ca8e"), - ("amount", 100), - ( - "chain", - OrderedDict( - [ - ("pk", 2), - ("chain_name", "Bitcoin"), - ("chain_id", "1010"), - ( - "fund_manager_address", - "0x5802f1035AbB8B191bc12Ce4668E3815e8B7Efa0", - ), - ("native_currency_name", "bitcoin"), - ("symbol", "BTC"), - ("decimals", 18), - ("explorer_url", "https://blockstream.info/testnet/"), - ("rpc_url", None), - ("logo_url", None), - ("modal_url", None), - ("gas_image_url", None), - ("max_claim_amount", 100), - ("is_testnet", False), - ( - "tokentap_contract_address", - "0xB67ec856346b22e4BDA2ab2B53d70D61a2014358", - ), - ("chain_type", "EVM"), - ( - "block_scan_address", - "https://blockstream.info/testnet/address/0x5802f1035AbB8B191bc12Ce4668E3815e8B7Efa0", - ), - ] - ), - ), - ( - "permissions", - [ - OrderedDict( - [ - ("id", 1), - ("name", "BrightID Meet Verification"), - ( - "description", - "Verify that you have met the distributor in person.", - ), - ("resourcetype", "BrightIDMeetVerification"), - ] - ), - OrderedDict( - [ - ("id", 5), - ("name", "Once In A Life Time Verification"), - ( - "description", - "Verify that you have not claimed from this distribution before.", - ), - ("resourcetype", "OnceInALifeTimeVerification"), - ] - ), - ], - ), - ("created_at", "2023-06-24T18:41:13.872011Z"), - ("deadline", "2023-07-01T18:41:13.871801Z"), - ("max_number_of_claims", 10), - ("notes", "Test Notes"), - ] - ), - "user_profile": 1, - "created_at": "2023-06-24T18:41:13.929304Z", - "payload": { - "user": "0xc1cbb2ab97260a8a7d4591045a9fb34ec14e87fb", - "token": "0x83ff60e2f93f8edd0637ef669c69d5fb4f64ca8e", - "amount": 100, - "nonce": 1937405620, - "signature": "0xc28ef6f1604c89c319b93b757eeaff211962231063ad17108dacd3416e701b326527fadec7da4bbe3d2ed324ef6b395e62be62d1d62fa7ebc1f56d4742a6e1ad1c", - }, - "status": "Pending", - "tx_hash": None, - }, -} +import csv +from prizetap.models import LineaRaffleEntries, Raffle + +# Initialize empty dictionary and lists +data_dict = {} +addresses = [] +chances = [] + +# Read the CSV file and fill the dictionary and lists +with open("lin.csv", "r") as csv_file: + csv_reader = csv.reader(csv_file) + + for row in csv_reader: + num = int(row[0]) + address = row[1] + chance = int(row[2]) + + data_dict[num] = {"address": address, "chance": chance} + addresses.append(address) + chances.append(chance) + + +# Split lists into chunks of size 100 +def split_list(input_list, chunk_size): + return [ + input_list[i : i + chunk_size] for i in range(0, len(input_list), chunk_size) + ] + + +addresses_chunks = split_list(addresses, 100) +chances_chunks = split_list(chances, 100) + +# Output +# print(data_dict) +print(addresses_chunks) +print(chances_chunks) +# print(LineaRaffleEntries.objects.all().count()) +print(len(data_dict)) + + +def add_entries(data_dict): + linea_raffle = Raffle.objects.get(name="Linea Gas Pass") + for i in data_dict: + LineaRaffleEntries.objects.create( + wallet_address=data_dict[i]["address"], + raffle=linea_raffle, + raffle_entry_id=i, + ) + + +# add_entries(data_dict) +print(LineaRaffleEntries.objects.all().count()) From 7ef475024380d79d3ef0d4ce8f8ec9acace2a0a2 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 01:50:01 +0330 Subject: [PATCH 10/21] celery increase period --- brightIDfaucet/celery.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brightIDfaucet/celery.py b/brightIDfaucet/celery.py index 64248d22..c6adff54 100644 --- a/brightIDfaucet/celery.py +++ b/brightIDfaucet/celery.py @@ -56,15 +56,15 @@ }, "request-random-words-for-linea-raffles": { "task": "prizetap.tasks.request_random_words_for_expired_linea_raffles", - "schedule": 60 + "schedule": 300 }, "draw-linea-raffles": { "task": "prizetap.tasks.draw_expired_linea_raffles", - "schedule": 60 + "schedule": 300 }, "set-linea-raffle-winners": { "task": "prizetap.tasks.set_the_winner_of_linea_raffles", - "schedule": 60 + "schedule": 300 } } From 549a1eb22712cff61ddcec8a63950b299c7b2b7f Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 01:57:07 +0330 Subject: [PATCH 11/21] celery periods update --- brightIDfaucet/celery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brightIDfaucet/celery.py b/brightIDfaucet/celery.py index c6adff54..729e1b0b 100644 --- a/brightIDfaucet/celery.py +++ b/brightIDfaucet/celery.py @@ -60,11 +60,11 @@ }, "draw-linea-raffles": { "task": "prizetap.tasks.draw_expired_linea_raffles", - "schedule": 300 + "schedule": 60 }, "set-linea-raffle-winners": { "task": "prizetap.tasks.set_the_winner_of_linea_raffles", - "schedule": 300 + "schedule": 60 } } From 6561f875d6a7eda804fa3ea800abf8310d0694a6 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:08:48 +0330 Subject: [PATCH 12/21] Refactor linea tasks --- prizetap/tasks.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 55b9bfba..a16cbc55 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -99,10 +99,8 @@ def request_random_words_for_linea_raffle(raffle: Raffle): raffle_client = LineaPrizetapContractClient(raffle) winners_count = raffle_client.get_raffle_winners_count() tx_hash = vrf_client.request_random_words(winners_count) - receipt = raffle_client.wait_for_transaction_receipt(tx_hash) - if receipt['status'] == 1: - raffle.vrf_tx_hash = tx_hash - raffle.save() + raffle.vrf_tx_hash = tx_hash + raffle.save() @shared_task(bind=True) def draw_expired_linea_raffles(self): @@ -149,11 +147,9 @@ def draw_linea_raffle(raffle: Raffle): ), muon_response['shieldSignature'] ) - receipt = raffle_client.wait_for_transaction_receipt( - tx_hash) - if receipt['status'] == 1: - raffle.status = Raffle.Status.CLOSED - raffle.save() + print(tx_hash) + raffle.status = Raffle.Status.CLOSED + raffle.save() @shared_task(bind=True) From b49bc5e86444c3e414140859ca05e2dd4dd09a96 Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Tue, 17 Oct 2023 00:40:02 +0200 Subject: [PATCH 13/21] change tmp.py --- tmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmp.py b/tmp.py index 26ec2bee..43d09790 100644 --- a/tmp.py +++ b/tmp.py @@ -48,5 +48,5 @@ def add_entries(data_dict): ) -# add_entries(data_dict) +add_entries(data_dict) print(LineaRaffleEntries.objects.all().count()) From 09f9450041f314fff4f5f273223790b47c0a9e3f Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Tue, 17 Oct 2023 00:50:45 +0200 Subject: [PATCH 14/21] change tmp.py --- tmp.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tmp.py b/tmp.py index 43d09790..bd49363e 100644 --- a/tmp.py +++ b/tmp.py @@ -44,7 +44,6 @@ def add_entries(data_dict): LineaRaffleEntries.objects.create( wallet_address=data_dict[i]["address"], raffle=linea_raffle, - raffle_entry_id=i, ) From 4dd8d3765ddd94eb8937ba9904e2a077e358c612 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:20:54 +0330 Subject: [PATCH 15/21] bugfix --- prizetap/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index a16cbc55..5863b3ec 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -143,7 +143,7 @@ def draw_linea_raffle(raffle: Raffle): ( muon_response['signatures'][0]['signature'], muon_response['signatures'][0]['owner'], - muon_data['init']['nonceAddress'] + muon_response['data']['init']['nonceAddress'] ), muon_response['shieldSignature'] ) From d9fe2cd14b2122a6145ed2a6e2556605a7c18365 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:28:16 +0330 Subject: [PATCH 16/21] bugfix --- prizetap/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 5863b3ec..933dd8d9 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -131,12 +131,12 @@ def draw_linea_raffle(raffle: Raffle): f"https://shield.unitap.app/v1/?app=stage_unitap&method=random-words¶ms[chainId]={raffle.chain.chain_id}¶ms[prizetapRaffle]={raffle.contract}¶ms[raffleId]={raffle.raffleId}" ) muon_response = muon_response.json() - print(muon_response) if muon_response['success']: muon_response = muon_response['result'] muon_data = muon_response['data']['result'] raffle_client = LineaPrizetapContractClient(raffle) tx_hash = raffle_client.draw_raffle( + raffle.raffleId, muon_data['expirationTime'], muon_data['randomWords'], muon_response['reqId'], From 9620566e71f29d83be6e31606d8e7fd182f71c89 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:45:46 +0330 Subject: [PATCH 17/21] bugfix --- prizetap/tasks.py | 5 ++--- prizetap/utils.py | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 933dd8d9..02b30e8b 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -136,15 +136,14 @@ def draw_linea_raffle(raffle: Raffle): muon_data = muon_response['data']['result'] raffle_client = LineaPrizetapContractClient(raffle) tx_hash = raffle_client.draw_raffle( - raffle.raffleId, muon_data['expirationTime'], muon_data['randomWords'], muon_response['reqId'], - ( + [ muon_response['signatures'][0]['signature'], muon_response['signatures'][0]['owner'], muon_response['data']['init']['nonceAddress'] - ), + ], muon_response['shieldSignature'] ) print(tx_hash) diff --git a/prizetap/utils.py b/prizetap/utils.py index e49cb0f3..ca0c7bb1 100644 --- a/prizetap/utils.py +++ b/prizetap/utils.py @@ -18,15 +18,8 @@ def __init__(self, raffle) -> None: self.set_contract(self.raffle.contract, abi) self.set_account(self.raffle.chain.wallet.private_key) - def draw_raffle(self, expiration_time, random_words, reqId, muon_sig, gateway_sig): - func = self.contract.functions.drawRaffle( - self.raffle.raffleId, - expiration_time, - random_words, - reqId, - muon_sig, - gateway_sig - ) + def draw_raffle(self): + func = self.contract.functions.heldRaffle(self.raffle.raffleId) return self.contract_txn(func) def get_raffle_winner(self): @@ -40,6 +33,17 @@ def __init__(self, raffle) -> None: abi = LINEA_PRIZETAP_ABI self.set_contract(self.raffle.contract, abi) + def draw_raffle(self, expiration_time, random_words, reqId, muon_sig, gateway_sig): + func = self.contract.functions.drawRaffle( + self.raffle.raffleId, + expiration_time, + random_words, + reqId, + muon_sig, + gateway_sig + ) + return self.contract_txn(func) + def get_raffle_winners(self): func = self.contract.functions.getWinners(self.raffle.raffleId) return self.contract_call(func) From 9ed1c5ef3a811bbce662330b7680703f3ebfcd19 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:46:42 +0330 Subject: [PATCH 18/21] Celery period update --- brightIDfaucet/celery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightIDfaucet/celery.py b/brightIDfaucet/celery.py index 729e1b0b..8e010675 100644 --- a/brightIDfaucet/celery.py +++ b/brightIDfaucet/celery.py @@ -56,7 +56,7 @@ }, "request-random-words-for-linea-raffles": { "task": "prizetap.tasks.request_random_words_for_expired_linea_raffles", - "schedule": 300 + "schedule": 150 }, "draw-linea-raffles": { "task": "prizetap.tasks.draw_expired_linea_raffles", From 8cb71a05bab14e2bc5b7c3ceaaf6a0ee036f203e Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 02:58:08 +0330 Subject: [PATCH 19/21] bugfix --- prizetap/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 02b30e8b..2deaf308 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -135,9 +135,10 @@ def draw_linea_raffle(raffle: Raffle): muon_response = muon_response['result'] muon_data = muon_response['data']['result'] raffle_client = LineaPrizetapContractClient(raffle) + random_words = [int(r) for r in muon_data['randomWords']] tx_hash = raffle_client.draw_raffle( - muon_data['expirationTime'], - muon_data['randomWords'], + int(muon_data['expirationTime']), + random_words, muon_response['reqId'], [ muon_response['signatures'][0]['signature'], From 4e2052f578b9a9d55d954d40efa95b5b7c1dd92b Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Tue, 17 Oct 2023 01:35:45 +0200 Subject: [PATCH 20/21] change tmp.py --- tmp2.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tmp2.py diff --git a/tmp2.py b/tmp2.py new file mode 100644 index 00000000..0be60460 --- /dev/null +++ b/tmp2.py @@ -0,0 +1,33 @@ +import csv +from prizetap.models import LineaRaffleEntries, Raffle +from prizetap.utils import LineaPrizetapContractClient + + +def get_winners(raffle): + raffle_client = LineaPrizetapContractClient(raffle) + winner_addresses = raffle_client.get_raffle_winners() + return winner_addresses + + +def set_winners(raffle, winner_addresses): + for entry in raffle.linea_entries: + if entry.wallet_address in winner_addresses: + entry.is_winner = True + entry.save() + + +def count_winners(raffle): + winners = 0 + for entry in raffle.linea_entries: + if entry.is_winner: + winners += 1 + print(winners) + + +linea_raffle = Raffle.objects.get(name="Linea Gas Pass") +count_winners(linea_raffle) +winners = get_winners(linea_raffle) +print("a", winners) +print("b", len(winners)) +set_winners(linea_raffle, winners) +count_winners("a", linea_raffle) From 8f887a12741b938cb91402885075564828b9b04f Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Tue, 17 Oct 2023 05:01:33 +0330 Subject: [PATCH 21/21] bugfix --- prizetap/tasks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 2deaf308..fcba9fcb 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -140,11 +140,11 @@ def draw_linea_raffle(raffle: Raffle): int(muon_data['expirationTime']), random_words, muon_response['reqId'], - [ - muon_response['signatures'][0]['signature'], - muon_response['signatures'][0]['owner'], - muon_response['data']['init']['nonceAddress'] - ], + { + "signature": muon_response['signatures'][0]['signature'], + "owner": muon_response['signatures'][0]['owner'], + "nonce": muon_response['data']['init']['nonceAddress'] + }, muon_response['shieldSignature'] ) print(tx_hash)