difftreelog
Public storage
in: master
3 files changed
pallets/nft/src/sponsorship.rsdiffbeforeafterboth14 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId,14 REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId,15};15};16use pallet_common::{CollectionHandle};16use pallet_common::{CollectionHandle};17use pallet_common::account::CrossAccountId;171818pub fn withdraw_transfer<T: Config>(19pub fn withdraw_transfer<T: Config>(19 collection: &CollectionHandle<T>,20 collection: &CollectionHandle<T>,20 who: &T::AccountId,21 who: &T::AccountId,21 item_id: &TokenId,22 item_id: &TokenId,22) -> Option<()> {23) -> Option<()> {2425 // preliminary sponsoring correctness check26 if !((pallet_nonfungible::TokenData::<T>::get((collection.id, item_id))?.owner).as_sub()27 == who) || (pallet_refungible::Owned::<T>::get((28 collection.id,29 T::CrossAccountId::from_sub(who.clone()),30 item_id,31 ))) {32 return None;33 }34 23 // sponsor timeout35 // sponsor timeout24 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;36 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;90}102}9110392pub fn withdraw_set_variable_meta_data<T: Config>(104pub fn withdraw_set_variable_meta_data<T: Config>(105 who: &T::AccountId,93 collection: &CollectionHandle<T>,106 collection: &CollectionHandle<T>,94 item_id: &TokenId,107 item_id: &TokenId,95 data: &[u8],108 data: &[u8],96) -> Option<()> {109) -> Option<()> {110111 // preliminary sponsoring correctness check112 if !((pallet_nonfungible::TokenData::<T>::get((collection.id, item_id))?.owner).as_sub()113 == who) || (pallet_refungible::Owned::<T>::get((114 collection.id,115 T::CrossAccountId::from_sub(who.clone()),116 item_id,117 ))) {118 return None;119 }12097 // Can't sponsor fungible collection, this tx will be rejected121 // Can't sponsor fungible collection, this tx will be rejected98 // as invalid122 // as invalid204 data,228 data,205 } => {229 } => {206 let (sponsor, collection) = load(*collection_id)?;230 let (sponsor, collection) = load(*collection_id)?;207 withdraw_set_variable_meta_data::<T>(&collection, item_id, data).map(|()| sponsor)231 withdraw_set_variable_meta_data::<T>(&who, &collection, item_id, data).map(|()| sponsor)208 }232 }209 _ => None,233 _ => None,210 }234 }pallets/nonfungible/src/lib.rsdiffbeforeafterboth58 }58 }595960 #[pallet::pallet]60 #[pallet::pallet]61 #[pallet::generate_store(pub(super) trait Store)]61 #[pallet::generate_store(pub trait Store)]62 pub struct Pallet<T>(_);62 pub struct Pallet<T>(_);636364 #[pallet::storage]64 #[pallet::storage]65 pub(super) type TokensMinted<T: Config> =65 pub type TokensMinted<T: Config> =66 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;66 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;67 #[pallet::storage]67 #[pallet::storage]68 pub(super) type TokensBurnt<T: Config> =68 pub type TokensBurnt<T: Config> =69 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;69 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;707071 #[pallet::storage]71 #[pallet::storage]72 pub(super) type TokenData<T: Config> = StorageNMap<72 pub type TokenData<T: Config> = StorageNMap<73 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),73 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),74 Value = ItemData<T>,74 Value = ItemData<T>,75 QueryKind = OptionQuery,75 QueryKind = OptionQuery,76 >;76 >;777778 /// Used to enumerate tokens owned by account78 /// Used to enumerate tokens owned by account79 #[pallet::storage]79 #[pallet::storage]80 pub(super) type Owned<T: Config> = StorageNMap<80 pub type Owned<T: Config> = StorageNMap<81 Key = (81 Key = (82 Key<Twox64Concat, CollectionId>,82 Key<Twox64Concat, CollectionId>,83 Key<Blake2_128Concat, T::CrossAccountId>,83 Key<Blake2_128Concat, T::CrossAccountId>,88 >;88 >;898990 #[pallet::storage]90 #[pallet::storage]91 pub(super) type AccountBalance<T: Config> = StorageNMap<91 pub type AccountBalance<T: Config> = StorageNMap<92 Key = (92 Key = (93 Key<Twox64Concat, CollectionId>,93 Key<Twox64Concat, CollectionId>,94 Key<Blake2_128Concat, T::CrossAccountId>,94 Key<Blake2_128Concat, T::CrossAccountId>,98 >;98 >;9999100 #[pallet::storage]100 #[pallet::storage]101 pub(super) type Allowance<T: Config> = StorageNMap<101 pub type Allowance<T: Config> = StorageNMap<102 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),102 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),103 Value = T::CrossAccountId,103 Value = T::CrossAccountId,104 QueryKind = OptionQuery,104 QueryKind = OptionQuery,pallets/refungible/src/lib.rsdiffbeforeafterboth54 }54 }555556 #[pallet::pallet]56 #[pallet::pallet]57 #[pallet::generate_store(pub(super) trait Store)]57 #[pallet::generate_store(pub trait Store)]58 pub struct Pallet<T>(_);58 pub struct Pallet<T>(_);595960 #[pallet::storage]60 #[pallet::storage]61 pub(super) type TokensMinted<T: Config> =61 pub type TokensMinted<T: Config> =62 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;62 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;63 #[pallet::storage]63 #[pallet::storage]64 pub(super) type TokensBurnt<T: Config> =64 pub type TokensBurnt<T: Config> =65 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;65 StorageMap<Hasher = Twox64Concat, Key = CollectionId, Value = u32, QueryKind = ValueQuery>;666667 #[pallet::storage]67 #[pallet::storage]68 pub(super) type TokenData<T: Config> = StorageNMap<68 pub type TokenData<T: Config> = StorageNMap<69 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),69 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),70 Value = ItemData,70 Value = ItemData,71 QueryKind = ValueQuery,71 QueryKind = ValueQuery,72 >;72 >;737374 #[pallet::storage]74 #[pallet::storage]75 pub(super) type TotalSupply<T: Config> = StorageNMap<75 pub type TotalSupply<T: Config> = StorageNMap<76 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),76 Key = (Key<Twox64Concat, CollectionId>, Key<Twox64Concat, TokenId>),77 Value = u128,77 Value = u128,78 QueryKind = ValueQuery,78 QueryKind = ValueQuery,79 >;79 >;808081 /// Used to enumerate tokens owned by account81 /// Used to enumerate tokens owned by account82 #[pallet::storage]82 #[pallet::storage]83 pub(super) type Owned<T: Config> = StorageNMap<83 pub type Owned<T: Config> = StorageNMap<84 Key = (84 Key = (85 Key<Twox64Concat, CollectionId>,85 Key<Twox64Concat, CollectionId>,86 Key<Blake2_128Concat, T::CrossAccountId>,86 Key<Blake2_128Concat, T::CrossAccountId>,91 >;91 >;929293 #[pallet::storage]93 #[pallet::storage]94 pub(super) type AccountBalance<T: Config> = StorageNMap<94 pub type AccountBalance<T: Config> = StorageNMap<95 Key = (95 Key = (96 Key<Twox64Concat, CollectionId>,96 Key<Twox64Concat, CollectionId>,97 // Owner97 // Owner102 >;102 >;103103104 #[pallet::storage]104 #[pallet::storage]105 pub(super) type Balance<T: Config> = StorageNMap<105 pub type Balance<T: Config> = StorageNMap<106 Key = (106 Key = (107 Key<Twox64Concat, CollectionId>,107 Key<Twox64Concat, CollectionId>,108 Key<Twox64Concat, TokenId>,108 Key<Twox64Concat, TokenId>,114 >;114 >;115115116 #[pallet::storage]116 #[pallet::storage]117 pub(super) type Allowance<T: Config> = StorageNMap<117 pub type Allowance<T: Config> = StorageNMap<118 Key = (118 Key = (119 Key<Twox64Concat, CollectionId>,119 Key<Twox64Concat, CollectionId>,120 Key<Twox64Concat, TokenId>,120 Key<Twox64Concat, TokenId>,