Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks committed Dec 7, 2023
1 parent df257c7 commit ad72c9f
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 53 deletions.
5 changes: 1 addition & 4 deletions contracts/factories/open-edition-factory/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ impl OpenEditionMinterInitMsgExtension {
// Optional: not time limited
if let Some(end_time) = init_msg.end_time {
if end_time <= init_msg.start_time {
return Err(ContractError::InvalidEndTime(
init_msg.start_time,
end_time,
));
return Err(ContractError::InvalidEndTime(init_msg.start_time, end_time));
}
}

Expand Down
21 changes: 13 additions & 8 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
use crate::error::ContractError;
use crate::helpers::mint_nft_msg;
use crate::msg::{ConfigResponse, EndTimeResponse, ExecuteMsg, MintableNumTokensResponse, MintCountResponse, MintPriceResponse, QueryMsg, StartTimeResponse, TotalMintCountResponse};
use crate::state::{increment_token_index, Config, ConfigExtension, CONFIG, MINTER_ADDRS, SG721_ADDRESS, STATUS, TOTAL_MINT_COUNT, MINTABLE_NUM_TOKENS};
use crate::msg::{
ConfigResponse, EndTimeResponse, ExecuteMsg, MintCountResponse, MintPriceResponse,
MintableNumTokensResponse, QueryMsg, StartTimeResponse, TotalMintCountResponse,
};
use crate::state::{
increment_token_index, Config, ConfigExtension, CONFIG, MINTABLE_NUM_TOKENS, MINTER_ADDRS,
SG721_ADDRESS, STATUS, TOTAL_MINT_COUNT,
};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{coin, to_binary, Addr, BankMsg, Binary, Coin, Deps, DepsMut, Empty, Env, MessageInfo, Order, Reply, ReplyOn, StdError, StdResult, Timestamp, WasmMsg, Event, Decimal};
use cosmwasm_std::{
coin, to_binary, Addr, BankMsg, Binary, Coin, Decimal, Deps, DepsMut, Empty, Env, Event,
MessageInfo, Order, Reply, ReplyOn, StdError, StdResult, Timestamp, WasmMsg,
};
use cw2::set_contract_version;
use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse};
Expand Down Expand Up @@ -84,7 +93,6 @@ pub fn instantiate(
// Validations/Check at the factory level:
// - Mint price, # of tokens / address, Start & End time, Max Tokens


// Use default start trading time if not provided
let mut collection_info = msg.collection_params.info.clone();
let offset = factory_params.max_trading_offset_secs;
Expand Down Expand Up @@ -497,10 +505,7 @@ pub fn execute_update_start_time(
// If the new start_time is after end_time return error
if let Some(end_time) = config.extension.end_time {
if start_time > end_time {
return Err(ContractError::InvalidStartTime(
end_time,
start_time,
));
return Err(ContractError::InvalidStartTime(end_time, start_time));
}
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/minters/open-edition-minter/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum ExecuteMsg {
MintTo {
recipient: String,
},
BurnRemaining {}
BurnRemaining {},
}

#[cw_serde]
Expand All @@ -39,7 +39,7 @@ pub enum QueryMsg {
MintCount { address: String },
TotalMintCount {},
Status {},
MintableNumTokens {}
MintableNumTokens {},
}

#[cw_serde]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use sg2::msg::CollectionParams;
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};

use crate::common_setup::msg::OpenEditionMinterCustomParams;
use crate::common_setup::setup_minter::common::constants::{CREATION_FEE, DEV_ADDRESS, MINT_FEE_FAIR_BURN, MIN_MINT_PRICE_OPEN_EDITION, MAX_TOKEN_LIMIT};
use crate::common_setup::setup_minter::common::constants::{
CREATION_FEE, DEV_ADDRESS, MAX_TOKEN_LIMIT, MINT_FEE_FAIR_BURN, MIN_MINT_PRICE_OPEN_EDITION,
};

pub fn mock_init_minter_extension(
start_time: Option<Timestamp>,
Expand Down
22 changes: 18 additions & 4 deletions test-suite/src/common_setup/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,15 @@ pub fn open_edition_minter_nft_data(
let (creator, buyer) = setup_accounts(&mut app);
let code_ids = open_edition_minter_code_ids(&mut app);
let collection_params = mock_collection_params_1(None);
let minter_params =
minter_params_open_edition(params_extension, init_msg, None, None, None, Some(nft_data), None);
let minter_params = minter_params_open_edition(
params_extension,
init_msg,
None,
None,
None,
Some(nft_data),
None,
);

let minter_collection_response = configure_open_edition_minter(
&mut app,
Expand All @@ -388,8 +395,15 @@ pub fn open_edition_minter_start_and_end_time(
let (creator, buyer) = setup_accounts(&mut app);
let code_ids = open_edition_minter_code_ids(&mut app);
let collection_params = mock_collection_params_1(None);
let minter_params =
minter_params_open_edition(params_extension, init_msg, start_time, end_time, None, None, None);
let minter_params = minter_params_open_edition(
params_extension,
init_msg,
start_time,
end_time,
None,
None,
None,
);

let minter_collection_response = configure_open_edition_minter(
&mut app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
mod tests {

mod init {
use crate::common_setup::setup_minter::common::constants::MAX_TOKEN_LIMIT;
use crate::open_edition_factory::tests::common::proper_instantiate;
use open_edition_factory::msg::{
OpenEditionUpdateParamsExtension, OpenEditionUpdateParamsMsg, ParamsResponse, SudoMsg,
};
use crate::common_setup::setup_minter::common::constants::MAX_TOKEN_LIMIT;
// Assumption: CreateMinter method is validated at the minter level

#[test]
Expand Down
2 changes: 1 addition & 1 deletion test-suite/src/open_edition_minter/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ mod complete_mint_all_outcomes_validation;
mod factory_create_minter;
mod frozen_factory;
mod ibc_asset_mint;
mod max_tokens_limit;
mod update_mint_price;
mod update_start_and_end_time;
mod max_tokens_limit;
2 changes: 1 addition & 1 deletion test-suite/src/open_edition_minter/tests/address_limit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{coins, Coin, Uint128, Timestamp};
use cosmwasm_std::{coins, Coin, Timestamp, Uint128};
use cw_multi_test::Executor;
use open_edition_factory::state::ParamsExtension;
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};
Expand Down
4 changes: 2 additions & 2 deletions test-suite/src/open_edition_minter/tests/allowed_code_ids.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{Coin, Uint128, Timestamp};
use cosmwasm_std::{Coin, Timestamp, Uint128};
use open_edition_factory::state::ParamsExtension;
use sg_std::{NATIVE_DENOM, GENESIS_MINT_START_TIME};
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};

use crate::common_setup::{
contract_boxes::custom_mock_app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use cw_multi_test::{BankSudo, Executor, SudoMsg};
use open_edition_factory::state::ParamsExtension;
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};

use open_edition_minter::msg::{ConfigResponse, EndTimeResponse, ExecuteMsg, MintableNumTokensResponse, MintCountResponse, MintPriceResponse, QueryMsg, StartTimeResponse, TotalMintCountResponse};
use open_edition_minter::msg::{
ConfigResponse, EndTimeResponse, ExecuteMsg, MintCountResponse, MintPriceResponse,
MintableNumTokensResponse, QueryMsg, StartTimeResponse, TotalMintCountResponse,
};
use sg4::StatusResponse;

use crate::common_setup::setup_accounts_and_block::{coins_for_msg, setup_block_time};
Expand All @@ -16,10 +19,7 @@ use crate::common_setup::templates::open_edition_minter_custom_template;

const MINT_PRICE: u128 = 100_000_000;

fn check_mint_revenues_distribution(
num_tokens: Option<u32>,
end_minter_time: Option<Timestamp>)
{
fn check_mint_revenues_distribution(num_tokens: Option<u32>, end_minter_time: Option<Timestamp>) {
let params_extension = ParamsExtension {
max_token_limit: 10,
max_per_address_limit: 10,
Expand Down Expand Up @@ -69,7 +69,6 @@ fn check_mint_revenues_distribution(
Timestamp::from_nanos(GENESIS_MINT_START_TIME + 100).to_string()
);


// Query End Time
// We know it is GENESIS_MINT_START_TIME + 10_000
let query_end_time_msg: QueryMsg = QueryMsg::EndTime {};
Expand All @@ -83,10 +82,7 @@ fn check_mint_revenues_distribution(
Some(Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000).to_string())
);
} else {
assert_eq!(
res.end_time,
None
);
assert_eq!(res.end_time, None);
}

// Query the Max Tokens or End Time depending on which test is executed
Expand Down Expand Up @@ -404,10 +400,7 @@ fn check_mint_revenues_distribution(
"Minting has ended"
);
} else {
assert_eq!(
res.err().unwrap().source().unwrap().to_string(),
"Sold out"
);
assert_eq!(res.err().unwrap().source().unwrap().to_string(), "Sold out");
}

// Can purge after sold out
Expand All @@ -432,14 +425,11 @@ fn check_mint_revenues_distribution(
fn check_mint_revenues_distribution_without_end_time() {
check_mint_revenues_distribution(
None,
Some(Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000))
Some(Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000)),
)
}

#[test]
fn check_mint_revenues_distribution_with_end_time() {
check_mint_revenues_distribution(
Some(5u32),
None
)
check_mint_revenues_distribution(Some(5u32), None)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use cosmwasm_std::{Coin, Timestamp, Uint128};
use open_edition_factory::state::ParamsExtension;
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};

use crate::common_setup::setup_minter::common::constants::{DEV_ADDRESS, MAX_TOKEN_LIMIT, MIN_MINT_PRICE_OPEN_EDITION};
use crate::common_setup::setup_minter::common::constants::{
DEV_ADDRESS, MAX_TOKEN_LIMIT, MIN_MINT_PRICE_OPEN_EDITION,
};
use crate::common_setup::setup_minter::open_edition_minter::minter_params::{
default_nft_data, init_msg,
};
Expand Down
9 changes: 8 additions & 1 deletion test-suite/src/open_edition_minter/tests/frozen_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ fn frozen_factory_cannot_create_new_minters() {
},
dev_fee_address: DEV_ADDRESS.to_string(),
};
let init_msg = init_msg(default_nft_data(), None, None, Some(Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000)), None, None);
let init_msg = init_msg(
default_nft_data(),
None,
None,
Some(Timestamp::from_nanos(GENESIS_MINT_START_TIME + 10_000)),
None,
None,
);
let vt = open_edition_minter_custom_template(params_extension, init_msg).unwrap();

let (mut router, creator, _buyer) = (vt.router, vt.accts.creator, vt.accts.buyer);
Expand Down
2 changes: 1 addition & 1 deletion test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{coin, Addr, Coin, Decimal, Uint128, Timestamp};
use cosmwasm_std::{coin, Addr, Coin, Decimal, Timestamp, Uint128};
use cw_multi_test::{BankSudo, Executor, SudoMsg};
use open_edition_factory::state::{OpenEditionMinterParams, ParamsExtension};
use open_edition_minter::msg::ExecuteMsg;
Expand Down
15 changes: 8 additions & 7 deletions test-suite/src/open_edition_minter/tests/max_tokens_limit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{coins, Coin, Uint128, Timestamp};
use cosmwasm_std::{coins, Coin, Timestamp, Uint128};
use cw_multi_test::Executor;
use open_edition_factory::state::ParamsExtension;
use sg_std::{GENESIS_MINT_START_TIME, NATIVE_DENOM};
Expand Down Expand Up @@ -52,7 +52,11 @@ fn check_max_tokens_limit_init() {
assert!(vt.is_ok());

let response = vt.unwrap();
let (mut router, creator, buyer) = (response.router, response.accts.creator, response.accts.buyer);
let (mut router, creator, buyer) = (
response.router,
response.accts.creator,
response.accts.buyer,
);
let minter_addr = response.collection_response_vec[0].minter.clone().unwrap();
// Set to a valid mint time
setup_block_time(&mut router, GENESIS_MINT_START_TIME + 101, None);
Expand Down Expand Up @@ -84,8 +88,5 @@ fn check_max_tokens_limit_init() {
&mint_msg,
&coins(MINT_PRICE, NATIVE_DENOM),
);
assert_eq!(
res.err().unwrap().source().unwrap().to_string(),
"Sold out"
);
}
assert_eq!(res.err().unwrap().source().unwrap().to_string(), "Sold out");
}

0 comments on commit ad72c9f

Please sign in to comment.