From e515627933c5a4221ed734de1901955a806de005 Mon Sep 17 00:00:00 2001 From: jhernadnezb Date: Thu, 25 Jan 2024 14:33:46 -0600 Subject: [PATCH] fix format --- .../vending-minter-merkle-wl/src/contract.rs | 17 ++++++++++------- .../minters/vending-minter-merkle-wl/src/msg.rs | 2 +- .../whitelist-merkletree/src/helpers.rs | 4 ++-- .../whitelist-merkletree/src/helpers/crypto.rs | 16 +++++++++++----- .../whitelists/whitelist-merkletree/src/msg.rs | 12 +++++------- .../whitelist-merkletree/src/tests.rs | 4 ++-- test-suite/src/common_setup.rs | 2 +- test-suite/src/common_setup/contract_boxes.rs | 3 +-- .../common_setup/setup_whitelist_merkletree.rs | 5 ++--- test-suite/src/whitelist_merkletree.rs | 2 +- test-suite/src/whitelist_merkletree/tests.rs | 2 +- 11 files changed, 37 insertions(+), 32 deletions(-) diff --git a/contracts/minters/vending-minter-merkle-wl/src/contract.rs b/contracts/minters/vending-minter-merkle-wl/src/contract.rs index 5fd81b599..c8dd1d504 100644 --- a/contracts/minters/vending-minter-merkle-wl/src/contract.rs +++ b/contracts/minters/vending-minter-merkle-wl/src/contract.rs @@ -29,13 +29,13 @@ use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME, NATIVE_DENOM}; use sg_whitelist::msg::{ ConfigResponse as WhitelistConfigResponse, HasMemberResponse, QueryMsg as WhitelistQueryMsg, }; -use whitelist_mtree::msg::QueryMsg as WhitelistMtreeQueryMsg; use sha2::{Digest, Sha256}; use shuffle::{fy::FisherYates, shuffler::Shuffler}; use std::convert::TryInto; use url::Url; use vending_factory::msg::{ParamsResponse, VendingMinterCreateMsg}; use vending_factory::state::VendingMinterParams; +use whitelist_mtree::msg::QueryMsg as WhitelistMtreeQueryMsg; pub type Response = cosmwasm_std::Response; pub type SubMsg = cosmwasm_std::SubMsg; @@ -489,7 +489,9 @@ pub fn execute_mint_sender( // If there is no active whitelist right now, check public mint // Check if after start_time - if is_public_mint(deps.as_ref(), &info, proof_hashes)? && (env.block.time < config.extension.start_time) { + if is_public_mint(deps.as_ref(), &info, proof_hashes)? + && (env.block.time < config.extension.start_time) + { return Err(ContractError::BeforeMintStartTime {}); } @@ -504,7 +506,11 @@ pub fn execute_mint_sender( // Check if a whitelist exists and not ended // Sender has to be whitelisted to mint -fn is_public_mint(deps: Deps, info: &MessageInfo, proof_hashes: Option>) -> Result { +fn is_public_mint( + deps: Deps, + info: &MessageInfo, + proof_hashes: Option>, +) -> Result { let config = CONFIG.load(deps.storage)?; // If there is no whitelist, there's only a public mint @@ -554,13 +560,10 @@ fn is_public_mint(deps: Deps, info: &MessageInfo, proof_hashes: Option bool { - wl_config_res.member_limit == 0 && - wl_config_res.num_members == 0 + wl_config_res.member_limit == 0 && wl_config_res.num_members == 0 } - pub fn execute_mint_to( deps: DepsMut, env: Env, diff --git a/contracts/minters/vending-minter-merkle-wl/src/msg.rs b/contracts/minters/vending-minter-merkle-wl/src/msg.rs index cdf95406c..9644543c3 100644 --- a/contracts/minters/vending-minter-merkle-wl/src/msg.rs +++ b/contracts/minters/vending-minter-merkle-wl/src/msg.rs @@ -11,7 +11,7 @@ pub struct InstantiateMsg { #[cw_serde] pub enum ExecuteMsg { Mint { - proof_hashes: Option> + proof_hashes: Option>, }, SetWhitelist { whitelist: String, diff --git a/contracts/whitelists/whitelist-merkletree/src/helpers.rs b/contracts/whitelists/whitelist-merkletree/src/helpers.rs index 90ecbaac7..8009d09df 100644 --- a/contracts/whitelists/whitelist-merkletree/src/helpers.rs +++ b/contracts/whitelists/whitelist-merkletree/src/helpers.rs @@ -1,4 +1,4 @@ -pub mod interface; -pub mod validators; pub mod crypto; +pub mod interface; pub mod utils; +pub mod validators; diff --git a/contracts/whitelists/whitelist-merkletree/src/helpers/crypto.rs b/contracts/whitelists/whitelist-merkletree/src/helpers/crypto.rs index a7e65c34f..b76747b28 100644 --- a/contracts/whitelists/whitelist-merkletree/src/helpers/crypto.rs +++ b/contracts/whitelists/whitelist-merkletree/src/helpers/crypto.rs @@ -1,9 +1,11 @@ -use cosmwasm_std::{HexBinary, StdResult, StdError}; +use cosmwasm_std::{HexBinary, StdError, StdResult}; pub fn valid_hash_string(hash_string: &String) -> StdResult<()> { let hex_res = HexBinary::from_hex(hash_string.as_str()); if hex_res.is_err() { - return Err(cosmwasm_std::StdError::InvalidHex { msg: hash_string.to_string() }); + return Err(cosmwasm_std::StdError::InvalidHex { + msg: hash_string.to_string(), + }); } let hex_binary = hex_res.unwrap(); @@ -11,7 +13,10 @@ pub fn valid_hash_string(hash_string: &String) -> StdResult<()> { let decoded = hex_binary.to_array::<32>(); if decoded.is_err() { - return Err(cosmwasm_std::StdError::InvalidDataSize { expected: 32, actual: hex_binary.len() as u64 }) + return Err(cosmwasm_std::StdError::InvalidDataSize { + expected: 32, + actual: hex_binary.len() as u64, + }); } Ok(()) } @@ -22,7 +27,8 @@ pub fn verify_merkle_root(merkle_root: &String) -> StdResult<()> { pub fn string_to_byte_slice(string: &String) -> StdResult<[u8; 32]> { let mut byte_slice = [0; 32]; - hex::decode_to_slice(string, &mut byte_slice) - .map_err(|_| StdError::GenericErr { msg: "Couldn't decode hash string".to_string() })?; + hex::decode_to_slice(string, &mut byte_slice).map_err(|_| StdError::GenericErr { + msg: "Couldn't decode hash string".to_string(), + })?; Ok(byte_slice) } diff --git a/contracts/whitelists/whitelist-merkletree/src/msg.rs b/contracts/whitelists/whitelist-merkletree/src/msg.rs index b995a3be6..f31680b00 100644 --- a/contracts/whitelists/whitelist-merkletree/src/msg.rs +++ b/contracts/whitelists/whitelist-merkletree/src/msg.rs @@ -21,7 +21,6 @@ pub struct InstantiateMsg { pub admins_mutable: bool, } - #[cw_serde] pub enum ExecuteMsg { UpdateStartTime(Timestamp), @@ -56,7 +55,10 @@ pub enum QueryMsg { #[returns(IsActiveResponse)] IsActive {}, #[returns(HasMemberResponse)] - HasMember { member: String, proof_hashes: Vec }, + HasMember { + member: String, + proof_hashes: Vec, + }, #[returns(ConfigResponse)] Config {}, #[returns(AdminListResponse)] @@ -69,16 +71,14 @@ pub enum QueryMsg { #[returns(MerkleRootResponse)] MerkleRoot {}, #[returns(MerkleTreeURIResponse)] - MerkleTreeURI {} + MerkleTreeURI {}, } - #[cw_serde] pub struct HasMemberResponse { pub has_member: bool, } - #[cw_serde] pub struct HasEndedResponse { pub has_ended: bool, @@ -99,7 +99,6 @@ pub struct MintPriceResponse { pub mint_price: Coin, } - #[cw_serde] pub struct ConfigResponse { pub num_members: u32, @@ -111,7 +110,6 @@ pub struct ConfigResponse { pub is_active: bool, } - #[cw_serde] pub struct MerkleRootResponse { pub merkle_root: String, diff --git a/contracts/whitelists/whitelist-merkletree/src/tests.rs b/contracts/whitelists/whitelist-merkletree/src/tests.rs index 87d3d2733..331bda8f8 100644 --- a/contracts/whitelists/whitelist-merkletree/src/tests.rs +++ b/contracts/whitelists/whitelist-merkletree/src/tests.rs @@ -1,3 +1,3 @@ -pub mod unit_tests; +pub mod hasher; pub mod test_helpers; -pub mod hasher; \ No newline at end of file +pub mod unit_tests; diff --git a/test-suite/src/common_setup.rs b/test-suite/src/common_setup.rs index 4f82d1ce0..cc10d8105 100644 --- a/test-suite/src/common_setup.rs +++ b/test-suite/src/common_setup.rs @@ -4,6 +4,6 @@ pub mod helpers; pub mod msg; pub mod setup_accounts_and_block; pub mod setup_collection_whitelist; -pub mod setup_whitelist_merkletree; pub mod setup_minter; +pub mod setup_whitelist_merkletree; pub mod templates; diff --git a/test-suite/src/common_setup/contract_boxes.rs b/test-suite/src/common_setup/contract_boxes.rs index 2f5be14a3..65a9fd3d0 100644 --- a/test-suite/src/common_setup/contract_boxes.rs +++ b/test-suite/src/common_setup/contract_boxes.rs @@ -64,7 +64,6 @@ pub fn contract_collection_whitelist() -> Box> Box::new(contract) } - pub fn contract_open_edition_minter() -> Box> { let contract = ContractWrapper::new( open_edition_minter::contract::execute, @@ -148,4 +147,4 @@ pub fn contract_whitelist_merkletree() -> Box> whitelist_mtree::contract::query, ); Box::new(contract) -} \ No newline at end of file +} diff --git a/test-suite/src/common_setup/setup_whitelist_merkletree.rs b/test-suite/src/common_setup/setup_whitelist_merkletree.rs index 09ccc77df..1b1ed4766 100644 --- a/test-suite/src/common_setup/setup_whitelist_merkletree.rs +++ b/test-suite/src/common_setup/setup_whitelist_merkletree.rs @@ -14,7 +14,7 @@ pub fn setup_whitelist_mtree_contract( creator: &Addr, whitelist_code_id: Option, denom: Option<&str>, - merkle_root: String + merkle_root: String, ) -> Addr { let whitelist_code_id = match whitelist_code_id { Some(value) => value, @@ -25,7 +25,6 @@ pub fn setup_whitelist_mtree_contract( None => NATIVE_DENOM, }; - let msg = WhitelistInstantiateMsg { start_time: Timestamp::from_nanos(GENESIS_MINT_START_TIME + 100), end_time: Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000_000), @@ -34,7 +33,7 @@ pub fn setup_whitelist_mtree_contract( admins: vec![creator.to_string()], admins_mutable: true, merkle_root, - merkle_tree_uri: None + merkle_tree_uri: None, }; router .instantiate_contract( diff --git a/test-suite/src/whitelist_merkletree.rs b/test-suite/src/whitelist_merkletree.rs index b90ccf403..14f00389d 100644 --- a/test-suite/src/whitelist_merkletree.rs +++ b/test-suite/src/whitelist_merkletree.rs @@ -1 +1 @@ -mod tests; \ No newline at end of file +mod tests; diff --git a/test-suite/src/whitelist_merkletree/tests.rs b/test-suite/src/whitelist_merkletree/tests.rs index 6b4013a43..07214813c 100644 --- a/test-suite/src/whitelist_merkletree/tests.rs +++ b/test-suite/src/whitelist_merkletree/tests.rs @@ -1 +1 @@ -mod integration_tests; \ No newline at end of file +mod integration_tests;