diff --git a/Cargo.lock b/Cargo.lock index a9354b470..87815c4d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4841,7 +4841,6 @@ dependencies = [ [[package]] name = "vending-minter-merkle-wl-featured" version = "3.13.0" - dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/collections/sg721-base/src/contract.rs b/contracts/collections/sg721-base/src/contract.rs index 9c46549f6..c91117bd3 100644 --- a/contracts/collections/sg721-base/src/contract.rs +++ b/contracts/collections/sg721-base/src/contract.rs @@ -388,7 +388,7 @@ where pub fn migrate(mut deps: DepsMut, env: Env, _msg: Empty) -> Result { let prev_contract_version = cw2::get_contract_version(deps.storage)?; - let valid_contract_names = vec![CONTRACT_NAME.to_string()]; + let valid_contract_names = [CONTRACT_NAME.to_string()]; if !valid_contract_names.contains(&prev_contract_version.contract) { return Err(StdError::generic_err("Invalid contract name for migration").into()); } diff --git a/contracts/factories/base-factory/src/contract.rs b/contracts/factories/base-factory/src/contract.rs index 362470866..f975feaa9 100644 --- a/contracts/factories/base-factory/src/contract.rs +++ b/contracts/factories/base-factory/src/contract.rs @@ -7,7 +7,7 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw_utils::must_pay; use semver::Version; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, transfer_funds_to_launchpad_dao}; use sg2::msg::UpdateMinterParamsMsg; use sg2::query::{AllowedCollectionCodeIdResponse, AllowedCollectionCodeIdsResponse, Sg2QueryMsg}; use sg2::MinterParams; @@ -57,14 +57,23 @@ pub fn execute_create_minter( info: MessageInfo, msg: BaseMinterCreateMsg, ) -> Result { - must_pay(&info, NATIVE_DENOM)?; + 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)?; - let params = SUDO_PARAMS.load(deps.storage)?; must_not_be_frozen(¶ms)?; let mut res = Response::new(); - checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + if params.creation_fee.denom == NATIVE_DENOM { + checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + } else { + transfer_funds_to_launchpad_dao( + &info, + params.creation_fee.amount.u128(), + ¶ms.creation_fee.denom, + &mut res, + )?; + } let msg = WasmMsg::Instantiate { admin: Some(info.sender.to_string()), diff --git a/contracts/factories/open-edition-factory/src/contract.rs b/contracts/factories/open-edition-factory/src/contract.rs index c17b9f94b..5a3056c64 100644 --- a/contracts/factories/open-edition-factory/src/contract.rs +++ b/contracts/factories/open-edition-factory/src/contract.rs @@ -11,7 +11,7 @@ use base_factory::contract::{ must_be_allowed_collection, must_not_be_frozen, must_pay_exact_amount, update_params, }; use base_factory::ContractError as BaseContractError; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, transfer_funds_to_launchpad_dao}; use sg2::query::{AllowedCollectionCodeIdResponse, AllowedCollectionCodeIdsResponse, Sg2QueryMsg}; use crate::error::ContractError; @@ -66,14 +66,23 @@ pub fn execute_create_minter( ) -> Result { let params = SUDO_PARAMS.load(deps.storage)?; - must_pay_exact_amount(¶ms, &info, NATIVE_DENOM)?; + must_pay_exact_amount(¶ms, &info, ¶ms.creation_fee.denom)?; must_be_allowed_collection(deps.as_ref(), msg.collection_params.code_id)?; must_not_be_frozen(¶ms)?; let mut res = Response::new(); - checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + if params.creation_fee.denom == NATIVE_DENOM { + checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + } else { + transfer_funds_to_launchpad_dao( + &info, + params.creation_fee.amount.u128(), + ¶ms.creation_fee.denom, + &mut res, + )?; + } msg.init_msg = OpenEditionMinterInitMsgExtension::validate( msg.init_msg.clone(), diff --git a/contracts/factories/vending-factory/src/contract.rs b/contracts/factories/vending-factory/src/contract.rs index 3d3e7813f..99cba082c 100644 --- a/contracts/factories/vending-factory/src/contract.rs +++ b/contracts/factories/vending-factory/src/contract.rs @@ -9,7 +9,7 @@ use cosmwasm_std::{ use cw2::set_contract_version; use cw_utils::must_pay; use semver::Version; -use sg1::checked_fair_burn; +use sg1::{checked_fair_burn, transfer_funds_to_launchpad_dao}; use sg2::query::{AllowedCollectionCodeIdResponse, AllowedCollectionCodeIdsResponse, Sg2QueryMsg}; use sg_std::{Response, NATIVE_DENOM}; @@ -57,14 +57,23 @@ pub fn execute_create_minter( info: MessageInfo, msg: VendingMinterCreateMsg, ) -> Result { - must_pay(&info, NATIVE_DENOM)?; + 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)?; - let params = SUDO_PARAMS.load(deps.storage)?; must_not_be_frozen(¶ms)?; let mut res = Response::new(); - checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + if params.creation_fee.denom == NATIVE_DENOM { + checked_fair_burn(&info, params.creation_fee.amount.u128(), None, &mut res)?; + } else { + transfer_funds_to_launchpad_dao( + &info, + params.creation_fee.amount.u128(), + ¶ms.creation_fee.denom, + &mut res, + )?; + } // Check the number of tokens is more than zero and less than the max limit if msg.init_msg.num_tokens == 0 || msg.init_msg.num_tokens > params.extension.max_token_limit { diff --git a/packages/sg1/src/lib.rs b/packages/sg1/src/lib.rs index a4b28745c..40ade39c7 100644 --- a/packages/sg1/src/lib.rs +++ b/packages/sg1/src/lib.rs @@ -1,11 +1,15 @@ -use cosmwasm_std::{coin, coins, Addr, BankMsg, Coin, Decimal, Event, MessageInfo, Uint128}; -use cw_utils::{may_pay, PaymentError}; +use cosmwasm_std::{ + coin, coins, ensure, Addr, BankMsg, Coin, Decimal, Event, MessageInfo, Uint128, +}; +use cw_utils::{may_pay, must_pay, PaymentError}; use sg_std::{create_fund_fairburn_pool_msg, Response, SubMsg, NATIVE_DENOM}; use thiserror::Error; // governance parameters const FEE_BURN_PERCENT: u64 = 50; const FOUNDATION: &str = "stars1xqz6xujjyz0r9uzn7srasle5uynmpa0zkjr5l8"; +const LAUNCHPAD_DAO_ADDRESS: &str = + "stars1huqk6ha02jgrm69lxh8xfgl6wch9wlg7s65ujxydwdr725cxvuus423tj0"; /// Burn and distribute fees and return an error if the fee is not enough pub fn checked_fair_burn( @@ -103,6 +107,27 @@ pub fn fair_burn(fee: u128, developer: Option, res: &mut Response) { res.events.push(event); } +pub fn transfer_funds_to_launchpad_dao( + info: &MessageInfo, + fee: u128, + accepted_denom: &str, + res: &mut Response, +) -> Result<(), FeeError> { + let payment = must_pay(info, accepted_denom)?; + ensure!( + payment.u128() >= fee, + FeeError::InsufficientFee(fee, payment.u128()) + ); + + let msg = BankMsg::Send { + to_address: LAUNCHPAD_DAO_ADDRESS.to_string(), + amount: vec![coin(payment.u128(), accepted_denom)], + }; + res.messages.push(SubMsg::new(msg)); + + Ok(()) +} + #[derive(Error, Debug, PartialEq, Eq)] pub enum FeeError { #[error("Insufficient fee: expected {0}, got {1}")]