pub fn validate(
        &self,
        announcements: &Vec<OracleAnnouncement>,
    ) -> Result<(), crate::error::Error> {
        let first = announcements
            .first()
            .expect("to have at least one element.");
        match &first.oracle_event.event_descriptor {
            EventDescriptor::EnumEvent(ee) => {
                for announcement in announcements {
                    match &announcement.oracle_event.event_descriptor {
                        EventDescriptor::EnumEvent(enum_desc) => {
                            if !unordered_equal(&ee.outcomes, &enum_desc.outcomes) {
                                return Err(Error::InvalidParameters(
                                    "Oracles don't have same enum outcomes.".to_string(),
                                ));
                            }
                        }
                        _ => {
                            return Err(Error::InvalidParameters(
                                "Expected enum event descriptor.".to_string(),
                            ))
                        }
                    }
                }
                match self {
                    ContractDescriptor::Enum(ed) => ed.validate(ee),
                    _ => Err(Error::InvalidParameters(
                        "Event descriptor from contract and oracle differ.".to_string(),
                    )),
                }
            }
            EventDescriptor::DigitDecompositionEvent(_) => match self {
                ContractDescriptor::Numerical(n) => {
                    let min_nb_digits = n.oracle_numeric_infos.get_min_nb_digits();
                    let max_value = n
                        .oracle_numeric_infos
                        .base
                        .checked_pow(min_nb_digits as u32)
                        .ok_or_else(|| {
                            Error::InvalidParameters("Could not compute max value".to_string())
                        })?;
                    n.validate(max_value as u64)
                }
                _ => Err(Error::InvalidParameters(
                    "Event descriptor from contract and oracle differ.".to_string(),
                )),
            },
        }
    }
/// Validate that all possible outcomes that can be attested by the oracle(s)
/// have a single associated payout.
Validate that all possible outcomes that can be attested by the oracle(s)
have a single associated payout.
Validate that all possible outcomes that can be attested by the oracle ( s ) have a single associated payout .
pub fn validate(
        &self,
        announcements: &Vec<OracleAnnouncement>,
    ) -> Result<(), crate::error::Error> {
        let first = announcements
            .first()
            .expect("to have at least one element.");
        match &first.oracle_event.event_descriptor {
            EventDescriptor::EnumEvent(ee) => {
                for announcement in announcements {
                    match &announcement.oracle_event.event_descriptor {
                        EventDescriptor::EnumEvent(enum_desc) => {
                            if !unordered_equal(&ee.outcomes, &enum_desc.outcomes) {
                                return Err(Error::InvalidParameters(
                                    "Oracles don't have same enum outcomes.".to_string(),
                                ));
                            }
                        }
                        _ => {
                            return Err(Error::InvalidParameters(
                                "Expected enum event descriptor.".to_string(),
                            ))
                        }
                    }
                }
                match self {
                    ContractDescriptor::Enum(ed) => ed.validate(ee),
                    _ => Err(Error::InvalidParameters(
                        "Event descriptor from contract and oracle differ.".to_string(),
                    )),
                }
            }
            EventDescriptor::DigitDecompositionEvent(_) => match self {
                ContractDescriptor::Numerical(n) => {
                    let min_nb_digits = n.oracle_numeric_infos.get_min_nb_digits();
                    let max_value = n
                        .oracle_numeric_infos
                        .base
                        .checked_pow(min_nb_digits as u32)
                        .ok_or_else(|| {
                            Error::InvalidParameters("Could not compute max value".to_string())
                        })?;
                    n.validate(max_value as u64)
                }
                _ => Err(Error::InvalidParameters(
                    "Event descriptor from contract and oracle differ.".to_string(),
                )),
            },
        }
    }
pub fn validate ( & self , announcements : & Vec < OracleAnnouncement > , ) -> Result < ( ) , crate :: error :: Error > { let first = announcements . first ( ) . expect ( " " ) ; match & first . oracle_event . event_descriptor { EventDescriptor :: EnumEvent ( ee ) => { for announcement in announcements { match & announcement . oracle_event . event_descriptor { EventDescriptor :: EnumEvent ( enum_desc ) => { if ! unordered_equal ( & ee . outcomes , & enum_desc . outcomes ) { return Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) ; } } _ => { return Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) } } } match self { ContractDescriptor :: Enum ( ed ) => ed . validate ( ee ) , _ => Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) , } } EventDescriptor :: DigitDecompositionEvent ( _ ) => match self { ContractDescriptor :: Numerical ( n ) => { let min_nb_digits = n . oracle_numeric_infos . get_min_nb_digits ( ) ; let max_value = n . oracle_numeric_infos . base . checked_pow ( min_nb_digits as u32 ) . ok_or_else ( | | { Error :: InvalidParameters ( " " . to_string ( ) ) } ) ? ; n . validate ( max_value as u64 ) } _ => Err ( Error :: InvalidParameters ( " " . to_string ( ) , ) ) , } , } }
Validate that all possible outcomes that can be attested by the oracle(s)
have a single associated payout.
Validate that all possible outcomes that can be attested by the oracle ( s ) have a single associated payout .
&self
announcements
&Vec<OracleAnnouncement>