From 107106e6bc98e5323a3abe4969773eb0c2809f60 Mon Sep 17 00:00:00 2001 From: Amiya Behera Date: Thu, 23 Nov 2023 11:35:11 +0530 Subject: [PATCH] department-funding --- pallets/department-funding/src/extras.rs | 99 ++++++- pallets/department-funding/src/lib.rs | 326 +++++++++++++---------- pallets/department-funding/src/mock.rs | 15 +- pallets/department-funding/src/types.rs | 38 +++ pallets/project-tips/src/tests.rs | 2 - pallets/sortition-sum-game/src/types.rs | 2 +- 6 files changed, 330 insertions(+), 152 deletions(-) create mode 100644 pallets/department-funding/src/types.rs diff --git a/pallets/department-funding/src/extras.rs b/pallets/department-funding/src/extras.rs index 7d07a47..a110b79 100644 --- a/pallets/department-funding/src/extras.rs +++ b/pallets/department-funding/src/extras.rs @@ -1,20 +1,80 @@ use crate::*; -impl Pallet { +impl DepartmentRequiredFund { + pub fn new( + department_required_fund_id: DepartmentRequiredFundId, + department_id: DepartmentId, + tipping_name: TippingName, + funding_needed: BalanceOf, + creator: T::AccountId, + ) -> Self { + DepartmentRequiredFund { + created: new_who_and_when::(creator.clone()), + department_required_fund_id, + department_id, + tipping_name, + funding_needed, + creator, + } + } +} +impl Pallet { pub(super) fn get_phase_data() -> PhaseData { T::SchellingGameSharedSource::create_phase_data(50, 5, 3, 100, (100, 100)) } - pub fn ensure_min_stake_deparment(department_id: DeparmentId) -> DispatchResult { - let stake = DepartmentStakeBalance::::get(department_id); - let min_stake = MinimumDepartmentStake::::get(); - // println!("stake {:?}", stake); - // println!("min stake {:?}", min_stake); - ensure!(stake >= min_stake, Error::::LessThanMinStake); + + pub fn ensure_validation_on_positive_externality( + department_required_fund_id: DepartmentRequiredFundId, + ) -> DispatchResult { + let bool_data = ValidateDepartmentRequiredFund::::get(department_required_fund_id); + ensure!(bool_data == true, Error::::ValidationForDepartmentRequiredFundIdIsOff); Ok(()) } + pub fn get_department_id_from_department_required_fund_id( + department_required_fund_id: DepartmentRequiredFundId, + ) -> Result { + Ok(1) + } + + // pub fn ensure_user_is_project_creator_and_project_exists( + // project_id: ProjectId, + // user: T::AccountId, + // ) -> DispatchResult { + // let project_option: Option> = Projects::get(project_id); + // match project_option { + // Some(project) => { + // let creator = project.creator; + // ensure!(creator == user, Error::::ProjectCreatorDontMatch); + // }, + // None => Err(Error::::ProjectDontExists)?, + // } + + // Ok(()) + // } + + // pub fn ensure_staking_period_set_once_project_id(project_id: ProjectId) -> DispatchResult { + // let block_number_option = >::get(project_id); + // match block_number_option { + // Some(_block) => Err(Error::::ProjectIdStakingPeriodAlreadySet)?, + // None => Ok(()), + // } + // } + + pub fn get_block_number_of_schelling_game( + department_required_fund_id: DepartmentRequiredFundId, + ) -> Result, DispatchError> { + let block_number_option = + >::get(department_required_fund_id); + let block_number = match block_number_option { + Some(block_number) => block_number, + None => Err(Error::::BlockDepartmentRequiredFundIdNotExists)?, + }; + Ok(block_number) + } + pub(super) fn u64_to_balance_saturated(input: u64) -> BalanceOf { input.saturated_into::>() } @@ -22,4 +82,29 @@ impl Pallet { pub(super) fn u64_to_block_saturated(input: u64) -> BlockNumberOf { input.saturated_into::>() } + + pub(super) fn value_of_tipping_name(tipping: TippingName) -> TippingValue> { + match tipping { + TippingName::SmallTipper => TippingValue { + max_tipping_value: 10_000u64.saturated_into::>(), + stake_required: 10u64.saturated_into::>(), + }, + TippingName::BigTipper => TippingValue { + max_tipping_value: 100_000u64.saturated_into::>(), + stake_required: 50u64.saturated_into::>(), + }, + TippingName::SmallSpender => TippingValue { + max_tipping_value: 1_000_000u64.saturated_into::>(), + stake_required: 100u64.saturated_into::>(), + }, + TippingName::MediumSpender => TippingValue { + max_tipping_value: 10_000_000u64.saturated_into::>(), + stake_required: 200u64.saturated_into::>(), + }, + TippingName::BigSpender => TippingValue { + max_tipping_value: 100_000_000u64.saturated_into::>(), + stake_required: 500u64.saturated_into::>(), + }, + } + } } diff --git a/pallets/department-funding/src/lib.rs b/pallets/department-funding/src/lib.rs index 7fc4e3d..c90f7c7 100644 --- a/pallets/department-funding/src/lib.rs +++ b/pallets/department-funding/src/lib.rs @@ -3,6 +3,7 @@ /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// +// One can enhance validation measures by increasing staking power for local residents or individuals with positive externalities—those who contribute to the network for a good cause. pub use pallet::*; #[cfg(test)] @@ -17,13 +18,14 @@ pub mod weights; pub use weights::*; mod extras; +mod types; use frame_support::sp_runtime::traits::Saturating; use frame_support::sp_runtime::SaturatedConversion; use frame_support::sp_std::prelude::*; use frame_support::{ dispatch::{DispatchError, DispatchResult}, - ensure, fail, + ensure, }; use frame_support::{ traits::{Currency, ExistenceRequirement, Get, ReservableCurrency, WithdrawReasons}, @@ -33,17 +35,21 @@ use pallet_support::{ ensure_content_is_valid, new_who_and_when, remove_from_vec, Content, PositiveExternalityPostId, WhoAndWhen, WhoAndWhenOf, }; -use schelling_game_shared::types::{Period, RangePoint, SchellingGameType, PhaseData}; +use schelling_game_shared::types::{Period, PhaseData, RangePoint, SchellingGameType}; use schelling_game_shared_link::SchellingGameSharedLink; use shared_storage_link::SharedStorageLink; use sortition_sum_game::types::SumTreeName; +pub use types::DEPARTMENT_REQUIRED_FUND_ID; +use types::{DepartmentRequiredFund, TippingName, TippingValue}; + type AccountIdOf = ::AccountId; type BalanceOf = <::Currency as Currency>>::Balance; pub type BlockNumberOf = ::BlockNumber; pub type SumTreeNameType = SumTreeName, BlockNumberOf>; -type DeparmentId = u64; +type DepartmentId = u64; +type DepartmentRequiredFundId = u64; -#[frame_support::pallet] +#[frame_support::pallet(dev_mode)] pub mod pallet { use super::*; use frame_support::pallet_prelude::*; @@ -55,7 +61,9 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] - pub trait Config: frame_system::Config + schelling_game_shared::Config { + pub trait Config: + frame_system::Config + schelling_game_shared::Config + pallet_timestamp::Config + { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type representing the weight of this pallet @@ -71,7 +79,6 @@ pub mod pallet { RangePoint = RangePoint, Period = Period, PhaseData = PhaseData, - >; type Currency: ReservableCurrency; } @@ -89,15 +96,34 @@ pub mod pallet { 10000u128.saturated_into::>() } + #[pallet::type_value] + pub fn DefaultForNextDepartmentRequiredFundId() -> DepartmentRequiredFundId { + DEPARTMENT_REQUIRED_FUND_ID + } + + #[pallet::storage] + #[pallet::getter(fn next_department_required_fund_id)] + pub type NextDepartmentRequiredFundId = StorageValue< + _, + DepartmentRequiredFundId, + ValueQuery, + DefaultForNextDepartmentRequiredFundId, + >; + #[pallet::storage] - #[pallet::getter(fn department_stake)] - pub type DepartmentStakeBalance = - StorageMap<_, Twox64Concat, DeparmentId, BalanceOf, ValueQuery>; + #[pallet::getter(fn get_department_required_funds)] + pub type DepartmentRequiredFunds = + StorageMap<_, Blake2_128Concat, DepartmentRequiredFundId, DepartmentRequiredFund>; #[pallet::storage] - #[pallet::getter(fn validation_department_block_number)] - pub type ValidationDepartmentBlock = - StorageMap<_, Blake2_128Concat, DeparmentId, BlockNumberOf, ValueQuery>; + #[pallet::getter(fn validate_positive_externality)] + pub type ValidateDepartmentRequiredFund = + StorageMap<_, Twox64Concat, DepartmentRequiredFundId, bool, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn validation_department_required_funds_block_number)] + pub type ValidationDepartmentRequiredFundsBlock = + StorageMap<_, Blake2_128Concat, DepartmentRequiredFundId, BlockNumberOf>; // Pallets use events to inform users when important changes are made. // https://docs.substrate.io/main-docs/build/events-errors/ @@ -107,6 +133,19 @@ pub mod pallet { /// Event documentation should end with an array that provides descriptive names for event /// parameters. [something, who] SomethingStored { something: u32, who: T::AccountId }, + ProjectCreated { + account: T::AccountId, + department_required_fund_id: DepartmentRequiredFundId, + }, + StakinPeriodStarted { + department_required_fund_id: DepartmentRequiredFundId, + block_number: BlockNumberOf, + }, + ApplyJurors { + department_required_fund_id: DepartmentRequiredFundId, + block_number: BlockNumberOf, + account: T::AccountId, + }, } // Errors inform users that something went wrong. @@ -119,152 +158,161 @@ pub mod pallet { LessThanMinStake, CannotStakeNow, ChoiceOutOfRange, + FundingMoreThanTippingValue, + DepartmentRequiredFundDontExits, + BlockDepartmentRequiredFundIdNotExists, + ValidationForDepartmentRequiredFundIdIsOff, } - // Dispatchable functions allows users to interact with the pallet and invoke state changes. - // These functions materialize as "extrinsics", which are often compared to transactions. - // Dispatchable functions must be annotated with a weight and must return a DispatchResult. + // Check deparment exists, it will done using loose coupling #[pallet::call] impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn add_department_stake( + #[pallet::weight(0)] + pub fn create_department_required_fund( origin: OriginFor, - department_id: DeparmentId, - deposit: BalanceOf, + department_id: DepartmentId, + tipping_name: TippingName, + funding_needed: BalanceOf, ) -> DispatchResult { let who = ensure_signed(origin)?; + let tipping_value = Self::value_of_tipping_name(tipping_name); + let max_tipping_value = tipping_value.max_tipping_value; + let stake_required = tipping_value.stake_required; + let new_department_fund_id = Self::next_department_required_fund_id(); + let new_department_fund: DepartmentRequiredFund = DepartmentRequiredFund::new( + new_department_fund_id, + department_id, + tipping_name, + funding_needed, + who.clone(), + ); + ensure!(funding_needed <= max_tipping_value, Error::::FundingMoreThanTippingValue); // Check user has done kyc let _ = ::Currency::withdraw( &who, - deposit, + stake_required, WithdrawReasons::TRANSFER, ExistenceRequirement::AllowDeath, )?; - let stake = DepartmentStakeBalance::::get(department_id); - let total_balance = stake.saturating_add(deposit); - DepartmentStakeBalance::::insert(department_id, total_balance); - - // emit event + DepartmentRequiredFunds::insert(new_department_fund_id, new_department_fund); + NextDepartmentRequiredFundId::::mutate(|n| { + *n += 1; + }); + + Self::deposit_event(Event::ProjectCreated { + account: who, + department_required_fund_id: new_department_fund_id, + }); Ok(()) } - // #[pallet::weight(10_000 + T::DbWeight::get().writes(1))] - // pub fn set_validate_positive_externality( - // origin: OriginFor, - // value: bool, - // ) -> DispatchResult { - // let who = ensure_signed(origin)?; - // // Check user has done kyc - - // ValidatePositiveExternality::::insert(&who, value); - // // emit event - // Ok(()) - // } - + // Check update and discussion time over, only project creator can apply staking period #[pallet::call_index(1)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] + #[pallet::weight(0)] pub fn apply_staking_period( origin: OriginFor, - department_id: DeparmentId, + department_required_fund_id: DepartmentRequiredFundId, ) -> DispatchResult { - let who = ensure_signed(origin)?; - // Self::ensure_validation_on_positive_externality(user_to_calculate.clone())?; - Self::ensure_min_stake_deparment(department_id)?; + + Ok(()) + } - let pe_block_number = >::get(department_id); - let now = >::block_number(); - let six_month_number = (6 * 30 * 24 * 60 * 60) / 6; - let six_month_block = Self::u64_to_block_saturated(six_month_number); - let modulus = now % six_month_block; - let storage_main_block = now - modulus; - // println!("{:?}", now); - // println!("{:?}", three_month_number); - // println!("{:?}", storage_main_block); - // println!("{:?}", pe_block_number); - - let key = SumTreeName::DepartmentScore { - department_id, - block_number: storage_main_block.clone(), - }; + // // Check update and discussion time over, only project creator can apply staking period + // #[pallet::call_index(1)] + // #[pallet::weight(0)] + // pub fn apply_staking_period(origin: OriginFor, department_required_fund_id: DepartmentRequiredFundId) -> DispatchResult { + // let who = ensure_signed(origin)?; - // let game_type = SchellingGameType::PositiveExternality; + // Self::ensure_user_is_project_creator_and_project_exists(project_id, who)?; + // Self::ensure_staking_period_set_once_project_id(project_id)?; - if storage_main_block > pe_block_number { - >::insert(department_id, storage_main_block); - // check what if called again - T::SchellingGameSharedSource::set_to_staking_period_pe_link(key.clone(), now)?; - T::SchellingGameSharedSource::create_tree_helper_link(key, 3)?; + // let now = >::block_number(); - // println!("{:?}", data); - } else { - return Err(Error::::CannotStakeNow.into()); - } + // let key = SumTreeName::ProjectTips { project_id, block_number: now.clone() }; - Ok(()) - } + // >::insert(project_id, now.clone()); + // // check what if called again, its done with `ensure_staking_period_set_once_project_id` + // T::SchellingGameSharedSource::set_to_staking_period_pe_link(key.clone(), now.clone())?; + // T::SchellingGameSharedSource::create_tree_helper_link(key, 3)?; + + // Self::deposit_event(Event::StakinPeriodStarted { project_id, block_number: now }); + + // Ok(()) + // } #[pallet::call_index(2)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn apply_jurors_positive_externality( + #[pallet::weight(0)] + pub fn apply_jurors_project_tips( origin: OriginFor, - department_id: DeparmentId, + department_required_fund_id: DepartmentRequiredFundId, stake: BalanceOf, ) -> DispatchResult { let who = ensure_signed(origin)?; - // Self::ensure_validation_on_positive_externality(user_to_calculate.clone())?; - Self::ensure_min_stake_deparment(department_id)?; - - let pe_block_number = >::get(department_id); + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; let phase_data = Self::get_phase_data(); - T::SchellingGameSharedSource::apply_jurors_helper_link(key, phase_data, who, stake)?; + T::SchellingGameSharedSource::apply_jurors_helper_link( + key, + phase_data, + who.clone(), + stake, + )?; + Self::deposit_event(Event::ApplyJurors { + department_required_fund_id, + block_number, + account: who, + }); Ok(()) } #[pallet::call_index(3)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn pass_period(origin: OriginFor, department_id: DeparmentId) -> DispatchResult { + #[pallet::weight(0)] + pub fn pass_period( + origin: OriginFor, + department_required_fund_id: DepartmentRequiredFundId, + ) -> DispatchResult { let _who = ensure_signed(origin)?; - let pe_block_number = >::get(department_id); + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; let now = >::block_number(); let phase_data = Self::get_phase_data(); T::SchellingGameSharedSource::change_period_link(key, phase_data, now)?; - Ok(()) } #[pallet::call_index(4)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn draw_jurors_positive_externality( + #[pallet::weight(0)] + pub fn draw_jurors( origin: OriginFor, - department_id: DeparmentId, + department_required_fund_id: DepartmentRequiredFundId, iterations: u64, ) -> DispatchResult { let _who = ensure_signed(origin)?; - let pe_block_number = >::get(department_id); + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; let phase_data = Self::get_phase_data(); @@ -277,14 +325,17 @@ pub mod pallet { // Unstaking // Stop drawn juror to unstake ✔️ #[pallet::call_index(5)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn unstaking(origin: OriginFor, department_id: DeparmentId) -> DispatchResult { + #[pallet::weight(0)] + pub fn unstaking( + origin: OriginFor, + department_required_fund_id: DepartmentRequiredFundId, + ) -> DispatchResult { let who = ensure_signed(origin)?; - let pe_block_number = >::get(department_id); - - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; T::SchellingGameSharedSource::unstaking_helper_link(key, who)?; @@ -292,70 +343,65 @@ pub mod pallet { } #[pallet::call_index(6)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] + #[pallet::weight(0)] pub fn commit_vote( origin: OriginFor, - department_id: DeparmentId, + department_required_fund_id: DepartmentRequiredFundId, vote_commit: [u8; 32], ) -> DispatchResult { let who = ensure_signed(origin)?; - let pe_block_number = >::get(department_id); - - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; - T::SchellingGameSharedSource::commit_vote_for_score_helper_link(key, who, vote_commit)?; + T::SchellingGameSharedSource::commit_vote_helper_link(key, who, vote_commit)?; Ok(()) } #[pallet::call_index(7)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] + #[pallet::weight(0)] pub fn reveal_vote( origin: OriginFor, - department_id: DeparmentId, - choice: i64, + department_required_fund_id: DepartmentRequiredFundId, + choice: u128, salt: Vec, ) -> DispatchResult { let who = ensure_signed(origin)?; - ensure!(choice <= 5 && choice >= 1, Error::::ChoiceOutOfRange); - - let pe_block_number = >::get(department_id); - - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; - T::SchellingGameSharedSource::reveal_vote_score_helper_link(key, who, choice, salt)?; + T::SchellingGameSharedSource::reveal_vote_two_choice_helper_link( + key, who, choice, salt, + )?; Ok(()) } #[pallet::call_index(8)] - #[pallet::weight(Weight::from_parts(10_000, u64::MAX) + T::DbWeight::get().writes(1))] - pub fn get_incentives(origin: OriginFor, department_id: DeparmentId) -> DispatchResult { - let _who = ensure_signed(origin)?; - let pe_block_number = >::get(department_id); - let key = SumTreeName::DepartmentScore { - department_id, - block_number: pe_block_number.clone(), + #[pallet::weight(0)] + pub fn get_incentives( + origin: OriginFor, + department_required_fund_id: DepartmentRequiredFundId, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + let block_number = + Self::get_block_number_of_schelling_game(department_required_fund_id)?; + let key = SumTreeName::DepartmentRequiredFund { + department_required_fund_id, + block_number: block_number.clone(), }; let phase_data = Self::get_phase_data(); - T::SchellingGameSharedSource::get_incentives_score_schelling_helper_link( - key.clone(), - phase_data, - RangePoint::ZeroToFive, + T::SchellingGameSharedSource::get_incentives_two_choice_helper_link( + key, phase_data, who, )?; - - let score = T::SchellingGameSharedSource::get_mean_value_link(key.clone()); - // // println!("Score {:?}", score); - - // To do - // T::SharedStorageSource::set_positive_externality_link(user_to_calculate, score)?; - Ok(()) } } diff --git a/pallets/department-funding/src/mock.rs b/pallets/department-funding/src/mock.rs index 4388683..af047a0 100644 --- a/pallets/department-funding/src/mock.rs +++ b/pallets/department-funding/src/mock.rs @@ -1,5 +1,5 @@ use crate as pallet_template; -use frame_support::{traits::{ConstU16, ConstU64, GenesisBuild}}; +use frame_support::{parameter_types, traits::{ConstU16, ConstU64, GenesisBuild}}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -19,7 +19,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system, - TemplateModule: pallet_template, + DepartmentFunding: pallet_template, Balances: pallet_balances, SharedStorage:shared_storage, SchellingGameShared: schelling_game_shared, @@ -54,6 +54,17 @@ impl frame_system::Config for Test { type AccountData = pallet_balances::AccountData; // New code } +parameter_types! { + pub const MinimumPeriod: u64 = 5; +} + +impl pallet_timestamp::Config for Test { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); +} + impl shared_storage::Config for Test { type RuntimeEvent = RuntimeEvent; diff --git a/pallets/department-funding/src/types.rs b/pallets/department-funding/src/types.rs new file mode 100644 index 0000000..aa8e09f --- /dev/null +++ b/pallets/department-funding/src/types.rs @@ -0,0 +1,38 @@ +use super::*; +use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; +use frame_support::pallet_prelude::*; +use scale_info::TypeInfo; + +pub const DEPARTMENT_REQUIRED_FUND_ID: DepartmentRequiredFundId = 1; + + + + +#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)] +pub enum TippingName { + SmallTipper, + BigTipper, + SmallSpender, + MediumSpender, + BigSpender, +} + +#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo)] +pub struct TippingValue { + pub max_tipping_value: Balance, + pub stake_required: Balance, +} + +#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)] +#[scale_info(skip_type_params(T))] +pub struct DepartmentRequiredFund { + pub created: WhoAndWhenOf, + pub department_required_fund_id: DepartmentRequiredFundId, + pub department_id: DepartmentId, + pub tipping_name: TippingName, + pub funding_needed: BalanceOf, + pub creator: T::AccountId, +} + + + diff --git a/pallets/project-tips/src/tests.rs b/pallets/project-tips/src/tests.rs index 2c8f559..ad2f407 100644 --- a/pallets/project-tips/src/tests.rs +++ b/pallets/project-tips/src/tests.rs @@ -245,8 +245,6 @@ fn schelling_game_test() { assert_ok!(ProjectTips::get_incentives(RuntimeOrigin::signed(14), 1)); let balance: u64 = Balances::free_balance(14); assert_eq!(300025, balance); - - }) } diff --git a/pallets/sortition-sum-game/src/types.rs b/pallets/sortition-sum-game/src/types.rs index ad1804f..48e8388 100644 --- a/pallets/sortition-sum-game/src/types.rs +++ b/pallets/sortition-sum-game/src/types.rs @@ -9,7 +9,7 @@ type CitizenId = u64; pub enum SumTreeName { ProfileValidation { citizen_address: AccountId, block_number: BlockNumber}, PositiveExternality {user_address: AccountId, block_number: BlockNumber }, - DepartmentScore {department_id: u64, block_number: BlockNumber}, + DepartmentRequiredFund {department_required_fund_id: u64, block_number: BlockNumber}, ProjectTips { project_id: u64, block_number: BlockNumber }, }