use crate::{AuthIndex, ExodusSession, DkgIndex, RoastSession};

pub enum ExodusOk<NetworkCurve> {
    ExodusEmptyRequests(AuthIndex, NetworkCurve),
    ExodusWaitingState(AuthIndex, NetworkCurve),
    ExodusNonceCommitted(ExodusSession, RoastSession, AuthIndex, NetworkCurve),
    ExodusGroupCommitted(ExodusSession, RoastSession, AuthIndex, NetworkCurve),
    ExodusSignedPartially(ExodusSession, RoastSession, AuthIndex, NetworkCurve),
    ExodusVerifyingShareMissed(AuthIndex, DkgIndex, NetworkCurve),

    DkgNotPartOfRound(u8, AuthIndex, NetworkCurve),
    DkgRoundRegistered(u8, AuthIndex, NetworkCurve),
    DkgPreviousPurged(AuthIndex, NetworkCurve),
    DkgRoundsCleared(AuthIndex, NetworkCurve),
    DkgRoundAlreadyPassed(u8, AuthIndex, NetworkCurve),
    DkgRoundWaitingPeriod(u8, AuthIndex, NetworkCurve),
    DkgRoundNothingStored(u8, AuthIndex, NetworkCurve),
    DkgRoundMaxSignersNarrowed(u8, AuthIndex, AuthIndex, AuthIndex, NetworkCurve),
}

impl<NetworkCurve> core::fmt::Display for ExodusOk<NetworkCurve>
where
	NetworkCurve: core::fmt::Display
{
    fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
        match self {
            ExodusOk::ExodusEmptyRequests(auth_index, curve) => write!(fmt, "No EXODUS requests found by authority #{auth_index} for curve {curve}."),
            ExodusOk::ExodusWaitingState(auth_index, curve) => write!(fmt, "Waiting for EXODUS requests to be processed by authority #{auth_index} for curve {curve}."),
            ExodusOk::ExodusNonceCommitted(exodus, roast, auth_index, curve) => write!(fmt, "Nonce committed for EXODUS {exodus:?} on ROAST session {roast:?} by authority #{auth_index} for curve {curve}."),
            ExodusOk::ExodusGroupCommitted(exodus, roast, auth_index, curve) => write!(fmt, "Aggregated nonce and binding factor proof committed for EXODUS {exodus:?} on ROAST session {roast:?} by authority #{auth_index} for curve {curve}."),
            ExodusOk::ExodusSignedPartially(exodus, roast, auth_index, curve) => write!(fmt, "Partial signature created for EXODUS {exodus:?} on ROAST session {roast:?} by authority #{auth_index} for curve {curve}."),
            ExodusOk::ExodusVerifyingShareMissed(auth_index, dkg_index, curve) => write!(fmt, "EXODUS Round no verifying share for authority #{auth_index} based on DKG session #{dkg_index} for curve {curve}."),

            ExodusOk::DkgNotPartOfRound(round, auth_index, curve) => write!(fmt, "DKG authority #{auth_index} for network curve {curve} is not part of Round{round}."),
            ExodusOk::DkgRoundRegistered(round, auth_index, curve) => write!(fmt, "DKG Round{round} registered by authority #{auth_index} for network curve {curve}."),
            ExodusOk::DkgPreviousPurged(auth_index, curve) => write!(fmt, "Storage prepared for new DKG session by authority #{auth_index} for network curve {curve}."),
            ExodusOk::DkgRoundsCleared(auth_index, curve) => write!(fmt, "DKG Rounds cleared from storage by authority #{auth_index} for network curve {curve}."),
    	    ExodusOk::DkgRoundAlreadyPassed(round, auth_index, curve) => write!(fmt, "DKG Round{round} already done by authority #{auth_index} for network curve {curve}."),
            ExodusOk::DkgRoundWaitingPeriod(round, auth_index, curve) => write!(fmt, "DKG Round{round} waiting to be applied by authority #{auth_index} for network curve {curve}."),
            ExodusOk::DkgRoundNothingStored(round, auth_index, curve) => write!(fmt, "DKG nothing stored from Round{round} by authority #{auth_index} for network curve {curve}."),
            ExodusOk::DkgRoundMaxSignersNarrowed(round, auth_index, prev_max, curr_max, curve) => write!(fmt, "DKG Round{round} narrowed max_signers from {prev_max} to {curr_max} by {auth_index} for network curve {curve}."),
        }
    }
}
