# Path: deploy/utils.py
# def check_succesful_tx(web3, txid, timeout=180) -> dict:
#     receipt = wait_for_transaction_receipt(web3, txid, timeout=timeout)
#     txinfo = web3.eth.getTransaction(txid)
#     return receipt, txinfo["gas"] != receipt["gasUsed"]
# 
# def get_expected_tokens(amount, token_multiplier, final_price):
#     return (token_multiplier * amount) // final_price
# 
# Path: tests/utils_logs.py
# class LogFilter:
#     def __init__(self,
#         web3,
#         abi,
#         address,
#         event_name,
#         from_block=0,
#         to_block='latest',
#         filters=None,
#         callback=None):
#         self.web3 = web3
#         self.event_name = event_name
# 
#         # Callback for every registered log
#         self.callback = callback
# 
#         filter_kwargs = {
#             'fromBlock': from_block,
#             'toBlock': to_block,
#             'address': address
#         }
# 
#         event_abi = [i for i in abi if i['type'] == 'event' and i['name'] == event_name]
#         if len(event_abi) == 0:
#             return None
# 
#         self.event_abi = event_abi[0]
#         assert self.event_abi
# 
#         filters = filters if filters else {}
#         self.filter = construct_event_filter_params(
#             self.event_abi,
#             argument_filters=filters,
#             **filter_kwargs)[1]
#         filter_params = input_filter_params_formatter(self.filter)
#         self.filter = web3.eth.filter(filter_params)
# 
#     def init(self, post_callback=None):
#         for log in self.get_logs():
#             log['event'] = self.event_name
#             self.callback(log)
#         if post_callback:
#             post_callback()
# 
#     def watch(self):
#         def log_callback(log):
#             log = self.set_log_data(log)
#             self.callback(log)
# 
#         self.filter.watch(log_callback)
# 
#     def stop(self):
#         if self.filter.running:
#             self.filter.stop_watching()
# 
#     def get_logs(self):
#         response = self.web3.eth.getFilterLogs(self.filter.filter_id)
#         logs = log_array_formatter(response)
#         formatted_logs = []
#         for log in [dict(log) for log in logs]:
#             formatted_logs.append(self.set_log_data(log))
#         return formatted_logs
# 
#     def set_log_data(self, log):
#         log = dict(log_array_formatter([log])[0])
#         log['args'] = get_event_data(self.event_abi, log)['args']
#         log['event'] = self.event_name
#         return log


from time import time
from web3.utils.compat import (
    Timeout,
)
from deploy.utils import (
    check_succesful_tx,
    get_expected_tokens
)
from tests.utils_logs import LogFilter
import logging
        if self.file:
            with open(self.file, 'a') as f:
                f.write('%s,%s,%s,%s,%s,%s\n' % (event['blockNumber'], address,
                                                 self.bidder_addresses[address],
                                                 sent_amount, expected_tokens, diff_tokens))
        else:
            log.info('Verified address %s, diff: %s, sent tokens: %s, expected tokens: %s,'
                     ' bid value: %s)' % (address, diff_tokens, sent_amount,
                                          expected_tokens, self.bidder_addresses[address]))

    def distribution_ended_checks(self):
        log.info('Waiting to make sure we get all ClaimedTokens events')

        with Timeout(300) as timeout:
            while not self.distribution_ended or len(self.addresses_claimed) != \
                    len(self.verified_claims):
                log.info('Distribution ended: %s', str(self.distribution_ended))
                log.info('Claimed %s, verified claims %s' % (len(self.addresses_claimed),
                                                             len(self.verified_claims)))
                timeout.sleep(50)

        assert len(self.addresses_claimed) == len(self.verified_claims)
        self.filter_claims.stop()
        self.filter_distributed.stop()

        log.info('DISTRIBUTION COMPLETE')
        if self.file:
            log.info('The following file has been created: %s', self.file)

    def handle_auction_logs(self, event_name, callback):

# Path: deploy/utils.py
# def check_succesful_tx(web3, txid, timeout=180) -> dict:
#     receipt = wait_for_transaction_receipt(web3, txid, timeout=timeout)
#     txinfo = web3.eth.getTransaction(txid)
#     return receipt, txinfo["gas"] != receipt["gasUsed"]
# 
# def get_expected_tokens(amount, token_multiplier, final_price):
#     return (token_multiplier * amount) // final_price
# 
# Path: tests/utils_logs.py
# class LogFilter:
#     def __init__(self,
#         web3,
#         abi,
#         address,
#         event_name,
#         from_block=0,
#         to_block='latest',
#         filters=None,
#         callback=None):
#         self.web3 = web3
#         self.event_name = event_name
# 
#         # Callback for every registered log
#         self.callback = callback
# 
#         filter_kwargs = {
#             'fromBlock': from_block,
#             'toBlock': to_block,
#             'address': address
#         }
# 
#         event_abi = [i for i in abi if i['type'] == 'event' and i['name'] == event_name]
#         if len(event_abi) == 0:
#             return None
# 
#         self.event_abi = event_abi[0]
#         assert self.event_abi
# 
#         filters = filters if filters else {}
#         self.filter = construct_event_filter_params(
#             self.event_abi,
#             argument_filters=filters,
#             **filter_kwargs)[1]
#         filter_params = input_filter_params_formatter(self.filter)
#         self.filter = web3.eth.filter(filter_params)
# 
#     def init(self, post_callback=None):
#         for log in self.get_logs():
#             log['event'] = self.event_name
#             self.callback(log)
#         if post_callback:
#             post_callback()
# 
#     def watch(self):
#         def log_callback(log):
#             log = self.set_log_data(log)
#             self.callback(log)
# 
#         self.filter.watch(log_callback)
# 
#     def stop(self):
#         if self.filter.running:
#             self.filter.stop_watching()
# 
#     def get_logs(self):
#         response = self.web3.eth.getFilterLogs(self.filter.filter_id)
#         logs = log_array_formatter(response)
#         formatted_logs = []
#         for log in [dict(log) for log in logs]:
#             formatted_logs.append(self.set_log_data(log))
#         return formatted_logs
# 
#     def set_log_data(self, log):
#         log = dict(log_array_formatter([log])[0])
#         log['args'] = get_event_data(self.event_abi, log)['args']
#         log['event'] = self.event_name
#         return log


# Path: distributor/distributor.py
from time import time
from web3.utils.compat import (
    Timeout,
)
from deploy.utils import (
    check_succesful_tx,
    get_expected_tokens
)
from tests.utils_logs import LogFilter
import logging

        if self.file:
            with open(self.file, 'a') as f:
                f.write('%s,%s,%s,%s,%s,%s\n' % (event['blockNumber'], address,
                                                 self.bidder_addresses[address],
                                                 sent_amount, expected_tokens, diff_tokens))
        else:
            log.info('Verified address %s, diff: %s, sent tokens: %s, expected tokens: %s,'
                     ' bid value: %s)' % (address, diff_tokens, sent_amount,
                                          expected_tokens, self.bidder_addresses[address]))

    def distribution_ended_checks(self):
        log.info('Waiting to make sure we get all ClaimedTokens events')

        with Timeout(300) as timeout:
            while not self.distribution_ended or len(self.addresses_claimed) != \
                    len(self.verified_claims):
                log.info('Distribution ended: %s', str(self.distribution_ended))
                log.info('Claimed %s, verified claims %s' % (len(self.addresses_claimed),
                                                             len(self.verified_claims)))
                timeout.sleep(50)

        assert len(self.addresses_claimed) == len(self.verified_claims)
        self.filter_claims.stop()
        self.filter_distributed.stop()

        log.info('DISTRIBUTION COMPLETE')
        if self.file:
            log.info('The following file has been created: %s', self.file)

    def handle_auction_logs(self, event_name, callback):

        return LogFilter(