Closed dvc94ch closed 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
Superceeds #51