-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
squad: gatekeepersCatalyst App Backend, System Development & Integration TeamCatalyst App Backend, System Development & Integration Team
Description
Summary
Implement a function which could perform a simple tally without any delegations. Just taking into account Contest Ballot, Contest Parameters, Proposal and some other needed documents but without any delegation part.
It should mainly follow the catalyst-libs/rust/catalyst-voting/tests/voting_test.rs but in terms of documents which were mentioned previously.
Acceptance criteria
- implement a public function for
catalyst-contestwhich would take as an argumentContest Parametersdocument andproviderinstance and returns tally result in the form ofHashMap<DocumentRef, u64>. whereDocumentRefis a reference to the correspondingProposaldocument andu64its a final "score" of it.
fn tally(contest: &ContestParameters, provider: Provider) -> anyhow::Result<TallyResult>;- Added a unit test following mainly
catalyst-libs/rust/catalyst-voting/tests/voting_test.rsby preparing all necessary documents and submitting them to the provider and callingtallyfunction to get the expected result.
Important notes
- How to determine which
Proposaldocument assigned to the contest ?
Get theContest Parametersparametersmetadata field value, find allProposaldocuments which are referencing to the to exactly the same document under theparametersmetadata field. Consider ONLY latest byverfield ofProposaldocument.
let param = contest_param.doc_meta().parameters();
let search_query = CatalystSignedDocumentSearchQuery {
doc_type: PROPOSAL,
parameters: Some(DocumentRefSelector::Eq(param)),
};
let proposals = provider.try_search_docs(search_query)?;- How to get the list of voted "users" with their voting power ?
Go through allContest Ballotdocuments and collect its authors/singers at the point ofvoting_start.
type VotingPower = HashMap<CatalystId, u64>;
let voting_end = contest_param.voting_end();
let voting_power = ballots.iter().map(|b| (b.voter(), provider.try_get_voting_power_up_to(b.voter(), voting_end))).collect()- What if the same user was voted twice (double vote) ?
Take into account only the latestContest Ballotdocument by theidandverfields
Metadata
Metadata
Assignees
Labels
squad: gatekeepersCatalyst App Backend, System Development & Integration TeamCatalyst App Backend, System Development & Integration Team
Type
Projects
Status
🏗 In progress