From 710f92e241a4072aa43c7e73aa45581f1d4135a9 Mon Sep 17 00:00:00 2001 From: Shayan Shiravani Date: Sun, 19 Nov 2023 14:16:53 +0330 Subject: [PATCH] bugfix --- prizetap/tasks.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/prizetap/tasks.py b/prizetap/tasks.py index 53bcbbfd..c7024ca1 100644 --- a/prizetap/tasks.py +++ b/prizetap/tasks.py @@ -161,10 +161,14 @@ def set_raffle_ids(self): print(f"Could not acquire process lock at {self.name}") return raffles_queryset = ( - Raffle.objects.filter(status=Raffle.Status.PENDING).filter(raffleId__isnull=True).order_by("id") + Raffle.objects.filter(status=Raffle.Status.PENDING) + .filter(raffleId__isnull=True) + .filter(tx_hash__isnull=False) + .order_by("id") ) if raffles_queryset.count() > 0: for raffle in raffles_queryset: + print(f"Setting the raffle {raffle.name} raffleId") contract_client = PrizetapContractClient(raffle) receipt = contract_client.get_transaction_receipt(raffle.tx_hash) @@ -176,44 +180,44 @@ def set_raffle_ids(self): is_valid = True if onchain_raffle["status"] != 0: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} status") + logging.error(f"Mismatch raffle {raffle.pk} status") if onchain_raffle["lastParticipantIndex"] != 0: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} lastParticipantIndex") + logging.error(f"Mismatch raffle {raffle.pk} lastParticipantIndex") if onchain_raffle["lastWinnerIndex"] != 0: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} lastWinnerIndex") + logging.error(f"Mismatch raffle {raffle.pk} lastWinnerIndex") if onchain_raffle["participantsCount"] != 0: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} participantsCount") + logging.error(f"Mismatch raffle {raffle.pk} participantsCount") if raffle.creator_address != onchain_raffle["initiator"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} initiator") + logging.error(f"Mismatch raffle {raffle.pk} initiator") if raffle.max_number_of_entries != onchain_raffle["maxParticipants"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} maxParticipants") + logging.error(f"Mismatch raffle {raffle.pk} maxParticipants") if raffle.max_multiplier != onchain_raffle["maxMultiplier"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} maxMultiplier") - if raffle.start_at != onchain_raffle["startTime"]: + logging.error(f"Mismatch raffle {raffle.pk} maxMultiplier") + if int(raffle.start_at.timestamp()) != onchain_raffle["startTime"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} startTime") - if raffle.deadline != onchain_raffle["endTime"]: + logging.error(f"Mismatch raffle {raffle.pk} startTime") + if int(raffle.deadline.timestamp()) != onchain_raffle["endTime"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} endTime") + logging.error(f"Mismatch raffle {raffle.pk} endTime") if raffle.winners_count != onchain_raffle["winnersCount"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} winnersCount") + logging.error(f"Mismatch raffle {raffle.pk} winnersCount") if raffle.is_prize_nft: if raffle.prize_asset != onchain_raffle["collection"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} collection") + logging.error(f"Mismatch raffle {raffle.pk} collection") else: if raffle.prize_amount != onchain_raffle["prizeAmount"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} prizeAmount") + logging.error(f"Mismatch raffle {raffle.pk} prizeAmount") if raffle.prize_asset != onchain_raffle["currency"]: is_valid = False - logging.error(f"Mismatch raffle {raffle.raffleId} currency") + logging.error(f"Mismatch raffle {raffle.pk} currency") if is_valid: raffle.save()