@@ -23,8 +23,9 @@ pub mod pallet {
23
23
use frame_system:: { ensure_signed, pallet_prelude:: * } ;
24
24
25
25
#[ 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
+ {
28
29
type Event : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: Event > ;
29
30
type Currency : Currency < Self :: AccountId > ;
30
31
}
@@ -75,7 +76,7 @@ pub mod pallet {
75
76
let origin = ensure_signed ( origin) ?;
76
77
77
78
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 ( ) ) ;
79
80
ensure ! ( owned >= amount, Error :: <T >:: NotEnoughOwned ) ;
80
81
81
82
NFTsForSale :: < T > :: insert ( nft_id, origin. clone ( ) , SaleData { price, amount } ) ;
@@ -95,7 +96,7 @@ pub mod pallet {
95
96
let buyer = ensure_signed ( origin) ?;
96
97
97
98
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 ( ) ) ;
99
100
100
101
ensure ! ( amount <= sale_data. amount, Error :: <T >:: NotEnoughInSale ) ;
101
102
ensure ! ( sale_data. amount <= owned, Error :: <T >:: NotEnoughOwned ) ;
@@ -107,7 +108,12 @@ pub mod pallet {
107
108
108
109
<T as pallet:: Config >:: Currency :: transfer ( & buyer, & seller, total_to_pay, KeepAlive ) ?;
109
110
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
+ ) ;
111
117
112
118
if amount == sale_data. amount {
113
119
NFTsForSale :: < T > :: remove ( nft_id, seller. clone ( ) ) ;
0 commit comments