From fb94f617a84106a056b317c097ca7db859100c2e Mon Sep 17 00:00:00 2001 From: Daniel Gabriele Date: Sun, 26 Nov 2023 19:49:32 -0500 Subject: [PATCH] &str to string --- contracts/minters/base-minter/src/contract.rs | 5 ++--- .../open-edition-minter/src/contract.rs | 3 +-- .../vending-minter-wl-flex/src/contract.rs | 3 +-- .../minters/vending-minter/src/contract.rs | 3 +-- packages/sg2/src/lib.rs | 19 +------------------ .../setup_minter/base_minter/mock_params.rs | 1 + .../open_edition_minter/mock_params.rs | 3 +++ .../vending_minter/mock_params.rs | 1 + .../tests/ibc_asset_mint.rs | 3 +++ 9 files changed, 14 insertions(+), 27 deletions(-) diff --git a/contracts/minters/base-minter/src/contract.rs b/contracts/minters/base-minter/src/contract.rs index 1f006c362..cd917a6c3 100644 --- a/contracts/minters/base-minter/src/contract.rs +++ b/contracts/minters/base-minter/src/contract.rs @@ -13,7 +13,6 @@ use cw2::set_contract_version; use cw_utils::{must_pay, nonpayable, parse_reply_instantiate_data}; use sg1::checked_fair_burn; use sg2::query::Sg2QueryMsg; -use sg2::UriScheme; use sg4::{QueryMsg, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; use sg721_base::msg::{CollectionInfoResponse, QueryMsg as Sg721QueryMsg}; @@ -53,7 +52,7 @@ pub fn instantiate( uri_scheme: factory_params .params .uri_scheme - .unwrap_or(UriScheme::Ipfs) + .unwrap_or("ipfs".to_owned()) .to_string(), extension: Empty {}, }; @@ -122,7 +121,7 @@ pub fn execute_mint_sender( ) -> Result { let config = CONFIG.load(deps.storage)?; let collection_address = COLLECTION_ADDRESS.load(deps.storage)?; - let token_uri = token_uri.trim(); + let token_uri = token_uri.trim().to_owned(); // This is a 1:1 minter, minted at min_mint_price // Should mint and then list on the marketplace for secondary sales diff --git a/contracts/minters/open-edition-minter/src/contract.rs b/contracts/minters/open-edition-minter/src/contract.rs index 0de555dfe..4ae28edc4 100644 --- a/contracts/minters/open-edition-minter/src/contract.rs +++ b/contracts/minters/open-edition-minter/src/contract.rs @@ -21,7 +21,6 @@ use open_edition_factory::types::NftMetadataType; use semver::Version; use sg1::{checked_fair_burn, ibc_denom_fair_burn}; use sg2::query::Sg2QueryMsg; -use sg2::UriScheme; use sg4::{Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; use sg_std::{StargazeMsgWrapper, NATIVE_DENOM}; @@ -59,7 +58,7 @@ pub fn instantiate( let uri_scheme = factory_params .uri_scheme - .unwrap_or(UriScheme::Ipfs) + .unwrap_or("ipfs".to_owned()) .to_string(); match msg.init_msg.nft_data.nft_data_type { diff --git a/contracts/minters/vending-minter-wl-flex/src/contract.rs b/contracts/minters/vending-minter-wl-flex/src/contract.rs index cdfc0b134..ed7b2dd09 100644 --- a/contracts/minters/vending-minter-wl-flex/src/contract.rs +++ b/contracts/minters/vending-minter-wl-flex/src/contract.rs @@ -22,7 +22,6 @@ use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; use sg1::{checked_fair_burn, ibc_denom_fair_burn}; use sg2::query::Sg2QueryMsg; -use sg2::UriScheme; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME, NATIVE_DENOM}; @@ -75,7 +74,7 @@ pub fn instantiate( let uri_scheme = factory_params .uri_scheme - .unwrap_or(UriScheme::Ipfs) + .unwrap_or("ipfs".to_owned()) .to_string(); // sanitize base token uri diff --git a/contracts/minters/vending-minter/src/contract.rs b/contracts/minters/vending-minter/src/contract.rs index 12eb0a1d0..7cf8c4daa 100644 --- a/contracts/minters/vending-minter/src/contract.rs +++ b/contracts/minters/vending-minter/src/contract.rs @@ -23,7 +23,6 @@ use rand_xoshiro::Xoshiro128PlusPlus; use semver::Version; use sg1::{checked_fair_burn, ibc_denom_fair_burn}; use sg2::query::Sg2QueryMsg; -use sg2::UriScheme; use sg4::{MinterConfig, Status, StatusResponse, SudoMsg}; use sg721::{ExecuteMsg as Sg721ExecuteMsg, InstantiateMsg as Sg721InstantiateMsg}; use sg_std::{StargazeMsgWrapper, GENESIS_MINT_START_TIME, NATIVE_DENOM}; @@ -90,7 +89,7 @@ pub fn instantiate( let uri_scheme = factory_params .uri_scheme - .unwrap_or(UriScheme::Ipfs) + .unwrap_or("ipfs".to_owned()) .to_string(); // sanitize base token uri diff --git a/packages/sg2/src/lib.rs b/packages/sg2/src/lib.rs index 272a36533..2827c6f64 100644 --- a/packages/sg2/src/lib.rs +++ b/packages/sg2/src/lib.rs @@ -1,5 +1,3 @@ -use core::fmt; - use cosmwasm_schema::cw_serde; use cosmwasm_std::Coin; @@ -20,21 +18,6 @@ pub struct MinterParams { pub min_mint_price: Coin, pub mint_fee_bps: u64, pub max_trading_offset_secs: u64, - pub uri_scheme: Option, + pub uri_scheme: Option, pub extension: T, } - -#[cw_serde] -pub enum UriScheme { - Https, - Ipfs, -} - -impl fmt::Display for UriScheme { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Self::Ipfs => write!(f, "ipfs"), - Self::Https => write!(f, "https"), - } - } -} diff --git a/test-suite/src/common_setup/setup_minter/base_minter/mock_params.rs b/test-suite/src/common_setup/setup_minter/base_minter/mock_params.rs index 443b7a9a7..98a8ef761 100644 --- a/test-suite/src/common_setup/setup_minter/base_minter/mock_params.rs +++ b/test-suite/src/common_setup/setup_minter/base_minter/mock_params.rs @@ -17,6 +17,7 @@ pub fn mock_params() -> BaseMinterParams { mint_fee_bps: MINT_FEE_BPS, max_trading_offset_secs: 60 * 60 * 24 * 7, extension: None, + uri_scheme: Some("ipfs".to_owned()), } } diff --git a/test-suite/src/common_setup/setup_minter/open_edition_minter/mock_params.rs b/test-suite/src/common_setup/setup_minter/open_edition_minter/mock_params.rs index b473aca6b..b01edf57e 100644 --- a/test-suite/src/common_setup/setup_minter/open_edition_minter/mock_params.rs +++ b/test-suite/src/common_setup/setup_minter/open_edition_minter/mock_params.rs @@ -72,6 +72,7 @@ pub fn mock_params_proper() -> OpenEditionMinterParams { min_mint_price: coin(MIN_MINT_PRICE_OPEN_EDITION, NATIVE_DENOM), mint_fee_bps: MINT_FEE_FAIR_BURN, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100, @@ -98,6 +99,7 @@ pub fn mock_params_custom(custom_params: OpenEditionMinterCustomParams) -> OpenE min_mint_price: coin(MIN_MINT_PRICE_OPEN_EDITION, denom), mint_fee_bps, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100, @@ -122,6 +124,7 @@ pub fn mock_params_custom_min_mint_price( min_mint_price, mint_fee_bps: MINT_FEE_FAIR_BURN, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100, diff --git a/test-suite/src/common_setup/setup_minter/vending_minter/mock_params.rs b/test-suite/src/common_setup/setup_minter/vending_minter/mock_params.rs index 3339e0248..676abca94 100644 --- a/test-suite/src/common_setup/setup_minter/vending_minter/mock_params.rs +++ b/test-suite/src/common_setup/setup_minter/vending_minter/mock_params.rs @@ -59,6 +59,7 @@ pub fn mock_params(mint_denom: Option) -> VendingMinterParams { ), mint_fee_bps: MINT_FEE_FAIR_BURN, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_token_limit: MAX_TOKEN_LIMIT, max_per_address_limit: MAX_PER_ADDRESS_LIMIT, diff --git a/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs b/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs index 1d4e05f3f..8a65be444 100644 --- a/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs +++ b/test-suite/src/open_edition_minter/tests/ibc_asset_mint.rs @@ -45,6 +45,7 @@ fn check_custom_create_minter_denom() { min_mint_price: init_msg.mint_price.clone(), mint_fee_bps: MINT_FEE_FAIR_BURN, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100, @@ -121,6 +122,7 @@ fn one_hundred_percent_burned_ibc_minter() { min_mint_price: init_msg.mint_price.clone(), mint_fee_bps: 10000, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100, @@ -202,6 +204,7 @@ fn zero_mint_fee() { min_mint_price: init_msg.mint_price.clone(), mint_fee_bps: 0, max_trading_offset_secs: 60 * 60 * 24 * 7, + uri_scheme: Some("ipfs".to_owned()), extension: ParamsExtension { max_per_address_limit: 10, airdrop_mint_fee_bps: 100,