diff --git a/cosmwasm-contracts/marketing/src/contract.rs b/cosmwasm-contracts/marketing/src/contract.rs index 98063d4f98..21649f10de 100644 --- a/cosmwasm-contracts/marketing/src/contract.rs +++ b/cosmwasm-contracts/marketing/src/contract.rs @@ -11,6 +11,7 @@ pub struct MarketingContract { pub(crate) news: Map, pub(crate) upcoming_collections: Map, pub(crate) live_collections: Map, + pub(crate) highlighted_collections: Map, } #[entry_points] @@ -33,12 +34,14 @@ impl MarketingContract { , news: Option> , upcoming_collections: Option> , live_collections: Option> + , highlighted_collections: Option> ) -> StdResult { self.config.save(deps.storage, &config)?; self.banners.save(deps.storage, &banners)?; self.news.save(deps.storage, &news)?; self.upcoming_collections.save(deps.storage, &upcoming_collections)?; self.live_collections.save(deps.storage, &live_collections)?; + self.highlighted_collections.save(deps.storage, &highlighted_collections)?; Ok(Response::default()) } @@ -134,6 +137,23 @@ impl MarketingContract { Ok(Response::new().add_attributes(attributes)) } + #[msg(exec)] + // Only the admin can execute it + pub fn update_highlighted_collections( + &self, + ctx: ExecCtx, + collections: Vec, + ) -> Result { + let mut attributes = vec![attr("action", "update_highlighted_collections")]; + // Permission check + if ctx.info.sender != config.admin_addr { + return Err(ContractError::Unauthorized); + } + self.highlighted_collections.save(ctx.deps.storage, &collections)?; + + Ok(Response::new().add_attributes(attributes)) + } + #[msg(query)] pub fn get_config(&self, ctx: QueryCtx) -> StdResult { let config = self.config.load(ctx.deps.storage)?; @@ -163,6 +183,12 @@ impl MarketingContract { let upcoming_collections = self.upcoming_collections.load(ctx.deps.storage)?; Ok(upcoming_collections) } + + #[msg(query)] + pub fn get_highlighted_collections(&self, ctx: QueryCtx) -> StdResult> { + let highlighted_collections = self.highlighted_collections.load(ctx.deps.storage)?; + Ok(highlighted_collections) + } } #[cw_serde]