git.delta.rocks / unique-network / refs/commits / d488824556c1

difftreelog

Merge pull request #65 from usetech-llc/feature/NFTPAR-288

Greg Zaitsev2021-01-18parents: #add913f #4e9eae9.patch.diff
in: master
Feature/nftpar 288

3 files changed

modifiednode/src/chain_spec.rsdiffbeforeafterboth
--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -209,7 +209,10 @@
                 custom_data_limit: 2048,
                 nft_sponsor_transfer_timeout: 15,
                 fungible_sponsor_transfer_timeout: 15,
-                refungible_sponsor_transfer_timeout: 15,
+				refungible_sponsor_transfer_timeout: 15,
+				offchain_schema_limit: 1024,
+				variable_on_chain_schema_limit: 1024,
+				const_on_chain_schema_limit: 1024,
             },
         }),
         pallet_contracts: Some(ContractsConfig {
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -74,6 +74,12 @@
     ReFungible(DecimalPoints),
 }
 
+impl Default for CollectionMode {
+    fn default() -> Self {
+        Self::Invalid
+    }
+}
+
 impl Into<u8> for CollectionMode {
     fn into(self) -> u8 {
         match self {
@@ -97,12 +103,6 @@
     }
 }
 
-impl Default for CollectionMode {
-    fn default() -> Self {
-        Self::Invalid
-    }
-}
-
 #[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 pub enum SchemaVersion {
@@ -208,6 +208,11 @@
     pub nft_sponsor_transfer_timeout: u32,
     pub fungible_sponsor_transfer_timeout: u32,
     pub refungible_sponsor_transfer_timeout: u32,
+
+    // Schema limits
+    pub offchain_schema_limit: u32,
+    pub variable_on_chain_schema_limit: u32,
+    pub const_on_chain_schema_limit: u32,
 }
 
 pub trait WeightInfo {
@@ -367,7 +372,9 @@
         /// Account token limit exceeded per collection
         AccountTokenLimitExceeded,
         /// Collection limit bounds per collection exceeded
-        CollectionLimitBoundsExceeded
+        CollectionLimitBoundsExceeded,
+        /// Schema data size limit bound exceeded
+        SchemaDataLimitExceeded
 	}
 }
 
@@ -1281,6 +1288,9 @@
             let sender = ensure_signed(origin)?;
             Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
 
+            // check schema limit
+            ensure!(schema.len() as u32 > ChainLimit::get().offchain_schema_limit, "");
+
             let mut target_collection = <Collection<T>>::get(collection_id);
             target_collection.offchain_schema = schema;
             <Collection<T>>::insert(collection_id, target_collection);
@@ -1309,6 +1319,9 @@
             let sender = ensure_signed(origin)?;
             Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
 
+            // check schema limit
+            ensure!(schema.len() as u32 > ChainLimit::get().const_on_chain_schema_limit, "");
+
             let mut target_collection = <Collection<T>>::get(collection_id);
             target_collection.const_on_chain_schema = schema;
             <Collection<T>>::insert(collection_id, target_collection);
@@ -1337,6 +1350,9 @@
             let sender = ensure_signed(origin)?;
             Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;
 
+            // check schema limit
+            ensure!(schema.len() as u32 > ChainLimit::get().variable_on_chain_schema_limit, "");
+
             let mut target_collection = <Collection<T>>::get(collection_id);
             target_collection.variable_on_chain_schema = schema;
             <Collection<T>>::insert(collection_id, target_collection);
addedpallets/nft/src/types.rsdiffbeforeafterboth

no changes