From c6e16fc3c38f5adcdeb0f432214dd706f6303c23 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 10 Nov 2024 16:08:02 +0300 Subject: [PATCH] Include mint price denom check in stage validation --- .../tiered-whitelist-flex/src/helpers.rs | 22 +++++++------------ .../src/helpers/utils.rs | 22 +++++++------------ .../tiered-whitelist/src/helpers.rs | 22 +++++++------------ 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/contracts/whitelists/tiered-whitelist-flex/src/helpers.rs b/contracts/whitelists/tiered-whitelist-flex/src/helpers.rs index afeacfb34..6495402f0 100644 --- a/contracts/whitelists/tiered-whitelist-flex/src/helpers.rs +++ b/contracts/whitelists/tiered-whitelist-flex/src/helpers.rs @@ -35,20 +35,14 @@ pub fn validate_stages(env: &Env, stages: &[Stage]) -> Result<(), ContractError> StdError::generic_err("Cannot have more than 3 stages") ); - // // Check mint price is valid - // if stages - // .iter() - // .any(|stage| stage.mint_price.amount.u128() < MIN_MINT_PRICE) - // { - // return Err(ContractError::InvalidUnitPrice( - // MIN_MINT_PRICE, - // stages - // .iter() - // .map(|s| s.mint_price.amount.u128()) - // .min() - // .unwrap(), - // )); - // } + // Check stages have matching mint price denoms + let mint_denom = stages[0].mint_price.denom.clone(); + ensure!( + stages + .iter() + .all(|stage| stage.mint_price.denom == mint_denom), + StdError::generic_err("All stages must have the same mint price denom") + ); ensure!( stages[0].start_time > env.block.time, diff --git a/contracts/whitelists/tiered-whitelist-merkletree/src/helpers/utils.rs b/contracts/whitelists/tiered-whitelist-merkletree/src/helpers/utils.rs index 6789bd70c..bc5fae524 100644 --- a/contracts/whitelists/tiered-whitelist-merkletree/src/helpers/utils.rs +++ b/contracts/whitelists/tiered-whitelist-merkletree/src/helpers/utils.rs @@ -59,20 +59,14 @@ pub fn validate_stages(env: &Env, stages: &[Stage]) -> Result<(), ContractError> }); } - // // Check mint price is valid - // if stages - // .iter() - // .any(|stage| stage.mint_price.amount.u128() < MIN_MINT_PRICE) - // { - // return Err(ContractError::InvalidUnitPrice( - // MIN_MINT_PRICE, - // stages - // .iter() - // .map(|s| s.mint_price.amount.u128()) - // .min() - // .unwrap(), - // )); - // } + // Check stages have matching mint price denoms + let mint_denom = stages[0].mint_price.denom.clone(); + ensure!( + stages + .iter() + .all(|stage| stage.mint_price.denom == mint_denom), + StdError::generic_err("All stages must have the same mint price denom") + ); ensure!( stages[0].start_time > env.block.time, diff --git a/contracts/whitelists/tiered-whitelist/src/helpers.rs b/contracts/whitelists/tiered-whitelist/src/helpers.rs index 641dd2a69..846d2fe04 100644 --- a/contracts/whitelists/tiered-whitelist/src/helpers.rs +++ b/contracts/whitelists/tiered-whitelist/src/helpers.rs @@ -51,20 +51,14 @@ pub fn validate_stages(env: &Env, stages: &[Stage]) -> Result<(), ContractError> }); } - // // Check mint price is valid - // if stages - // .iter() - // .any(|stage| stage.mint_price.amount.u128() < MIN_MINT_PRICE) - // { - // return Err(ContractError::InvalidUnitPrice( - // MIN_MINT_PRICE, - // stages - // .iter() - // .map(|s| s.mint_price.amount.u128()) - // .min() - // .unwrap(), - // )); - // } + // Check stages have matching mint price denoms + let mint_denom = stages[0].mint_price.denom.clone(); + ensure!( + stages + .iter() + .all(|stage| stage.mint_price.denom == mint_denom), + StdError::generic_err("All stages must have the same mint price denom") + ); ensure!( stages[0].start_time > env.block.time,