diff --git a/pallets/bidding/src/functions.rs b/pallets/bidding/src/functions.rs index 08fef09a..35dfbabf 100644 --- a/pallets/bidding/src/functions.rs +++ b/pallets/bidding/src/functions.rs @@ -22,8 +22,8 @@ impl Pallet { Roles::InvestorLog::::iter().map(|x| x.0).collect_into(&mut investors); investors.retain(|x|{ let status = Houses::Pallet::::contributions(x.clone()).unwrap(); - let contribution0 = Self::hfund_bal_to_u128(status.contributed_balance).unwrap(); - let contribution = Self::u128_to_onboarding_bal(contribution0).unwrap(); + let contribution = status.contributed_balance; + //user contributed more than 5% of asset_price contribution > Percent::from_percent(5) * asset_price //should be minimun contribution calculated from asset price. //ToDo: We also want to only include users that did not contributed to a purchase for y_blocks (to be defined). @@ -39,16 +39,6 @@ impl Pallet { } - // Conversion of BalanceOf to u128 - pub fn hfund_bal_to_u128(input: Houses::BalanceOf) -> Option { - input.try_into().ok() - } - - // Conversion of BalanceOf to u128 - pub fn u128_to_onboarding_bal(input: u128) -> Option> { - input.try_into().ok() - } - } diff --git a/pallets/bidding/src/types.rs b/pallets/bidding/src/types.rs index 7d25cc37..9b23fc8d 100644 --- a/pallets/bidding/src/types.rs +++ b/pallets/bidding/src/types.rs @@ -17,8 +17,6 @@ pub use scale_info::{prelude::vec, TypeInfo}; pub use serde::{Deserialize, Serialize}; pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; -pub type BalanceOf0 = -<::LocalCurrency as Currency<::AccountId>>::Balance; + <::Currency as Currency<::AccountId>>::Balance; pub type AccountIdOf = ::AccountId; pub type BlockNumberOf = BlockNumberFor; \ No newline at end of file diff --git a/pallets/housing_fund/src/functions.rs b/pallets/housing_fund/src/functions.rs index aacd017f..c2007193 100644 --- a/pallets/housing_fund/src/functions.rs +++ b/pallets/housing_fund/src/functions.rs @@ -12,7 +12,7 @@ impl Pallet { /// Check that the fund can afford the amount pub fn check_available_fund(value: BalanceOf) -> bool { let fund_account = Self::fund_account_id(); - let amount = T::LocalCurrency::free_balance(&fund_account); + let amount = ::Currency::free_balance(&fund_account); amount>value } @@ -26,7 +26,7 @@ impl Pallet { pub fn get_contribution_share() -> Vec> { let mut contribution_shares = Vec::>::new(); let fund_account = Self::fund_account_id(); - let total = T::LocalCurrency::free_balance(&fund_account); + let total = ::Currency::free_balance(&fund_account); for (account_id, contribution) in Contributions::::iter() { @@ -55,7 +55,7 @@ impl Pallet { ) -> DispatchResultWithPostInfo { // Check that the fund can afford the bid let fund_account = Self::fund_account_id(); - let fund = T::LocalCurrency::free_balance(&fund_account); + let fund = ::Currency::free_balance(&fund_account); ensure!(fund>amount, Error::::NotEnoughFundForHouse); @@ -83,7 +83,7 @@ impl Pallet { } // The amount is tagged as reserved in the fund for the account_id - T::LocalCurrency::reserve(&Self::fund_account_id(), amount)?; + ::Currency::reserve(&Self::fund_account_id(), amount)?; // Get the block number for timestamp let block_number = >::block_number(); @@ -132,7 +132,7 @@ impl Pallet { }); } - T::LocalCurrency::unreserve(&Self::fund_account_id(), reservation.amount); + ::Currency::unreserve(&Self::fund_account_id(), reservation.amount); Reservations::::remove((nft_collection_id, nft_item_id)); // Get the block number for timestamp @@ -161,7 +161,7 @@ impl Pallet { let reservation = reservation_wrap.unwrap(); // The amount is unreserved in the currency pallet - T::LocalCurrency::unreserve(&Self::fund_account_id(), reservation.amount); + ::Currency::unreserve(&Self::fund_account_id(), reservation.amount); // Get the block number for timestamp let block_number = >::block_number(); diff --git a/pallets/housing_fund/src/lib.rs b/pallets/housing_fund/src/lib.rs index d9fa6b1e..9fb680c2 100644 --- a/pallets/housing_fund/src/lib.rs +++ b/pallets/housing_fund/src/lib.rs @@ -45,8 +45,6 @@ pub mod pallet { pub trait Config: frame_system::Config + NFT::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type LocalCurrency: frame_support::traits::Currency - + frame_support::traits::ReservableCurrency; type MinContribution: Get>; type FundThreshold: Get>; type MaxFundContribution: Get>; @@ -164,7 +162,7 @@ pub mod pallet { // Check if account has enough to contribute ensure!( - T::LocalCurrency::free_balance(&who) >= amount, + ::Currency::free_balance(&who) >= amount, Error::::NotEnoughToContribute ); @@ -208,7 +206,7 @@ pub mod pallet { // The amount is transferred to the treasurery - T::LocalCurrency::transfer( + ::Currency::transfer( &who, &Pallet::::fund_account_id(), amount, @@ -257,7 +255,7 @@ pub mod pallet { // Get the fund balance let fund_account = Self::fund_account_id(); - let fund = T::LocalCurrency::free_balance(&fund_account); + let fund = ::Currency::free_balance(&fund_account); // Check that the fund has enough transferable for the withdraw ensure!(fund>amount, Error::::NotEnoughInTransferableForWithdraw); @@ -285,7 +283,7 @@ pub mod pallet { // The amount is transferred from the treasury to the account - T::LocalCurrency::transfer( + ::Currency::transfer( &Pallet::::fund_account_id(), &who, amount, diff --git a/pallets/housing_fund/src/types.rs b/pallets/housing_fund/src/types.rs index 419cb5f9..f19afecc 100644 --- a/pallets/housing_fund/src/types.rs +++ b/pallets/housing_fund/src/types.rs @@ -15,7 +15,7 @@ pub use frame_system::{ensure_signed, ensure_root, pallet_prelude::*, RawOrigin} pub use scale_info::{prelude::vec::Vec, TypeInfo}; pub use serde::{Deserialize, Serialize}; -pub type BalanceOf = <::LocalCurrency as Currency>>::Balance; +pub type BalanceOf = <::Currency as Currency>>::Balance; pub type AccountIdOf = ::AccountId; pub type BlockNumberOf = BlockNumberFor; diff --git a/pallets/onboarding/src/functions.rs b/pallets/onboarding/src/functions.rs index 44c1db2e..ef8a51ec 100644 --- a/pallets/onboarding/src/functions.rs +++ b/pallets/onboarding/src/functions.rs @@ -91,8 +91,8 @@ impl Pallet { let owner = Nft::Pallet::::owner(collection_id, item_id) .ok_or(Error::::CollectionOrItemUnknown)?; ensure!(buyer != owner, Error::::BuyFromSelf); - let balance = ::Currency::reserved_balance(&owner); - let _returned = ::Currency::unreserve(&owner, balance); + let balance = ::Currency::reserved_balance(&owner); + let _returned = ::Currency::unreserve(&owner, balance); // The reserved funds in Housing Fund from the house bidding are unreserved for the transfer // transaction @@ -101,7 +101,7 @@ impl Pallet { //Transfer funds from HousingFund to owner let price = Prices::::get(collection_id, item_id).unwrap(); let fund_id = T::PalletId::get().into_account_truncating(); - ::Currency::transfer( + ::Currency::transfer( &fund_id, &owner, price, diff --git a/pallets/onboarding/src/lib.rs b/pallets/onboarding/src/lib.rs index 9544f55a..24522e62 100644 --- a/pallets/onboarding/src/lib.rs +++ b/pallets/onboarding/src/lib.rs @@ -96,8 +96,6 @@ pub mod pallet { { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type Currency: ReservableCurrency - + IsType<::LocalCurrency>; type Prop: Parameter + UnfilteredDispatchable::RuntimeOrigin> + From> @@ -396,11 +394,11 @@ pub struct GenesisConfig { Self::change_status(frame_system::RawOrigin::Root.into(), collection, item_id, Status::REJECTED).ok(); let owner = Nft::Pallet::::owner(collection_id, item_id).unwrap(); - let balance = ::Currency::reserved_balance(&owner); + let balance = ::Currency::reserved_balance(&owner); let fees = ::Slash::get().mul_floor(balance); let remain = balance.saturating_sub(fees); - ::Currency::unreserve(&owner, fees); - let res = ::Currency::transfer( + ::Currency::unreserve(&owner, fees); + let res = ::Currency::transfer( &owner, &Self::account_id(), fees, @@ -408,7 +406,7 @@ pub struct GenesisConfig { ); debug_assert!(res.is_ok()); - let res1 = ::Currency::reserve(&owner, remain); + let res1 = ::Currency::reserve(&owner, remain); debug_assert!(res1.is_ok()); Self::deposit_event(Event::RejectedForEditing { @@ -445,10 +443,10 @@ pub struct GenesisConfig { Self::change_status(frame_system::RawOrigin::Root.into(), collection, item_id, Status::SLASH).ok(); let owner = Nft::Pallet::::owner(collection_id, item_id).unwrap(); Nft::Pallet::::burn(origin, collection, item_id).ok(); - let balance = ::Currency::reserved_balance(&owner); + let balance = ::Currency::reserved_balance(&owner); ensure!(balance > Zero::zero(), Error::::NoneValue); - ::Currency::unreserve(&owner, balance); - let res = ::Currency::transfer( + ::Currency::unreserve(&owner, balance); + let res = ::Currency::transfer( &owner, &Self::account_id(), balance, @@ -489,11 +487,11 @@ pub struct GenesisConfig { let item_id: T::NftItemId = Nft::ItemsCount::::get()[idx].into(); //Create asset - let balance1 = ::Currency::free_balance(&caller); + let balance1 = ::Currency::free_balance(&caller); let balance0 = T::ProposalFee::get().mul_floor(price.unwrap()); ensure!(balance1 > balance0, Error::::InsufficientBalance); - ::Currency::reserve(&caller, balance0).ok(); + ::Currency::reserve(&caller, balance0).ok(); Self::create_asset(origin.clone(), collection, metadata, price, item_id,max_tenants).ok(); diff --git a/pallets/onboarding/src/mock.rs b/pallets/onboarding/src/mock.rs index d475f6bf..f78695d4 100644 --- a/pallets/onboarding/src/mock.rs +++ b/pallets/onboarding/src/mock.rs @@ -138,7 +138,6 @@ parameter_types! { impl pallet_onboarding::Config for Test { type RuntimeEvent = RuntimeEvent; - type Currency = Balances; type Prop = RuntimeCall; type ProposalFee = ProposalFee; type Slash = SlashedFee; @@ -159,7 +158,6 @@ parameter_types! { impl pallet_housing_fund::Config for Test { type RuntimeEvent = RuntimeEvent; - type LocalCurrency = Balances; type MinContribution = MinContribution; type FundThreshold = FundThreshold; type MaxFundContribution = MaxFundContribution; diff --git a/pallets/onboarding/src/types.rs b/pallets/onboarding/src/types.rs index 861dcd06..78c43bf4 100644 --- a/pallets/onboarding/src/types.rs +++ b/pallets/onboarding/src/types.rs @@ -29,7 +29,7 @@ pub use sp_std::vec::Vec; pub type BlockNumberOf = BlockNumberFor; pub type NftCollectionOf = Nft::PossibleCollections; pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Currency<::AccountId>>::Balance; pub type BalanceOf1 = <::Currency as Currency<::AccountId>>::Balance; pub type CallOf = ::RuntimeCall; diff --git a/pallets/roles/src/types.rs b/pallets/roles/src/types.rs index 7486d301..192c630b 100644 --- a/pallets/roles/src/types.rs +++ b/pallets/roles/src/types.rs @@ -134,7 +134,7 @@ impl HouseSeller }; SellerApprovalList::::mutate(|list| { - let check=list.force_push(hw.clone()); + let _=list.try_push(hw.clone()).map_err(|_| "Max number of requests reached").ok(); }); hw @@ -198,7 +198,7 @@ impl Servicer { Servicer { account_id: acc.clone(), age: now, activated: false}; ServicerApprovalList::::mutate(|list| { - list.force_push(sv.clone()); + list.try_push(sv.clone()).map_err(|_| "Max number of requests reached").ok(); }); sv @@ -274,7 +274,7 @@ impl Notary let notary = Notary { account_id: caller.clone(), age: now, activated: false}; NotaryApprovalList::::mutate(|list| { - list.force_push(notary.clone()); + list.try_push(notary.clone()).map_err(|_| "Max number of requests reached").ok(); }); notary diff --git a/pallets/share_distributor/Cargo.toml b/pallets/share_distributor/Cargo.toml new file mode 100644 index 00000000..4d4eff0b --- /dev/null +++ b/pallets/share_distributor/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "share_distributor" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/pallets/share_distributor/src/main.rs b/pallets/share_distributor/src/main.rs new file mode 100644 index 00000000..a30eb952 --- /dev/null +++ b/pallets/share_distributor/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}