git.delta.rocks / unique-network / refs/commits / 503c92cd6363

difftreelog

feat remove schemaName/schemaVersion

Yaroslav Bolyukin2022-10-14parent: #9d4aa0e.patch.diff
in: master

4 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -660,16 +660,6 @@
 	pub mod key {
 		use super::*;
 
-		/// Key "schemaName".
-		pub fn schema_name() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)
-		}
-
-		/// Key "schemaVersion".
-		pub fn schema_version() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"schemaVersion").expect(EXPECT_CONVERT_ERROR)
-		}
-
 		/// Key "baseURI".
 		pub fn base_uri() -> up_data_structs::PropertyKey {
 			property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)
@@ -688,32 +678,6 @@
 		/// Key "parentNft".
 		pub fn parent_nft() -> up_data_structs::PropertyKey {
 			property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)
-		}
-
-		/// Key "ERC721Metadata".
-		pub fn erc721_metadata() -> up_data_structs::PropertyKey {
-			property_key_from_bytes(b"ERC721Metadata").expect(EXPECT_CONVERT_ERROR)
-		}
-	}
-
-	/// Values.
-	pub mod value {
-		use super::*;
-
-		/// Value "Schema version".
-		pub const SCHEMA_VERSION: &[u8] = b"1.0.0";
-
-		/// Value "ERC721Metadata".
-		pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";
-
-		/// Value for [`ERC721_METADATA`].
-		pub fn erc721() -> up_data_structs::PropertyValue {
-			property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)
-		}
-
-		/// Value for [`SCHEMA_VERSION`].
-		pub fn schema_version() -> up_data_structs::PropertyValue {
-			property_value_from_bytes(SCHEMA_VERSION).expect(EXPECT_CONVERT_ERROR)
 		}
 	}
 
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -33,10 +33,7 @@
 use pallet_evm_coder_substrate::dispatch_to_evm;
 use sp_std::vec::Vec;
 use pallet_common::{
-	erc::{
-		CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key,
-		static_property::value,
-	},
+	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
 	CollectionHandle, CollectionPropertyPermissions,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -29,7 +29,7 @@
 use frame_support::{BoundedBTreeMap, BoundedVec};
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions,
-	erc::{CommonEvmHandler, CollectionCall, static_property::key, static_property::value},
+	erc::{CommonEvmHandler, CollectionCall, static_property::key},
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm};
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
25 dispatch::CollectionDispatch,25 dispatch::CollectionDispatch,
26 erc::{26 erc::{
27 CollectionHelpersEvents,27 CollectionHelpersEvents,
28 static_property::{key, value as property_value},28 static_property::{key},
29 },29 },
30 Pallet as PalletCommon,30 Pallet as PalletCommon,
31};31};
125 } else {125 } else {
126 up_data_structs::CollectionPropertiesPermissionsVec::default()126 up_data_structs::CollectionPropertiesPermissionsVec::default()
127 };127 };
128 let properties = if add_properties {128 let properties = if add_properties && !base_uri_value.is_empty() {
129 let mut properties = vec![
130 up_data_structs::Property {
131 key: key::schema_name(),
132 value: property_value::erc721(),
133 },
134 up_data_structs::Property {
135 key: key::schema_version(),
136 value: property_value::schema_version(),
137 },
138 ];
139 if !base_uri_value.is_empty() {
140 properties.push(up_data_structs::Property {129 vec![up_data_structs::Property {
141 key: key::base_uri(),130 key: key::base_uri(),
142 value: base_uri_value,131 value: base_uri_value,
143 })132 }]
133 .try_into()
134 .expect("limit >= 1")
144 }135 } else {
145 properties
146 .try_into()
147 .map_err(|e| Error::Revert(format!("{:?}", e)))?
148 } else {
149 up_data_structs::CollectionPropertiesVec::default()136 up_data_structs::CollectionPropertiesVec::default()
150 };137 };
151138
404 }391 }
405392
406 let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);393 let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);
407 let mut new_properties = vec![];
408 if all_properties.get(&key::schema_name()).is_none() {394 if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {
409 self.recorder().consume_sstore()?;
410 new_properties.push(up_data_structs::Property {
411 key: key::schema_name(),
412 value: property_value::erc721(),
413 });
414 new_properties.push(up_data_structs::Property {
415 key: key::schema_version(),
416 value: property_value::schema_version(),
417 });
418 }
419 if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {
420 new_properties.push(up_data_structs::Property {
421 key: key::base_uri(),
422 value: base_uri
423 .into_bytes()
424 .try_into()
425 .map_err(|_| "base uri is too large")?,
426 });
427 }
428
429 if !new_properties.is_empty() {
430 self.recorder().consume_sstore()?;395 self.recorder().consume_sstore()?;
431 <PalletCommon<T>>::set_collection_properties(&collection, &caller, new_properties)396 <PalletCommon<T>>::set_collection_properties(
397 &collection,
398 &caller,
399 vec![up_data_structs::Property {
400 key: key::base_uri(),
401 value: base_uri
402 .into_bytes()
403 .try_into()
404 .map_err(|_| "base uri is too large")?,
405 }],
406 )
432 .map_err(dispatch_to_evm::<T>)?;407 .map_err(dispatch_to_evm::<T>)?;
433 }408 }