//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using Ajuna.NetApi.Model.Types.Base;
using Ajuna.ServiceLayer.Attributes;
using Ajuna.ServiceLayer.Storage;
using System.Collections.Generic;
using System.Threading.Tasks;


namespace Bajun.Network.NET.RestService.Generated.Storage
{
    
    
    /// <summary>
    /// IIdentityStorage interface definition.
    /// </summary>
    public interface IIdentityStorage : IStorage
    {
        
        /// <summary>
        /// >> IdentityOf
        ///  Information that is pertinent to identify the entity behind an account.
        /// 
        ///  TWOX-NOTE: OK ��� `AccountId` is a secure hash.
        /// </summary>
        Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration GetIdentityOf(string key);
        
        /// <summary>
        /// >> SuperOf
        ///  The super-identity of an alternative "sub" identity together with its name, within that
        ///  context. If the account is not some other account's sub-identity, then just `None`.
        /// </summary>
        Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData> GetSuperOf(string key);
        
        /// <summary>
        /// >> SubsOf
        ///  Alternative "sub" identities of this account.
        /// 
        ///  The first item is the deposit, the second is a vector of the accounts.
        /// 
        ///  TWOX-NOTE: OK ��� `AccountId` is a secure hash.
        /// </summary>
        Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14> GetSubsOf(string key);
        
        /// <summary>
        /// >> Registrars
        ///  The set of registrars. Not expected to get very big as can only be added through a
        ///  special origin (likely a council motion).
        /// 
        ///  The index into this can be cast to `RegistrarIndex` to get a valid value.
        /// </summary>
        Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT15 GetRegistrars();
    }
    
    /// <summary>
    /// IdentityStorage class definition.
    /// </summary>
    public sealed class IdentityStorage : IIdentityStorage
    {
        
        /// <summary>
        /// _identityOfTypedStorage typed storage field
        /// </summary>
        private TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration> _identityOfTypedStorage;
        
        /// <summary>
        /// _superOfTypedStorage typed storage field
        /// </summary>
        private TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData>> _superOfTypedStorage;
        
        /// <summary>
        /// _subsOfTypedStorage typed storage field
        /// </summary>
        private TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14>> _subsOfTypedStorage;
        
        /// <summary>
        /// _registrarsTypedStorage typed storage field
        /// </summary>
        private TypedStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT15> _registrarsTypedStorage;
        
        /// <summary>
        /// IdentityStorage constructor.
        /// </summary>
        public IdentityStorage(IStorageDataProvider storageDataProvider, List<IStorageChangeDelegate> storageChangeDelegates)
        {
            this.IdentityOfTypedStorage = new TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration>("Identity.IdentityOf", storageDataProvider, storageChangeDelegates);
            this.SuperOfTypedStorage = new TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData>>("Identity.SuperOf", storageDataProvider, storageChangeDelegates);
            this.SubsOfTypedStorage = new TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14>>("Identity.SubsOf", storageDataProvider, storageChangeDelegates);
            this.RegistrarsTypedStorage = new TypedStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT15>("Identity.Registrars", storageDataProvider, storageChangeDelegates);
        }
        
        /// <summary>
        /// _identityOfTypedStorage property
        /// </summary>
        public TypedMapStorage<Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration> IdentityOfTypedStorage
        {
            get
            {
                return _identityOfTypedStorage;
            }
            set
            {
                _identityOfTypedStorage = value;
            }
        }
        
        /// <summary>
        /// _superOfTypedStorage property
        /// </summary>
        public TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData>> SuperOfTypedStorage
        {
            get
            {
                return _superOfTypedStorage;
            }
            set
            {
                _superOfTypedStorage = value;
            }
        }
        
        /// <summary>
        /// _subsOfTypedStorage property
        /// </summary>
        public TypedMapStorage<Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14>> SubsOfTypedStorage
        {
            get
            {
                return _subsOfTypedStorage;
            }
            set
            {
                _subsOfTypedStorage = value;
            }
        }
        
        /// <summary>
        /// _registrarsTypedStorage property
        /// </summary>
        public TypedStorage<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT15> RegistrarsTypedStorage
        {
            get
            {
                return _registrarsTypedStorage;
            }
            set
            {
                _registrarsTypedStorage = value;
            }
        }
        
        /// <summary>
        /// Connects to all storages and initializes the change subscription handling.
        /// </summary>
        public async Task InitializeAsync(Ajuna.ServiceLayer.Storage.IStorageDataProvider dataProvider)
        {
            await IdentityOfTypedStorage.InitializeAsync("Identity", "IdentityOf");
            await SuperOfTypedStorage.InitializeAsync("Identity", "SuperOf");
            await SubsOfTypedStorage.InitializeAsync("Identity", "SubsOf");
            await RegistrarsTypedStorage.InitializeAsync("Identity", "Registrars");
        }
        
        /// <summary>
        /// Implements any storage change for Identity.IdentityOf
        /// </summary>
        [StorageChange("Identity", "IdentityOf")]
        public void OnUpdateIdentityOf(string key, string data)
        {
            IdentityOfTypedStorage.Update(key, data);
        }
        
        /// <summary>
        /// >> IdentityOf
        ///  Information that is pertinent to identify the entity behind an account.
        /// 
        ///  TWOX-NOTE: OK ��� `AccountId` is a secure hash.
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration GetIdentityOf(string key)
        {
            if ((key == null))
            {
                return null;
            }
            if (IdentityOfTypedStorage.Dictionary.TryGetValue(key, out Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.Registration result))
            {
                return result;
            }
            else
            {
                return null;
            }
        }
        
        /// <summary>
        /// Implements any storage change for Identity.SuperOf
        /// </summary>
        [StorageChange("Identity", "SuperOf")]
        public void OnUpdateSuperOf(string key, string data)
        {
            SuperOfTypedStorage.Update(key, data);
        }
        
        /// <summary>
        /// >> SuperOf
        ///  The super-identity of an alternative "sub" identity together with its name, within that
        ///  context. If the account is not some other account's sub-identity, then just `None`.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData> GetSuperOf(string key)
        {
            if ((key == null))
            {
                return null;
            }
            if (SuperOfTypedStorage.Dictionary.TryGetValue(key, out Ajuna.NetApi.Model.Types.Base.BaseTuple<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.crypto.AccountId32, Bajun.Network.NET.NetApiExt.Generated.Model.pallet_identity.types.EnumData> result))
            {
                return result;
            }
            else
            {
                return null;
            }
        }
        
        /// <summary>
        /// Implements any storage change for Identity.SubsOf
        /// </summary>
        [StorageChange("Identity", "SubsOf")]
        public void OnUpdateSubsOf(string key, string data)
        {
            SubsOfTypedStorage.Update(key, data);
        }
        
        /// <summary>
        /// >> SubsOf
        ///  Alternative "sub" identities of this account.
        /// 
        ///  The first item is the deposit, the second is a vector of the accounts.
        /// 
        ///  TWOX-NOTE: OK ��� `AccountId` is a secure hash.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14> GetSubsOf(string key)
        {
            if ((key == null))
            {
                return null;
            }
            if (SubsOfTypedStorage.Dictionary.TryGetValue(key, out Ajuna.NetApi.Model.Types.Base.BaseTuple<Ajuna.NetApi.Model.Types.Primitive.U128, Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT14> result))
            {
                return result;
            }
            else
            {
                return null;
            }
        }
        
        /// <summary>
        /// Implements any storage change for Identity.Registrars
        /// </summary>
        [StorageChange("Identity", "Registrars")]
        public void OnUpdateRegistrars(string data)
        {
            RegistrarsTypedStorage.Update(data);
        }
        
        /// <summary>
        /// >> Registrars
        ///  The set of registrars. Not expected to get very big as can only be added through a
        ///  special origin (likely a council motion).
        /// 
        ///  The index into this can be cast to `RegistrarIndex` to get a valid value.
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT15 GetRegistrars()
        {
            return RegistrarsTypedStorage.Get();
        }
    }
}
