difftreelog
NFTPAR-288. Limit schema size
in: master
2 files changed
node/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 {
pallets/nft/src/lib.rsdiffbeforeafterboth74 ReFungible(DecimalPoints),74 ReFungible(DecimalPoints),75}75}7677impl Default for CollectionMode {78 fn default() -> Self {79 Self::Invalid80 }81}768277impl Into<u8> for CollectionMode {83impl Into<u8> for CollectionMode {78 fn into(self) -> u8 {84 fn into(self) -> u8 {97 }103 }98}104}99100impl Default for CollectionMode {101 fn default() -> Self {102 Self::Invalid103 }104}105105106#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]106#[derive(Encode, Decode, Eq, Debug, Clone, PartialEq)]107#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]107#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]209 pub fungible_sponsor_transfer_timeout: u32,209 pub fungible_sponsor_transfer_timeout: u32,210 pub refungible_sponsor_transfer_timeout: u32,210 pub refungible_sponsor_transfer_timeout: u32,211212 // Schema limits213 pub offchain_schema_limit: u32,214 pub variable_on_chain_schema_limit: u32,215 pub const_on_chain_schema_limit: u32,211}216}212217213pub trait WeightInfo {218pub trait WeightInfo {367 /// Account token limit exceeded per collection372 /// Account token limit exceeded per collection368 AccountTokenLimitExceeded,373 AccountTokenLimitExceeded,369 /// Collection limit bounds per collection exceeded374 /// Collection limit bounds per collection exceeded370 CollectionLimitBoundsExceeded375 CollectionLimitBoundsExceeded,376 /// Schema data size limit bound exceeded377 SchemaDataLimitExceeded371 }378 }372}379}3733801281 let sender = ensure_signed(origin)?;1288 let sender = ensure_signed(origin)?;1282 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1289 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;12901291 // check schema limit1292 ensure!(schema.len() as u32 > ChainLimit::get().offchain_schema_limit, "");128312931284 let mut target_collection = <Collection<T>>::get(collection_id);1294 let mut target_collection = <Collection<T>>::get(collection_id);1285 target_collection.offchain_schema = schema;1295 target_collection.offchain_schema = schema;1309 let sender = ensure_signed(origin)?;1319 let sender = ensure_signed(origin)?;1310 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1320 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;13211322 // check schema limit1323 ensure!(schema.len() as u32 > ChainLimit::get().const_on_chain_schema_limit, "");131113241312 let mut target_collection = <Collection<T>>::get(collection_id);1325 let mut target_collection = <Collection<T>>::get(collection_id);1313 target_collection.const_on_chain_schema = schema;1326 target_collection.const_on_chain_schema = schema;1337 let sender = ensure_signed(origin)?;1350 let sender = ensure_signed(origin)?;1338 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;1351 Self::check_owner_or_admin_permissions(collection_id, sender.clone())?;13521353 // check schema limit1354 ensure!(schema.len() as u32 > ChainLimit::get().variable_on_chain_schema_limit, "");133913551340 let mut target_collection = <Collection<T>>::get(collection_id);1356 let mut target_collection = <Collection<T>>::get(collection_id);1341 target_collection.variable_on_chain_schema = schema;1357 target_collection.variable_on_chain_schema = schema;