Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
94cf161
Add pallet-alliance
koushiro Sep 17, 2021
f12601d
Update multihash/cid and format
koushiro Sep 17, 2021
0d93dd6
Remove useless deps
koushiro Sep 18, 2021
3bfc260
Add pallet-alliance into node runtime
koushiro Sep 18, 2021
445649e
Fix has_identity
koushiro Sep 22, 2021
0d2eaee
Add TooMantBlacklist Error
koushiro Oct 4, 2021
b69980d
Add TooLongWebsiteUrlLength Error
koushiro Oct 4, 2021
9cab715
Add remove_announcement
koushiro Oct 4, 2021
9241f08
Derive pallet_identity::Config and Fix test/benchmarking
koushiro Oct 5, 2021
0a71502
Add part weight for call of pallet-alliance
koushiro Oct 5, 2021
d7aeddf
Remove pallet_identity Config trait
koushiro Oct 9, 2021
b07520e
Fix propose arguments
koushiro Oct 11, 2021
9774055
Some nits
koushiro Oct 11, 2021
0013afd
cargo fmt
koushiro Oct 11, 2021
6b2c8af
Fix benchmarking of add_blacklist/remove_blacklist
koushiro Oct 11, 2021
1d2bc71
Some nits
koushiro Oct 11, 2021
e7f0cd3
Add benchmarking for init_members
koushiro Oct 11, 2021
181738b
Add benchmarking for propose/vote/veto
koushiro Oct 11, 2021
a359aea
Fix benchmarking
koushiro Oct 11, 2021
d1bb18d
Remove some useless
koushiro Oct 11, 2021
a2f986f
fix some compile issue
xlc Mar 12, 2022
e37664e
more fix
xlc Mar 12, 2022
a04c5b8
all checks
xlc Mar 12, 2022
fde2562
refactor
xlc Mar 12, 2022
1757810
refactor event
xlc Mar 12, 2022
03a6be5
refactor
xlc Mar 12, 2022
3e4e7f4
cleanup
xlc Mar 12, 2022
7333148
cleanup
xlc Mar 12, 2022
06b42a8
Merge branch 'master' into polkadot-alliance-review
xlc Mar 24, 2022
c49b633
fix benchmarking
xlc Mar 24, 2022
bbd087b
fix warning
xlc Mar 24, 2022
062bad8
fmt
xlc Mar 24, 2022
8ab53a8
fix benchmarks
xlc Mar 25, 2022
86b4fcf
Merge remote-tracking branch 'origin/master' into polkadot-alliance-r…
xlc Mar 31, 2022
c16c2a7
with storage info
xlc Mar 31, 2022
58ca07d
fmt
xlc Mar 31, 2022
4013d84
add new config
xlc Apr 2, 2022
a0c0971
fix benchmarks
xlc Apr 2, 2022
31f846b
fix
xlc Apr 3, 2022
616646b
fmt
xlc Apr 3, 2022
02aaf4e
Apply suggestions from code review
xlc Apr 4, 2022
82f84d1
improvements
xlc Apr 8, 2022
551e830
fix
xlc Apr 8, 2022
451396e
update docs
joepetrowski Apr 9, 2022
814d520
rename events, errors, and functions
joepetrowski Apr 9, 2022
f90df9e
make kicking events clearer
joepetrowski Apr 9, 2022
d93f872
Merge pull request #2 from joepetrowski/polkadot-alliance-review
xlc Apr 10, 2022
35d50b9
fix
xlc Apr 10, 2022
e024c73
fix tests
xlc Apr 10, 2022
1d0eef4
fix tests
xlc Apr 10, 2022
4f2a0bd
fix runtime
xlc Apr 10, 2022
3c8b878
fix build
xlc Apr 10, 2022
0f12ed4
remove unneeded change
xlc Apr 10, 2022
b20b72a
Merge remote-tracking branch 'origin/master' into polkadot-alliance-r…
xlc Apr 13, 2022
5b6b336
remove Candidate role from Alliance
joepetrowski Apr 30, 2022
a97b897
merge master
joepetrowski Apr 30, 2022
0970b78
fmt grumbles
joepetrowski Apr 30, 2022
d292548
update lock
joepetrowski Apr 30, 2022
6da40be
update recursion limit
joepetrowski Apr 30, 2022
dc6400c
benchmarks
joepetrowski Apr 30, 2022
428638a
convert-try
joepetrowski Apr 30, 2022
c029b0c
benchmark assertions
joepetrowski Apr 30, 2022
5ed70ae
fmt ,
joepetrowski Apr 30, 2022
d7766b0
merge master
joepetrowski May 19, 2022
50726b3
cargo lock
joepetrowski May 20, 2022
60d9434
Update frame/alliance/src/benchmarking.rs
joepetrowski May 20, 2022
2809717
Apply suggestions from code review
joepetrowski May 20, 2022
f270ada
add docs to public interfaces
joepetrowski May 20, 2022
955854a
Apply suggestions from code review
joepetrowski May 23, 2022
944a612
fix build (node)
joepetrowski May 23, 2022
7c063c8
review
joepetrowski May 23, 2022
5feb2d1
Merge remote-tracking branch 'origin' into polkadot-alliance-review
joepetrowski May 25, 2022
a576428
Merge remote-tracking branch 'origin' into polkadot-alliance-review
joepetrowski May 30, 2022
fb8dd06
merge master
joepetrowski Jun 8, 2022
0e39490
use EitherOfDiverse
joepetrowski Jun 8, 2022
d89078d
update cargo toml
joepetrowski Jun 9, 2022
8338125
make all dispatch class Normal
joepetrowski Jun 10, 2022
fdf4dc9
change blacklist to unscrupulous
joepetrowski Jun 10, 2022
0c10bcd
formatting
joepetrowski Jun 10, 2022
3ee24a8
fmt oops
joepetrowski Jun 10, 2022
78b63c1
rename benchmarking unscrupulous account creator
joepetrowski Jun 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
xlc committed Mar 12, 2022
commit 03a6be5dc562ded543bcc1483ee456a67291b5ef
66 changes: 33 additions & 33 deletions frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ pub mod pallet {
#[pallet::compact] threshold: u32,
proposal: Box<<T as Config<I>>::Proposal>,
#[pallet::compact] length_bound: u32,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
let proposor = ensure_signed(origin)?;
ensure!(Self::is_votable_member(&proposor), Error::<T, I>::NotVotableMember);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite clear why the condition to propose and vote is the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not? similar to council, only council member can propose motion.


Expand All @@ -509,7 +509,7 @@ pub mod pallet {
}

T::ProposalProvider::propose_proposal(proposor, threshold, proposal, length_bound)?;
Ok(().into())
Ok(())
}

/// Add an aye or nay vote for the sender to the given proposal.
Expand All @@ -524,20 +524,20 @@ pub mod pallet {
proposal: T::Hash,
#[pallet::compact] index: ProposalIndex,
approve: bool,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(Self::is_votable_member(&who), Error::<T, I>::NotVotableMember);

T::ProposalProvider::vote_proposal(who, proposal, index, approve)?;
Ok(().into())
Ok(())
}

/// Disapprove a proposal about set_rule and elevate_ally, close, and remove it from
/// the system, regardless of its current state.
///
/// Must be called by a founder.
#[pallet::weight(T::WeightInfo::veto(T::MaxProposals::get()))]
pub fn veto(origin: OriginFor<T>, proposal_hash: T::Hash) -> DispatchResultWithPostInfo {
pub fn veto(origin: OriginFor<T>, proposal_hash: T::Hash) -> DispatchResult {
let proposor = ensure_signed(origin)?;
ensure!(Self::is_founder(&proposor), Error::<T, I>::NotFounder);

Expand All @@ -546,7 +546,7 @@ pub mod pallet {
match proposal.expect("proposal must be exist; qed").is_sub_type() {
Some(Call::set_rule { .. }) | Some(Call::elevate_ally { .. }) => {
T::ProposalProvider::veto_proposal(proposal_hash);
Ok(().into())
Ok(())
},
_ => Err(Error::<T, I>::NotVetoableProposal.into()),
}
Expand Down Expand Up @@ -613,7 +613,7 @@ pub mod pallet {
mut founders: Vec<T::AccountId>,
mut fellows: Vec<T::AccountId>,
mut allies: Vec<T::AccountId>,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
ensure_root(origin)?;

ensure!(
Expand Down Expand Up @@ -647,39 +647,39 @@ pub mod pallet {
);

Self::deposit_event(Event::MembersInitialized { founders, fellows, allies });
Ok(().into())
Ok(())
}

/// Set a new IPFS cid to the alliance rule.
#[pallet::weight(T::WeightInfo::set_rule())]
pub fn set_rule(origin: OriginFor<T>, rule: Cid) -> DispatchResultWithPostInfo {
pub fn set_rule(origin: OriginFor<T>, rule: Cid) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;

Rule::<T, I>::put(&rule);

Self::deposit_event(Event::NewRule { rule });
Ok(().into())
Ok(())
}

/// Make a new announcement by a new IPFS cid about the alliance issues.
#[pallet::weight(T::WeightInfo::announce())]
pub fn announce(origin: OriginFor<T>, announcement: Cid) -> DispatchResultWithPostInfo {
pub fn announce(origin: OriginFor<T>, announcement: Cid) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;

let mut announcements = <Announcements<T, I>>::get();
announcements.push(announcement.clone());
<Announcements<T, I>>::put(announcements);

Self::deposit_event(Event::NewAnnouncement { announcement });
Ok(().into())
Ok(())
}

/// Remove the announcement.
#[pallet::weight(T::WeightInfo::remove_announcement())]
pub fn remove_announcement(
origin: OriginFor<T>,
announcement: Cid,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;

let mut announcements = <Announcements<T, I>>::get();
Expand All @@ -691,12 +691,12 @@ pub mod pallet {
<Announcements<T, I>>::put(announcements);

Self::deposit_event(Event::AnnouncementRemoved { announcement });
Ok(().into())
Ok(())
}

/// Submit oneself for candidacy. A fixed amount of deposit is recorded.
#[pallet::weight(T::WeightInfo::submit_candidacy())]
pub fn submit_candidacy(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
pub fn submit_candidacy(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(!Self::is_account_blacklist(&who), Error::<T, I>::AlreadyInBlacklist);
ensure!(!Self::is_candidate(&who), Error::<T, I>::AlreadyCandidate);
Expand All @@ -718,7 +718,7 @@ pub mod pallet {
nominator: None,
reserved: Some(deposit),
});
Ok(().into())
Ok(())
}

/// Founder or fellow can nominate someone to join the alliance and become a candidate.
Expand All @@ -727,7 +727,7 @@ pub mod pallet {
pub fn nominate_candidacy(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
let nominator = ensure_signed(origin)?;
ensure!(Self::is_votable_member(&nominator), Error::<T, I>::NotVotableMember);
let who = T::Lookup::lookup(who)?;
Expand All @@ -746,15 +746,15 @@ pub mod pallet {
nominator: Some(nominator),
reserved: None,
});
Ok(().into())
Ok(())
}

/// Approve a `Candidate` to become an `Ally`.
#[pallet::weight(T::WeightInfo::approve_candidate())]
pub fn approve_candidate(
origin: OriginFor<T>,
candidate: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;
let candidate = T::Lookup::lookup(candidate)?;
ensure!(Self::is_candidate(&candidate), Error::<T, I>::NotCandidate);
Expand All @@ -764,15 +764,15 @@ pub mod pallet {
Self::add_member(&candidate, MemberRole::Ally)?;

Self::deposit_event(Event::CandidateApproved { candidate });
Ok(().into())
Ok(())
}

/// Reject a `Candidate` back to an ordinary account.
#[pallet::weight(T::WeightInfo::reject_candidate())]
pub fn reject_candidate(
origin: OriginFor<T>,
candidate: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;
let candidate = T::Lookup::lookup(candidate)?;
ensure!(Self::is_candidate(&candidate), Error::<T, I>::NotCandidate);
Expand All @@ -784,15 +784,15 @@ pub mod pallet {
}

Self::deposit_event(Event::CandidateRejected { candidate });
Ok(().into())
Ok(())
}

/// Elevate an ally to fellow.
#[pallet::weight(T::WeightInfo::reject_candidate())]
pub fn elevate_ally(
origin: OriginFor<T>,
ally: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;
let ally = T::Lookup::lookup(ally)?;
ensure!(Self::is_ally(&ally), Error::<T, I>::NotAlly);
Expand All @@ -802,12 +802,12 @@ pub mod pallet {
Self::add_member(&ally, MemberRole::Fellow)?;

Self::deposit_event(Event::AllyElevated { ally });
Ok(().into())
Ok(())
}

/// As a member, retire and back to an ordinary account and unlock its deposit.
#[pallet::weight(T::WeightInfo::retire())]
pub fn retire(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
pub fn retire(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
ensure!(!Self::is_kicking(&who), Error::<T, I>::KickingMember);

Expand All @@ -819,15 +819,15 @@ pub mod pallet {
debug_assert!(err_amount.is_zero());
}
Self::deposit_event(Event::MemberRetired { member: who, unreserved: deposit });
Ok(().into())
Ok(())
}

/// Kick a member to ordinary account with its deposit slashed.
#[pallet::weight(T::WeightInfo::kick_member())]
pub fn kick_member(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;
let member = T::Lookup::lookup(who)?;
ensure!(Self::is_kicking(&member), Error::<T, I>::NotKickingMember);
Expand All @@ -839,15 +839,15 @@ pub mod pallet {
T::Slashed::on_unbalanced(T::Currency::slash_reserved(&member, deposit).0);
}
Self::deposit_event(Event::MemberKicked { member, slashed: deposit });
Ok(().into())
Ok(())
}

/// Add accounts or websites into blacklist.
#[pallet::weight(T::WeightInfo::add_blacklist(infos.len() as u32, T::MaxWebsiteUrlLength::get()))]
pub fn add_blacklist(
origin: OriginFor<T>,
infos: Vec<BlacklistItem<T::AccountId>>,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;

let mut accounts = vec![];
Expand Down Expand Up @@ -879,15 +879,15 @@ pub mod pallet {

Self::do_add_blacklist(&mut accounts, &mut webs)?;
Self::deposit_event(Event::BlacklistAdded { items: infos });
Ok(().into())
Ok(())
}

/// Remove accounts or websites from blacklist.
#[pallet::weight(<T as Config<I>>::WeightInfo::remove_blacklist(infos.len() as u32, T::MaxWebsiteUrlLength::get()))]
pub fn remove_blacklist(
origin: OriginFor<T>,
infos: Vec<BlacklistItem<T::AccountId>>,
) -> DispatchResultWithPostInfo {
) -> DispatchResult {
T::SuperMajorityOrigin::ensure_origin(origin)?;
let mut accounts = vec![];
let mut webs = vec![];
Expand All @@ -900,7 +900,7 @@ pub mod pallet {
}
Self::do_remove_blacklist(&mut accounts, &mut webs)?;
Self::deposit_event(Event::BlacklistRemoved { items: infos });
Ok(().into())
Ok(())
}
}
}
Expand Down Expand Up @@ -930,7 +930,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}

fn has_member(role: MemberRole) -> bool {
!Members::<T, I>::get(role).is_empty()
Members::<T, I>::decode_len(role).unwrap_or_default() > 0
}

fn member_role_of(who: &T::AccountId) -> Option<MemberRole> {
Expand Down