@@ -23,8 +23,9 @@ pub mod pallet {
2323 use frame_system:: { ensure_signed, pallet_prelude:: * } ;
2424
2525 #[ pallet:: config]
26- pub trait Config : frame_system:: Config + scale_info:: TypeInfo {
27- todo ! ( "add a dependency on pallet_marketplace_nft on the previous line" ) ;
26+ pub trait Config :
27+ frame_system:: Config + scale_info:: TypeInfo + pallet_marketplace_nfts:: Config
28+ {
2829 type Event : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: Event > ;
2930 type Currency : Currency < Self :: AccountId > ;
3031 }
@@ -75,7 +76,7 @@ pub mod pallet {
7576 let origin = ensure_signed ( origin) ?;
7677
7778 ensure ! ( amount > 0 , Error :: <T >:: ZeroAmount ) ;
78- let owned = todo ! ( "get the amount owned from the pallet_nft account storage" ) ;
79+ let owned = pallet_marketplace_nfts :: Pallet :: < T > :: account ( nft_id , origin . clone ( ) ) ;
7980 ensure ! ( owned >= amount, Error :: <T >:: NotEnoughOwned ) ;
8081
8182 NFTsForSale :: < T > :: insert ( nft_id, origin. clone ( ) , SaleData { price, amount } ) ;
@@ -95,7 +96,7 @@ pub mod pallet {
9596 let buyer = ensure_signed ( origin) ?;
9697
9798 let sale_data = NFTsForSale :: < T > :: get ( nft_id, seller. clone ( ) ) ;
98- let owned = todo ! ( "get the amount owned from the pallet_nft account storage" ) ;
99+ let owned = pallet_marketplace_nfts :: Pallet :: < T > :: account ( nft_id , seller . clone ( ) ) ;
99100
100101 ensure ! ( amount <= sale_data. amount, Error :: <T >:: NotEnoughInSale ) ;
101102 ensure ! ( sale_data. amount <= owned, Error :: <T >:: NotEnoughOwned ) ;
@@ -107,7 +108,12 @@ pub mod pallet {
107108
108109 <T as pallet:: Config >:: Currency :: transfer ( & buyer, & seller, total_to_pay, KeepAlive ) ?;
109110
110- todo ! ( "call the pallet_marketplace_nft transfer function" ) ;
111+ pallet_marketplace_nfts:: Pallet :: < T > :: unchecked_transfer (
112+ nft_id,
113+ seller. clone ( ) ,
114+ buyer. clone ( ) ,
115+ amount,
116+ ) ;
111117
112118 if amount == sale_data. amount {
113119 NFTsForSale :: < T > :: remove ( nft_id, seller. clone ( ) ) ;
0 commit comments