From a605f3dd7e424cbc4b1b4f93396b09232a349325 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Fri, 27 May 2022 18:41:27 +0000 Subject: [PATCH] fix: transfersubbundles --- --- a/pallets/structure/src/lib.rs +++ b/pallets/structure/src/lib.rs @@ -156,8 +156,8 @@ budget: &dyn Budget, ) -> Result { let target_parent = match T::CrossTokenAddressMapping::address_to_token(&user) { - Some((collection, token)) => Parent::Token(collection, token), - None => Parent::User(user), + Some((collection, token)) => Self::find_topmost_owner(collection, token, budget)?, + None => user, }; // Tried to nest token in itself @@ -172,7 +172,7 @@ return Err(>::OuroborosDetected.into()) } // Found needed parent, token is indirecty owned - v if v == target_parent => return Ok(true), + Parent::User(user) if user == target_parent => return Ok(true), // Token is owned by other user Parent::User(_) => return Ok(false), Parent::TokenNotFound => return Err(>::TokenNotFound.into()), --- 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 { @@ -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::(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) -> DispatchResultWithPostInfo { ensure!(!items_data.is_empty(), Error::::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::(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) -> 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::(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::(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::(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::(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget)) } -- gitstuff