Skip to content

Commit 50b6e45

Browse files
committed
hide all currency uses & imports
1 parent aa950e6 commit 50b6e45

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

pallets/gated-marketplace/src/functions.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use frame_support::{pallet_prelude::*};
44
use frame_support::sp_io::hashing::blake2_256;
55
use sp_runtime::sp_std::vec::Vec;
66
use crate::types::*;
7-
use frame_support::traits::{Currency};
8-
use frame_support::traits::ExistenceRequirement::KeepAlive;
7+
//use frame_support::traits::{Currency};
8+
//use frame_support::traits::ExistenceRequirement::KeepAlive;
99

1010
impl<T: Config> Pallet<T> {
1111

@@ -151,7 +151,7 @@ impl<T: Config> Pallet<T> {
151151
Ok(())
152152
}
153153

154-
pub fn do_enlist_sell_offer(authority: T::AccountId, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: BalanceOf<T>,) -> DispatchResult {
154+
pub fn do_enlist_sell_offer(authority: T::AccountId, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: u128,) -> DispatchResult {
155155
//This function is only called by the owner of the marketplace
156156
//ensure the marketplace exists
157157
ensure!(<Marketplaces<T>>::contains_key(marketplace_id), Error::<T>::MarketplaceNotFound);
@@ -164,7 +164,7 @@ impl<T: Config> Pallet<T> {
164164
}
165165

166166
//ensure the price is valid
167-
Self::is_the_price_valid(price)?;
167+
// Self::is_the_price_valid(price)?;
168168

169169
//Add timestamp to the offer
170170
let(timestamp, timestamp2) = Self::get_timestamp_in_milliseconds().ok_or(Error::<T>::TimestampError)?;
@@ -214,7 +214,7 @@ impl<T: Config> Pallet<T> {
214214
Ok(())
215215
}
216216

217-
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 {
217+
pub fn do_enlist_buy_offer(authority: T::AccountId, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: u128,) -> DispatchResult {
218218
//ensure the item is for sale, if not, return error
219219
Self::can_this_item_receive_buy_orders(collection_id, item_id, marketplace_id)?;
220220

@@ -231,11 +231,11 @@ impl<T: Config> Pallet<T> {
231231
}
232232

233233
//ensure user has enough balance to create the offer
234-
let total_user_balance = T::LocalCurrency::total_balance(&authority);
235-
ensure!(total_user_balance >= price, Error::<T>::NotEnoughBalance);
234+
// let total_user_balance = T::LocalCurrency::total_balance(&authority);
235+
// ensure!(total_user_balance >= price, Error::<T>::NotEnoughBalance);
236236

237237
//ensure the price is valid
238-
Self::is_the_price_valid(price)?;
238+
// Self::is_the_price_valid(price)?;
239239

240240
//Add timestamp to the offer
241241
let(timestamp, timestamp2) = Self::get_timestamp_in_milliseconds().ok_or(Error::<T>::TimestampError)?;
@@ -310,11 +310,11 @@ impl<T: Config> Pallet<T> {
310310

311311
//TODO: Use free_balance instead of total_balance
312312
//Get the buyer's balance
313-
let total_amount_buyer = T::LocalCurrency::total_balance(&buyer);
313+
// let total_amount_buyer = T::LocalCurrency::total_balance(&buyer);
314314
//ensure the buyer has enough balance to buy the item
315-
ensure!(total_amount_buyer > offer_data.price, Error::<T>::NotEnoughBalance);
315+
// ensure!(total_amount_buyer > offer_data.price, Error::<T>::NotEnoughBalance);
316316
//Transfer the balance
317-
T::LocalCurrency::transfer(&buyer, &owner_item, offer_data.price, KeepAlive)?;
317+
// T::LocalCurrency::transfer(&buyer, &owner_item, offer_data.price, KeepAlive)?;
318318

319319
//Use uniques transfer function to transfer the item to the buyer
320320
pallet_uniques::Pallet::<T>::do_transfer(offer_data.collection_id, offer_data.item_id, buyer.clone(), |_, _|{
@@ -362,11 +362,11 @@ impl<T: Config> Pallet<T> {
362362

363363
//TODO: Use free_balance instead of total_balance
364364
//Get the buyer's balance
365-
let total_amount_buyer = T::LocalCurrency::total_balance(&offer_data.creator);
365+
// let total_amount_buyer = T::LocalCurrency::total_balance(&offer_data.creator);
366366
//ensure the buy_offer_creator has enough balance to buy the item
367-
ensure!(total_amount_buyer > offer_data.price, Error::<T>::NotEnoughBalance);
367+
// ensure!(total_amount_buyer > offer_data.price, Error::<T>::NotEnoughBalance);
368368
//Transfer the balance to the owner of the item
369-
T::LocalCurrency::transfer(&offer_data.creator, &owner_item, offer_data.price, KeepAlive)?;
369+
// T::LocalCurrency::transfer(&offer_data.creator, &owner_item, offer_data.price, KeepAlive)?;
370370

371371
//Use uniques transfer function to transfer the item to the market_participant
372372
pallet_uniques::Pallet::<T>::do_transfer(offer_data.collection_id, offer_data.item_id, offer_data.creator.clone(), |_, _|{
@@ -743,14 +743,14 @@ impl<T: Config> Pallet<T> {
743743
}
744744
}
745745

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-
}
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+
// }
754754

755755
fn does_exist_offer_id_for_this_item(collection_id: T::CollectionId, item_id: T::ItemId, offer_id: [u8;32]) -> DispatchResult {
756756
let offers = <OffersByItem<T>>::try_get(collection_id, item_id).map_err(|_| Error::<T>::OfferNotFound)?;
@@ -759,14 +759,14 @@ impl<T: Config> Pallet<T> {
759759
Ok(())
760760
}
761761

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-
}
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+
// }
770770

771771
fn _get_offer_creator(offer_id: [u8;32],) -> Result<T::AccountId, DispatchError> {
772772
//we already know that the offer exists, so we don't need to check it here.

pallets/gated-marketplace/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod types;
2020
pub mod pallet {
2121
use frame_support::{pallet_prelude::{*, OptionQuery}, transactional};
2222
use frame_system::pallet_prelude::*;
23-
use frame_support::traits::Currency;
23+
//use frame_support::traits::Currency;
2424
//use sp_runtime::sp_std::vec::Vec;
2525
use crate::types::*;
2626
//use frame_support::traits::tokens::Balance;
@@ -29,7 +29,7 @@ pub mod pallet {
2929
#[pallet::config]
3030
pub trait Config: frame_system::Config + pallet_fruniques::Config + pallet_uniques::Config + pallet_timestamp::Config{
3131
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
32-
type LocalCurrency: Currency<Self::AccountId>;
32+
//type LocalCurrency: Currency<Self::AccountId>;
3333
//type Balance: Balance + MaybeSerializeDeserialize + Debug + MaxEncodedLen;
3434

3535
type RemoveOrigin: EnsureOrigin<Self::Origin>;
@@ -533,7 +533,7 @@ pub mod pallet {
533533
/// - If the selected collection doesn't exist, it will throw an error.
534534
#[transactional]
535535
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
536-
pub fn enlist_sell_offer(origin: OriginFor<T>, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: BalanceOf<T>,) -> DispatchResult {
536+
pub fn enlist_sell_offer(origin: OriginFor<T>, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: u128,) -> DispatchResult {
537537
let who = ensure_signed(origin)?;
538538

539539
Self::do_enlist_sell_offer(who, marketplace_id, collection_id, item_id, price)
@@ -626,7 +626,7 @@ pub mod pallet {
626626
/// - You need to have the enough balance to create the buy order.
627627
#[transactional]
628628
#[pallet::weight(10_000 + T::DbWeight::get().writes(1))]
629-
pub fn enlist_buy_offer(origin: OriginFor<T>, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: BalanceOf<T>,) -> DispatchResult {
629+
pub fn enlist_buy_offer(origin: OriginFor<T>, marketplace_id: [u8;32], collection_id: T::CollectionId, item_id: T::ItemId, price: u128,) -> DispatchResult {
630630
let who = ensure_signed(origin)?;
631631

632632
Self::do_enlist_buy_offer(who, marketplace_id, collection_id, item_id, price)

pallets/gated-marketplace/src/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl pallet_gated_marketplace::Config for Test {
8888
type MaxApplicationsPerCustodian = MaxApplicationsPerCustodian;
8989
type MaxOffersPerMarket = MaxOffersPerMarket;
9090
type MaxMarketsPerItem = MaxMarketsPerItem;
91-
type LocalCurrency = Balances;
91+
//type LocalCurrency = Balances;
9292
}
9393

9494
impl pallet_fruniques::Config for Test {

pallets/gated-marketplace/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use frame_support::pallet_prelude::*;
44
//use frame_system::pallet_prelude::*;
55
use frame_support::traits::Currency;
66

7-
pub type BalanceOf<T> = <<T as Config>::LocalCurrency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
7+
//pub type BalanceOf<T> = <<T as Config>::LocalCurrency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
88

99
#[derive(CloneNoBound,Encode, Decode, RuntimeDebugNoBound, Default, TypeInfo, MaxEncodedLen,)]
1010
#[scale_info(skip_type_params(T))]
@@ -99,7 +99,7 @@ pub struct OfferData<T: Config>{
9999
pub collection_id: T::CollectionId,
100100
pub item_id: T::ItemId,
101101
pub creator: T::AccountId,
102-
pub price: BalanceOf<T>,
102+
pub price: u128,
103103
pub status: OfferStatus,
104104
pub creation_date: u64,
105105
pub expiration_date: u64,

0 commit comments

Comments
 (0)