From d12eabafa03fa800d57c68ccdec36d1a78255028 Mon Sep 17 00:00:00 2001 From: jason-c-child Date: Fri, 27 Sep 2024 12:34:33 -0800 Subject: [PATCH] allow no-cost manual renewal --- contracts/marketplace/src/execute.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/contracts/marketplace/src/execute.rs b/contracts/marketplace/src/execute.rs index d907f1c..009cfc8 100644 --- a/contracts/marketplace/src/execute.rs +++ b/contracts/marketplace/src/execute.rs @@ -548,22 +548,26 @@ pub fn execute_renew( &ask.token_id, name_minter_params.base_price.u128(), )?; + let mut final_price = renewal_price; + if let Some(_valid_bid) = _valid_bid { + let payment = may_pay(&info, NATIVE_DENOM)?; - let payment = may_pay(&info, NATIVE_DENOM)?; - - ask.renewal_fund += payment; - - ensure!( - ask.renewal_fund >= renewal_price, - ContractError::InsufficientRenewalFunds { - expected: coin(renewal_price.u128(), NATIVE_DENOM), - actual: coin(ask.renewal_fund.u128(), NATIVE_DENOM), - } - ); + ask.renewal_fund += payment; + + ensure!( + ask.renewal_fund >= renewal_price, + ContractError::InsufficientRenewalFunds { + expected: coin(renewal_price.u128(), NATIVE_DENOM), + actual: coin(ask.renewal_fund.u128(), NATIVE_DENOM), + } + ); + } else { + final_price = Uint128::zero(); + } let mut response = Response::new(); - response = renew_name(deps, &env, &sudo_params, ask, renewal_price, response)?; + response = renew_name(deps, &env, &sudo_params, ask, final_price, response)?; Ok(response) }