Child bounties comments (#11053)

* * formatting
* use uniform notion of parent and child, no "master" or "general" entity
* README updated to match comments
* `parent_index` used over simply `index`

* rm `parent_*` change

* parent_bounty_id

* parent_index rm

* fmt

* Apply suggestions from code review
This commit is contained in:
Dan Shields
2022-04-16 02:55:37 -07:00
committed by GitHub
parent 362dc50940
commit c6e452108b
4 changed files with 90 additions and 62 deletions
+16 -8
View File
@@ -35,10 +35,17 @@
//! curator or once the bounty is active or payout is pending, resulting in the slash of the
//! curator's deposit.
//!
//! This pallet may opt into using a [`ChildBountyManager`] that enables bounties to be split into
//! sub-bounties, as children of anh established bounty (called the parent in the context of it's
//! children).
//!
//! > NOTE: The parent bounty cannot be closed if it has a non-zero number of it has active child
//! > bounties associated with it.
//!
//! ### Terminology
//!
//! Bounty:
//!
//! - **Bounty spending proposal:** A proposal to reward a predefined body of work upon completion
//! by the Treasury.
//! - **Proposer:** An account proposing a bounty spending.
@@ -60,6 +67,7 @@
//! ### Dispatchable Functions
//!
//! Bounty protocol:
//!
//! - `propose_bounty` - Propose a specific treasury amount to be earmarked for a predefined set of
//! tasks and stake the required deposit.
//! - `approve_bounty` - Accept a specific treasury amount to be earmarked for a predefined body of
@@ -165,9 +173,9 @@ pub enum BountyStatus<AccountId, BlockNumber> {
},
}
/// The child-bounty manager.
/// The child bounty manager.
pub trait ChildBountyManager<Balance> {
/// Get the active child-bounties for a parent bounty.
/// Get the active child bounties for a parent bounty.
fn child_bounties_count(bounty_id: BountyIndex) -> BountyIndex;
/// Get total curator fees of children-bounty curators.
@@ -231,7 +239,7 @@ pub mod pallet {
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
/// The child-bounty manager.
/// The child bounty manager.
type ChildBountyManager: ChildBountyManager<BalanceOf<Self>>;
}
@@ -256,7 +264,7 @@ pub mod pallet {
PendingPayout,
/// The bounties cannot be claimed/closed because it's still in the countdown period.
Premature,
/// The bounty cannot be closed because it has active child-bounties.
/// The bounty cannot be closed because it has active child bounties.
HasActiveChildBounty,
/// Too many approvals are already queued.
TooManyQueued,
@@ -552,7 +560,7 @@ pub mod pallet {
Bounties::<T>::try_mutate_exists(bounty_id, |maybe_bounty| -> DispatchResult {
let mut bounty = maybe_bounty.as_mut().ok_or(Error::<T>::InvalidIndex)?;
// Ensure no active child-bounties before processing the call.
// Ensure no active child bounties before processing the call.
ensure!(
T::ChildBountyManager::child_bounties_count(bounty_id) == 0,
Error::<T>::HasActiveChildBounty
@@ -610,8 +618,8 @@ pub mod pallet {
let err_amount = T::Currency::unreserve(&curator, bounty.curator_deposit);
debug_assert!(err_amount.is_zero());
// Get total child-bounties curator fees, and subtract it from master curator
// fee.
// Get total child bounties curator fees, and subtract it from the parent
// curator fee (the fee in present referenced bounty, `self`).
let children_fee = T::ChildBountyManager::children_curator_fees(bounty_id);
debug_assert!(children_fee <= fee);
@@ -663,7 +671,7 @@ pub mod pallet {
|maybe_bounty| -> DispatchResultWithPostInfo {
let bounty = maybe_bounty.as_ref().ok_or(Error::<T>::InvalidIndex)?;
// Ensure no active child-bounties before processing the call.
// Ensure no active child bounties before processing the call.
ensure!(
T::ChildBountyManager::child_bounties_count(bounty_id) == 0,
Error::<T>::HasActiveChildBounty