Skip to content

Commit

Permalink
incentive meta
Browse files Browse the repository at this point in the history
  • Loading branch information
amiyatulu committed Jun 3, 2024
1 parent 2f0ed9e commit dd2b381
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
21 changes: 19 additions & 2 deletions custom-pallets/project-tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use trait_schelling_game_shared::SchellingGameSharedLink;
use trait_shared_storage::SharedStorageLink;
use pallet_sortition_sum_game::types::SumTreeName;
pub use types::PROJECT_ID;
use types::{Project, TippingName, TippingValue};
use types::{Project, TippingName, TippingValue, Incentives, IncentivesMetaData};

type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
type BalanceOf<T> = <<T as Config>::Currency as Currency<AccountIdOf<T>>>::Balance;
Expand All @@ -55,7 +55,9 @@ type ProjectId = u64;

#[frame_support::pallet(dev_mode)]
pub mod pallet {
use super::*;
use core::default;

use super::*;


#[pallet::pallet]
Expand Down Expand Up @@ -123,6 +125,21 @@ pub mod pallet {
pub type ValidationBlock<T: Config> =
StorageMap<_, Blake2_128Concat, ProjectId, BlockNumberOf<T>>;


#[pallet::storage]
#[pallet::getter(fn incentives_count)]
pub type IncentiveCount<T:Config> = StorageMap<_, Blake2_128Concat, T::AccountId, Incentives<T>>;


#[pallet::type_value]
pub fn IncentivesMetaValue<T: Config>() -> IncentivesMetaData<T> {
IncentivesMetaData::default()
}

#[pallet::storage]
#[pallet::getter(fn incentives_meta)]
pub type IncentivesMeta<T:Config> = StorageValue<_, IncentivesMetaData<T>, ValueQuery, IncentivesMetaValue<T>>;

// Pallets use events to inform users when important changes are made.
// https://docs.substrate.io/main-docs/build/events-errors/
#[pallet::event]
Expand Down
29 changes: 29 additions & 0 deletions custom-pallets/project-tips/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,32 @@ pub struct Project<T: Config> {
pub funding_needed: BalanceOf<T>,
pub project_leader: T::AccountId,
}

#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct Incentives<T: Config> {
pub number_of_games: u32,
pub winner: u32,
pub loser: u32,
pub start: WhoAndWhenOf<T>,
pub update: WhoAndWhenOf<T>,
}


#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct IncentivesMetaData<T: Config> {
pub total_number: u32,
pub disincentive_times: u32,
pub total_block: BlockNumberOf<T>,
}

impl<T: Config> Default for IncentivesMetaData<T> {
fn default() -> Self {
Self {
total_number: 20,
disincentive_times: 15, // its 1.5
total_block: 432000u64.saturated_into::<BlockNumberOf<T>>() // 30 days = (24*60*60)/6 * 30
}
}
}

0 comments on commit dd2b381

Please sign in to comment.