Skip to content

Commit adf1db5

Browse files
committed
fix: Marketing: remove collection stuff from contract, cargo check
1 parent 00c98fc commit adf1db5

File tree

3 files changed

+18
-119
lines changed

3 files changed

+18
-119
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cw-contracts/marketing/src/contract.rs

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct Banner {
1414
}
1515

1616
#[cw_serde]
17-
pub struct Action {
17+
pub struct NewsAction {
1818
pub label: String,
1919
pub url: String,
2020
}
@@ -25,17 +25,7 @@ pub struct News {
2525
pub subtitle: String,
2626
pub text: String,
2727
pub image: String,
28-
pub actions: Option<Vec<Action>>,
29-
}
30-
31-
#[cw_serde]
32-
pub struct MarketingCollectionPreview {
33-
pub address: String,
34-
pub image_uri: String,
35-
pub collection_name: String,
36-
pub creator_name: String,
37-
pub twitter_url: String,
38-
pub secondary_during_mint: bool,
28+
pub actions: Option<Vec<NewsAction>>,
3929
}
4030

4131
#[cw_serde]
@@ -47,9 +37,6 @@ pub struct MarketingContract {
4737
pub(crate) config: Item<'static, Config>,
4838
pub(crate) banners: Map<'static, u64, Banner>,
4939
pub(crate) news: Map<'static, u64, News>,
50-
pub(crate) upcoming_collections: Map<'static, u64, MarketingCollectionPreview>,
51-
pub(crate) live_collections: Map<'static, u64, MarketingCollectionPreview>,
52-
pub(crate) highlighted_collections: Map<'static, u64, MarketingCollectionPreview>,
5340
}
5441

5542
#[entry_points]
@@ -61,9 +48,6 @@ impl MarketingContract {
6148
config: Item::new("config"),
6249
banners: Map::new("banners"),
6350
news: Map::new("news"),
64-
upcoming_collections: Map::new("upcoming_collections"),
65-
live_collections: Map::new("live_collections"),
66-
highlighted_collections: Map::new("highlighted_collections"),
6751
}
6852
}
6953

@@ -142,72 +126,6 @@ impl MarketingContract {
142126
Ok(Response::new().add_attributes(attributes))
143127
}
144128

145-
#[msg(exec)]
146-
// Only the admin can execute it
147-
pub fn update_live_collections(
148-
&self,
149-
ctx: ExecCtx,
150-
live_collections: Vec<MarketingCollectionPreview>,
151-
) -> Result<Response, ContractError> {
152-
let attributes = vec![attr("action", "update_live_collections")];
153-
let config = self.config.load(ctx.deps.storage)?;
154-
// Permission check
155-
if ctx.info.sender != config.admin_addr {
156-
return Err(ContractError::Unauthorized);
157-
}
158-
// Replace all live_collections with the new ones
159-
self.live_collections.clear(ctx.deps.storage);
160-
for (index, live_collection) in live_collections.into_iter().enumerate() {
161-
self.live_collections.save(ctx.deps.storage, index as u64, &live_collection)?;
162-
}
163-
164-
Ok(Response::new().add_attributes(attributes))
165-
}
166-
167-
#[msg(exec)]
168-
// Only the admin can execute it
169-
pub fn update_upcoming_collections(
170-
&self,
171-
ctx: ExecCtx,
172-
upcoming_collections: Vec<MarketingCollectionPreview>,
173-
) -> Result<Response, ContractError> {
174-
let attributes = vec![attr("action", "update_upcoming_collections")];
175-
let config = self.config.load(ctx.deps.storage)?;
176-
// Permission check
177-
if ctx.info.sender != config.admin_addr {
178-
return Err(ContractError::Unauthorized);
179-
}
180-
// Replace all upcoming_collections with the new ones
181-
self.upcoming_collections.clear(ctx.deps.storage);
182-
for (index, upcoming_collection) in upcoming_collections.into_iter().enumerate() {
183-
self.upcoming_collections.save(ctx.deps.storage, index as u64, &upcoming_collection)?;
184-
}
185-
186-
Ok(Response::new().add_attributes(attributes))
187-
}
188-
189-
#[msg(exec)]
190-
// Only the admin can execute it
191-
pub fn update_highlighted_collections(
192-
&self,
193-
ctx: ExecCtx,
194-
highlighted_collections: Vec<MarketingCollectionPreview>,
195-
) -> Result<Response, ContractError> {
196-
let attributes = vec![attr("action", "update_highlighted_collections")];
197-
let config = self.config.load(ctx.deps.storage)?;
198-
// Permission check
199-
if ctx.info.sender != config.admin_addr {
200-
return Err(ContractError::Unauthorized);
201-
}
202-
// Replace all highlighted_collections with the new ones
203-
self.highlighted_collections.clear(ctx.deps.storage);
204-
for (index, highlighted_collection) in highlighted_collections.into_iter().enumerate() {
205-
self.highlighted_collections.save(ctx.deps.storage, index as u64, &highlighted_collection)?;
206-
}
207-
208-
Ok(Response::new().add_attributes(attributes))
209-
}
210-
211129
#[msg(query)]
212130
pub fn get_config(&self, ctx: QueryCtx) -> StdResult<Config> {
213131
let config = self.config.load(ctx.deps.storage)?;
@@ -235,39 +153,6 @@ impl MarketingContract {
235153

236154
Ok(news)
237155
}
238-
239-
#[msg(query)]
240-
pub fn get_live_collections(&self, ctx: QueryCtx) -> StdResult<Vec<MarketingCollectionPreview>> {
241-
let live_collections: Vec<MarketingCollectionPreview> = self
242-
.live_collections
243-
.range(ctx.deps.storage, None, None, cosmwasm_std::Order::Ascending)
244-
.map(|item| item.map(|(_, live_collection)| live_collection))
245-
.collect::<StdResult<Vec<MarketingCollectionPreview>>>()?;
246-
247-
Ok(live_collections)
248-
}
249-
250-
#[msg(query)]
251-
pub fn get_upcoming_collections(&self, ctx: QueryCtx) -> StdResult<Vec<MarketingCollectionPreview>> {
252-
let upcoming_collections: Vec<MarketingCollectionPreview> = self
253-
.upcoming_collections
254-
.range(ctx.deps.storage, None, None, cosmwasm_std::Order::Ascending)
255-
.map(|item| item.map(|(_, upcoming_collection)| upcoming_collection))
256-
.collect::<StdResult<Vec<MarketingCollectionPreview>>>()?;
257-
258-
Ok(upcoming_collections)
259-
}
260-
261-
#[msg(query)]
262-
pub fn get_highlighted_collections(&self, ctx: QueryCtx) -> StdResult<Vec<MarketingCollectionPreview>> {
263-
let highlighted_collections: Vec<MarketingCollectionPreview> = self
264-
.highlighted_collections
265-
.range(ctx.deps.storage, None, None, cosmwasm_std::Order::Ascending)
266-
.map(|item| item.map(|(_, highlighted_collection)| highlighted_collection))
267-
.collect::<StdResult<Vec<MarketingCollectionPreview>>>()?;
268-
269-
Ok(highlighted_collections)
270-
}
271156
}
272157

273158

rust/cw-contracts/marketing/src/multitest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use sylvia::multitest::App;
22

3-
use crate::contract::{multitest_utils::CodeId, Action, News};
3+
use crate::contract::{multitest_utils::CodeId, NewsAction, News};
44
use crate::error::ContractError;
55

66
#[test]
@@ -13,7 +13,7 @@ fn basic_full_flow() {
1313
let contract_creator = "creator";
1414
let unauthorized_sender = "unauthorized_sender";
1515

16-
let action = Action {
16+
let action = NewsAction {
1717
label: "".to_string(),
1818
url: "".to_string()
1919
};

0 commit comments

Comments
 (0)