From 23ca4c43414a33b0d8ea51dd831b559ef5d6ce05 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 29 Oct 2024 06:51:48 +0000 Subject: [PATCH] Allow payment reuse for application redeployment (#960) Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75) Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/960 Reviewed-by: ashwin Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- stack_orchestrator/deploy/webapp/util.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index dd3bfe96..5f670270 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -846,16 +846,19 @@ def confirm_payment(laconic: LaconicRegistryClient, record, payment_address, min ) return False - # Check if the payment was already used on a + # Check if the payment was already used on a deployment used = laconic.app_deployments( - {"deployer": payment_address, "payment": tx.hash}, all=True + {"deployer": record.attributes.deployer, "payment": tx.hash}, all=True ) if len(used): - logger.log(f"{record.id}: payment {tx.hash} already used on deployment {used}") - return False + # Check that payment was used for deployment of same application + app_record = laconic.get_record(record.attributes.application, require=True) + if app_record.id != used[0].attributes.application: + logger.log(f"{record.id}: payment {tx.hash} already used on a different application deployment {used}") + return False used = laconic.app_deployment_removals( - {"deployer": payment_address, "payment": tx.hash}, all=True + {"deployer": record.attributes.deployer, "payment": tx.hash}, all=True ) if len(used): logger.log(