git.delta.rocks / unique-network / refs/commits / 17af80bda9a2

difftreelog

CORE-390 Refactor naming

Trubnikov Sergey2022-06-03parent: #cd24a66.patch.diff
in: master

7 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -317,7 +317,7 @@
 
 fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {
 	collection
-		.check_is_read_only()
+		.check_is_mutable()
 		.map_err(dispatch_to_evm::<T>)?;
 	<crate::CollectionById<T>>::insert(collection.id, collection.collection.clone());
 	Ok(())
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -149,19 +149,19 @@
 			))
 	}
 	pub fn save(self) -> Result<(), DispatchError> {
-		self.check_is_read_only()?;
+		self.check_is_mutable()?;
 		<CollectionById<T>>::insert(self.id, self.collection);
 		Ok(())
 	}
 
 	pub fn set_sponsor(&mut self, sponsor: T::AccountId) -> DispatchResult {
-		self.check_is_read_only()?;
+		self.check_is_mutable()?;
 		self.collection.sponsorship = SponsorshipState::Unconfirmed(sponsor);
 		Ok(())
 	}
 
 	pub fn confirm_sponsorship(&mut self, sender: &T::AccountId) -> Result<bool, DispatchError> {
-		self.check_is_read_only()?;
+		self.check_is_mutable()?;
 
 		if self.collection.sponsorship.pending_sponsor() != Some(sender) {
 			return Ok(false);
@@ -686,7 +686,7 @@
 			sponsorship,
 			limits,
 			permissions,
-			read_only,
+			external_collection,
 		} = <CollectionById<T>>::get(collection)?;
 
 		let token_property_permissions = <CollectionPropertyPermissions<T>>::get(collection)
@@ -716,7 +716,7 @@
 			permissions,
 			token_property_permissions,
 			properties,
-			read_only,
+			read_only: external_collection,
 		})
 	}
 }
@@ -797,7 +797,7 @@
 					Self::clamp_permissions(data.mode.clone(), &Default::default(), permissions)
 				})
 				.unwrap_or_else(|| Ok(CollectionPermissions::default()))?,
-			read_only: false,
+			external_collection: false,
 		};
 
 		let mut collection_properties = up_data_structs::CollectionProperties::get();
@@ -854,7 +854,7 @@
 		collection: CollectionHandle<T>,
 		sender: &T::CrossAccountId,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		ensure!(
 			collection.limits.owner_can_destroy(),
 			<Error<T>>::NoPermission,
@@ -884,7 +884,7 @@
 		sender: &T::CrossAccountId,
 		property: Property,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		collection.check_is_owner_or_admin(sender)?;
 
 		CollectionProperties::<T>::try_mutate(collection.id, |properties| {
@@ -930,7 +930,7 @@
 		sender: &T::CrossAccountId,
 		properties: Vec<Property>,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		for property in properties {
 			Self::set_collection_property(collection, sender, property)?;
@@ -944,7 +944,7 @@
 		sender: &T::CrossAccountId,
 		property_key: PropertyKey,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		collection.check_is_owner_or_admin(sender)?;
 
 		CollectionProperties::<T>::try_mutate(collection.id, |properties| {
@@ -966,7 +966,7 @@
 		sender: &T::CrossAccountId,
 		property_keys: Vec<PropertyKey>,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		for key in property_keys {
 			Self::delete_collection_property(collection, sender, key)?;
@@ -992,7 +992,7 @@
 		sender: &T::CrossAccountId,
 		property_permission: PropertyKeyPermission,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		collection.check_is_owner_or_admin(sender)?;
 
 		let all_permissions = CollectionPropertyPermissions::<T>::get(collection.id);
@@ -1024,7 +1024,7 @@
 		sender: &T::CrossAccountId,
 		property_permissions: Vec<PropertyKeyPermission>,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		for prop_pemission in property_permissions {
 			Self::set_property_permission(collection, sender, prop_pemission)?;
@@ -1113,7 +1113,7 @@
 		user: &T::CrossAccountId,
 		allowed: bool,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		collection.check_is_owner_or_admin(sender)?;
 
 		// =========
@@ -1133,7 +1133,7 @@
 		user: &T::CrossAccountId,
 		admin: bool,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		collection.check_is_owner_or_admin(sender)?;
 
 		let was_admin = <IsAdmin<T>>::get((collection.id, user));
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -168,7 +168,7 @@
 		owner: &T::CrossAccountId,
 		amount: u128,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		let total_supply = <TotalSupply<T>>::get(collection.id)
 			.checked_sub(amount)
@@ -216,7 +216,7 @@
 		amount: u128,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		ensure!(
 			collection.limits.transfers_enabled(),
@@ -287,7 +287,7 @@
 		data: BTreeMap<T::CrossAccountId, u128>,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		if !collection.is_owner_or_admin(sender) {
 			ensure!(
@@ -390,7 +390,7 @@
 		spender: &T::CrossAccountId,
 		amount: u128,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(owner)?;
 			collection.check_allowlist(spender)?;
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -336,7 +336,7 @@
 		sender: &T::CrossAccountId,
 		token: TokenId,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		let token_data =
 			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
@@ -458,7 +458,7 @@
 			&property.key,
 			is_token_create,
 		)?;
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {
 			let property = property.clone();
@@ -496,8 +496,8 @@
 		token_id: TokenId,
 		property_key: PropertyKey,
 	) -> DispatchResult {
+		collection.check_is_mutable()?;
 		Self::check_token_change_permission(collection, sender, token_id, &property_key, false)?;
-		collection.check_is_read_only()?;
 
 		<TokenProperties<T>>::try_mutate((collection.id, token_id), |properties| {
 			properties.remove(&property_key)
@@ -574,7 +574,7 @@
 		token_id: TokenId,
 		property_keys: Vec<PropertyKey>,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		for key in property_keys {
 			Self::delete_token_property(collection, sender, token_id, key)?;
@@ -622,7 +622,7 @@
 		token: TokenId,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		ensure!(
 			collection.limits.transfers_enabled(),
@@ -902,7 +902,7 @@
 		token: TokenId,
 		spender: Option<&T::CrossAccountId>,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(sender)?;
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -234,7 +234,7 @@
 	}
 
 	pub fn burn_token(collection: &RefungibleHandle<T>, token_id: TokenId) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		let burnt = <TokensBurnt<T>>::get(collection.id)
 			.checked_add(1)
 			.ok_or(ArithmeticError::Overflow)?;
@@ -254,7 +254,7 @@
 		token: TokenId,
 		amount: u128,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		let total_supply = <TotalSupply<T>>::get((collection.id, token))
 			.checked_sub(amount)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -327,7 +327,7 @@
 		amount: u128,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		ensure!(
 			collection.limits.transfers_enabled(),
 			<CommonError<T>>::TransferNotAllowed
@@ -576,7 +576,7 @@
 		token: TokenId,
 		amount: u128,
 	) -> DispatchResult {
-		collection.check_is_read_only()?;
+		collection.check_is_mutable()?;
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(sender)?;
 			collection.check_allowlist(spender)?;
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -304,7 +304,7 @@
 		pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
 			let collection = <CollectionHandle<T>>::try_get(collection_id)?;
-			collection.check_is_read_only()?;
+			collection.check_is_mutable()?;
 
 			// =========
 
@@ -407,7 +407,7 @@
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
 
 			let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
-			target_collection.check_is_read_only()?;
+			target_collection.check_is_mutable()?;
 			target_collection.check_is_owner(&sender)?;
 
 			target_collection.owner = new_owner.clone();
modifiedprimitives/data-structs/src/lib.rsdiffbeforeafterboth
316 #[version(2.., upper(Default::default()))]316 #[version(2.., upper(Default::default()))]
317 pub permissions: CollectionPermissions,317 pub permissions: CollectionPermissions,
318318
319 /// Marks that this collection is not "unique", and managed from external.
319 #[version(2.., upper(false))]320 #[version(2.., upper(false))]
320 pub read_only: bool,321 pub external_collection: bool,
321322
322 #[version(..2)]323 #[version(..2)]
323 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,324 pub variable_on_chain_schema: BoundedVec<u8, ConstU32<VARIABLE_ON_CHAIN_SCHEMA_LIMIT>>,