From 4e2052f578b9a9d55d954d40efa95b5b7c1dd92b Mon Sep 17 00:00:00 2001 From: Mohamad Bastin Date: Tue, 17 Oct 2023 01:35:45 +0200 Subject: [PATCH] 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)