@@ -4,6 +4,7 @@ use frame_support::{pallet_prelude::*};
44use frame_support:: sp_io:: hashing:: blake2_256;
55use sp_runtime:: sp_std:: vec:: Vec ;
66use crate :: types:: * ;
7+ use frame_support:: traits:: Time ;
78//use frame_support::traits::{Currency};
89//use frame_support::traits::ExistenceRequirement::KeepAlive;
910
@@ -712,26 +713,13 @@ impl<T: Config> Pallet<T> {
712713 }
713714 Ok ( ( ) )
714715 }
715-
716- //TODO: merge the timestamp function to convert from moment to milliseconds.
717- fn convert_moment_to_u64_in_milliseconds ( date : T :: Moment ) -> Result < u64 , DispatchError > {
718- let date_as_u64_millis;
719- if let Some ( _date_as_u64) = TryInto :: < u64 > :: try_into ( date) . ok ( ) {
720- date_as_u64_millis = _date_as_u64;
721- } else {
722- return Err ( Error :: < T > :: TimestampError ) ?;
723- }
724-
725- Ok ( date_as_u64_millis)
726- }
716+
727717
728718 fn get_timestamp_in_milliseconds ( ) -> Option < ( u64 , u64 ) > {
729- let timestamp: <T as pallet_timestamp:: Config >:: Moment = <pallet_timestamp:: Pallet < T > >:: get ( ) ;
730-
731- let timestamp2 = Self :: convert_moment_to_u64_in_milliseconds ( timestamp) . unwrap_or ( 0 ) ;
732- let timestamp3 = timestamp2 + ( 7 * 24 * 60 * 60 * 1000 ) ;
719+ let timestamp: u64 = T :: Timestamp :: now ( ) . into ( ) ;
720+ let timestamp2 = timestamp + ( 7 * 24 * 60 * 60 * 1000 ) ;
733721
734- Some ( ( timestamp2 , timestamp3 ) )
722+ Some ( ( timestamp , timestamp2 ) )
735723 }
736724
737725 fn _is_offer_status ( offer_id : [ u8 ; 32 ] , offer_status : OfferStatus , ) -> bool {
@@ -743,14 +731,6 @@ impl<T: Config> Pallet<T> {
743731 }
744732 }
745733
746- // fn _get_offer_price(offer_id: [u8;32],) -> Result<BalanceOf<T>, DispatchError> {
747- // //we already know that the offer exists, so we don't need to check it here.
748- // if let Some(offer) = <OffersInfo<T>>::get(offer_id) {
749- // return Ok(offer.price);
750- // } else {
751- // return Err(Error::<T>::OfferNotFound)?;
752- // }
753- // }
754734
755735 fn does_exist_offer_id_for_this_item ( collection_id : T :: CollectionId , item_id : T :: ItemId , offer_id : [ u8 ; 32 ] ) -> DispatchResult {
756736 let offers = <OffersByItem < T > >:: try_get ( collection_id, item_id) . map_err ( |_| Error :: < T > :: OfferNotFound ) ?;
@@ -759,14 +739,6 @@ impl<T: Config> Pallet<T> {
759739 Ok ( ( ) )
760740 }
761741
762- // fn is_the_price_valid(price: BalanceOf<T>,) -> DispatchResult {
763- // let minimun_amount: BalanceOf<T> = 1000u32.into();
764- // if price > minimun_amount {
765- // return Ok(());
766- // } else {
767- // return Err(Error::<T>::PriceMustBeGreaterThanZero)?;
768- // }
769- // }
770742
771743 fn _get_offer_creator ( offer_id : [ u8 ; 32 ] , ) -> Result < T :: AccountId , DispatchError > {
772744 //we already know that the offer exists, so we don't need to check it here.
0 commit comments