difftreelog
Add properties extrinsics
in: master
10 files changed
pallets/common/src/lib.rsdiffbeforeafterboth736 ) -> DispatchResult {736 ) -> DispatchResult {737 collection.check_is_owner_or_admin(sender)?;737 collection.check_is_owner_or_admin(sender)?;738738739 CollectionProperties::<T>::get(collection.id).try_change_property(property)?;739 CollectionProperties::<T>::try_mutate(740 collection.id,741 |properties| properties.try_change_property(property.clone())742 )?;743744 <Pallet<T>>::deposit_event(Event::CollectionPropertySet(collection.id, property));740745741 Ok(())746 Ok(())742 }747 }748749 pub fn change_collection_properties(750 collection: &CollectionHandle<T>,751 sender: &T::CrossAccountId,752 properties: Vec<Property>,753 ) -> DispatchResult {754 for property in properties {755 Self::change_collection_property(collection, sender, property)?;756 }757758 Ok(())759 }743760744 pub fn change_property_permission(761 pub fn change_property_permission(745 collection: &CollectionHandle<T>,762 collection: &CollectionHandle<T>,909 fn create_multiple_items(amount: u32) -> Weight;926 fn create_multiple_items(amount: u32) -> Weight;910 fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;927 fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;911 fn burn_item() -> Weight;928 fn burn_item() -> Weight;912 fn set_property() -> Weight;929 fn change_collection_properties(amount: u32) -> Weight;930 fn change_token_properties(amount: u32) -> Weight;913 fn transfer() -> Weight;931 fn transfer() -> Weight;914 fn approve() -> Weight;932 fn approve() -> Weight;915 fn transfer_from() -> Weight;933 fn transfer_from() -> Weight;945 amount: u128,963 amount: u128,946 ) -> DispatchResultWithPostInfo;964 ) -> DispatchResultWithPostInfo;947965948 fn change_collection_property(966 fn change_collection_properties(949 &self,967 &self,950 sender: T::CrossAccountId,968 sender: T::CrossAccountId,951 property: Property,969 properties: Vec<Property>,952 ) -> DispatchResultWithPostInfo;970 ) -> DispatchResultWithPostInfo;953971954 fn change_token_property(972 fn change_token_properties(955 &self,973 &self,956 sender: T::CrossAccountId,974 sender: T::CrossAccountId,957 token_id: TokenId,975 token_id: TokenId,958 property: Property,976 property: Vec<Property>,959 ) -> DispatchResultWithPostInfo;977 ) -> DispatchResultWithPostInfo;960978961 fn transfer(979 fn transfer(pallets/fungible/src/common.rsdiffbeforeafterboth50 <SelfWeightOf<T>>::burn_item()50 <SelfWeightOf<T>>::burn_item()51 }51 }5253 fn change_collection_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::change_collection_properties(amount)55 }525653 fn set_property() -> Weight {57 fn change_token_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::set_property()58 <SelfWeightOf<T>>::change_token_properties(amount)55 }59 }566057 fn transfer() -> Weight {61 fn transfer() -> Weight {229 )233 )230 }234 }231235232 fn change_collection_property(236 fn change_collection_properties(233 &self,237 &self,234 _sender: T::CrossAccountId,238 _sender: T::CrossAccountId,235 _property: Property,239 _property: Vec<Property>,236 ) -> DispatchResultWithPostInfo {240 ) -> DispatchResultWithPostInfo {237 fail!(<Error<T>>::PropertiesNotAllowed)241 fail!(<Error<T>>::PropertiesNotAllowed)238 }242 }239243240 fn change_token_property(244 fn change_token_properties(241 &self,245 &self,242 _sender: T::CrossAccountId,246 _sender: T::CrossAccountId,243 _token_id: TokenId,247 _token_id: TokenId,244 _property: Property,248 _property: Vec<Property>,245 ) -> DispatchResultWithPostInfo {249 ) -> DispatchResultWithPostInfo {246 fail!(<Error<T>>::PropertiesNotAllowed)250 fail!(<Error<T>>::PropertiesNotAllowed)247 }251 }pallets/fungible/src/weights.rsdiffbeforeafterboth35 fn create_item() -> Weight;35 fn create_item() -> Weight;36 fn create_multiple_items_ex(b: u32, ) -> Weight;36 fn create_multiple_items_ex(b: u32, ) -> Weight;37 fn burn_item() -> Weight;37 fn burn_item() -> Weight;38 fn set_property() -> Weight;38 fn change_collection_properties(amount: u32) -> Weight;39 fn change_token_properties(amount: u32) -> Weight;39 fn transfer() -> Weight;40 fn transfer() -> Weight;40 fn approve() -> Weight;41 fn approve() -> Weight;41 fn transfer_from() -> Weight;42 fn transfer_from() -> Weight;71 .saturating_add(T::DbWeight::get().writes(2 as Weight))72 .saturating_add(T::DbWeight::get().writes(2 as Weight))72 }73 }737474 fn set_property() -> Weight {75 fn change_collection_properties(amount: u32) -> Weight {75 // Error76 // Error76 077 077 }78 }7980 fn change_token_properties(amount: u32) -> Weight {81 // Error82 083 }788479 // Storage: Fungible Balance (r:2 w:2)85 // Storage: Fungible Balance (r:2 w:2)80 fn transfer() -> Weight {86 fn transfer() -> Weight {134 .saturating_add(RocksDbWeight::get().writes(2 as Weight))140 .saturating_add(RocksDbWeight::get().writes(2 as Weight))135 }141 }136142137 fn set_property() -> Weight {143 fn change_collection_properties(amount: u32) -> Weight {138 // Error144 // Error139 0145 0140 }146 }147148 fn change_token_properties(amount: u32) -> Weight {149 // Error150 0151 }141152142 // Storage: Fungible Balance (r:2 w:2)153 // Storage: Fungible Balance (r:2 w:2)143 fn transfer() -> Weight {154 fn transfer() -> Weight {pallets/nonfungible/src/common.rsdiffbeforeafterboth50 <SelfWeightOf<T>>::burn_item()50 <SelfWeightOf<T>>::burn_item()51 }51 }5253 fn change_collection_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::change_collection_properties(amount)55 }525653 fn set_property() -> Weight {57 fn change_token_properties(amount: u32) -> Weight {54 <SelfWeightOf<T>>::set_property()58 <SelfWeightOf<T>>::change_token_properties(amount)55 }59 }566057 fn transfer() -> Weight {61 fn transfer() -> Weight {145 )149 )146 }150 }151152 fn change_collection_properties(153 &self,154 sender: T::CrossAccountId,155 properties: Vec<Property>,156 ) -> DispatchResultWithPostInfo {157 let weight = <CommonWeights<T>>::change_collection_properties(properties.len() as u32);158159 with_weight(160 <Pallet<T>>::change_collection_properties(self, &sender, properties),161 weight162 )163 }164165 fn change_token_properties(166 &self,167 sender: T::CrossAccountId,168 token_id: TokenId,169 properties: Vec<Property>,170 ) -> DispatchResultWithPostInfo {171 let weight = <CommonWeights<T>>::change_token_properties(properties.len() as u32);172173 with_weight(174 <Pallet<T>>::change_token_properties(self, &sender, token_id, properties),175 weight176 )177 }147178148 fn burn_item(179 fn burn_item(149 &self,180 &self,241 }272 }242 }273 }243244 fn change_collection_property(245 &self,246 sender: T::CrossAccountId,247 property: Property,248 ) -> DispatchResultWithPostInfo {249 // let token_id = None;250 with_weight(251 // <Pallet<T>>::change_property(self, &sender, token_id, property),252 Ok(()),253 <CommonWeights<T>>::set_property(),254 )255 }256257 fn change_token_property(258 &self,259 sender: T::CrossAccountId,260 token_id: TokenId,261 property: Property,262 ) -> DispatchResultWithPostInfo {263 with_weight(264 // <Pallet<T>>::change_property(self, &sender, Some(token_id), property),265 Ok(()),266 <CommonWeights<T>>::set_property(),267 )268 }269274270 fn set_variable_metadata(275 fn set_variable_metadata(271 &self,276 &self,pallets/nonfungible/src/lib.rsdiffbeforeafterboth265 .map(|p| p.clone())265 .map(|p| p.clone())266 .unwrap_or(PropertyPermission::None);266 .unwrap_or(PropertyPermission::None);267267268 let check_token_owner = || -> DispatchResult {269 let token_data = <TokenData<T>>::get((collection.id, token_id))268 let token_data = <TokenData<T>>::get((collection.id, token_id))270 .ok_or(<CommonError<T>>::TokenNotFound)?;269 .ok_or(<CommonError<T>>::TokenNotFound)?;271270271 let check_token_owner = || -> DispatchResult {272 ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);272 ensure!(&token_data.owner == sender, <CommonError<T>>::NoPermission);273274 Ok(())273 Ok(())275 };274 };276275277 let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))276 let is_property_exists = TokenProperties::<T>::get((collection.id, token_id))278 .get_property(&property.key)277 .get_property(&property.key)304 Ok(())303 Ok(())305 }304 }305306 pub fn change_token_properties(307 collection: &NonfungibleHandle<T>,308 sender: &T::CrossAccountId,309 token_id: TokenId,310 properties: Vec<Property>,311 ) -> DispatchResult {312 for property in properties {313 Self::change_token_property(collection, sender, token_id, property)?;314 }315316 Ok(())317 }318319 pub fn change_collection_properties(320 collection: &NonfungibleHandle<T>,321 sender: &T::CrossAccountId,322 properties: Vec<Property>,323 ) -> DispatchResult {324 <PalletCommon<T>>::change_collection_properties(collection, sender, properties)325 }306326307 pub fn transfer(327 pub fn transfer(308 collection: &NonfungibleHandle<T>,328 collection: &NonfungibleHandle<T>,pallets/nonfungible/src/weights.rsdiffbeforeafterboth36 fn create_multiple_items(b: u32, ) -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;37 fn create_multiple_items_ex(b: u32, ) -> Weight;38 fn burn_item() -> Weight;38 fn burn_item() -> Weight;39 fn set_property() -> Weight;39 fn change_collection_properties(amount: u32) -> Weight;40 fn change_token_properties(amount: u32) -> Weight;40 fn transfer() -> Weight;41 fn transfer() -> Weight;41 fn approve() -> Weight;42 fn approve() -> Weight;42 fn transfer_from() -> Weight;43 fn transfer_from() -> Weight;92 .saturating_add(T::DbWeight::get().writes(4 as Weight))93 .saturating_add(T::DbWeight::get().writes(4 as Weight))93 }94 }9596 fn change_collection_properties(amount: u32) -> Weight {97 // TODO calculate appropriate weight98 (50_000_000 as Weight).saturating_mul(amount as Weight)99 }9410095 fn set_property() -> Weight {101 fn change_token_properties(amount: u32) -> Weight {96 // TODO calculate appropriate weight102 // TODO calculate appropriate weight97 50_000_000 as Weight103 (50_000_000 as Weight).saturating_mul(amount as Weight)98 }104 }99105100 // Storage: Nonfungible TokenData (r:1 w:1)106 // Storage: Nonfungible TokenData (r:1 w:1)187 .saturating_add(RocksDbWeight::get().writes(4 as Weight))193 .saturating_add(RocksDbWeight::get().writes(4 as Weight))188 }194 }195196 fn change_collection_properties(amount: u32) -> Weight {197 // TODO calculate appropriate weight198 (50_000_000 as Weight).saturating_mul(amount as Weight)199 }189200190 fn set_property() -> Weight {201 fn change_token_properties(amount: u32) -> Weight {191 // TODO calculate appropriate weight202 // TODO calculate appropriate weight192 50_000_000 as Weight203 (50_000_000 as Weight).saturating_mul(amount as Weight)193 }204 }194205195 // Storage: Nonfungible TokenData (r:1 w:1)206 // Storage: Nonfungible TokenData (r:1 w:1)pallets/refungible/src/common.rsdiffbeforeafterboth66 max_weight_of!(burn_item_partial(), burn_item_fully())66 max_weight_of!(burn_item_partial(), burn_item_fully())67 }67 }6869 fn change_collection_properties(amount: u32) -> Weight {70 <SelfWeightOf<T>>::change_collection_properties(amount)71 }687269 fn set_property() -> Weight {73 fn change_token_properties(amount: u32) -> Weight {70 <SelfWeightOf<T>>::set_property()74 <SelfWeightOf<T>>::change_token_properties(amount)71 }75 }727673 fn transfer() -> Weight {77 fn transfer() -> Weight {248 )252 )249 }253 }250254251 fn change_collection_property(255 fn change_collection_properties(252 &self,256 &self,253 _sender: T::CrossAccountId,257 _sender: T::CrossAccountId,254 _property: Property,258 _property: Vec<Property>,255 ) -> DispatchResultWithPostInfo {259 ) -> DispatchResultWithPostInfo {256 fail!(<Error<T>>::PropertiesNotAllowed)260 fail!(<Error<T>>::PropertiesNotAllowed)257 }261 }258262259 fn change_token_property(263 fn change_token_properties(260 &self,264 &self,261 _sender: T::CrossAccountId,265 _sender: T::CrossAccountId,262 _token_id: TokenId,266 _token_id: TokenId,263 _property: Property,267 _property: Vec<Property>,264 ) -> DispatchResultWithPostInfo {268 ) -> DispatchResultWithPostInfo {265 fail!(<Error<T>>::PropertiesNotAllowed)269 fail!(<Error<T>>::PropertiesNotAllowed)266 }270 }pallets/refungible/src/weights.rsdiffbeforeafterboth38 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;38 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;39 fn burn_item_partial() -> Weight;39 fn burn_item_partial() -> Weight;40 fn burn_item_fully() -> Weight;40 fn burn_item_fully() -> Weight;41 fn set_property() -> Weight;41 fn change_collection_properties(amount: u32) -> Weight;42 fn change_token_properties(amount: u32) -> Weight;42 fn transfer_normal() -> Weight;43 fn transfer_normal() -> Weight;43 fn transfer_creating() -> Weight;44 fn transfer_creating() -> Weight;44 fn transfer_removing() -> Weight;45 fn transfer_removing() -> Weight;131 .saturating_add(T::DbWeight::get().writes(6 as Weight))132 .saturating_add(T::DbWeight::get().writes(6 as Weight))132 }133 }133134134 fn set_property() -> Weight {135 fn change_collection_properties(amount: u32) -> Weight {135 // Error136 // Error136 0137 0137 }138 }139140 fn change_token_properties(amount: u32) -> Weight {141 // Error142 0143 }138144139 // Storage: Refungible Balance (r:2 w:2)145 // Storage: Refungible Balance (r:2 w:2)140 fn transfer_normal() -> Weight {146 fn transfer_normal() -> Weight {305 .saturating_add(RocksDbWeight::get().writes(6 as Weight))311 .saturating_add(RocksDbWeight::get().writes(6 as Weight))306 }312 }307313308 fn set_property() -> Weight {314 fn change_collection_properties(amount: u32) -> Weight {309 // Error315 // Error310 0316 0311 }317 }318319 fn change_token_properties(amount: u32) -> Weight {320 // Error321 0322 }312323313 // Storage: Refungible Balance (r:2 w:2)324 // Storage: Refungible Balance (r:2 w:2)314 fn transfer_normal() -> Weight {325 fn transfer_normal() -> Weight {pallets/unique/src/lib.rsdiffbeforeafterboth694 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))694 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))695 }695 }696697 #[weight = T::CommonWeightInfo::change_collection_properties(properties.len() as u32)]698 #[transactional]699 pub fn change_collection_properties(700 origin,701 collection_id: CollectionId,702 properties: Vec<Property>703 ) -> DispatchResultWithPostInfo {704 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);705706 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);707708 dispatch_call::<T, _>(collection_id, |d| d.change_collection_properties(sender, properties))709 }710711 #[weight = T::CommonWeightInfo::change_token_properties(properties.len() as u32)]712 #[transactional]713 pub fn change_token_properties(714 origin,715 collection_id: CollectionId,716 token_id: TokenId,717 properties: Vec<Property>718 ) -> DispatchResultWithPostInfo {719 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);720721 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);722723 dispatch_call::<T, _>(collection_id, |d| d.change_token_properties(sender, token_id, properties))724 }696725697 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]726 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]698 #[transactional]727 #[transactional]runtime/common/src/weights.rsdiffbeforeafterboth54 dispatch_weight::<T>() + max_weight_of!(burn_item())54 dispatch_weight::<T>() + max_weight_of!(burn_item())55 }55 }5657 fn change_collection_properties(amount: u32) -> Weight {58 dispatch_weight::<T>() + max_weight_of!(change_collection_properties(amount))59 }566057 fn set_property() -> Weight {61 fn change_token_properties(amount: u32) -> Weight {58 dispatch_weight::<T>() + max_weight_of!(set_property())62 dispatch_weight::<T>() + max_weight_of!(change_token_properties(amount))59 }63 }606461 fn transfer() -> Weight {65 fn transfer() -> Weight {