diff --git a/contracts/collections/sg721-base/src/contract.rs b/contracts/collections/sg721-base/src/contract.rs index f39d00e0e..d564e99e1 100644 --- a/contracts/collections/sg721-base/src/contract.rs +++ b/contracts/collections/sg721-base/src/contract.rs @@ -207,6 +207,11 @@ where return Err(ContractError::Unauthorized {}); } + if let Some(new_creator) = collection_msg.creator { + deps.api.addr_validate(&new_creator)?; + collection.creator = new_creator; + } + collection.description = collection_msg .description .unwrap_or_else(|| collection.description.to_string()); diff --git a/packages/mint-hooks/derive/src/lib.rs b/packages/mint-hooks/derive/src/lib.rs index 68213e8d2..e02bda1e5 100644 --- a/packages/mint-hooks/derive/src/lib.rs +++ b/packages/mint-hooks/derive/src/lib.rs @@ -19,10 +19,7 @@ fn merge_variants(metadata: TokenStream, left: TokenStream, right: TokenStream) // parse the left enum let mut left: DeriveInput = parse_macro_input!(left); - let Enum(DataEnum { - variants, - .. - }) = &mut left.data else { + let Enum(DataEnum { variants, .. }) = &mut left.data else { return syn::Error::new(left.ident.span(), "only enums can accept variants") .to_compile_error() .into(); @@ -31,16 +28,16 @@ fn merge_variants(metadata: TokenStream, left: TokenStream, right: TokenStream) // parse the right enum let right: DeriveInput = parse_macro_input!(right); let Enum(DataEnum { - variants: to_add, - .. - }) = right.data else { + variants: to_add, .. + }) = right.data + else { return syn::Error::new(left.ident.span(), "only enums can provide variants") .to_compile_error() .into(); }; // insert variants from the right to the left - variants.extend(to_add.into_iter()); + variants.extend(to_add); quote! { #left }.into() } diff --git a/packages/sg721/src/lib.rs b/packages/sg721/src/lib.rs index 6f7ffcb45..d7008c68f 100644 --- a/packages/sg721/src/lib.rs +++ b/packages/sg721/src/lib.rs @@ -89,6 +89,7 @@ pub struct UpdateCollectionInfoMsg { pub external_link: Option>, pub explicit_content: Option, pub royalty_info: Option>, + pub creator: Option, } #[cw_serde] diff --git a/test-suite/src/sg721_base/tests/integration_tests.rs b/test-suite/src/sg721_base/tests/integration_tests.rs index bd2c6b14d..dc09ea2f9 100644 --- a/test-suite/src/sg721_base/tests/integration_tests.rs +++ b/test-suite/src/sg721_base/tests/integration_tests.rs @@ -279,6 +279,7 @@ mod tests { contract, &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: None, image: None, external_link: None, @@ -290,6 +291,7 @@ mod tests { ); assert!(res.is_err()); } + #[test] fn update_collection_info() { // customize params so external_link is None @@ -313,6 +315,7 @@ mod tests { let (mut app, contract) = custom_proper_instantiate(custom_create_minter_msg); let creator = Addr::unchecked("creator".to_string()); + let new_creator = Addr::unchecked("new_creator".to_string()); // succeeds let res = app.execute_contract( @@ -320,6 +323,7 @@ mod tests { contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), @@ -341,6 +345,7 @@ mod tests { contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), @@ -374,6 +379,7 @@ mod tests { contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), @@ -401,6 +407,7 @@ mod tests { contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), @@ -419,20 +426,21 @@ mod tests { ); // raise royalty_info by 2% succeeds - let royalty_info: Option = Some(RoyaltyInfoResponse { + let royalty_info: RoyaltyInfoResponse = RoyaltyInfoResponse { payment_address: creator.to_string(), share: Decimal::percent(9), - }); + }; let res = app.execute_contract( creator.clone(), contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), explicit_content: None, - royalty_info: Some(royalty_info.clone()), + royalty_info: Some(Some(royalty_info.clone())), }, }, &[], @@ -443,14 +451,15 @@ mod tests { .wrap() .query_wasm_smart(contract.clone(), &QueryMsg::CollectionInfo {}) .unwrap(); - assert_eq!(res.royalty_info.unwrap(), royalty_info.unwrap()); + assert_eq!(res.royalty_info.unwrap(), royalty_info); - // update explicit content + // update explicit content with new creator let res = app.execute_contract( creator.clone(), contract.clone(), &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: Some(new_creator.to_string()), description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link.clone()), @@ -479,7 +488,7 @@ mod tests { assert!(res.is_err()); // freeze collection to prevent further updates let res = app.execute_contract( - creator.clone(), + new_creator.clone(), contract.clone(), &Sg721ExecuteMsg::::FreezeCollectionInfo {}, &[], @@ -488,10 +497,11 @@ mod tests { // trying to update collection after frozen should throw err let res = app.execute_contract( - creator, + new_creator, contract, &Sg721ExecuteMsg::::UpdateCollectionInfo { collection_info: UpdateCollectionInfoMsg { + creator: None, description: Some(params.info.description.clone()), image: Some(params.info.image.clone()), external_link: Some(params.info.external_link),