Skip to content

Contest Parameters document type processing. #714

@Mr-Leshiy

Description

@Mr-Leshiy

Summary

For the full voting experience with the Representatives and Delegations need to define a special document type as Contest Parameters with its own specific validation logic.

Description

  • Define a new Rust type struct ContestParameters.
  • Add a necessary methods to expose data according to the Contest Parameters document type. All these data should be taken from the payload. For the first version lets assume that the JSON payload would always has all necessary data we need.
    • contest timeline (start and end date).
    • election public key (???)
#[derive(serde::Deserialise)]
struct ContestPrarametersPayload {
   voting_start: chrono::Datetime<Utc>,
   voting_end: chrono::Datetime<Utc>,
   election_pk: String,
}
  • Add a new ContestParametersRule with the corresponding CatalystSignedDocumentValidationRule trait implementation.
  • Add a constructor
    pub async fn new<Provider>(
        doc: &CatalystSignedDocument,
        provider: &Provider,
    ) -> anyhow::Result<Self>
    where
        Provider: CatalystSignedDocumentProvider,
    {
        if doc.report().is_problematic() {
            anyhow::bail!("Provided document is not valid {:?}", doc.report())
        }
        anyhow::ensure!(
            doc.doc_type()? == &CONTEST_PARAMETERS,
            "Document must be Contest Ballot type"
        );
     // perform the same set of validation as for the `CatalystSignedDocumentValidationRule`
    ...
}
  • Add a corresponding test cases

Metadata

Metadata

Assignees

Labels

squad: gatekeepersCatalyst App Backend, System Development & Integration Team

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions