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

difftreelog

fix transfersubbundles

Daniel Shiposha2022-05-27parent: #101a189.patch.diff
in: master

2 files changed

modifiedpallets/structure/src/lib.rsdiffbeforeafterboth
156 budget: &dyn Budget,156 budget: &dyn Budget,
157 ) -> Result<bool, DispatchError> {157 ) -> Result<bool, DispatchError> {
158 let target_parent = match T::CrossTokenAddressMapping::address_to_token(&user) {158 let target_parent = match T::CrossTokenAddressMapping::address_to_token(&user) {
159 Some((collection, token)) => Parent::Token(collection, token),159 Some((collection, token)) => Self::find_topmost_owner(collection, token, budget)?,
160 None => Parent::User(user),160 None => user,
161 };161 };
162162
163 // Tried to nest token in itself163 // Tried to nest token in itself
172 return Err(<Error<T>>::OuroborosDetected.into())172 return Err(<Error<T>>::OuroborosDetected.into())
173 }173 }
174 // Found needed parent, token is indirecty owned174 // Found needed parent, token is indirecty owned
175 v if v == target_parent => return Ok(true),175 Parent::User(user) if user == target_parent => return Ok(true),
176 // Token is owned by other user176 // Token is owned by other user
177 Parent::User(_) => return Ok(false),177 Parent::User(_) => return Ok(false),
178 Parent::TokenNotFound => return Err(<Error<T>>::TokenNotFound.into()),178 Parent::TokenNotFound => return Err(<Error<T>>::TokenNotFound.into()),
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -52,6 +52,8 @@
 pub mod weights;
 use weights::WeightInfo;
 
+const NESTING_BUDGET: u32 = 5;
+
 decl_error! {
 	/// Error for non-fungible-token module.
 	pub enum Error for Module<T: Config> {
@@ -605,7 +607,7 @@
 		#[transactional]
 		pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))
 		}
@@ -633,7 +635,7 @@
 		pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {
 			ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))
 		}
@@ -714,7 +716,7 @@
 		#[transactional]
 		pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))
 		}
@@ -794,7 +796,7 @@
 		#[transactional]
 		pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.burn_from(sender, from, item_id, value, &budget))
 		}
@@ -826,7 +828,7 @@
 		#[transactional]
 		pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))
 		}
@@ -877,7 +879,7 @@
 		#[transactional]
 		pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-			let budget = budget::Value::new(2);
+			let budget = budget::Value::new(NESTING_BUDGET);
 
 			dispatch_call::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))
 		}