Skip to content

Commit

Permalink
ValidationBlock rename
Browse files Browse the repository at this point in the history
  • Loading branch information
amiyatulu committed May 7, 2024
1 parent 8257c08 commit 58f92f4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .helix/config.toml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[editor.lsp]
display-inlay-hints = true


[keys.normal.space]
"H" = ":toggle lsp.display-inlay-hints"

2 changes: 1 addition & 1 deletion pallets/department-funding/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl<T: Config> Pallet<T> {
department_required_fund_id: DepartmentRequiredFundId,
) -> Result<BlockNumberOf<T>, DispatchError> {
let block_number_option =
<ValidationDepartmentRequiredFundsBlock<T>>::get(department_required_fund_id);
<ValidationBlock<T>>::get(department_required_fund_id);
let block_number = match block_number_option {
Some(block_number) => block_number,
None => Err(Error::<T>::BlockDepartmentRequiredFundIdNotExists)?,
Expand Down
6 changes: 3 additions & 3 deletions pallets/department-funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ pub mod pallet {
StorageMap<_, Twox64Concat, DepartmentRequiredFundId, bool, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn validation_department_required_funds_block_number)]
pub type ValidationDepartmentRequiredFundsBlock<T: Config> =
#[pallet::getter(fn validation_block)]
pub type ValidationBlock<T: Config> =
StorageMap<_, Blake2_128Concat, DepartmentRequiredFundId, BlockNumberOf<T>>;

#[pallet::storage]
Expand Down Expand Up @@ -245,7 +245,7 @@ pub mod pallet {
department_required_fund_id,
block_number: now.clone(),
};
ValidationDepartmentRequiredFundsBlock::<T>::insert(
ValidationBlock::<T>::insert(
department_required_fund_id,
now.clone(),
);
Expand Down
12 changes: 6 additions & 6 deletions pallets/profile-validation/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<T: Config> Pallet<T> {

pub fn get_evidence_period_end_block(profile_user_account: T::AccountId) -> Option<u32> {
let now = <frame_system::Pallet<T>>::block_number();
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -125,7 +125,7 @@ impl<T: Config> Pallet<T> {

pub fn get_staking_period_end_block(profile_user_account: T::AccountId) -> Option<u32> {
let now = <frame_system::Pallet<T>>::block_number();
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -141,7 +141,7 @@ impl<T: Config> Pallet<T> {
}

pub fn get_drawing_period_end(profile_user_account: T::AccountId) -> (u64, u64, bool) {
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -156,7 +156,7 @@ impl<T: Config> Pallet<T> {

pub fn get_commit_period_end_block(profile_user_account: T::AccountId) -> Option<u32> {
let now = <frame_system::Pallet<T>>::block_number();
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -172,7 +172,7 @@ impl<T: Config> Pallet<T> {

pub fn get_vote_period_end_block(profile_user_account: T::AccountId) -> Option<u32> {
let now = <frame_system::Pallet<T>>::block_number();
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -187,7 +187,7 @@ impl<T: Config> Pallet<T> {
}

pub fn selected_as_juror(profile_user_account: T::AccountId, who: T::AccountId) -> bool {
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand Down
26 changes: 13 additions & 13 deletions pallets/profile-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ pub mod pallet {
StorageMap<_, Blake2_128Concat, T::AccountId, BalanceOf<T>, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn profile_validation_blocknumber)]
pub type ProfileValidationBlock<T: Config> =
#[pallet::getter(fn validation_block)]
pub type ValidationBlock<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, BlockNumberOf<T>, ValueQuery>;

#[pallet::storage]
Expand Down Expand Up @@ -317,7 +317,7 @@ pub mod pallet {
///
/// ## Storage
///
/// - `ProfileValidationBlock`: Stores the block number to be used for the profile's validation when `amount_to_fund` equals `required_fund`.
/// - `ValidationBlock`: Stores the block number to be used for the profile's validation when `amount_to_fund` equals `required_fund`.
/// - `ProfileFundDetails`: Stores details of funds deposited by users for a specific profile.
/// - `ProfileTotalFundCollected`: Keeps track of the total funds collected for each profile.
/// - `RegistrationFee`: Retrieves the registration fee required for profile validation.
Expand Down Expand Up @@ -371,7 +371,7 @@ pub mod pallet {
citizen_address: profile_user_account.clone(),
block_number: now.clone(),
};
<ProfileValidationBlock<T>>::insert(&profile_user_account, now);
<ValidationBlock<T>>::insert(&profile_user_account, now);

// Set a link to the evidence period in the Schelling Game.
T::SchellingGameSharedSource::set_to_evidence_period_link(key, now)?;
Expand Down Expand Up @@ -467,7 +467,7 @@ pub mod pallet {
},
}

let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand Down Expand Up @@ -658,7 +658,7 @@ pub mod pallet {
) -> DispatchResult {
let _who = ensure_signed(origin)?;

let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand Down Expand Up @@ -697,7 +697,7 @@ pub mod pallet {
) -> DispatchResult {
let who = ensure_signed(origin)?;

let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand Down Expand Up @@ -726,7 +726,7 @@ pub mod pallet {
iterations: u64,
) -> DispatchResult {
let _who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -748,7 +748,7 @@ pub mod pallet {
profile_user_account: T::AccountId,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -766,7 +766,7 @@ pub mod pallet {
vote_commit: [u8; 32],
) -> DispatchResult {
let who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -785,7 +785,7 @@ pub mod pallet {
salt: Vec<u8>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -806,7 +806,7 @@ pub mod pallet {
profile_user_account: T::AccountId,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);

let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
Expand All @@ -826,7 +826,7 @@ pub mod pallet {
profile_user_account: T::AccountId,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let block_number = <ProfileValidationBlock<T>>::get(&profile_user_account);
let block_number = <ValidationBlock<T>>::get(&profile_user_account);
let key = SumTreeName::ProfileValidation {
citizen_address: profile_user_account.clone(),
block_number,
Expand Down
4 changes: 2 additions & 2 deletions pallets/project-tips/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<T: Config> Pallet<T> {
}

pub fn ensure_staking_period_set_once_project_id(project_id: ProjectId) -> DispatchResult {
let block_number_option = <ValidationProjectBlock<T>>::get(project_id);
let block_number_option = <ValidationBlock<T>>::get(project_id);
match block_number_option {
Some(_block) => Err(Error::<T>::ProjectIdStakingPeriodAlreadySet)?,
None => Ok(()),
Expand All @@ -53,7 +53,7 @@ impl<T: Config> Pallet<T> {
pub fn get_block_number_of_schelling_game(
project_id: ProjectId,
) -> Result<BlockNumberOf<T>, DispatchError> {
let block_number_option = <ValidationProjectBlock<T>>::get(project_id);
let block_number_option = <ValidationBlock<T>>::get(project_id);
let block_number = match block_number_option {
Some(block_number) => block_number,
None => Err(Error::<T>::BlockNumberProjectIdNotExists)?,
Expand Down
6 changes: 3 additions & 3 deletions pallets/project-tips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ pub mod pallet {
// StorageMap<_, Twox64Concat, DepartmentId, BalanceOf<T>, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn validation_project_block_number)]
pub type ValidationProjectBlock<T: Config> =
#[pallet::getter(fn validation_block)]
pub type ValidationBlock<T: Config> =
StorageMap<_, Blake2_128Concat, ProjectId, BlockNumberOf<T>>;

// Pallets use events to inform users when important changes are made.
Expand Down Expand Up @@ -234,7 +234,7 @@ pub mod pallet {

let key = SumTreeName::ProjectTips { project_id, block_number: now.clone() };

<ValidationProjectBlock<T>>::insert(project_id, now.clone());
<ValidationBlock<T>>::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)?;
Expand Down

0 comments on commit 58f92f4

Please sign in to comment.