@@ -183,7 +183,7 @@ impl<T: Config> Pallet<T> {
183183 //This function is only called by the owner of the marketplace
184184 //ensure the marketplace exists
185185 ensure ! ( <Marketplaces <T >>:: contains_key( marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
186-
186+ Self :: is_authorized ( authority . clone ( ) , & marketplace_id , Permission :: EnlistSellOffer ) ? ;
187187 //ensure the collection exists
188188 if let Some ( a) = pallet_uniques:: Pallet :: < T > :: owner ( collection_id, item_id) {
189189 ensure ! ( a == authority, Error :: <T >:: NotOwner ) ;
@@ -244,13 +244,14 @@ impl<T: Config> Pallet<T> {
244244 }
245245
246246 pub fn do_enlist_buy_offer ( authority : T :: AccountId , marketplace_id : [ u8 ; 32 ] , collection_id : T :: CollectionId , item_id : T :: ItemId , price : BalanceOf < T > , ) -> DispatchResult {
247- //TODO: ensure the user is a Marketparticipant
248-
247+ // ensure the user is a Marketparticipant
248+ //ensure!(<ApplicantsByMarketplace<T>>::get(marketplace_id, ApplicationStatus::Approved).contains(&authority), Error::<T>::ApplicantNotFound);
249249 //ensure the item is for sale, if not, return error
250250 ensure ! ( <OffersByItem <T >>:: contains_key( collection_id, item_id) , Error :: <T >:: ItemNotForSale ) ;
251-
251+
252252 //ensure the marketplace exists
253253 ensure ! ( <Marketplaces <T >>:: contains_key( marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
254+ Self :: is_authorized ( authority. clone ( ) , & marketplace_id, Permission :: EnlistBuyOffer ) ?;
254255
255256 //ensure the collection exists
256257 //For this case user doesn't have to be the owner of the collection
@@ -314,6 +315,8 @@ impl<T: Config> Pallet<T> {
314315 }
315316
316317 pub fn do_take_sell_offer ( buyer : T :: AccountId , offer_id : [ u8 ; 32 ] , marketplace_id : [ u8 ; 32 ] , collection_id : T :: CollectionId , item_id : T :: ItemId , ) -> DispatchResult {
318+ ensure ! ( <Marketplaces <T >>:: contains_key( marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
319+ Self :: is_authorized ( buyer. clone ( ) , & marketplace_id, Permission :: TakeSellOffer ) ?;
317320 //This extrisicn is called by the user who wants to buy the item
318321 //ensure the collection & owner exists
319322 let owner_item = pallet_uniques:: Pallet :: < T > :: owner ( collection_id, item_id) . ok_or ( Error :: < T > :: OwnerNotFound ) ?;
@@ -358,6 +361,8 @@ impl<T: Config> Pallet<T> {
358361
359362 pub fn do_take_buy_offer ( authority : T :: AccountId , offer_id : [ u8 ; 32 ] , marketplace_id : [ u8 ; 32 ] , collection_id : T :: CollectionId , item_id : T :: ItemId , ) -> DispatchResult {
360363 //This extrinsic is called by the owner of the item who accepts the buy offer from the interested user.
364+ ensure ! ( <Marketplaces <T >>:: contains_key( & marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
365+ Self :: is_authorized ( authority. clone ( ) , & marketplace_id, Permission :: TakeBuyOffer ) ?;
361366 //ensure the collection & owner exists
362367 let owner_item = pallet_uniques:: Pallet :: < T > :: owner ( collection_id, item_id) . ok_or ( Error :: < T > :: OwnerNotFound ) ?;
363368
@@ -408,7 +413,7 @@ impl<T: Config> Pallet<T> {
408413 pub fn do_duplicate_offer ( authority : T :: AccountId , offer_id : [ u8 ; 32 ] , marketplace_id : [ u8 ; 32 ] , collection_id : T :: CollectionId , item_id : T :: ItemId , modified_price : BalanceOf < T > ) -> DispatchResult {
409414 //ensure new marketplace_id exits
410415 ensure ! ( <Marketplaces <T >>:: contains_key( marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
411-
416+ Self :: is_authorized ( authority . clone ( ) , & marketplace_id , Permission :: DuplicateOffer ) ? ;
412417 //ensure that the offer_id exists
413418 ensure ! ( <OffersInfo <T >>:: contains_key( offer_id) , Error :: <T >:: OfferNotFound ) ;
414419
@@ -455,7 +460,7 @@ impl<T: Config> Pallet<T> {
455460 pub fn do_remove_offer ( authority : T :: AccountId , offer_id : [ u8 ; 32 ] , marketplace_id : [ u8 ; 32 ] , collection_id : T :: CollectionId , item_id : T :: ItemId , ) -> DispatchResult {
456461 //ensure marketplace_id exits
457462 ensure ! ( <Marketplaces <T >>:: contains_key( marketplace_id) , Error :: <T >:: MarketplaceNotFound ) ;
458-
463+ Self :: is_authorized ( authority . clone ( ) , & marketplace_id , Permission :: RemoveOffer ) ? ;
459464 //ensure the offer_id exists
460465 ensure ! ( <OffersInfo <T >>:: contains_key( offer_id) , Error :: <T >:: OfferNotFound ) ;
461466
0 commit comments