Handle requests with auction when deploying webapps from registry
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 35s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m6s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m53s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 6m52s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m26s
Smoke Test / Run basic test suite (pull_request) Successful in 3m59s

This commit is contained in:
Prathamesh Musale 2024-10-01 19:25:17 +05:30
parent 74edf16d14
commit 0694c31807

View File

@ -345,6 +345,12 @@ def dump_known_requests(filename, requests, status="SEEN"):
"my payment address are examined).", "my payment address are examined).",
is_flag=True, is_flag=True,
) )
@click.option(
"--auction-requests",
help="Handle requests with auction id set (skips payment confirmation).",
is_flag=True,
default=False,
)
@click.option( @click.option(
"--config-upload-dir", "--config-upload-dir",
help="The directory containing uploaded config.", help="The directory containing uploaded config.",
@ -385,6 +391,7 @@ def command( # noqa: C901
private_key_file, private_key_file,
private_key_passphrase, private_key_passphrase,
all_requests, all_requests,
auction_requests,
): ):
if request_id and discover: if request_id and discover:
print("Cannot specify both --request-id and --discover", file=sys.stderr) print("Cannot specify both --request-id and --discover", file=sys.stderr)
@ -579,21 +586,36 @@ def command( # noqa: C901
requests_to_execute = [] requests_to_execute = []
if min_required_payment: if min_required_payment:
for r in requests_to_check_for_payment: for r in requests_to_check_for_payment:
main_logger.log(f"{r.id}: Confirming payment...") if (not r.attributes.payment) and r.attributes.auction:
if confirm_payment( if not auction_requests:
laconic, main_logger.log(f"Skipping request {r.id}: not handling requests with auction.")
r, dump_known_requests(state_file, [r], status="SKIP")
payment_address, else:
min_required_payment, # Check if we are in auction winners
main_logger, auction_id = r.attributes.auction
): auction = laconic.get_auction(auction_id)
main_logger.log(f"{r.id}: Payment confirmed.") if not auction:
requests_to_execute.append(r) 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: else:
main_logger.log( main_logger.log(f"{r.id}: Confirming payment...")
f"Skipping request {r.id}: unable to verify payment." if confirm_payment(
) laconic,
dump_known_requests(state_file, [r], status="UNPAID") 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: else:
requests_to_execute = requests_to_check_for_payment requests_to_execute = requests_to_check_for_payment