Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayanShiravani committed Nov 19, 2023
1 parent d6a2319 commit 710f92e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions prizetap/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

0 comments on commit 710f92e

Please sign in to comment.