# Path: deploy/utils.py
# def amount_format(web3, wei):
# def createWallet():
# def check_succesful_tx(web3, txid, timeout=180) -> dict:
#     def __init__(self,
#                  web3,
#                  abi,
#                  address,
#                  event_name,
#                  from_block=0,
#                  to_block='latest',
#                  filters=None,
#                  callback=None):
#     def get_logs(self):
#     def set_log_data(self, log):
#     def watch_logs(self, callback):
#         def log_callback(log):
#     def stop(self):
# def watch_logs(contract, event, callback, params={}):
# def print_logs(contract, event, name=''):
# def returnFundsToOwner(web3, owner, bidder):
# def sendFunds(web3, owner, bidder, max_bid):
# def assignFundsToBidders(web3, owner: str, bidders: list, distribution_limit: int=None):
# def set_connection_pool_size(web3, pool_connections, pool_size):
# def get_expected_tokens(amount, token_multiplier, final_price):
# class LogFilter:


import logging
import gevent
from deploy.utils import (
    check_succesful_tx,
    amount_format,
    passphrase,
    returnFundsToOwner,
    assignFundsToBidders
)
    from deploy.bidder import Bidder
            amount = auction.call().missingFundsToEndAuction()
            if(amount > 10):
                amount = amount // 7
            log.info('Bid > missing funds, trying with {0} WEI ({bidder})'
                     .format(amount, bidder=bidder))
    return amount


def deploy_bidders(bidder_addrs, web3, auction, kwargs):
    if auction.call().stage() != AUCTION_STARTED:
        log.warning('requested bidders deployment, but auction is not started yet')
        return
    bidder_objs = []
    for addr in bidder_addrs:
        bidder = Bidder(web3, auction, addr)
        bidder.max_bid_ceiling = kwargs['max_bid_ceiling']
        bidder.bid_interval = kwargs['bid_interval']
        bidder.max_bid_price = kwargs['max_bid_amount']
        bidder.min_bid_price = kwargs['min_bid_amount']
        bidder_objs.append(bidder)
    for i in range(0, kwargs['wei_bidders']):
        if i == 0:
            bidder_objs[i].max_bids = 1
        bidder_objs[i].max_bid_price = 1
        bidder_objs[i].min_bid_price = 1
    bidder_gevents = [gevent.spawn(b.run) for b in bidder_objs]
    gevent.joinall(bidder_gevents)


def claim_tokens(auction, bidder, web3):

# Path: deploy/utils.py
# def amount_format(web3, wei):
# def createWallet():
# def check_succesful_tx(web3, txid, timeout=180) -> dict:
#     def __init__(self,
#                  web3,
#                  abi,
#                  address,
#                  event_name,
#                  from_block=0,
#                  to_block='latest',
#                  filters=None,
#                  callback=None):
#     def get_logs(self):
#     def set_log_data(self, log):
#     def watch_logs(self, callback):
#         def log_callback(log):
#     def stop(self):
# def watch_logs(contract, event, callback, params={}):
# def print_logs(contract, event, name=''):
# def returnFundsToOwner(web3, owner, bidder):
# def sendFunds(web3, owner, bidder, max_bid):
# def assignFundsToBidders(web3, owner: str, bidders: list, distribution_limit: int=None):
# def set_connection_pool_size(web3, pool_connections, pool_size):
# def get_expected_tokens(amount, token_multiplier, final_price):
# class LogFilter:


# Path: deploy/simulation.py
import logging
import gevent
from deploy.utils import (
    check_succesful_tx,
    amount_format,
    passphrase,
    returnFundsToOwner,
    assignFundsToBidders
)
    from deploy.bidder import Bidder

            amount = auction.call().missingFundsToEndAuction()
            if(amount > 10):
                amount = amount // 7
            log.info('Bid > missing funds, trying with {0} WEI ({bidder})'
                     .format(amount, bidder=bidder))
    return amount


def deploy_bidders(bidder_addrs, web3, auction, kwargs):
    if auction.call().stage() != AUCTION_STARTED:
        log.warning('requested bidders deployment, but auction is not started yet')
        return
    bidder_objs = []
    for addr in bidder_addrs:
        bidder = Bidder(web3, auction, addr)
        bidder.max_bid_ceiling = kwargs['max_bid_ceiling']
        bidder.bid_interval = kwargs['bid_interval']
        bidder.max_bid_price = kwargs['max_bid_amount']
        bidder.min_bid_price = kwargs['min_bid_amount']
        bidder_objs.append(bidder)
    for i in range(0, kwargs['wei_bidders']):
        if i == 0:
            bidder_objs[i].max_bids = 1
        bidder_objs[i].max_bid_price = 1
        bidder_objs[i].min_bid_price = 1
    bidder_gevents = [gevent.spawn(b.run) for b in bidder_objs]
    gevent.joinall(bidder_gevents)


def claim_tokens(auction, bidder, web3):

    unlocked = web3.personal.unlockAccount(bidder, passphrase)