diff --git a/Cargo.lock b/Cargo.lock index 3651e64bf..463cef38e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4304,7 +4304,6 @@ dependencies = [ "serde", "sg-std", "sg1", - "sg2", "sg721", "thiserror", ] @@ -4328,7 +4327,6 @@ dependencies = [ "sg-std", "sg-whitelist", "sg1", - "sg2", "sg4", "sg721", "sha2 0.10.8", @@ -4336,7 +4334,6 @@ dependencies = [ "thiserror", "token-merge-factory", "url", - "vending-factory", ] [[package]] diff --git a/contracts/factories/token-merge-factory/Cargo.toml b/contracts/factories/token-merge-factory/Cargo.toml index 690cd4233..9cc0dd852 100644 --- a/contracts/factories/token-merge-factory/Cargo.toml +++ b/contracts/factories/token-merge-factory/Cargo.toml @@ -36,7 +36,6 @@ schemars = { workspace = true } semver = { workspace = true } serde = { workspace = true } sg1 = { workspace = true } -sg2 = { workspace = true } sg721 = { workspace = true } sg-std = { workspace = true } thiserror = { workspace = true } diff --git a/contracts/factories/token-merge-factory/src/contract.rs b/contracts/factories/token-merge-factory/src/contract.rs index c159bca27..1cdc1131e 100644 --- a/contracts/factories/token-merge-factory/src/contract.rs +++ b/contracts/factories/token-merge-factory/src/contract.rs @@ -1,4 +1,3 @@ -use base_factory::contract::must_be_allowed_collection; use base_factory::ContractError as BaseContractError; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; @@ -10,13 +9,12 @@ use cw2::set_contract_version; use cw_utils::must_pay; use semver::Version; use sg1::{checked_fair_burn, transfer_funds_to_launchpad_dao}; -use sg2::query::{AllowedCollectionCodeIdResponse, AllowedCollectionCodeIdsResponse, Sg2QueryMsg}; use sg_std::{Response, NATIVE_DENOM}; use crate::error::ContractError; use crate::msg::{ - ExecuteMsg, InstantiateMsg, ParamsResponse, SudoMsg, TokenMergeMinterCreateMsg, - TokenMergeUpdateParamsMsg, + AllowedCollectionCodeIdResponse, AllowedCollectionCodeIdsResponse, ExecuteMsg, InstantiateMsg, + ParamsResponse, QueryMsg, SudoMsg, TokenMergeMinterCreateMsg, TokenMergeUpdateParamsMsg, }; use crate::state::SUDO_PARAMS; @@ -59,7 +57,12 @@ pub fn execute_create_minter( ) -> Result { let params = SUDO_PARAMS.load(deps.storage)?; must_pay(&info, ¶ms.creation_fee.denom)?; - must_be_allowed_collection(deps.as_ref(), msg.collection_params.code_id)?; + ensure!( + params + .allowed_sg721_code_ids + .contains(&msg.collection_params.code_id), + ContractError::InvalidCollectionCodeId {} + ); ensure!(!params.frozen, ContractError::Frozen {}); @@ -160,13 +163,13 @@ pub fn sudo_update_params( } #[cfg_attr(not(feature = "library"), entry_point)] -pub fn query(deps: Deps, _env: Env, msg: Sg2QueryMsg) -> StdResult { +pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { match msg { - Sg2QueryMsg::Params {} => to_json_binary(&query_params(deps)?), - Sg2QueryMsg::AllowedCollectionCodeIds {} => { + QueryMsg::Params {} => to_json_binary(&query_params(deps)?), + QueryMsg::AllowedCollectionCodeIds {} => { to_json_binary(&query_allowed_collection_code_ids(deps)?) } - Sg2QueryMsg::AllowedCollectionCodeId(code_id) => { + QueryMsg::AllowedCollectionCodeId(code_id) => { to_json_binary(&query_allowed_collection_code_id(deps, code_id)?) } } diff --git a/contracts/factories/token-merge-factory/src/error.rs b/contracts/factories/token-merge-factory/src/error.rs index b72dff3f9..a7f27174e 100644 --- a/contracts/factories/token-merge-factory/src/error.rs +++ b/contracts/factories/token-merge-factory/src/error.rs @@ -21,6 +21,9 @@ pub enum ContractError { #[error("Factory frozen. Cannot make new minters.")] Frozen {}, + #[error("InvalidCodeId")] + InvalidCollectionCodeId {}, + #[error("InvalidNumTokens {max}, min: 1")] InvalidNumTokens { max: u32, min: u32 }, diff --git a/contracts/factories/token-merge-factory/src/msg.rs b/contracts/factories/token-merge-factory/src/msg.rs index 4b8e0dcbb..0ef5ff20b 100644 --- a/contracts/factories/token-merge-factory/src/msg.rs +++ b/contracts/factories/token-merge-factory/src/msg.rs @@ -1,12 +1,11 @@ +use crate::state::TokenMergeFactoryParams; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Coin, Timestamp}; -use sg2::msg::{CreateMinterMsg, Sg2ExecuteMsg, UpdateMinterParamsMsg}; - -use crate::state::TokenMergeMinterParams; +use sg721::{CollectionInfo, RoyaltyInfoResponse}; #[cw_serde] pub struct InstantiateMsg { - pub params: TokenMergeMinterParams, + pub params: TokenMergeFactoryParams, } #[cw_serde] @@ -17,16 +16,35 @@ pub struct TokenMergeMinterInitMsgExtension { pub mint_tokens: Vec, pub per_address_limit: u32, } + +#[cw_serde] +pub struct CollectionParams { + /// The collection code id + pub code_id: u64, + pub name: String, + pub symbol: String, + pub info: CollectionInfo, +} +#[cw_serde] +pub struct CreateMinterMsg { + pub init_msg: T, + pub collection_params: CollectionParams, +} + pub type TokenMergeMinterCreateMsg = CreateMinterMsg; -pub type ExecuteMsg = Sg2ExecuteMsg; +#[cw_serde] +pub enum ExecuteMsg { + CreateMinter(TokenMergeMinterCreateMsg), +} #[cw_serde] -pub enum SudoMsg { - UpdateParams(Box), +pub enum QueryMsg { + Params {}, + AllowedCollectionCodeIds {}, + AllowedCollectionCodeId(u64), } -/// Message for params so they can be updated individually by governance #[cw_serde] pub struct TokenMergeUpdateParamsExtension { pub max_token_limit: Option, @@ -35,8 +53,24 @@ pub struct TokenMergeUpdateParamsExtension { pub airdrop_mint_fee_bps: Option, pub shuffle_fee: Option, } +#[cw_serde] +pub struct UpdateMinterParamsMsg { + /// The minter code id + pub code_id: Option, + pub add_sg721_code_ids: Option>, + pub rm_sg721_code_ids: Option>, + pub frozen: Option, + pub creation_fee: Option, + pub max_trading_offset_secs: Option, + pub extension: T, +} pub type TokenMergeUpdateParamsMsg = UpdateMinterParamsMsg; +#[cw_serde] +pub enum SudoMsg { + UpdateParams(Box), +} + #[cw_serde] pub struct MintToken { pub collection: String, @@ -44,5 +78,15 @@ pub struct MintToken { } #[cw_serde] pub struct ParamsResponse { - pub params: TokenMergeMinterParams, + pub params: TokenMergeFactoryParams, +} + +#[cw_serde] +pub struct AllowedCollectionCodeIdsResponse { + pub code_ids: Vec, +} + +#[cw_serde] +pub struct AllowedCollectionCodeIdResponse { + pub allowed: bool, } diff --git a/contracts/factories/token-merge-factory/src/state.rs b/contracts/factories/token-merge-factory/src/state.rs index a0ae401cf..2266b182e 100644 --- a/contracts/factories/token-merge-factory/src/state.rs +++ b/contracts/factories/token-merge-factory/src/state.rs @@ -1,12 +1,11 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::Coin; use cw_storage_plus::Item; -use sg2::CodeId; #[cw_serde] -pub struct TokenMergeMinterParams { +pub struct TokenMergeFactoryParams { pub code_id: u64, - pub allowed_sg721_code_ids: Vec, + pub allowed_sg721_code_ids: Vec, pub frozen: bool, pub creation_fee: Coin, pub max_trading_offset_secs: u64, @@ -17,4 +16,4 @@ pub struct TokenMergeMinterParams { pub shuffle_fee: Coin, } -pub const SUDO_PARAMS: Item = Item::new("sudo-params"); +pub const SUDO_PARAMS: Item = Item::new("sudo-params"); diff --git a/contracts/minters/token-merge-minter/Cargo.toml b/contracts/minters/token-merge-minter/Cargo.toml index 8f4838765..f3ae95f00 100644 --- a/contracts/minters/token-merge-minter/Cargo.toml +++ b/contracts/minters/token-merge-minter/Cargo.toml @@ -43,13 +43,11 @@ serde = { workspace = true } sha2 = { workspace = true } shuffle = { git = "https://github.com/webmaster128/shuffle", branch = "rm-getrandom", version = "0.1.7" } sg1 = { workspace = true } -sg2 = { workspace = true } sg4 = { workspace = true } sg721 = { workspace = true } sg-std = { workspace = true } sg-whitelist = { workspace = true, features = ["library"] } thiserror = { workspace = true } url = { workspace = true } -vending-factory = { workspace = true, features = ["library"] } token-merge-factory = { workspace = true, features = ["library"] } semver = {workspace = true } diff --git a/contracts/minters/token-merge-minter/src/contract.rs b/contracts/minters/token-merge-minter/src/contract.rs index f9b660c55..c3da191b8 100644 --- a/contracts/minters/token-merge-minter/src/contract.rs +++ b/contracts/minters/token-merge-minter/src/contract.rs @@ -23,13 +23,13 @@ use rand_core::{RngCore, SeedableRng}; use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; use sg1::{checked_fair_burn, distribute_mint_fees}; -use sg2::query::Sg2QueryMsg; use sg4::{Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME}; use sha2::{Digest, Sha256}; use shuffle::{fy::FisherYates, shuffler::Shuffler}; use std::convert::TryInto; +use token_merge_factory::msg::QueryMsg as FactoryQueryMsg; use token_merge_factory::msg::{MintToken, ParamsResponse, TokenMergeMinterCreateMsg}; use url::Url; pub type Response = cosmwasm_std::Response; @@ -61,7 +61,7 @@ pub fn instantiate( // This will fail if the sender cannot parse a response from the factory contract let factory_response: ParamsResponse = deps .querier - .query_wasm_smart(factory.clone(), &Sg2QueryMsg::Params {})?; + .query_wasm_smart(factory.clone(), &FactoryQueryMsg::Params {})?; let factory_params = factory_response.params; // set default status so it can be queried without failing @@ -283,6 +283,8 @@ pub fn execute_receive_nft( .add_attribute("token_id", token_id)); } + RECEIVED_TOKENS.remove(deps.storage, (&recipient_addr, info.sender.to_string())); + action = "mint_sender"; _execute_mint(deps, env, info, action, false, Some(recipient_addr), None) } @@ -328,7 +330,7 @@ pub fn execute_shuffle( let factory: ParamsResponse = deps .querier - .query_wasm_smart(config.factory, &Sg2QueryMsg::Params {})?; + .query_wasm_smart(config.factory, &FactoryQueryMsg::Params {})?; let factory_params = factory.params; // Check exact shuffle fee payment included in message @@ -464,7 +466,7 @@ fn _execute_mint( let factory: ParamsResponse = deps .querier - .query_wasm_smart(config.factory, &Sg2QueryMsg::Params {})?; + .query_wasm_smart(config.factory, &FactoryQueryMsg::Params {})?; let factory_params = factory.params; if is_admin { @@ -679,7 +681,7 @@ pub fn execute_update_start_trading_time( // add custom rules here let factory_params: ParamsResponse = deps .querier - .query_wasm_smart(config.factory.clone(), &Sg2QueryMsg::Params {})?; + .query_wasm_smart(config.factory.clone(), &FactoryQueryMsg::Params {})?; let default_start_time_with_offset = config .extension .start_time @@ -732,7 +734,7 @@ pub fn execute_update_per_address_limit( let factory: ParamsResponse = deps .querier - .query_wasm_smart(config.factory.clone(), &Sg2QueryMsg::Params {})?; + .query_wasm_smart(config.factory.clone(), &FactoryQueryMsg::Params {})?; let factory_params = factory.params; if per_address_limit == 0 || per_address_limit > factory_params.max_per_address_limit { diff --git a/contracts/minters/token-merge-minter/src/msg.rs b/contracts/minters/token-merge-minter/src/msg.rs index 4a5ace5be..720064725 100644 --- a/contracts/minters/token-merge-minter/src/msg.rs +++ b/contracts/minters/token-merge-minter/src/msg.rs @@ -2,20 +2,13 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::Timestamp; use cw721::Cw721ReceiveMsg; use token_merge_factory::msg::MintToken; -use vending_factory::{msg::VendingMinterCreateMsg, state::VendingMinterParams}; - -#[cw_serde] -pub struct InstantiateMsg { - pub create_msg: VendingMinterCreateMsg, - pub params: VendingMinterParams, -} #[cw_serde] pub enum ExecuteMsg { ReceiveNft(Cw721ReceiveMsg), Purge {}, UpdateStartTime(Timestamp), - /// Runs custom checks against TradingStartTime on VendingMinter, then updates by calling sg721-base + /// Runs custom checks against TradingStartTime on TokenMergeMinter, then updates by calling sg721-base UpdateStartTradingTime(Option), UpdatePerAddressLimit { per_address_limit: u32,