File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -859,11 +859,14 @@ impl<T: Config> Pallet<T> {
859
859
Ok ( ( ) )
860
860
}
861
861
862
- pub fn do_cancel_offer ( order_id : StorageId ) -> DispatchResult {
862
+ pub fn do_cancel_offer ( who : T :: AccountId , order_id : StorageId ) -> DispatchResult {
863
863
// ensure offer exists
864
864
ensure ! ( <AfloatOffers <T >>:: contains_key( order_id) , Error :: <T >:: OfferNotFound ) ;
865
865
//get offer details
866
866
let offer = <AfloatOffers < T > >:: get ( order_id) . unwrap ( ) ;
867
+ let is_admin_or_owner = Self :: is_admin_or_owner ( who. clone ( ) ) ?;
868
+ ensure ! ( is_admin_or_owner || offer. creator_id == who, Error :: <T >:: Unauthorized ) ;
869
+
867
870
match offer. status {
868
871
OfferStatus :: CREATED => {
869
872
<AfloatOffers < T > >:: try_mutate ( order_id, |offer| -> DispatchResult {
Original file line number Diff line number Diff line change @@ -433,9 +433,7 @@ pub mod pallet {
433
433
#[ pallet:: weight( Weight :: from_parts( 10_000 , 0 ) + T :: DbWeight :: get( ) . reads_writes( 1 , 1 ) ) ]
434
434
pub fn cancel_offer ( origin : OriginFor < T > , order_id : StorageId ) -> DispatchResult {
435
435
let who = ensure_signed ( origin. clone ( ) ) ?;
436
- let is_admin_or_owner = Self :: is_admin_or_owner ( who. clone ( ) ) ?;
437
- ensure ! ( is_admin_or_owner, Error :: <T >:: Unauthorized ) ;
438
- Self :: do_cancel_offer ( order_id)
436
+ Self :: do_cancel_offer ( who, order_id)
439
437
}
440
438
}
441
439
}
You can’t perform that action at this time.
0 commit comments