-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add back sudo to rococo * runtime api * runtime-api-wiring * some dummy log statements * attempt 1 to add try-runtime * second attempt * add to the cli * fix warn issue * on initialise, remove on runtime upgrade proposasl * add the new storage version migration * pick runtime * new migration for proposals * fmt * fix v3-v4 migration test * fix 2 * fix brief migration test * clippy * fmt * new MilestoneVote implementation * fix implementation * get project individual votes * remove total votes api * fmt * ummm * new format for Individual votes * boom baby, and a fmt * clippy * fix build * fmt * bump spec version * 1 * individual votes impl with storage * fix buggy impl * define immutability, update on vote * use individual votes for oninit and submit and close voting + update migration * fixing build * seperated test files, tested ImmutableVotes * fix runtime api, reorg proposals * fmt * fmt * clippy * migration, err handling * fix migration * fmt * fix * clippy * update executive and spec version * fmt * remove todos * remove wrong comment * fix failing test * fmt * run on gcp * bump to rebuild * use self hosted runner * already installed on runner * attempt auto scaling runner * increase disk size * bump to build again * dont delete at the end of the job * remove unused directories * bump * change region * split the jobs * add -y flag * test menually installing rust * -y flag * more -y * remove double install of protobugf * -y * trial 1 * fix * fix2 * fix3 * bump up * bump * change zone * bump * lol -y * bump * bump 2 * set home directory * try to run as user * init commit * commit 2 * test * test 3 * attempt 4 * bump * bump * bump * bump * bump * reduce image size * bump * bump * bump again * add clippy * build essentials * clang * refactor * typo * typo 2 * make zone configurable --------- Co-authored-by: samelamin <hussam.elamin@gmail.com> (cherry picked from commit 84dd997) # Conflicts: # Cargo.lock # pallets/proposals/src/lib.rs
- Loading branch information
Showing
18 changed files
with
1,602 additions
and
1,234 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use sp_std::vec::Vec; | ||
|
||
sp_api::decl_runtime_apis! { | ||
pub trait ProposalsApi<AccountId> where AccountId: codec::Codec { | ||
pub trait ProposalsApi<AccountId, Balance> | ||
where AccountId: codec::Codec + Ord, | ||
{ | ||
fn get_project_account_by_id(project_id: u32) -> AccountId; | ||
fn get_all_project_data(project_id: u32) -> Option<(Vec<u8>, Vec<u8>)>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use crate::*; | ||
impl<T: Config> ImmutableIndividualVotes<T> { | ||
/// Create a new set of individual votes bound to a set of milestone keys. | ||
/// Instantiates the votes as defaults. | ||
#[allow(clippy::type_complexity)] | ||
pub(crate) fn new( | ||
milestone_keys: BoundedVec<MilestoneKey, T::MaxMilestonesPerProject>, | ||
) -> Self { | ||
let mut outer_votes: BoundedBTreeMap< | ||
MilestoneKey, | ||
BoundedBTreeMap<AccountIdOf<T>, bool, T::MaximumContributorsPerProject>, | ||
T::MaxMilestonesPerProject, | ||
> = BoundedBTreeMap::new(); | ||
|
||
for milestone_key in milestone_keys.iter() { | ||
let inner_votes: BoundedBTreeMap< | ||
AccountIdOf<T>, | ||
bool, | ||
T::MaximumContributorsPerProject, | ||
> = BoundedBTreeMap::new(); | ||
// outer_votes and milestone_keys are bounded by the same binding so this will never fail. | ||
outer_votes | ||
.try_insert(milestone_key.to_owned(), inner_votes) | ||
.expect("milestone_keys and outer_votes have been bound by the same binding; qed"); | ||
} | ||
|
||
Self { inner: outer_votes } | ||
} | ||
|
||
/// Insert the vote from an individual on a milestone. | ||
pub(crate) fn insert_individual_vote( | ||
&mut self, | ||
milestone_key: MilestoneKey, | ||
account_id: &AccountIdOf<T>, | ||
vote: bool, | ||
) -> Result<(), DispatchError> { | ||
if let Some(votes) = self.inner.get_mut(&milestone_key) { | ||
if let Some(_existing_vote) = votes.get_mut(account_id) { | ||
return Err(Error::<T>::VotesAreImmutable.into()); | ||
} else { | ||
votes | ||
.try_insert(account_id.clone(), vote) | ||
.map_err(|_| Error::<T>::TooManyContributions)?; | ||
} | ||
} else { | ||
return Err(Error::<T>::IndividualVoteNotFound.into()); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Clear the votes for a given milestone. | ||
/// Used when a milestone is submitted. | ||
/// Skips if the milestone is not found. | ||
pub(crate) fn clear_milestone_votes(&mut self, milestone_key: MilestoneKey) { | ||
if let Some(btree) = self.inner.get_mut(&milestone_key) { | ||
*btree = Default::default() | ||
} | ||
} | ||
|
||
/// Take a mutable reference to the inner individual votes item. | ||
#[allow(dead_code)] | ||
pub(crate) fn as_mut(&mut self) -> &mut IndividualVotes<T> { | ||
&mut self.inner | ||
} | ||
} | ||
|
||
impl<T: Config> AsRef<IndividualVotes<T>> for ImmutableIndividualVotes<T> { | ||
fn as_ref(&self) -> &IndividualVotes<T> { | ||
&self.inner | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub mod immutable_votes; | ||
pub mod pallet_impls; | ||
|
||
pub use immutable_votes::*; | ||
pub use pallet_impls::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.