Skip to content

Commit

Permalink
separated minimum sold and is owner into two variables for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
joemonem committed Mar 14, 2024
1 parent 63955c0 commit 246edc1
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,14 @@ fn execute_end_sale(ctx: ExecuteContext, limit: Option<u32>) -> Result<Response,
let number_of_tokens_available = NUMBER_OF_TOKENS_AVAILABLE.load(deps.storage)?;
// In case the minimum sold tokens threshold is met, it has to be the owner who calls the function
let contract = ADOContract::default();
let minimum_and_owner = state.min_tokens_sold <= state.amount_sold
&& contract.is_contract_owner(deps.storage, info.sender.as_str())?;
let has_minimum_sold = state.min_tokens_sold <= state.amount_sold;
let is_owner = contract.is_contract_owner(deps.storage, info.sender.as_str())?;

ensure!(
// If all tokens have been sold the sale can be ended too.
state.expiration.is_expired(&env.block)
|| number_of_tokens_available.is_zero()
|| minimum_and_owner,
|| (has_minimum_sold && is_owner),
ContractError::SaleNotEnded {}
);
if state.amount_sold < state.min_tokens_sold {
Expand Down

0 comments on commit 246edc1

Please sign in to comment.