//------------------------------------------------------------------------------
// <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.Attributes;
using Ajuna.NetApi.Model.Types.Base;
using Ajuna.NetApi.Model.Types.Metadata.V14;
using System.Collections.Generic;


namespace Bajun.Network.NET.NetApiExt.Generated.Model.polkadot_primitives.v2
{
    
    
    /// <summary>
    /// >> 155 - Composite[polkadot_primitives.v2.PersistedValidationData]
    /// </summary>
    [AjunaNodeType(TypeDefEnum.Composite)]
    public sealed class PersistedValidationData : BaseType
    {
        
        /// <summary>
        /// >> parent_head
        /// </summary>
        private Bajun.Network.NET.NetApiExt.Generated.Model.polkadot_parachain.primitives.HeadData _parentHead;
        
        /// <summary>
        /// >> relay_parent_number
        /// </summary>
        private Ajuna.NetApi.Model.Types.Primitive.U32 _relayParentNumber;
        
        /// <summary>
        /// >> relay_parent_storage_root
        /// </summary>
        private Bajun.Network.NET.NetApiExt.Generated.Model.primitive_types.H256 _relayParentStorageRoot;
        
        /// <summary>
        /// >> max_pov_size
        /// </summary>
        private Ajuna.NetApi.Model.Types.Primitive.U32 _maxPovSize;
        
        public Bajun.Network.NET.NetApiExt.Generated.Model.polkadot_parachain.primitives.HeadData ParentHead
        {
            get
            {
                return this._parentHead;
            }
            set
            {
                this._parentHead = value;
            }
        }
        
        public Ajuna.NetApi.Model.Types.Primitive.U32 RelayParentNumber
        {
            get
            {
                return this._relayParentNumber;
            }
            set
            {
                this._relayParentNumber = value;
            }
        }
        
        public Bajun.Network.NET.NetApiExt.Generated.Model.primitive_types.H256 RelayParentStorageRoot
        {
            get
            {
                return this._relayParentStorageRoot;
            }
            set
            {
                this._relayParentStorageRoot = value;
            }
        }
        
        public Ajuna.NetApi.Model.Types.Primitive.U32 MaxPovSize
        {
            get
            {
                return this._maxPovSize;
            }
            set
            {
                this._maxPovSize = value;
            }
        }
        
        public override string TypeName()
        {
            return "PersistedValidationData";
        }
        
        public override byte[] Encode()
        {
            var result = new List<byte>();
            result.AddRange(ParentHead.Encode());
            result.AddRange(RelayParentNumber.Encode());
            result.AddRange(RelayParentStorageRoot.Encode());
            result.AddRange(MaxPovSize.Encode());
            return result.ToArray();
        }
        
        public override void Decode(byte[] byteArray, ref int p)
        {
            var start = p;
            ParentHead = new Bajun.Network.NET.NetApiExt.Generated.Model.polkadot_parachain.primitives.HeadData();
            ParentHead.Decode(byteArray, ref p);
            RelayParentNumber = new Ajuna.NetApi.Model.Types.Primitive.U32();
            RelayParentNumber.Decode(byteArray, ref p);
            RelayParentStorageRoot = new Bajun.Network.NET.NetApiExt.Generated.Model.primitive_types.H256();
            RelayParentStorageRoot.Decode(byteArray, ref p);
            MaxPovSize = new Ajuna.NetApi.Model.Types.Primitive.U32();
            MaxPovSize.Decode(byteArray, ref p);
            TypeSize = p - start;
        }
    }
}
