From 52ab3f9acd31f06b416549607662a8bbd33e3b09 Mon Sep 17 00:00:00 2001 From: John Y Date: Mon, 7 Mar 2022 10:34:31 -0500 Subject: [PATCH 01/12] clean up funds in tests --- contracts/minter/src/contract_tests.rs | 62 +++++--------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/contracts/minter/src/contract_tests.rs b/contracts/minter/src/contract_tests.rs index 49b10d1fd..a471297f4 100644 --- a/contracts/minter/src/contract_tests.rs +++ b/contracts/minter/src/contract_tests.rs @@ -545,21 +545,11 @@ fn mint_count_query() { setup_block_time(&mut router, GENESIS_MINT_START_TIME - 1000); let wl_msg = WhitelistExecuteMsg::UpdateEndTime(EXPIRATION_TIME); - let res = router.execute_contract( - creator.clone(), - whitelist_addr.clone(), - &wl_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); assert!(res.is_ok()); let wl_msg = WhitelistExecuteMsg::UpdateStartTime(Timestamp::from_nanos(0)); - let res = router.execute_contract( - creator.clone(), - whitelist_addr.clone(), - &wl_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); assert!(res.is_ok()); // Set whitelist in minter contract @@ -570,7 +560,7 @@ fn mint_count_query() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), + &vec![], ); assert!(res.is_ok()); @@ -582,7 +572,7 @@ fn mint_count_query() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), + &vec![], ); assert!(res.is_ok()); @@ -591,12 +581,7 @@ fn mint_count_query() { to_add: vec![buyer.to_string()], }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract( - creator.clone(), - whitelist_addr, - &wasm_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &vec![]); assert!(res.is_ok()); setup_block_time(&mut router, GENESIS_MINT_START_TIME); @@ -770,31 +755,16 @@ fn whitelist_access_len_add_remove_expiration() { // Update whitelist_expiration fails if not admin let wl_msg = WhitelistExecuteMsg::UpdateEndTime(AFTER_GENESIS_TIME); router - .execute_contract( - buyer.clone(), - whitelist_addr.clone(), - &wl_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ) + .execute_contract(buyer.clone(), whitelist_addr.clone(), &wl_msg, &vec![]) .unwrap_err(); // Update whitelist_expiration succeeds when from admin let wl_msg = WhitelistExecuteMsg::UpdateEndTime(AFTER_GENESIS_TIME); - let res = router.execute_contract( - creator.clone(), - whitelist_addr.clone(), - &wl_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); assert!(res.is_ok()); let wl_msg = WhitelistExecuteMsg::UpdateStartTime(Timestamp::from_nanos(0)); - let res = router.execute_contract( - creator.clone(), - whitelist_addr.clone(), - &wl_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); assert!(res.is_ok()); // Set whitelist in minter contract @@ -805,7 +775,7 @@ fn whitelist_access_len_add_remove_expiration() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), + &vec![], ); assert!(res.is_ok()); @@ -824,12 +794,7 @@ fn whitelist_access_len_add_remove_expiration() { to_add: vec![buyer.to_string()], }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract( - creator.clone(), - whitelist_addr.clone(), - &wasm_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wasm_msg, &vec![]); assert!(res.is_ok()); // Mint fails, not whitelist price @@ -919,12 +884,7 @@ fn whitelist_access_len_add_remove_expiration() { // Remove buyer from whitelist let inner_msg = AddMembersMsg { to_add: vec![] }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract( - creator.clone(), - whitelist_addr, - &wasm_msg, - &coins(UNIT_PRICE, NATIVE_DENOM), - ); + let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &vec![]); assert!(res.is_ok()); // Mint fails From 0d410bef0dadc9a0fd1d062f7d6a33cd09727087 Mon Sep 17 00:00:00 2001 From: John Y Date: Mon, 7 Mar 2022 10:37:45 -0500 Subject: [PATCH 02/12] upgrade fee tests --- contracts/whitelist/src/contract.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/contracts/whitelist/src/contract.rs b/contracts/whitelist/src/contract.rs index cd49b228d..b1cad1291 100644 --- a/contracts/whitelist/src/contract.rs +++ b/contracts/whitelist/src/contract.rs @@ -756,13 +756,31 @@ mod tests { let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err.to_string(), "IncorrectCreationFee 1 < 0"); + // 0 upgrade fee + let msg = ExecuteMsg::IncreaseMemberLimit(1502); + let info = mock_info(ADMIN, &[coin(0, "ustars")]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()); + + // 0 upgrade fee + let msg = ExecuteMsg::IncreaseMemberLimit(2000); + let info = mock_info(ADMIN, &[coin(0, "ustars")]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()); + + // needs upgrade fee + let msg = ExecuteMsg::IncreaseMemberLimit(4002); + let info = mock_info(ADMIN, &[coin(300_000_000, "ustars")]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()); + // over MAX_MEMBERS, Invalid member limit let msg = ExecuteMsg::IncreaseMemberLimit(6000); let info = mock_info(ADMIN, &[coin(400_000_000, "ustars")]); let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!( err.to_string(), - "Invalid member limit. min: 1002, max: 5000, got: 6000" + "Invalid member limit. min: 4002, max: 5000, got: 6000" ); } } From a4f422007ddb7c6368ab8955c8c541cf82fd48ed Mon Sep 17 00:00:00 2001 From: John Y Date: Mon, 7 Mar 2022 10:45:03 -0500 Subject: [PATCH 03/12] fix linter --- contracts/minter/src/contract_tests.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/contracts/minter/src/contract_tests.rs b/contracts/minter/src/contract_tests.rs index a471297f4..d1405e41c 100644 --- a/contracts/minter/src/contract_tests.rs +++ b/contracts/minter/src/contract_tests.rs @@ -545,11 +545,11 @@ fn mint_count_query() { setup_block_time(&mut router, GENESIS_MINT_START_TIME - 1000); let wl_msg = WhitelistExecuteMsg::UpdateEndTime(EXPIRATION_TIME); - let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &[]); assert!(res.is_ok()); let wl_msg = WhitelistExecuteMsg::UpdateStartTime(Timestamp::from_nanos(0)); - let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &[]); assert!(res.is_ok()); // Set whitelist in minter contract @@ -560,7 +560,7 @@ fn mint_count_query() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &vec![], + &[], ); assert!(res.is_ok()); @@ -572,7 +572,7 @@ fn mint_count_query() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &vec![], + &[], ); assert!(res.is_ok()); @@ -581,7 +581,7 @@ fn mint_count_query() { to_add: vec![buyer.to_string()], }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &[]); assert!(res.is_ok()); setup_block_time(&mut router, GENESIS_MINT_START_TIME); @@ -755,16 +755,16 @@ fn whitelist_access_len_add_remove_expiration() { // Update whitelist_expiration fails if not admin let wl_msg = WhitelistExecuteMsg::UpdateEndTime(AFTER_GENESIS_TIME); router - .execute_contract(buyer.clone(), whitelist_addr.clone(), &wl_msg, &vec![]) + .execute_contract(buyer.clone(), whitelist_addr.clone(), &wl_msg, &[]) .unwrap_err(); // Update whitelist_expiration succeeds when from admin let wl_msg = WhitelistExecuteMsg::UpdateEndTime(AFTER_GENESIS_TIME); - let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &[]); assert!(res.is_ok()); let wl_msg = WhitelistExecuteMsg::UpdateStartTime(Timestamp::from_nanos(0)); - let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wl_msg, &[]); assert!(res.is_ok()); // Set whitelist in minter contract @@ -775,7 +775,7 @@ fn whitelist_access_len_add_remove_expiration() { creator.clone(), minter_addr.clone(), &set_whitelist_msg, - &vec![], + &[], ); assert!(res.is_ok()); @@ -794,7 +794,7 @@ fn whitelist_access_len_add_remove_expiration() { to_add: vec![buyer.to_string()], }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wasm_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr.clone(), &wasm_msg, &[]); assert!(res.is_ok()); // Mint fails, not whitelist price @@ -884,7 +884,7 @@ fn whitelist_access_len_add_remove_expiration() { // Remove buyer from whitelist let inner_msg = AddMembersMsg { to_add: vec![] }; let wasm_msg = WhitelistExecuteMsg::AddMembers(inner_msg); - let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &vec![]); + let res = router.execute_contract(creator.clone(), whitelist_addr, &wasm_msg, &[]); assert!(res.is_ok()); // Mint fails From 44628b39772efc611edefe42c0171cdcd8731436 Mon Sep 17 00:00:00 2001 From: John Y Date: Mon, 7 Mar 2022 10:53:23 -0500 Subject: [PATCH 04/12] add another fee test --- contracts/whitelist/src/contract.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contracts/whitelist/src/contract.rs b/contracts/whitelist/src/contract.rs index b1cad1291..e7abf9200 100644 --- a/contracts/whitelist/src/contract.rs +++ b/contracts/whitelist/src/contract.rs @@ -768,9 +768,15 @@ mod tests { let res = execute(deps.as_mut(), mock_env(), info, msg); assert!(res.is_ok()); + // needs upgrade fee + let msg = ExecuteMsg::IncreaseMemberLimit(2002); + let info = mock_info(ADMIN, &[coin(100_000_000, "ustars")]); + let res = execute(deps.as_mut(), mock_env(), info, msg); + assert!(res.is_ok()); + // needs upgrade fee let msg = ExecuteMsg::IncreaseMemberLimit(4002); - let info = mock_info(ADMIN, &[coin(300_000_000, "ustars")]); + let info = mock_info(ADMIN, &[coin(200_000_000, "ustars")]); let res = execute(deps.as_mut(), mock_env(), info, msg); assert!(res.is_ok()); From 2642be704a089471c5d59eaa80f05b8fda9f20e7 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 12:04:00 -0500 Subject: [PATCH 05/12] Chanage royalties to royalty_info --- contracts/sg721/schema/collection_info_response.json | 2 +- contracts/sg721/src/contract.rs | 6 +++--- contracts/sg721/src/msg.rs | 2 +- types/contracts/sg721/collection_info_response.d.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/sg721/schema/collection_info_response.json b/contracts/sg721/schema/collection_info_response.json index 8676fb14e..d285d1113 100644 --- a/contracts/sg721/schema/collection_info_response.json +++ b/contracts/sg721/schema/collection_info_response.json @@ -23,7 +23,7 @@ "image": { "type": "string" }, - "royalty": { + "royalty_info": { "anyOf": [ { "$ref": "#/definitions/RoyaltyInfoResponse" diff --git a/contracts/sg721/src/contract.rs b/contracts/sg721/src/contract.rs index 0501bd21e..a917fbc7b 100644 --- a/contracts/sg721/src/contract.rs +++ b/contracts/sg721/src/contract.rs @@ -123,7 +123,7 @@ fn query_config(deps: Deps) -> StdResult { description: info.description, image: info.image, external_link: info.external_link, - royalty: royalty_info_res, + royalty_info: royalty_info_res, }) } @@ -168,7 +168,7 @@ mod tests { "https://example.com/external.html", value.external_link.unwrap() ); - assert_eq!(None, value.royalty); + assert_eq!(None, value.royalty_info); } #[test] @@ -206,7 +206,7 @@ mod tests { payment_address: creator, share: Decimal::percent(10), }), - value.royalty + value.royalty_info ); } } diff --git a/contracts/sg721/src/msg.rs b/contracts/sg721/src/msg.rs index e43f20976..c2f715221 100644 --- a/contracts/sg721/src/msg.rs +++ b/contracts/sg721/src/msg.rs @@ -145,5 +145,5 @@ pub struct CollectionInfoResponse { pub description: String, pub image: String, pub external_link: Option, - pub royalty: Option, + pub royalty_info: Option, } diff --git a/types/contracts/sg721/collection_info_response.d.ts b/types/contracts/sg721/collection_info_response.d.ts index a1fc84638..8f62af5cf 100644 --- a/types/contracts/sg721/collection_info_response.d.ts +++ b/types/contracts/sg721/collection_info_response.d.ts @@ -5,6 +5,6 @@ creator: string description: string external_link?: (string | null) image: string -royalty?: (RoyaltyInfoResponse | null) +royalty_info?: (RoyaltyInfoResponse | null) [k: string]: unknown } From c751878984e95613889b1e6db54bf00d186deb4c Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 12:05:19 -0500 Subject: [PATCH 06/12] Update versions --- Cargo.lock | 4 ++-- contracts/minter/Cargo.toml | 2 +- contracts/sg721/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1ce67a9c5..135313287 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -524,7 +524,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "minter" -version = "0.7.2" +version = "0.7.3" dependencies = [ "anyhow", "cosmwasm-schema", @@ -768,7 +768,7 @@ dependencies = [ [[package]] name = "sg721" -version = "0.7.2" +version = "0.7.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/minter/Cargo.toml b/contracts/minter/Cargo.toml index 47e1539f5..6d79af11b 100644 --- a/contracts/minter/Cargo.toml +++ b/contracts/minter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minter" -version = "0.7.2" +version = "0.7.3" authors = ["Jake Hartnell "] edition = "2018" diff --git a/contracts/sg721/Cargo.toml b/contracts/sg721/Cargo.toml index ec2db9240..cf84ff75a 100644 --- a/contracts/sg721/Cargo.toml +++ b/contracts/sg721/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sg721" -version = "0.7.2" +version = "0.7.3" authors = ["Shane Vitarana "] edition = "2018" From bab6abb1ce870a7ab6cd787b97b5a254c23e3209 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 12:59:05 -0500 Subject: [PATCH 07/12] Informational updates --- contracts/sg721/src/msg.rs | 2 +- contracts/whitelist/src/contract.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/contracts/sg721/src/msg.rs b/contracts/sg721/src/msg.rs index c2f715221..b8cd1c163 100644 --- a/contracts/sg721/src/msg.rs +++ b/contracts/sg721/src/msg.rs @@ -20,7 +20,7 @@ pub struct RoyaltyInfoResponse { impl RoyaltyInfoResponse { pub fn share_validate(&self) -> Result { - if self.share > Decimal::one() || self.share < Decimal::zero() { + if self.share > Decimal::one() { return Err(ContractError::InvalidRoyalities {}); } diff --git a/contracts/whitelist/src/contract.rs b/contracts/whitelist/src/contract.rs index e7abf9200..afbaa6f8e 100644 --- a/contracts/whitelist/src/contract.rs +++ b/contracts/whitelist/src/contract.rs @@ -328,7 +328,7 @@ pub fn execute_increase_member_limit( member_limit: u32, ) -> Result { let mut config = CONFIG.load(deps.storage)?; - if config.member_limit > member_limit || member_limit > MAX_MEMBERS { + if config.member_limit >= member_limit || member_limit > MAX_MEMBERS { return Err(ContractError::InvalidMemberLimit { min: config.member_limit, max: MAX_MEMBERS, @@ -751,8 +751,14 @@ mod tests { assert!(res.is_ok()); // 0 upgrade fee, fails when including a fee + // don't allow updating to the same number of memebers let msg = ExecuteMsg::IncreaseMemberLimit(1002); let info = mock_info(ADMIN, &[coin(1, "ustars")]); + execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); + + // 0 upgrade fee, fails when including a fee + let msg = ExecuteMsg::IncreaseMemberLimit(1003); + let info = mock_info(ADMIN, &[coin(1, "ustars")]); let err = execute(deps.as_mut(), mock_env(), info, msg).unwrap_err(); assert_eq!(err.to_string(), "IncorrectCreationFee 1 < 0"); From 6be672437a9a184d30a47a6b722ffe13b2640d36 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 13:53:30 -0500 Subject: [PATCH 08/12] Check if whitelist is already set --- contracts/minter/src/contract.rs | 4 ++++ contracts/minter/src/error.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/contracts/minter/src/contract.rs b/contracts/minter/src/contract.rs index d2955b53d..41db6e197 100644 --- a/contracts/minter/src/contract.rs +++ b/contracts/minter/src/contract.rs @@ -191,6 +191,10 @@ pub fn execute_set_whitelist( return Err(ContractError::AlreadyStarted {}); } + if config.whitelist.is_some() { + return Err(ContractError::WhitelistAlreadySet {}); + } + config.whitelist = Some(deps.api.addr_validate(whitelist)?); CONFIG.save(deps.storage, &config)?; diff --git a/contracts/minter/src/error.rs b/contracts/minter/src/error.rs index f52f9bc2f..0b20717ce 100644 --- a/contracts/minter/src/error.rs +++ b/contracts/minter/src/error.rs @@ -48,6 +48,9 @@ pub enum ContractError { #[error("BeforeGenesisTime")] BeforeGenesisTime {}, + #[error("WhitelistAlreadySet")] + WhitelistAlreadySet {}, + #[error("InvalidStartTime {0} < {1}")] InvalidStartTime(Timestamp, Timestamp), From 44d1cdb321e1a21229cba3f5f839e4c1dca285c9 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 13:59:05 -0500 Subject: [PATCH 09/12] Add test --- contracts/minter/src/contract_tests.rs | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/contracts/minter/src/contract_tests.rs b/contracts/minter/src/contract_tests.rs index b41658303..3a30303b3 100644 --- a/contracts/minter/src/contract_tests.rs +++ b/contracts/minter/src/contract_tests.rs @@ -739,6 +739,39 @@ fn whitelist_already_started() { .unwrap_err(); } +#[test] +fn whitelist_already_set() { + let mut router = custom_mock_app(); + let (creator, _) = setup_accounts(&mut router); + let num_tokens = 1; + let (minter_addr, _) = setup_minter_contract(&mut router, &creator, num_tokens); + let whitelist_addr = setup_whitelist_contract(&mut router, &creator); + + setup_block_time(&mut router, GENESIS_MINT_START_TIME - 1000); + + // set whitelist in minter contract + let set_whitelist_msg = ExecuteMsg::SetWhitelist { + whitelist: whitelist_addr.to_string(), + }; + router + .execute_contract( + creator.clone(), + minter_addr.clone(), + &set_whitelist_msg, + &coins(UNIT_PRICE, NATIVE_DENOM), + ) + .unwrap(); + + router + .execute_contract( + creator.clone(), + minter_addr, + &set_whitelist_msg, + &coins(UNIT_PRICE, NATIVE_DENOM), + ) + .unwrap_err(); +} + #[test] fn whitelist_access_len_add_remove_expiration() { let mut router = custom_mock_app(); From 80d1f9cc95f4c2d38371efdb0c84c4129e1d15a8 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 14:29:04 -0500 Subject: [PATCH 10/12] Test for whitelist being active --- contracts/minter/src/contract.rs | 10 ++++++++-- contracts/minter/src/contract_tests.rs | 7 ++++--- contracts/minter/src/error.rs | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/contracts/minter/src/contract.rs b/contracts/minter/src/contract.rs index 41db6e197..a34bc40de 100644 --- a/contracts/minter/src/contract.rs +++ b/contracts/minter/src/contract.rs @@ -191,8 +191,14 @@ pub fn execute_set_whitelist( return Err(ContractError::AlreadyStarted {}); } - if config.whitelist.is_some() { - return Err(ContractError::WhitelistAlreadySet {}); + if let Some(wl) = config.whitelist { + let res: WhitelistConfigResponse = deps + .querier + .query_wasm_smart(wl, &WhitelistQueryMsg::Config {})?; + + if res.is_active { + return Err(ContractError::WhitelistAlreadyStarted {}); + } } config.whitelist = Some(deps.api.addr_validate(whitelist)?); diff --git a/contracts/minter/src/contract_tests.rs b/contracts/minter/src/contract_tests.rs index 3a30303b3..155d28133 100644 --- a/contracts/minter/src/contract_tests.rs +++ b/contracts/minter/src/contract_tests.rs @@ -740,7 +740,7 @@ fn whitelist_already_started() { } #[test] -fn whitelist_already_set() { +fn whitelist_can_update_before_start() { let mut router = custom_mock_app(); let (creator, _) = setup_accounts(&mut router); let num_tokens = 1; @@ -762,14 +762,15 @@ fn whitelist_already_set() { ) .unwrap(); + // can set twice before starting router .execute_contract( creator.clone(), - minter_addr, + minter_addr.clone(), &set_whitelist_msg, &coins(UNIT_PRICE, NATIVE_DENOM), ) - .unwrap_err(); + .unwrap(); } #[test] diff --git a/contracts/minter/src/error.rs b/contracts/minter/src/error.rs index 0b20717ce..7b353b2a5 100644 --- a/contracts/minter/src/error.rs +++ b/contracts/minter/src/error.rs @@ -48,8 +48,8 @@ pub enum ContractError { #[error("BeforeGenesisTime")] BeforeGenesisTime {}, - #[error("WhitelistAlreadySet")] - WhitelistAlreadySet {}, + #[error("WhitelistAlreadyStarted")] + WhitelistAlreadyStarted {}, #[error("InvalidStartTime {0} < {1}")] InvalidStartTime(Timestamp, Timestamp), From 8b3615cc21454f9f02567f9154d6f6c9428da704 Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 14:34:10 -0500 Subject: [PATCH 11/12] Fix linter issue --- contracts/minter/src/contract_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/minter/src/contract_tests.rs b/contracts/minter/src/contract_tests.rs index 155d28133..d6a248bde 100644 --- a/contracts/minter/src/contract_tests.rs +++ b/contracts/minter/src/contract_tests.rs @@ -766,7 +766,7 @@ fn whitelist_can_update_before_start() { router .execute_contract( creator.clone(), - minter_addr.clone(), + minter_addr, &set_whitelist_msg, &coins(UNIT_PRICE, NATIVE_DENOM), ) From 2b675521c7a54ae76ece5f1a1866e2330632f53c Mon Sep 17 00:00:00 2001 From: Shane Vitarana Date: Mon, 7 Mar 2022 15:04:34 -0500 Subject: [PATCH 12/12] Updated minter version --- Cargo.lock | 2 +- contracts/minter/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 135313287..9ec067a78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -524,7 +524,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "minter" -version = "0.7.3" +version = "0.7.4" dependencies = [ "anyhow", "cosmwasm-schema", diff --git a/contracts/minter/Cargo.toml b/contracts/minter/Cargo.toml index 6d79af11b..892e984f9 100644 --- a/contracts/minter/Cargo.toml +++ b/contracts/minter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minter" -version = "0.7.3" +version = "0.7.4" authors = ["Jake Hartnell "] edition = "2018"