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
52pub mod weights;52pub mod weights;
53use weights::WeightInfo;53use weights::WeightInfo;
54
55const NESTING_BUDGET: u32 = 5;
5456
55decl_error! {57decl_error! {
56 /// Error for non-fungible-token module.58 /// Error for non-fungible-token module.
605 #[transactional]607 #[transactional]
606 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {608 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {
607 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);609 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
608 let budget = budget::Value::new(2);610 let budget = budget::Value::new(NESTING_BUDGET);
609611
610 dispatch_call::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))612 dispatch_call::<T, _>(collection_id, |d| d.create_item(sender, owner, data, &budget))
611 }613 }
633 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {635 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {
634 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);636 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
635 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);637 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
636 let budget = budget::Value::new(2);638 let budget = budget::Value::new(NESTING_BUDGET);
637639
638 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))640 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data, &budget))
639 }641 }
714 #[transactional]716 #[transactional]
715 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {717 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
716 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);718 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
717 let budget = budget::Value::new(2);719 let budget = budget::Value::new(NESTING_BUDGET);
718720
719 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))721 dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data, &budget))
720 }722 }
794 #[transactional]796 #[transactional]
795 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {797 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
796 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);798 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
797 let budget = budget::Value::new(2);799 let budget = budget::Value::new(NESTING_BUDGET);
798800
799 dispatch_call::<T, _>(collection_id, |d| d.burn_from(sender, from, item_id, value, &budget))801 dispatch_call::<T, _>(collection_id, |d| d.burn_from(sender, from, item_id, value, &budget))
800 }802 }
826 #[transactional]828 #[transactional]
827 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {829 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
828 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);830 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
829 let budget = budget::Value::new(2);831 let budget = budget::Value::new(NESTING_BUDGET);
830832
831 dispatch_call::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))833 dispatch_call::<T, _>(collection_id, |d| d.transfer(sender, recipient, item_id, value, &budget))
832 }834 }
877 #[transactional]879 #[transactional]
878 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {880 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {
879 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);881 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
880 let budget = budget::Value::new(2);882 let budget = budget::Value::new(NESTING_BUDGET);
881883
882 dispatch_call::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))884 dispatch_call::<T, _>(collection_id, |d| d.transfer_from(sender, from, recipient, item_id, value, &budget))
883 }885 }