Skip to content

Commit

Permalink
Save mint lock state on collection creation (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
findolor authored Nov 22, 2022
1 parent 2af5817 commit 63f7456
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 8 additions & 9 deletions contracts/modules/mint/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ pub fn execute_create_collection(

COLLECTION_INFO.save(deps.storage, collection_id, &collection_info)?;

MINT_LOCKS.save(deps.storage, collection_id, &false)?;

let cw20_address = match fund_info.cw20_address {
Some(addr) => Some(deps.api.addr_validate(&addr)?),
None => None,
Expand Down Expand Up @@ -414,8 +416,8 @@ fn execute_mint(
collection_id: u32,
metadata_id: Option<u32>,
) -> Result<Response, ContractError> {
let mint_lock = MINT_LOCKS.may_load(deps.storage, collection_id)?;
if let Some(_mint_lock) = mint_lock {
let mint_lock = MINT_LOCKS.load(deps.storage, collection_id)?;
if mint_lock {
return Err(ContractError::LockedMint {});
}

Expand Down Expand Up @@ -713,8 +715,8 @@ fn execute_receive(
collection_id,
metadata_id,
} => {
let mint_lock = MINT_LOCKS.may_load(deps.storage, collection_id)?;
if let Some(_mint_lock) = mint_lock {
let mint_lock = MINT_LOCKS.load(deps.storage, collection_id)?;
if mint_lock {
return Err(ContractError::LockedMint {});
}

Expand Down Expand Up @@ -1002,11 +1004,8 @@ fn query_creators(deps: Deps) -> StdResult<ResponseWrapper<Vec<String>>> {
}

fn query_mint_lock(deps: Deps, collection_id: u32) -> StdResult<ResponseWrapper<bool>> {
let mint_lock = MINT_LOCKS.may_load(deps.storage, collection_id)?;
Ok(ResponseWrapper::new(
"mint_lock",
mint_lock.unwrap_or(false),
))
let mint_lock = MINT_LOCKS.load(deps.storage, collection_id)?;
Ok(ResponseWrapper::new("mint_lock", mint_lock))
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
5 changes: 0 additions & 5 deletions contracts/modules/mint/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ mod actions {
.query_wasm_smart(minter_addr.clone(), &msg)
.unwrap();
assert_eq!(response.data, true);

let msg = QueryMsg::MintLock { collection_id: 2 };
let response: ResponseWrapper<bool> =
app.wrap().query_wasm_smart(minter_addr, &msg).unwrap();
assert_eq!(response.data, false);
}
}

Expand Down

0 comments on commit 63f7456

Please sign in to comment.