//------------------------------------------------------------------------------
// <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;
using Ajuna.NetApi.Model.Extrinsics;
using Ajuna.NetApi.Model.Meta;
using Ajuna.NetApi.Model.Types;
using Ajuna.NetApi.Model.Types.Base;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;


namespace Bajun.Network.NET.NetApiExt.Generated.Storage
{
    
    
    public sealed class TreasuryStorage
    {
        
        // Substrate client for the storage calls.
        private SubstrateClientExt _client;
        
        public TreasuryStorage(SubstrateClientExt client)
        {
            this._client = client;
            _client.StorageKeyDict.Add(new System.Tuple<string, string>("Treasury", "ProposalCount"), new System.Tuple<Ajuna.NetApi.Model.Meta.Storage.Hasher[], System.Type, System.Type>(null, null, typeof(Ajuna.NetApi.Model.Types.Primitive.U32)));
            _client.StorageKeyDict.Add(new System.Tuple<string, string>("Treasury", "Proposals"), new System.Tuple<Ajuna.NetApi.Model.Meta.Storage.Hasher[], System.Type, System.Type>(new Ajuna.NetApi.Model.Meta.Storage.Hasher[] {
                            Ajuna.NetApi.Model.Meta.Storage.Hasher.Twox64Concat}, typeof(Ajuna.NetApi.Model.Types.Primitive.U32), typeof(Bajun.Network.NET.NetApiExt.Generated.Model.pallet_treasury.Proposal)));
            _client.StorageKeyDict.Add(new System.Tuple<string, string>("Treasury", "Deactivated"), new System.Tuple<Ajuna.NetApi.Model.Meta.Storage.Hasher[], System.Type, System.Type>(null, null, typeof(Ajuna.NetApi.Model.Types.Primitive.U128)));
            _client.StorageKeyDict.Add(new System.Tuple<string, string>("Treasury", "Approvals"), new System.Tuple<Ajuna.NetApi.Model.Meta.Storage.Hasher[], System.Type, System.Type>(null, null, typeof(Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT27)));
        }
        
        /// <summary>
        /// >> ProposalCountParams
        ///  Number of proposals that have been made.
        /// </summary>
        public static string ProposalCountParams()
        {
            return RequestGenerator.GetStorage("Treasury", "ProposalCount", Ajuna.NetApi.Model.Meta.Storage.Type.Plain);
        }
        
        /// <summary>
        /// >> ProposalCountDefault
        /// Default value as hex string
        /// </summary>
        public static string ProposalCountDefault()
        {
            return "0x00000000";
        }
        
        /// <summary>
        /// >> ProposalCount
        ///  Number of proposals that have been made.
        /// </summary>
        public async Task<Ajuna.NetApi.Model.Types.Primitive.U32> ProposalCount(CancellationToken token)
        {
            string parameters = TreasuryStorage.ProposalCountParams();
            var result = await _client.GetStorageAsync<Ajuna.NetApi.Model.Types.Primitive.U32>(parameters, token);
            return result;
        }
        
        /// <summary>
        /// >> ProposalsParams
        ///  Proposals that have been made.
        /// </summary>
        public static string ProposalsParams(Ajuna.NetApi.Model.Types.Primitive.U32 key)
        {
            return RequestGenerator.GetStorage("Treasury", "Proposals", Ajuna.NetApi.Model.Meta.Storage.Type.Map, new Ajuna.NetApi.Model.Meta.Storage.Hasher[] {
                        Ajuna.NetApi.Model.Meta.Storage.Hasher.Twox64Concat}, new Ajuna.NetApi.Model.Types.IType[] {
                        key});
        }
        
        /// <summary>
        /// >> ProposalsDefault
        /// Default value as hex string
        /// </summary>
        public static string ProposalsDefault()
        {
            return "0x00";
        }
        
        /// <summary>
        /// >> Proposals
        ///  Proposals that have been made.
        /// </summary>
        public async Task<Bajun.Network.NET.NetApiExt.Generated.Model.pallet_treasury.Proposal> Proposals(Ajuna.NetApi.Model.Types.Primitive.U32 key, CancellationToken token)
        {
            string parameters = TreasuryStorage.ProposalsParams(key);
            var result = await _client.GetStorageAsync<Bajun.Network.NET.NetApiExt.Generated.Model.pallet_treasury.Proposal>(parameters, token);
            return result;
        }
        
        /// <summary>
        /// >> DeactivatedParams
        ///  The amount which has been reported as inactive to Currency.
        /// </summary>
        public static string DeactivatedParams()
        {
            return RequestGenerator.GetStorage("Treasury", "Deactivated", Ajuna.NetApi.Model.Meta.Storage.Type.Plain);
        }
        
        /// <summary>
        /// >> DeactivatedDefault
        /// Default value as hex string
        /// </summary>
        public static string DeactivatedDefault()
        {
            return "0x00000000000000000000000000000000";
        }
        
        /// <summary>
        /// >> Deactivated
        ///  The amount which has been reported as inactive to Currency.
        /// </summary>
        public async Task<Ajuna.NetApi.Model.Types.Primitive.U128> Deactivated(CancellationToken token)
        {
            string parameters = TreasuryStorage.DeactivatedParams();
            var result = await _client.GetStorageAsync<Ajuna.NetApi.Model.Types.Primitive.U128>(parameters, token);
            return result;
        }
        
        /// <summary>
        /// >> ApprovalsParams
        ///  Proposal indices that have been approved but not yet awarded.
        /// </summary>
        public static string ApprovalsParams()
        {
            return RequestGenerator.GetStorage("Treasury", "Approvals", Ajuna.NetApi.Model.Meta.Storage.Type.Plain);
        }
        
        /// <summary>
        /// >> ApprovalsDefault
        /// Default value as hex string
        /// </summary>
        public static string ApprovalsDefault()
        {
            return "0x00";
        }
        
        /// <summary>
        /// >> Approvals
        ///  Proposal indices that have been approved but not yet awarded.
        /// </summary>
        public async Task<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT27> Approvals(CancellationToken token)
        {
            string parameters = TreasuryStorage.ApprovalsParams();
            var result = await _client.GetStorageAsync<Bajun.Network.NET.NetApiExt.Generated.Model.sp_core.bounded.bounded_vec.BoundedVecT27>(parameters, token);
            return result;
        }
    }
    
    public sealed class TreasuryCalls
    {
        
        /// <summary>
        /// >> propose_spend
        /// Contains one variant per dispatchable that can be called by an extrinsic.
        /// </summary>
        public static Method ProposeSpend(Ajuna.NetApi.Model.Types.Base.BaseCom<Ajuna.NetApi.Model.Types.Primitive.U128> value, Bajun.Network.NET.NetApiExt.Generated.Model.sp_runtime.multiaddress.EnumMultiAddress beneficiary)
        {
            System.Collections.Generic.List<byte> byteArray = new List<byte>();
            byteArray.AddRange(value.Encode());
            byteArray.AddRange(beneficiary.Encode());
            return new Method(41, "Treasury", 0, "propose_spend", byteArray.ToArray());
        }
        
        /// <summary>
        /// >> reject_proposal
        /// Contains one variant per dispatchable that can be called by an extrinsic.
        /// </summary>
        public static Method RejectProposal(Ajuna.NetApi.Model.Types.Base.BaseCom<Ajuna.NetApi.Model.Types.Primitive.U32> proposal_id)
        {
            System.Collections.Generic.List<byte> byteArray = new List<byte>();
            byteArray.AddRange(proposal_id.Encode());
            return new Method(41, "Treasury", 1, "reject_proposal", byteArray.ToArray());
        }
        
        /// <summary>
        /// >> approve_proposal
        /// Contains one variant per dispatchable that can be called by an extrinsic.
        /// </summary>
        public static Method ApproveProposal(Ajuna.NetApi.Model.Types.Base.BaseCom<Ajuna.NetApi.Model.Types.Primitive.U32> proposal_id)
        {
            System.Collections.Generic.List<byte> byteArray = new List<byte>();
            byteArray.AddRange(proposal_id.Encode());
            return new Method(41, "Treasury", 2, "approve_proposal", byteArray.ToArray());
        }
        
        /// <summary>
        /// >> spend
        /// Contains one variant per dispatchable that can be called by an extrinsic.
        /// </summary>
        public static Method Spend(Ajuna.NetApi.Model.Types.Base.BaseCom<Ajuna.NetApi.Model.Types.Primitive.U128> amount, Bajun.Network.NET.NetApiExt.Generated.Model.sp_runtime.multiaddress.EnumMultiAddress beneficiary)
        {
            System.Collections.Generic.List<byte> byteArray = new List<byte>();
            byteArray.AddRange(amount.Encode());
            byteArray.AddRange(beneficiary.Encode());
            return new Method(41, "Treasury", 3, "spend", byteArray.ToArray());
        }
        
        /// <summary>
        /// >> remove_approval
        /// Contains one variant per dispatchable that can be called by an extrinsic.
        /// </summary>
        public static Method RemoveApproval(Ajuna.NetApi.Model.Types.Base.BaseCom<Ajuna.NetApi.Model.Types.Primitive.U32> proposal_id)
        {
            System.Collections.Generic.List<byte> byteArray = new List<byte>();
            byteArray.AddRange(proposal_id.Encode());
            return new Method(41, "Treasury", 4, "remove_approval", byteArray.ToArray());
        }
    }
    
    public sealed class TreasuryConstants
    {
        
        /// <summary>
        /// >> ProposalBond
        ///  Fraction of a proposal's value that should be bonded in order to place the proposal.
        ///  An accepted proposal gets these back. A rejected proposal does not.
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.sp_arithmetic.per_things.Permill ProposalBond()
        {
            var result = new Bajun.Network.NET.NetApiExt.Generated.Model.sp_arithmetic.per_things.Permill();
            result.Create("0x50C30000");
            return result;
        }
        
        /// <summary>
        /// >> ProposalBondMinimum
        ///  Minimum amount of funds that should be placed in a deposit for making a proposal.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Primitive.U128 ProposalBondMinimum()
        {
            var result = new Ajuna.NetApi.Model.Types.Primitive.U128();
            result.Create("0x0010A5D4E80000000000000000000000");
            return result;
        }
        
        /// <summary>
        /// >> ProposalBondMaximum
        ///  Maximum amount of funds that should be placed in a deposit for making a proposal.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Base.BaseOpt<Ajuna.NetApi.Model.Types.Primitive.U128> ProposalBondMaximum()
        {
            var result = new Ajuna.NetApi.Model.Types.Base.BaseOpt<Ajuna.NetApi.Model.Types.Primitive.U128>();
            result.Create("0x00");
            return result;
        }
        
        /// <summary>
        /// >> SpendPeriod
        ///  Period between successive spends.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Primitive.U32 SpendPeriod()
        {
            var result = new Ajuna.NetApi.Model.Types.Primitive.U32();
            result.Create("0xE0C40000");
            return result;
        }
        
        /// <summary>
        /// >> Burn
        ///  Percentage of spare funds (if any) that are burnt per spend period.
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.sp_arithmetic.per_things.Permill Burn()
        {
            var result = new Bajun.Network.NET.NetApiExt.Generated.Model.sp_arithmetic.per_things.Permill();
            result.Create("0x00000000");
            return result;
        }
        
        /// <summary>
        /// >> PalletId
        ///  The treasury's pallet id, used for deriving its sovereign account ID.
        /// </summary>
        public Bajun.Network.NET.NetApiExt.Generated.Model.frame_support.PalletId PalletId()
        {
            var result = new Bajun.Network.NET.NetApiExt.Generated.Model.frame_support.PalletId();
            result.Create("0x616A2F7472737279");
            return result;
        }
        
        /// <summary>
        /// >> MaxApprovals
        ///  The maximum number of approvals that can wait in the spending queue.
        /// 
        ///  NOTE: This parameter is also used within the Bounties Pallet extension if enabled.
        /// </summary>
        public Ajuna.NetApi.Model.Types.Primitive.U32 MaxApprovals()
        {
            var result = new Ajuna.NetApi.Model.Types.Primitive.U32();
            result.Create("0x64000000");
            return result;
        }
    }
    
    public enum TreasuryErrors
    {
        
        /// <summary>
        /// >> InsufficientProposersBalance
        /// Proposer's balance is too low.
        /// </summary>
        InsufficientProposersBalance,
        
        /// <summary>
        /// >> InvalidIndex
        /// No proposal or bounty at that index.
        /// </summary>
        InvalidIndex,
        
        /// <summary>
        /// >> TooManyApprovals
        /// Too many approvals in the queue.
        /// </summary>
        TooManyApprovals,
        
        /// <summary>
        /// >> InsufficientPermission
        /// The spend origin is valid but the amount it is allowed to spend is lower than the
        /// amount to be spent.
        /// </summary>
        InsufficientPermission,
        
        /// <summary>
        /// >> ProposalNotApproved
        /// Proposal has not been approved.
        /// </summary>
        ProposalNotApproved,
    }
}
