Skip to content

Commit

Permalink
Update Mint{} for oe-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 dedcf97 commit c22cb10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 12 additions & 5 deletions contracts/minters/open-edition-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,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 @@ -352,14 +353,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 start and end time (if not optional)
if is_public_mint && (env.block.time < config.extension.start_time) {
return Err(ContractError::BeforeMintStartTime {});
Expand All @@ -384,6 +386,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 @@ -408,9 +411,13 @@ fn is_public_mint(
deps.querier.query_wasm_smart(
whitelist,
&WhitelistQueryMsg::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/open-edition-minter-merkle-wl/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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 c22cb10

Please sign in to comment.