difftreelog
feat remove schemaName/schemaVersion
in: master
4 files changed
pallets/common/src/erc.rsdiffbeforeafterboth660 pub mod key {660 pub mod key {661 use super::*;661 use super::*;662663 /// Key "schemaName".664 pub fn schema_name() -> up_data_structs::PropertyKey {665 property_key_from_bytes(b"schemaName").expect(EXPECT_CONVERT_ERROR)666 }667668 /// Key "schemaVersion".669 pub fn schema_version() -> up_data_structs::PropertyKey {670 property_key_from_bytes(b"schemaVersion").expect(EXPECT_CONVERT_ERROR)671 }672662673 /// Key "baseURI".663 /// Key "baseURI".674 pub fn base_uri() -> up_data_structs::PropertyKey {664 pub fn base_uri() -> up_data_structs::PropertyKey {690 property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)680 property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)691 }681 }692693 /// Key "ERC721Metadata".694 pub fn erc721_metadata() -> up_data_structs::PropertyKey {695 property_key_from_bytes(b"ERC721Metadata").expect(EXPECT_CONVERT_ERROR)696 }697 }682 }698699 /// Values.700 pub mod value {701 use super::*;702703 /// Value "Schema version".704 pub const SCHEMA_VERSION: &[u8] = b"1.0.0";705706 /// Value "ERC721Metadata".707 pub const ERC721_METADATA: &[u8] = b"ERC721Metadata";708709 /// Value for [`ERC721_METADATA`].710 pub fn erc721() -> up_data_structs::PropertyValue {711 property_value_from_bytes(ERC721_METADATA).expect(EXPECT_CONVERT_ERROR)712 }713714 /// Value for [`SCHEMA_VERSION`].715 pub fn schema_version() -> up_data_structs::PropertyValue {716 property_value_from_bytes(SCHEMA_VERSION).expect(EXPECT_CONVERT_ERROR)717 }718 }719683720 /// Convert `byte` to [`PropertyKey`].684 /// Convert `byte` to [`PropertyKey`].721 pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {685 pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {pallets/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};
pallets/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};
pallets/unique/src/eth/mod.rsdiffbeforeafterboth--- a/pallets/unique/src/eth/mod.rs
+++ b/pallets/unique/src/eth/mod.rs
@@ -25,7 +25,7 @@
dispatch::CollectionDispatch,
erc::{
CollectionHelpersEvents,
- static_property::{key, value as property_value},
+ static_property::{key},
},
Pallet as PalletCommon,
};
@@ -125,26 +125,13 @@
} else {
up_data_structs::CollectionPropertiesPermissionsVec::default()
};
- let properties = if add_properties {
- let mut properties = vec![
- up_data_structs::Property {
- key: key::schema_name(),
- value: property_value::erc721(),
- },
- up_data_structs::Property {
- key: key::schema_version(),
- value: property_value::schema_version(),
- },
- ];
- if !base_uri_value.is_empty() {
- properties.push(up_data_structs::Property {
- key: key::base_uri(),
- value: base_uri_value,
- })
- }
- properties
- .try_into()
- .map_err(|e| Error::Revert(format!("{:?}", e)))?
+ let properties = if add_properties && !base_uri_value.is_empty() {
+ vec![up_data_structs::Property {
+ key: key::base_uri(),
+ value: base_uri_value,
+ }]
+ .try_into()
+ .expect("limit >= 1")
} else {
up_data_structs::CollectionPropertiesVec::default()
};
@@ -404,32 +391,20 @@
}
let all_properties = <pallet_common::CollectionProperties<T>>::get(collection.id);
- let mut new_properties = vec![];
- if all_properties.get(&key::schema_name()).is_none() {
- self.recorder().consume_sstore()?;
- new_properties.push(up_data_structs::Property {
- key: key::schema_name(),
- value: property_value::erc721(),
- });
- new_properties.push(up_data_structs::Property {
- key: key::schema_version(),
- value: property_value::schema_version(),
- });
- }
if all_properties.get(&key::base_uri()).is_none() && !base_uri.is_empty() {
- new_properties.push(up_data_structs::Property {
- key: key::base_uri(),
- value: base_uri
- .into_bytes()
- .try_into()
- .map_err(|_| "base uri is too large")?,
- });
- }
-
- if !new_properties.is_empty() {
self.recorder().consume_sstore()?;
- <PalletCommon<T>>::set_collection_properties(&collection, &caller, new_properties)
- .map_err(dispatch_to_evm::<T>)?;
+ <PalletCommon<T>>::set_collection_properties(
+ &collection,
+ &caller,
+ vec![up_data_structs::Property {
+ key: key::base_uri(),
+ value: base_uri
+ .into_bytes()
+ .try_into()
+ .map_err(|_| "base uri is too large")?,
+ }],
+ )
+ .map_err(dispatch_to_evm::<T>)?;
}
self.recorder().consume_sstore()?;