difftreelog
cargo fmt
in: master
3 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterbothno syntactic changes
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -488,7 +488,10 @@
})
}
- pub fn set_token_property(property: Property, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+ pub fn set_token_property(
+ property: Property,
+ guard: &mut PropertyGuard<'_, T>,
+ ) -> DispatchResult {
Self::check_token_change_permission(&property.key, guard)?;
<TokenProperties<T>>::try_mutate((guard.collection.id, guard.token), |properties| {
@@ -530,7 +533,10 @@
Ok(())
}
- pub fn delete_token_property(property_key: PropertyKey, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+ pub fn delete_token_property(
+ property_key: PropertyKey,
+ guard: &mut PropertyGuard<'_, T>,
+ ) -> DispatchResult {
Self::check_token_change_permission(&property_key, guard)?;
<TokenProperties<T>>::try_mutate((guard.collection.id, guard.token), |properties| {
@@ -547,7 +553,10 @@
Ok(())
}
- fn check_token_change_permission(property_key: &PropertyKey, guard: &mut PropertyGuard<'_, T>) -> DispatchResult {
+ fn check_token_change_permission(
+ property_key: &PropertyKey,
+ guard: &mut PropertyGuard<'_, T>,
+ ) -> DispatchResult {
let permission = <PalletCommon<T>>::property_permissions(guard.collection.id)
.get(property_key)
.cloned()
pallets/nonfungible/src/property_guard.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/property_guard.rs
+++ b/pallets/nonfungible/src/property_guard.rs
@@ -1,63 +1,64 @@
use super::*;
pub struct PropertyGuard<'a, T: Config> {
- pub sender: &'a T::CrossAccountId,
- pub collection: &'a NonfungibleHandle<T>,
- pub token: TokenId,
- pub is_token_create: bool,
- budget: &'a dyn Budget,
+ pub sender: &'a T::CrossAccountId,
+ pub collection: &'a NonfungibleHandle<T>,
+ pub token: TokenId,
+ pub is_token_create: bool,
+ budget: &'a dyn Budget,
- collection_admin_result: Option<DispatchResult>,
- token_owner_result: Option<DispatchResult>,
+ collection_admin_result: Option<DispatchResult>,
+ token_owner_result: Option<DispatchResult>,
}
impl<'a, T: Config> PropertyGuard<'a, T> {
- pub fn new(
- sender: &'a T::CrossAccountId,
- collection: &'a NonfungibleHandle<T>,
- token: TokenId,
- is_token_create: bool,
- budget: &'a dyn Budget,
- ) -> Self {
- Self {
- sender,
- collection,
- token,
- is_token_create,
- budget,
+ pub fn new(
+ sender: &'a T::CrossAccountId,
+ collection: &'a NonfungibleHandle<T>,
+ token: TokenId,
+ is_token_create: bool,
+ budget: &'a dyn Budget,
+ ) -> Self {
+ Self {
+ sender,
+ collection,
+ token,
+ is_token_create,
+ budget,
- collection_admin_result: None,
- token_owner_result: None
- }
- }
+ collection_admin_result: None,
+ token_owner_result: None,
+ }
+ }
- pub fn check_collection_admin(&mut self) -> DispatchResult {
- if self.collection_admin_result.is_none() {
- self.collection_admin_result = Some(self.collection.check_is_owner_or_admin(self.sender));
- }
+ pub fn check_collection_admin(&mut self) -> DispatchResult {
+ if self.collection_admin_result.is_none() {
+ self.collection_admin_result =
+ Some(self.collection.check_is_owner_or_admin(self.sender));
+ }
- self.collection_admin_result.unwrap()
- }
+ self.collection_admin_result.unwrap()
+ }
- pub fn check_token_owner(&mut self) -> DispatchResult {
- if self.token_owner_result.is_none() {
- let is_owned = <PalletStructure<T>>::check_indirectly_owned(
- self.sender.clone(),
- self.collection.id,
- self.token,
- None,
- self.budget,
- )?;
+ pub fn check_token_owner(&mut self) -> DispatchResult {
+ if self.token_owner_result.is_none() {
+ let is_owned = <PalletStructure<T>>::check_indirectly_owned(
+ self.sender.clone(),
+ self.collection.id,
+ self.token,
+ None,
+ self.budget,
+ )?;
- let result = if is_owned {
- Ok(())
- } else {
- Err(<CommonError<T>>::NoPermission.into())
- };
+ let result = if is_owned {
+ Ok(())
+ } else {
+ Err(<CommonError<T>>::NoPermission.into())
+ };
- self.token_owner_result = Some(result);
- }
+ self.token_owner_result = Some(result);
+ }
- self.token_owner_result.unwrap()
- }
+ self.token_owner_result.unwrap()
+ }
}