Skip to content

Commit

Permalink
Update Mint{} for vending-minter-merkle-tree-wl
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks committed Sep 20, 2024
1 parent c22cb10 commit 835c76f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ pub fn execute(
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::Mint {
stage,
proof_hashes,
allocation,
} => execute_mint_sender(deps, env, info, proof_hashes, allocation),
} => execute_mint_sender(deps, env, info, stage, proof_hashes, allocation),
ExecuteMsg::Purge {} => execute_purge(deps, env, info),
ExecuteMsg::UpdateMintPrice { price } => execute_update_mint_price(deps, env, info, price),
ExecuteMsg::UpdateStartTime(time) => execute_update_start_time(deps, env, info, time),
Expand Down Expand Up @@ -498,14 +499,15 @@ pub fn execute_mint_sender(
deps: DepsMut,
env: Env,
info: MessageInfo,
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
let action = "mint_sender";

// If there is no active whitelist right now, check public mint
let is_public_mint = is_public_mint(deps.as_ref(), &info, proof_hashes, allocation)?;
let is_public_mint = is_public_mint(deps.as_ref(), &info, stage, proof_hashes, allocation)?;
// Check if after start_time
if is_public_mint && (env.block.time < config.extension.start_time) {
return Err(ContractError::BeforeMintStartTime {});
Expand All @@ -530,6 +532,7 @@ pub fn execute_mint_sender(
fn is_public_mint(
deps: Deps,
info: &MessageInfo,
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
) -> Result<bool, ContractError> {
Expand All @@ -554,9 +557,13 @@ fn is_public_mint(
deps.querier.query_wasm_smart(
whitelist,
&WhitelistMtreeQueryMsg::HasMember {
member: match allocation {
Some(allocation) => format!("{}{}", info.sender, allocation),
None => info.sender.to_string(),
member: match (stage, allocation) {
(None, Some(allocation)) => format!("{}{}", info.sender, allocation),
(Some(stage), None) => format!("{}{}", stage, info.sender),
(Some(stage), Some(allocation)) => {
format!("{}{}{}", stage, info.sender, allocation)
}
(None, None) => info.sender.to_string(),
},
proof_hashes: proof_hashes.unwrap(),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct InstantiateMsg {
#[cw_serde]
pub enum ExecuteMsg {
Mint {
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
},
Expand Down
17 changes: 12 additions & 5 deletions contracts/minters/vending-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ pub fn execute(
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::Mint {
stage,
proof_hashes,
allocation,
} => execute_mint_sender(deps, env, info, proof_hashes, allocation),
} => execute_mint_sender(deps, env, info, stage, proof_hashes, allocation),
ExecuteMsg::Purge {} => execute_purge(deps, env, info),
ExecuteMsg::UpdateMintPrice { price } => execute_update_mint_price(deps, env, info, price),
ExecuteMsg::UpdateStartTime(time) => execute_update_start_time(deps, env, info, time),
Expand Down Expand Up @@ -498,14 +499,15 @@ pub fn execute_mint_sender(
deps: DepsMut,
env: Env,
info: MessageInfo,
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
let action = "mint_sender";

// If there is no active whitelist right now, check public mint
let is_public_mint = is_public_mint(deps.as_ref(), &info, proof_hashes, allocation)?;
let is_public_mint = is_public_mint(deps.as_ref(), &info, stage, proof_hashes, allocation)?;
// Check if after start_time
if is_public_mint && (env.block.time < config.extension.start_time) {
return Err(ContractError::BeforeMintStartTime {});
Expand All @@ -530,6 +532,7 @@ pub fn execute_mint_sender(
fn is_public_mint(
deps: Deps,
info: &MessageInfo,
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
) -> Result<bool, ContractError> {
Expand All @@ -554,9 +557,13 @@ fn is_public_mint(
deps.querier.query_wasm_smart(
whitelist,
&WhitelistMtreeQueryMsg::HasMember {
member: match allocation {
Some(allocation) => format!("{}{}", info.sender, allocation),
None => info.sender.to_string(),
member: match (stage, allocation) {
(None, Some(allocation)) => format!("{}{}", info.sender, allocation),
(Some(stage), None) => format!("{}{}", stage, info.sender),
(Some(stage), Some(allocation)) => {
format!("{}{}{}", stage, info.sender, allocation)
}
(None, None) => info.sender.to_string(),
},
proof_hashes: proof_hashes.unwrap(),
},
Expand Down
1 change: 1 addition & 0 deletions contracts/minters/vending-minter-merkle-wl/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct InstantiateMsg {
#[cw_serde]
pub enum ExecuteMsg {
Mint {
stage: Option<u32>,
proof_hashes: Option<Vec<String>>,
allocation: Option<u32>,
},
Expand Down

0 comments on commit 835c76f

Please sign in to comment.