Skip to content

Commit

Permalink
Merge branch 'release/v3.x' into serkan/tiered-whitelists
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks authored Oct 31, 2024
2 parents 69ea6bd + 5fb3404 commit 3d74fa5
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 148 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/collections/sg721-metadata-onchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ sg-metadata = { workspace = true }
sg-std = { workspace = true }
cw-ownable = { workspace = true }
cw721-base = { workspace = true, features = ["library"] }
semver = { workspace = true }

[dev-dependencies]
cw721 = { workspace = true }
53 changes: 40 additions & 13 deletions contracts/collections/sg721-metadata-onchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ pub type Extension = Option<Empty>;
pub mod entry {
use super::*;

use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, StdError, StdResult};

use cosmwasm_std::{
entry_point, Binary, Deps, DepsMut, Env, Event, MessageInfo, StdError, StdResult,
};
use semver::Version;
use sg721_base::{msg::QueryMsg, ContractError};
use sg_std::Response;

Expand Down Expand Up @@ -57,33 +59,58 @@ pub mod entry {
}

#[entry_point]
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
pub fn migrate(mut deps: DepsMut, env: Env, _msg: Empty) -> Result<Response, ContractError> {
// make sure the correct contract is being upgraded, and it's being
// upgraded from the correct version.
if CONTRACT_VERSION < EARLIEST_VERSION {
let prev_contract_info = cw2::get_contract_version(deps.storage)?;
let prev_contract_name: String = prev_contract_info.contract;
let prev_contract_version: Version = prev_contract_info
.version
.parse()
.map_err(|_| StdError::generic_err("Unable to retrieve previous contract version"))?;

let new_version: Version = CONTRACT_VERSION
.parse()
.map_err(|_| StdError::generic_err("Invalid contract version"))?;

let earliest_version: Version = EARLIEST_VERSION
.parse()
.map_err(|_| StdError::generic_err("Invalid contract version"))?;

if prev_contract_version < earliest_version {
return Err(
StdError::generic_err("Cannot upgrade to a previous contract version").into(),
StdError::generic_err("The contract version is too old to be upgraded").into(),
);
}
if CONTRACT_VERSION > TO_VERSION {
if new_version < prev_contract_version {
return Err(
StdError::generic_err("Cannot upgrade to a previous contract version").into(),
);
}
// if same version return
if CONTRACT_VERSION == TO_VERSION {
if new_version == prev_contract_version {
return Ok(Response::new());
}

// update contract version
cw2::set_contract_version(deps.storage, CONTRACT_NAME, TO_VERSION)?;

// perform the upgrade
let cw17_res = cw721_base::upgrades::v0_17::migrate::<Extension, Empty, Empty, Empty>(deps)
.map_err(|e| sg721_base::ContractError::MigrationError(e.to_string()))?;
let mut sgz_res = Response::new();
sgz_res.attributes = cw17_res.attributes;
Ok(sgz_res)
let mut response = Response::new();

#[allow(clippy::cmp_owned)]
if prev_contract_version < Version::new(3, 0, 0) {
// perform the upgrade
response = sg721_base::upgrades::v3_0_0::upgrade(deps.branch(), &env, response)?;
}
response = response.add_event(
Event::new("migrate")
.add_attribute("from_name", prev_contract_name)
.add_attribute("from_version", prev_contract_version.to_string())
.add_attribute("to_name", CONTRACT_NAME)
.add_attribute("to_version", CONTRACT_VERSION),
);

Ok(response)
}
}

Expand Down
27 changes: 6 additions & 21 deletions contracts/minters/open-edition-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse};
use open_edition_factory::state::OpenEditionMinterParams;
use open_edition_factory::types::NftMetadataType;
use semver::Version;
use sg1::{checked_fair_burn, ibc_denom_fair_burn};
use sg1::distribute_mint_fees;
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -536,30 +536,15 @@ fn _execute_mint(
};
let network_fee = mint_price.amount * mint_fee;

// This is for the network fee msg
// send non-native fees to community pool
if mint_price.denom != NATIVE_DENOM {
// only send non-zero amounts
// send portion to dev addr
if !network_fee.is_zero() {
ibc_denom_fair_burn(
coin(network_fee.u128(), mint_price.denom.to_string()),
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}
} else if !network_fee.is_zero() {
checked_fair_burn(
&info,
network_fee.u128(),
if !network_fee.is_zero() {
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
false,
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}

Expand Down
27 changes: 6 additions & 21 deletions contracts/minters/open-edition-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse};
use open_edition_factory::state::OpenEditionMinterParams;
use open_edition_factory::types::NftMetadataType;
use semver::Version;
use sg1::{checked_fair_burn, ibc_denom_fair_burn};
use sg1::distribute_mint_fees;
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -594,30 +594,15 @@ fn _execute_mint(
};
let network_fee = mint_price.amount * mint_fee;

// This is for the network fee msg
// send non-native fees to community pool
if mint_price.denom != NATIVE_DENOM {
// only send non-zero amounts
// send portion to dev addr
if !network_fee.is_zero() {
ibc_denom_fair_burn(
coin(network_fee.u128(), mint_price.denom.to_string()),
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}
} else if !network_fee.is_zero() {
checked_fair_burn(
&info,
network_fee.u128(),
if !network_fee.is_zero() {
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
false,
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}

Expand Down
27 changes: 6 additions & 21 deletions contracts/minters/open-edition-minter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use open_edition_factory::msg::{OpenEditionMinterCreateMsg, ParamsResponse};
use open_edition_factory::state::OpenEditionMinterParams;
use open_edition_factory::types::NftMetadataType;
use semver::Version;
use sg1::{checked_fair_burn, ibc_denom_fair_burn};
use sg1::distribute_mint_fees;
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -579,30 +579,15 @@ fn _execute_mint(
};
let network_fee = mint_price.amount * mint_fee;

// This is for the network fee msg
// send non-native fees to community pool
if mint_price.denom != NATIVE_DENOM {
// only send non-zero amounts
// send portion to dev addr
if !network_fee.is_zero() {
ibc_denom_fair_burn(
coin(network_fee.u128(), mint_price.denom.to_string()),
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}
} else if !network_fee.is_zero() {
checked_fair_burn(
&info,
network_fee.u128(),
if !network_fee.is_zero() {
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
false,
Some(
deps.api
.addr_validate(&factory_params.extension.dev_fee_address)?,
),
&mut res,
)?;
}

Expand Down
15 changes: 7 additions & 8 deletions contracts/minters/vending-minter-featured/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro128PlusPlus;
use semver::Version;
use sg1::checked_fair_burn;
use sg1::{checked_fair_burn, distribute_mint_fees};
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -669,14 +669,13 @@ fn _execute_mint(

let network_fee = mint_price.amount * mint_fee;

// send non-native fees to community pool
let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string();

if !network_fee.is_zero() {
res = res.add_message(BankMsg::Send {
to_address: pa_dao.to_string(),
amount: vec![coin(network_fee.u128(), mint_price.denom.clone())],
});
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
true,
None,
)?;
}

let mintable_token_mapping = match token_id {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro128PlusPlus;
use semver::Version;
use sg1::checked_fair_burn;
use sg1::{checked_fair_burn, distribute_mint_fees};
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -708,13 +708,13 @@ fn _execute_mint(

let network_fee = mint_price.amount * mint_fee;

let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string();

if !network_fee.is_zero() {
res = res.add_message(BankMsg::Send {
to_address: pa_dao.to_string(),
amount: vec![coin(network_fee.u128(), mint_price.denom.clone())],
});
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
true,
None,
)?;
}

let mintable_token_mapping = match token_id {
Expand Down
23 changes: 9 additions & 14 deletions contracts/minters/vending-minter-merkle-wl/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro128PlusPlus;
use semver::Version;
use sg1::{checked_fair_burn, ibc_denom_fair_burn};
use sg1::{checked_fair_burn, distribute_mint_fees};
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME, NATIVE_DENOM};
use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME};
use sg_whitelist::msg::{
ConfigResponse as WhitelistConfigResponse, HasMemberResponse, QueryMsg as WhitelistQueryMsg,
};
Expand Down Expand Up @@ -708,18 +708,13 @@ fn _execute_mint(

let network_fee = mint_price.amount * mint_fee;

// send non-native fees to community pool
if mint_price.denom != NATIVE_DENOM {
// only send non-zero amounts
if !network_fee.is_zero() {
ibc_denom_fair_burn(
coin(network_fee.u128(), mint_price.clone().denom),
None,
&mut res,
)?;
}
} else {
checked_fair_burn(&info, network_fee.u128(), None, &mut res)?;
if !network_fee.is_zero() {
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
false,
None,
)?;
}

let mintable_token_mapping = match token_id {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro128PlusPlus;
use semver::Version;
use sg1::checked_fair_burn;
use sg1::{checked_fair_burn, distribute_mint_fees};
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -658,13 +658,13 @@ fn _execute_mint(
};
let network_fee = mint_price.amount * mint_fee;

let pa_dao = "stars159t8e03zlmgyekmdrpxnyf70rdky28v553kj53zsapqadaunt4wsmn5m3l".to_string();

if !network_fee.is_zero() {
res = res.add_message(BankMsg::Send {
to_address: pa_dao.to_string(),
amount: vec![coin(network_fee.u128(), mint_price.denom.clone())],
});
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
true,
None,
)?;
}

let mintable_token_mapping = match token_id {
Expand Down
22 changes: 9 additions & 13 deletions contracts/minters/vending-minter-wl-flex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use cw_utils::{may_pay, maybe_addr, nonpayable, parse_reply_instantiate_data};
use rand_core::{RngCore, SeedableRng};
use rand_xoshiro::Xoshiro128PlusPlus;
use semver::Version;
use sg1::{checked_fair_burn, ibc_denom_fair_burn};
use sg1::{checked_fair_burn, distribute_mint_fees};
use sg2::query::Sg2QueryMsg;
use sg4::{MinterConfig, Status, StatusResponse, SudoMsg};
use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg};
Expand Down Expand Up @@ -656,18 +656,14 @@ fn _execute_mint(
Decimal::bps(factory_params.mint_fee_bps)
};
let network_fee = mint_price.amount * mint_fee;
// use ibc_denom_fair_burn for non native denoms
if mint_price.denom != NATIVE_DENOM {
// only send non-zero amounts
if !network_fee.is_zero() {
ibc_denom_fair_burn(
coin(network_fee.u128(), mint_price.clone().denom),
None,
&mut res,
)?;
}
} else {
checked_fair_burn(&info, network_fee.u128(), None, &mut res)?;

if !network_fee.is_zero() {
distribute_mint_fees(
coin(network_fee.u128(), mint_price.clone().denom),
&mut res,
false,
None,
)?;
}

let mintable_token_mapping = match token_id {
Expand Down
Loading

0 comments on commit 3d74fa5

Please sign in to comment.