Skip to content

Commit

Permalink
Update mint count query logic for minters
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks committed Oct 31, 2024
1 parent e53b374 commit f832f27
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 15 deletions.
16 changes: 15 additions & 1 deletion contracts/minters/open-edition-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);
Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
17 changes: 15 additions & 2 deletions contracts/minters/open-edition-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,12 +1067,25 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let whitelist_mint_count =
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);

Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
whitelist_count: whitelist_mint_count,
whitelist_count: standard_wl_count + tiered_wl_count,
})
}

Expand Down
17 changes: 16 additions & 1 deletion contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);

Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
17 changes: 16 additions & 1 deletion contracts/minters/vending-minter-featured/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);

Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1295,9 +1295,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);
Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
16 changes: 15 additions & 1 deletion contracts/minters/vending-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,9 +1294,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);
Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
16 changes: 14 additions & 2 deletions contracts/minters/vending-minter-wl-flex-featured/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,12 +1224,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let whitelist_mint_count =
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);
Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
whitelist_count: whitelist_mint_count,
whitelist_count: standard_wl_count + tiered_wl_count,
})
}

Expand Down
18 changes: 16 additions & 2 deletions contracts/minters/vending-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,12 +1223,26 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let whitelist_mint_count =

let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);

Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
whitelist_count: whitelist_mint_count,
whitelist_count: standard_wl_count + tiered_wl_count,
})
}

Expand Down
16 changes: 15 additions & 1 deletion contracts/minters/vending-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,9 +1254,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
let addr = deps.api.addr_validate(&address)?;
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let standard_wl_count =
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_SS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0)
+ (WHITELIST_TS_MINTER_ADDRS
.key(&addr)
.may_load(deps.storage)?)
.unwrap_or(0);
Ok(MintCountResponse {
address: addr.to_string(),
count: mint_count,
count: mint_count + standard_wl_count + tiered_wl_count,
})
}

Expand Down
13 changes: 10 additions & 3 deletions test-suite/src/vending_minter/tests/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,21 @@ fn whitelist_mint_count_query() {
assert_eq!(res.count, 3);
assert_eq!(res.address, buyer.to_string());

// Mint fails
// Public Mint
let mint_msg = ExecuteMsg::Mint {};
let _res = router.execute_contract(
buyer.clone(),
minter_addr.clone(),
&mint_msg,
&coins(100_000_000, NATIVE_DENOM),
);
// Next Mint fails
let err = router
.execute_contract(
buyer.clone(),
minter_addr.clone(),
&mint_msg,
&coins(WHITELIST_AMOUNT, NATIVE_DENOM),
&coins(100_000_000, NATIVE_DENOM),
)
.unwrap_err();
assert_eq!(
Expand All @@ -346,7 +353,7 @@ fn whitelist_mint_count_query() {
},
)
.unwrap();
assert_eq!(res.count, 3);
assert_eq!(res.count, 4);
assert_eq!(res.address, buyer.to_string());
}

Expand Down

0 comments on commit f832f27

Please sign in to comment.