Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ thiserror = { workspace = true }
[features]
asset_base = []
crossmint = []
default = []
default = ["asset_base"]
library = []
8 changes: 4 additions & 4 deletions contracts/asset/src/contracts/asset_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
CONTRACT_NAME, CONTRACT_VERSION,
error::ContractResult,
msg::{AssetExtensionExecuteMsg, ExecuteMsg, InstantiateMsg},
traits::{AssetContract, DefaultAssetContract},
traits::DefaultAssetContract,
};
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw721::{
Expand All @@ -31,7 +31,7 @@ pub fn instantiate(
) -> ContractResult<Response> {
use crate::error::ContractError;

let contract: AssetBaseContract<'static> = AssetContract::default();
let contract: AssetBaseContract<'static> = DefaultAssetContract::default();

let response = contract
.instantiate_with_version(deps, &env, &info, msg, CONTRACT_NAME, CONTRACT_VERSION)
Expand All @@ -52,7 +52,7 @@ pub fn execute(
AssetExtensionExecuteMsg,
>,
) -> ContractResult<Response> {
let contract: AssetBaseContract<'static> = AssetContract::default();
let contract: AssetBaseContract<'static> = DefaultAssetContract::default();

contract
.execute_pluggable(deps, &env, &info, msg)
Expand All @@ -74,7 +74,7 @@ pub fn query(

use crate::error::ContractError;

let contract: AssetBaseContract<'static> = AssetContract::default();
let contract: AssetBaseContract<'static> = DefaultAssetContract::default();

contract
.query(deps, &env, msg)
Expand Down
26 changes: 12 additions & 14 deletions contracts/asset/src/default_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pub fn not_after_plugin(ctx: &mut PluginCtx<DefaultXionAssetContext, Empty>) ->
// can be made that exceeds 1 week from now
// this is to prevent an indefinite reservation that exceeds the time lock
pub fn time_lock_plugin(ctx: &mut PluginCtx<DefaultXionAssetContext, Empty>) -> StdResult<bool> {
if let Some(time_lock) = &ctx.data.time_lock {
if let Some(reservation) = &ctx.data.reservation {
if Expiration::AtTime(reservation.reserved_until).gt(&Expiration::AtTime(
if let Some(time_lock) = &ctx.data.time_lock
&& let Some(reservation) = &ctx.data.reservation
&& Expiration::AtTime(reservation.reserved_until).gt(&Expiration::AtTime(
ctx.env.block.time.plus_seconds(time_lock.as_secs()),
)) {
return Err(cosmwasm_std::StdError::generic_err(format!(
Expand All @@ -116,8 +116,6 @@ pub fn time_lock_plugin(ctx: &mut PluginCtx<DefaultXionAssetContext, Empty>) ->
Expiration::AtTime(ctx.env.block.time.plus_seconds(time_lock.as_secs()))
)));
}
}
}
Ok(true)
}

Expand Down Expand Up @@ -222,21 +220,21 @@ pub fn allowed_currencies_plugin(

let allowed_set: HashSet<&str> = allowed.iter().map(|d| d.denom.as_str()).collect();

if let Some(price) = &ctx.data.ask_price {
if !allowed_set.contains(price.denom.as_str()) {
if let Some(price) = &ctx.data.ask_price
&& !allowed_set.contains(price.denom.as_str()) {
return Err(cosmwasm_std::StdError::generic_err(
"ask price currency is not allowed",
));
}
}

if let Some(min_price) = &ctx.data.min_price {
if !allowed_set.contains(min_price.denom.as_str()) {
return Err(cosmwasm_std::StdError::generic_err(
"minimum price currency is not allowed",
));
if let Some(min_price) = &ctx.data.min_price
&& !allowed_set.contains(min_price.denom.as_str()) {
{
return Err(cosmwasm_std::StdError::generic_err(
"minimum price currency is not allowed",
));
}
}
}

for coin in &ctx.info.funds {
if !allowed_set.contains(coin.denom.as_str()) {
Expand Down
5 changes: 2 additions & 3 deletions contracts/asset/src/execute/reservation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ where
});
}

if let Some(reserved) = &listing.reserved {
if !Expiration::AtTime(reserved.reserved_until).is_expired(&env.block) {
if let Some(reserved) = &listing.reserved
&& !Expiration::AtTime(reserved.reserved_until).is_expired(&env.block) {
return Err(ContractError::ReservedAsset { id: id.clone() });
}
}

let reserver = if let Some(reserver) = reservation.reserver {
deps.api.addr_validate(&reserver)?
Expand Down
Loading