Skip to content

Commit f832f27

Browse files
committed
Update mint count query logic for minters
1 parent e53b374 commit f832f27

File tree

10 files changed

+147
-15
lines changed

10 files changed

+147
-15
lines changed

contracts/minters/open-edition-minter-merkle-wl/src/contract.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
10861086
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
10871087
let addr = deps.api.addr_validate(&address)?;
10881088
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1089+
let standard_wl_count =
1090+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1091+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1092+
.key(&addr)
1093+
.may_load(deps.storage)?)
1094+
.unwrap_or(0)
1095+
+ (WHITELIST_SS_MINTER_ADDRS
1096+
.key(&addr)
1097+
.may_load(deps.storage)?)
1098+
.unwrap_or(0)
1099+
+ (WHITELIST_TS_MINTER_ADDRS
1100+
.key(&addr)
1101+
.may_load(deps.storage)?)
1102+
.unwrap_or(0);
10891103
Ok(MintCountResponse {
10901104
address: addr.to_string(),
1091-
count: mint_count,
1105+
count: mint_count + standard_wl_count + tiered_wl_count,
10921106
})
10931107
}
10941108

contracts/minters/open-edition-minter-wl-flex/src/contract.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,12 +1067,25 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
10671067
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
10681068
let addr = deps.api.addr_validate(&address)?;
10691069
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1070-
let whitelist_mint_count =
1070+
let standard_wl_count =
10711071
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1072+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1073+
.key(&addr)
1074+
.may_load(deps.storage)?)
1075+
.unwrap_or(0)
1076+
+ (WHITELIST_SS_MINTER_ADDRS
1077+
.key(&addr)
1078+
.may_load(deps.storage)?)
1079+
.unwrap_or(0)
1080+
+ (WHITELIST_TS_MINTER_ADDRS
1081+
.key(&addr)
1082+
.may_load(deps.storage)?)
1083+
.unwrap_or(0);
1084+
10721085
Ok(MintCountResponse {
10731086
address: addr.to_string(),
10741087
count: mint_count,
1075-
whitelist_count: whitelist_mint_count,
1088+
whitelist_count: standard_wl_count + tiered_wl_count,
10761089
})
10771090
}
10781091

contracts/minters/open-edition-minter/src/contract.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
10571057
fn query_mint_count_per_address(deps: Deps, address: String) -> StdResult<MintCountResponse> {
10581058
let addr = deps.api.addr_validate(&address)?;
10591059
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1060+
let standard_wl_count =
1061+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1062+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1063+
.key(&addr)
1064+
.may_load(deps.storage)?)
1065+
.unwrap_or(0)
1066+
+ (WHITELIST_SS_MINTER_ADDRS
1067+
.key(&addr)
1068+
.may_load(deps.storage)?)
1069+
.unwrap_or(0)
1070+
+ (WHITELIST_TS_MINTER_ADDRS
1071+
.key(&addr)
1072+
.may_load(deps.storage)?)
1073+
.unwrap_or(0);
1074+
10601075
Ok(MintCountResponse {
10611076
address: addr.to_string(),
1062-
count: mint_count,
1077+
count: mint_count + standard_wl_count + tiered_wl_count,
10631078
})
10641079
}
10651080

contracts/minters/vending-minter-featured/src/contract.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,9 +1256,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12561256
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12571257
let addr = deps.api.addr_validate(&address)?;
12581258
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1259+
let standard_wl_count =
1260+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1261+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1262+
.key(&addr)
1263+
.may_load(deps.storage)?)
1264+
.unwrap_or(0)
1265+
+ (WHITELIST_SS_MINTER_ADDRS
1266+
.key(&addr)
1267+
.may_load(deps.storage)?)
1268+
.unwrap_or(0)
1269+
+ (WHITELIST_TS_MINTER_ADDRS
1270+
.key(&addr)
1271+
.may_load(deps.storage)?)
1272+
.unwrap_or(0);
1273+
12591274
Ok(MintCountResponse {
12601275
address: addr.to_string(),
1261-
count: mint_count,
1276+
count: mint_count + standard_wl_count + tiered_wl_count,
12621277
})
12631278
}
12641279

contracts/minters/vending-minter-merkle-wl-featured/src/contract.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,9 +1295,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12951295
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12961296
let addr = deps.api.addr_validate(&address)?;
12971297
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1298+
let standard_wl_count =
1299+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1300+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1301+
.key(&addr)
1302+
.may_load(deps.storage)?)
1303+
.unwrap_or(0)
1304+
+ (WHITELIST_SS_MINTER_ADDRS
1305+
.key(&addr)
1306+
.may_load(deps.storage)?)
1307+
.unwrap_or(0)
1308+
+ (WHITELIST_TS_MINTER_ADDRS
1309+
.key(&addr)
1310+
.may_load(deps.storage)?)
1311+
.unwrap_or(0);
12981312
Ok(MintCountResponse {
12991313
address: addr.to_string(),
1300-
count: mint_count,
1314+
count: mint_count + standard_wl_count + tiered_wl_count,
13011315
})
13021316
}
13031317

contracts/minters/vending-minter-merkle-wl/src/contract.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12941294
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12951295
let addr = deps.api.addr_validate(&address)?;
12961296
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1297+
let standard_wl_count =
1298+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1299+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1300+
.key(&addr)
1301+
.may_load(deps.storage)?)
1302+
.unwrap_or(0)
1303+
+ (WHITELIST_SS_MINTER_ADDRS
1304+
.key(&addr)
1305+
.may_load(deps.storage)?)
1306+
.unwrap_or(0)
1307+
+ (WHITELIST_TS_MINTER_ADDRS
1308+
.key(&addr)
1309+
.may_load(deps.storage)?)
1310+
.unwrap_or(0);
12971311
Ok(MintCountResponse {
12981312
address: addr.to_string(),
1299-
count: mint_count,
1313+
count: mint_count + standard_wl_count + tiered_wl_count,
13001314
})
13011315
}
13021316

contracts/minters/vending-minter-wl-flex-featured/src/contract.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,12 +1224,24 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12241224
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12251225
let addr = deps.api.addr_validate(&address)?;
12261226
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1227-
let whitelist_mint_count =
1227+
let standard_wl_count =
12281228
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1229+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1230+
.key(&addr)
1231+
.may_load(deps.storage)?)
1232+
.unwrap_or(0)
1233+
+ (WHITELIST_SS_MINTER_ADDRS
1234+
.key(&addr)
1235+
.may_load(deps.storage)?)
1236+
.unwrap_or(0)
1237+
+ (WHITELIST_TS_MINTER_ADDRS
1238+
.key(&addr)
1239+
.may_load(deps.storage)?)
1240+
.unwrap_or(0);
12291241
Ok(MintCountResponse {
12301242
address: addr.to_string(),
12311243
count: mint_count,
1232-
whitelist_count: whitelist_mint_count,
1244+
whitelist_count: standard_wl_count + tiered_wl_count,
12331245
})
12341246
}
12351247

contracts/minters/vending-minter-wl-flex/src/contract.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,12 +1223,26 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12231223
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12241224
let addr = deps.api.addr_validate(&address)?;
12251225
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1226-
let whitelist_mint_count =
1226+
1227+
let standard_wl_count =
12271228
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1229+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1230+
.key(&addr)
1231+
.may_load(deps.storage)?)
1232+
.unwrap_or(0)
1233+
+ (WHITELIST_SS_MINTER_ADDRS
1234+
.key(&addr)
1235+
.may_load(deps.storage)?)
1236+
.unwrap_or(0)
1237+
+ (WHITELIST_TS_MINTER_ADDRS
1238+
.key(&addr)
1239+
.may_load(deps.storage)?)
1240+
.unwrap_or(0);
1241+
12281242
Ok(MintCountResponse {
12291243
address: addr.to_string(),
12301244
count: mint_count,
1231-
whitelist_count: whitelist_mint_count,
1245+
whitelist_count: standard_wl_count + tiered_wl_count,
12321246
})
12331247
}
12341248

contracts/minters/vending-minter/src/contract.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,9 +1254,23 @@ pub fn query_status(deps: Deps) -> StdResult<StatusResponse> {
12541254
fn query_mint_count(deps: Deps, address: String) -> StdResult<MintCountResponse> {
12551255
let addr = deps.api.addr_validate(&address)?;
12561256
let mint_count = (MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1257+
let standard_wl_count =
1258+
(WHITELIST_MINTER_ADDRS.key(&addr).may_load(deps.storage)?).unwrap_or(0);
1259+
let tiered_wl_count = (WHITELIST_FS_MINTER_ADDRS
1260+
.key(&addr)
1261+
.may_load(deps.storage)?)
1262+
.unwrap_or(0)
1263+
+ (WHITELIST_SS_MINTER_ADDRS
1264+
.key(&addr)
1265+
.may_load(deps.storage)?)
1266+
.unwrap_or(0)
1267+
+ (WHITELIST_TS_MINTER_ADDRS
1268+
.key(&addr)
1269+
.may_load(deps.storage)?)
1270+
.unwrap_or(0);
12571271
Ok(MintCountResponse {
12581272
address: addr.to_string(),
1259-
count: mint_count,
1273+
count: mint_count + standard_wl_count + tiered_wl_count,
12601274
})
12611275
}
12621276

test-suite/src/vending_minter/tests/whitelist.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,21 @@ fn whitelist_mint_count_query() {
321321
assert_eq!(res.count, 3);
322322
assert_eq!(res.address, buyer.to_string());
323323

324-
// Mint fails
324+
// Public Mint
325325
let mint_msg = ExecuteMsg::Mint {};
326+
let _res = router.execute_contract(
327+
buyer.clone(),
328+
minter_addr.clone(),
329+
&mint_msg,
330+
&coins(100_000_000, NATIVE_DENOM),
331+
);
332+
// Next Mint fails
326333
let err = router
327334
.execute_contract(
328335
buyer.clone(),
329336
minter_addr.clone(),
330337
&mint_msg,
331-
&coins(WHITELIST_AMOUNT, NATIVE_DENOM),
338+
&coins(100_000_000, NATIVE_DENOM),
332339
)
333340
.unwrap_err();
334341
assert_eq!(
@@ -346,7 +353,7 @@ fn whitelist_mint_count_query() {
346353
},
347354
)
348355
.unwrap();
349-
assert_eq!(res.count, 3);
356+
assert_eq!(res.count, 4);
350357
assert_eq!(res.address, buyer.to_string());
351358
}
352359

0 commit comments

Comments
 (0)