sunshine-protocol / sunshine

Governance + Bounty Platform
Other
42 stars 16 forks source link

Add client to node. #52

Closed dvc94ch closed 4 years ago

dvc94ch commented 4 years ago

Superceeds #51

4meta5 commented 4 years ago

This method needs to be added to the decl_module of modules/vote-yesno as per the previous comment.

#[weight = SimpleDispatchInfo::zero()]
pub fn create_1p1v_percentage_threshold_vote(
    origin,
    organization: OrgId<T>,
    share_id: ShareId<T>,
    support_requirement: Permill,
    turnout_requirement: Permill,
) -> DispatchResult {
    let vote_creator = ensure_signed(origin)?;
    // default authentication is organization supervisor or sudo key
    let authentication: bool = <<T as Trait>::ShareData as OrgSupervisorKeyManagement<
        OrgId<T>,
        <T as frame_system::Trait>::AccountId,
    >>::is_organization_supervisor(organization, &vote_creator) ||
    <<T as Trait>::ShareData as SudoKeyManagement<
        <T as frame_system::Trait>::AccountId,
    >>::is_sudo_key(&vote_creator);
    ensure!(authentication, Error::<T>::NotAuthorizedToCreateVoteForOrganization);
    let threshold_config = ThresholdConfig::new_percentage_threshold(support_requirement, turnout_requirement);
    // share weighted count threshold
    let new_vote_id = Self::open_vote(organization, share_id, None, SupportedVoteTypes::ShareWeighted, threshold_config, None)?;
    // emit event
    Self::deposit_event(RawEvent::NewVoteStarted(organization, share_id, new_vote_id));
    Ok(())
}

I was going to add it to the fork but the fork is on your repo and I just suck at git