diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 3e69280a..6fe27240 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -345,6 +345,12 @@ def dump_known_requests(filename, requests, status="SEEN"): "my payment address are examined).", is_flag=True, ) +@click.option( + "--auction-requests", + help="Handle requests with auction id set (skips payment confirmation).", + is_flag=True, + default=False, +) @click.option( "--config-upload-dir", help="The directory containing uploaded config.", @@ -385,6 +391,7 @@ def command( # noqa: C901 private_key_file, private_key_passphrase, all_requests, + auction_requests, ): if request_id and discover: print("Cannot specify both --request-id and --discover", file=sys.stderr) @@ -579,21 +586,36 @@ def command( # noqa: C901 requests_to_execute = [] if min_required_payment: for r in requests_to_check_for_payment: - main_logger.log(f"{r.id}: Confirming payment...") - if confirm_payment( - laconic, - r, - payment_address, - min_required_payment, - main_logger, - ): - main_logger.log(f"{r.id}: Payment confirmed.") - requests_to_execute.append(r) + if (not r.attributes.payment) and r.attributes.auction: + if not auction_requests: + main_logger.log(f"Skipping request {r.id}: not handling requests with auction.") + dump_known_requests(state_file, [r], status="SKIP") + else: + # Check if we are in auction winners + auction_id = r.attributes.auction + auction = laconic.get_auction(auction_id) + if not auction: + raise Exception(f"Unable to locate auction: {auction_id}") + + if payment_address in auction.winnerAddresses: + main_logger.log(f"{r.id}: Auction winnner address confirmed.") + requests_to_execute.append(r) else: - main_logger.log( - f"Skipping request {r.id}: unable to verify payment." - ) - dump_known_requests(state_file, [r], status="UNPAID") + main_logger.log(f"{r.id}: Confirming payment...") + if confirm_payment( + laconic, + r, + payment_address, + min_required_payment, + main_logger, + ): + main_logger.log(f"{r.id}: Payment confirmed.") + requests_to_execute.append(r) + else: + main_logger.log( + f"Skipping request {r.id}: unable to verify payment." + ) + dump_known_requests(state_file, [r], status="UNPAID") else: requests_to_execute = requests_to_check_for_payment