use frame_support::{decl_event, weights::Weight};
use polymesh_primitives::agent::{AGId, AgentGroup};
use polymesh_primitives::asset::AssetId;
use polymesh_primitives::{EventDid, ExtrinsicPermissions, IdentityId};

pub trait WeightInfo {
    fn create_group(p: u32) -> Weight;
    fn create_group_and_add_auth(p: u32) -> Weight;
    fn create_and_change_custom_group(p: u32) -> Weight;
    fn set_group_permissions(p: u32) -> Weight;
    fn remove_agent() -> Weight;
    fn abdicate() -> Weight;
    fn change_group_builtin() -> Weight;
    fn change_group_custom() -> Weight;
    fn accept_become_agent() -> Weight;
}

pub trait Config: frame_system::Config + crate::balances::Config {
    /// The overarching event type.
    type RuntimeEvent: From<Event> + Into<<Self as frame_system::Config>::RuntimeEvent>;

    type WeightInfo: WeightInfo;
}

decl_event! {
    pub enum Event {
        /// An Agent Group was created.
        ///
        /// (Caller DID, AG's AssetId, AG's ID, AG's permissions)
        GroupCreated(EventDid, AssetId, AGId, ExtrinsicPermissions),

        /// An Agent Group's permissions was updated.
        ///
        /// (Caller DID, AG's AssetId, AG's ID, AG's new permissions)
        GroupPermissionsUpdated(EventDid, AssetId, AGId, ExtrinsicPermissions),

        /// An agent was added.
        ///
        /// (Caller/Agent DID, Agent's AssetId, Agent's group)
        AgentAdded(EventDid, AssetId, AgentGroup),

        /// An agent was removed.
        ///
        /// (Caller DID, Agent's AssetId, Agent's DID)
        AgentRemoved(EventDid, AssetId, IdentityId),

        /// An agent's group was changed.
        ///
        /// (Caller DID, Agent's AssetId, Agent's DID, The new group of the agent)
        GroupChanged(EventDid, AssetId, IdentityId, AgentGroup),
    }
}
