Skip to content

Commit

Permalink
allow no-cost manual renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-c-child committed Sep 27, 2024
1 parent 481b02e commit d12eaba
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions contracts/marketplace/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d12eaba

Please sign in to comment.