use frame_support::{
    pallet_prelude::*,
    storage::PrefixIterator,
};
use sp_runtime::{
    DispatchResult,
    traits::{AtLeast32BitUnsigned, Member},
};

pub trait NetworkDataBasicHandler {
    type NetworkId: Parameter
        + Member
        + AtLeast32BitUnsigned
        + Default
        + Copy
        + TypeInfo
        + MaybeSerializeDeserialize
        + MaxEncodedLen;
}

pub trait NetworkDataInspectHandler<Network>: NetworkDataBasicHandler {
    fn get(n: &Self::NetworkId) -> Option<Network>;
    fn iter() -> PrefixIterator<(Self::NetworkId, Network)>;
}

pub trait NetworkDataMutateHandler<Network>: NetworkDataInspectHandler<Network> {
    fn register(chain_id: Self::NetworkId, network: Network) -> DispatchResult;
    fn remove(chain_id: Self::NetworkId) -> DispatchResult;
}
