# ruff: noqa: F403, F405, E402
from pydantic import BaseModel, Field, ConfigDict
import datetime as dt
from enum import Enum
from typing import Optional

# this leads to circluar import!
# from ccdexplorer_fundamentals.cis import MongoTypeLoggedEvent


################
#
# CCD_ is the prefix for all Pydantic classes
# to prevent namespace collision with the
# protobuf generated classes.
#
################


class CredentialElement(Enum):
    """
    Enum class representing different types of credential elements.

    Attributes:
        firstName (int): Represents the first name of an individual.
        lastName (int): Represents the last name of an individual.
        sex (int): Represents the sex of an individual.
        dob (int): Represents the date of birth of an individual.
        countryOfResidence (int): Represents the country of residence of an individual.
        nationality (int): Represents the nationality of an individual.
        idDocType (int): Represents the type of identification document.
        idDocNo (int): Represents the identification document number.
        idDocIssuer (int): Represents the issuer of the identification document.
        idDocIssuedAt (int): Represents the issuance date of the identification document.
        idDocExpiresAt (int): Represents the expiration date of the identification document.
        nationalIdNo (int): Represents the national identification number.
        taxIdNo (int): Represents the tax identification number.
        lei (int): Represents the Legal Entity Identifier.
        legalName (int): Represents the legal name of a business entity.
        legalJurisdictionCountry (int): Represents the legal jurisdiction country of a business entity.
        businessNumber (int): Represents the business number of a business entity.
        registrationAuthority (int): Represents the registration authority of a business entity.
    """

    firstName = 0
    lastName = 1
    sex = 2
    dob = 3
    countryOfResidence = 4
    nationality = 5
    idDocType = 6
    idDocNo = 7
    idDocIssuer = 8
    idDocIssuedAt = 9
    idDocExpiresAt = 10
    nationalIdNo = 11
    taxIdNo = 12
    lei = 13
    legalName = 14
    legalJurisdictionCountry = 15
    businessNumber = 16
    registrationAuthority = 17


class CredentialDocType(Enum):
    """
    Enum class representing different types of credential documents.

    Attributes:
        na (str): Represents an unspecified or unknown document type.
        Passport (str): Represents a passport document type.
        National_ID_Card (str): Represents a national ID card document type.
        Driving_License (str): Represents a driving license document type.
        Immigration_Card (str): Represents an immigration card document type.
    """

    na = "0"
    Passport = "1"
    National_ID_Card = "2"
    Driving_License = "3"
    Immigration_Card = "4"


class ProtocolVersions(Enum):
    """
    Enum representing different protocol versions.

    Attributes:
        PROTOCOL_VERSION_1 (int): Protocol version 1.
        PROTOCOL_VERSION_2 (int): Protocol version 2.
        PROTOCOL_VERSION_3 (int): Protocol version 3.
        PROTOCOL_VERSION_4 (int): Protocol version 4.
        PROTOCOL_VERSION_5 (int): Protocol version 5.
        PROTOCOL_VERSION_6 (int): Protocol version 6.
        PROTOCOL_VERSION_7 (int): Protocol version 7.
        PROTOCOL_VERSION_8 (int): Protocol version 8.
    """

    PROTOCOL_VERSION_1 = 0
    PROTOCOL_VERSION_2 = 1
    PROTOCOL_VERSION_3 = 2
    PROTOCOL_VERSION_4 = 3
    PROTOCOL_VERSION_5 = 4
    PROTOCOL_VERSION_6 = 5
    PROTOCOL_VERSION_7 = 6
    PROTOCOL_VERSION_8 = 7


class OpenStatus(Enum):
    """
    Enum representing the open status of a resource.

    Attributes:
        open_for_all (int): The resource is open for all users.
        closed_for_new (int): The resource is closed for new users but open for existing users.
        closed_for_all (int): The resource is closed for all users.
    """

    open_for_all = 0
    closed_for_new = 1
    closed_for_all = 2


class CoolDownStatus(Enum):
    """
    Enum representing the different stages of cooldown status.

    Attributes:
        COOLDOWN (int): Represents the cooldown stage with a value of 0.
        PRE_COOLDOWN (int): Represents the pre-cooldown stage with a value of 1.
        PRE_PRE_COOLDOWN (int): Represents the pre-pre-cooldown stage with a value of 2.
    """

    COOLDOWN = 0
    PRE_COOLDOWN = 1
    PRE_PRE_COOLDOWN = 2


CCD_ArIdentity = int
CCD_IpIdentity = int
CCD_ArPublicKey = str
CCD_IpVerifyKey = str
CCD_IpCdiVerifyKey = str
CCD_BlockHash = str
CCD_TransactionHash = str
CCD_AccountAddress = str
CCD_AccountIndex = int
CCD_DelegatorId = CCD_AccountIndex
microCCD = int
CCD_BakerId = int
CCD_Epoch = int
CCD_Energy = int
CCD_DurationSeconds = int
CCD_Duration = int
CCD_ModuleRef = str
CCD_ContractEvent = str
CCD_Memo = str
CCD_RegisteredData = str
CCD_BakerSignatureVerifyKey = str
CCD_OpenStatus = int
CCD_BakerElectionVerifyKey = str
CCD_BakerAggregationVerifyKey = str
CCD_Parameter = str
CCD_AmountFraction = float
CCD_ReceiveName = str
CCD_CredentialsPerBlockLimit = int
CCD_LeadershipElectionNonce = str
CCD_CredentialRegistrationId = str
CCD_Sha256Hash = str
CCD_ElectionDifficulty = float
CCD_UpdatePublicKey = str
CCD_UpdateKeysIndex = int
CCD_UpdateKeysThreshold = int
CCD_TransactionTime = int
CCD_SignatureThreshold = int
CCD_IdentityProviderIdentity = int
CCD_ArThreshold = int
CCD_Commitment = str
CCD_VersionedModuleSource_ModuleSourceV0 = str
CCD_VersionedModuleSource_ModuleSourceV1 = str
CCD_ProtocolVersion = int
CCD_StateHash = str
CCD_TimeStamp = dt.datetime

CCD_SequenceNumber = int
CCD_StakePendingChange_Remove = CCD_TimeStamp
CCD_ContractStateV0 = str
CCD_InitName = str
CCD_EncryptedAmount = str
CCD_Empty = None
CCD_AccountThreshold = int
CCD_Policy_Attributes = str
CCD_Round = int
CCD_Epoch = int

# class CCD_Policy_Attributes(BaseModel):
#     key: int
#     value: str


class CCD_ContractAddress(BaseModel):
    """
    CCD_ContractAddress is a model representing a contract address with an index and subindex.

    Attributes:
        index (int): The index of the contract address.
        subindex (int): The subindex of the contract address.

    Methods:
        to_str() -> str:
            Converts the CCD_ContractAddress instance to a string representation in the format "<index,subindex>".

        from_str(str_repr: str) -> CCD_ContractAddress:
            Class method that creates a CCD_ContractAddress instance from a string representation in the format "<index,subindex>".
            Args:
                str_repr (str): The string representation of the contract address.
            Returns:
                CCD_ContractAddress: The corresponding CCD_ContractAddress instance.

        from_index(index: int, subindex: int) -> CCD_ContractAddress:
            Class method that creates a CCD_ContractAddress instance from given index and subindex.
            Args:
                index (int): The index of the contract address.
                subindex (int): The subindex of the contract address.
            Returns:
                CCD_ContractAddress: The corresponding CCD_ContractAddress instance.
    """

    index: int
    subindex: int

    def to_str(self):
        return f"<{self.index},{self.subindex}>"

    @classmethod
    def from_str(self, str_repr: str):
        """
        Parses a string representation of a CCD contract address and returns a CCD_ContractAddress object.
        Args:
            str_repr (str): The string representation of the CCD contract address in the format "(index,subindex)-otherinfo".
        Returns:
            CCD_ContractAddress: An object representing the parsed contract address.
        Raises:
            ValueError: If the string representation is not in the expected format.
        """

        contract_string = str_repr.split("-")[0]
        try:
            c = CCD_ContractAddress(
                **{
                    "index": contract_string.split(",")[0][1:],
                    "subindex": contract_string.split(",")[1][:-1],
                }
            )
        except:  # noqa: E722
            c = CCD_ContractAddress(
                **{
                    "index": contract_string.split(",")[0][1:],
                    "subindex": 0,
                }
            )
        return c

    @classmethod
    def from_index(self, index: int, subindex: int):
        """
        Create a CCD_ContractAddress instance from the given index and subindex.

        Args:
            index (int): The index value for the contract address.
            subindex (int): The subindex value for the contract address.

        Returns:
            CCD_ContractAddress: An instance of CCD_ContractAddress initialized with the provided index and subindex.
        """
        s = CCD_ContractAddress(**{"index": index, "subindex": subindex})
        return s


class CCD_Address(BaseModel):
    """
    CCD_Address is a model that represents an address in the CCD system.

    Attributes:
        account (Optional[CCD_AccountAddress]): An optional attribute representing the account address.
        contract (Optional[CCD_ContractAddress]): An optional attribute representing the contract address.
    """

    account: Optional[CCD_AccountAddress] = None
    contract: Optional[CCD_ContractAddress] = None


class CCD_RejectReason_InvalidInitMethod(BaseModel):
    """
    CCD_RejectReason_InvalidInitMethod is a model representing a rejection reason for an invalid initialization method.

    Attributes:
        module_ref (CCD_ModuleRef): Reference to the CCD module.
        init_name (CCD_InitName): Name of the initialization method.
    """

    module_ref: CCD_ModuleRef
    init_name: CCD_InitName


class CCD_RejectReason_InvalidReceiveMethod(BaseModel):
    """
    Represents a rejection reason for an invalid receive method in the CCD system.

    Attributes:
        module_ref (CCD_ModuleRef): Reference to the CCD module.
        receive_name (CCD_ReceiveName): Name of the receive method that is invalid.
    """

    module_ref: CCD_ModuleRef
    receive_name: CCD_ReceiveName


class CCD_RejectReason_AmountTooLarge(BaseModel):
    """
    Represents a rejection reason where the amount is too large.

    Attributes:
        address (CCD_Address): The address associated with the rejection.
        amount (microCCD): The amount that is considered too large.
    """

    address: CCD_Address
    amount: microCCD


class CCD_RejectReason_RejectedInit(BaseModel):
    """
    CCD_RejectReason_RejectedInit is a model representing the reason for rejection.

    Attributes:
        reject_reason (int): An integer representing the reason for rejection.
    """

    reject_reason: int


class CCD_RejectReason_RejectedReceive(BaseModel):
    """
    Represents a rejected receive reason for contract calls.

    Attributes:
        reject_reason (int): The reason code for the rejection.
        contract_address (CCD_ContractAddress): The address of the contract.
        receive_name (CCD_ReceiveName): The name of the receive function.
        parameter (CCD_Parameter): The parameter associated with the receive function.
    """

    reject_reason: int
    contract_address: CCD_ContractAddress
    receive_name: CCD_ReceiveName
    parameter: CCD_Parameter


class CCD_RejectReason_DuplicateCredIds(BaseModel):
    """
    CCD_RejectReason_DuplicateCredIds is a model representing a rejection reason due to duplicate credential IDs.

    Attributes:
        ids (list[CCD_CredentialRegistrationId]): A list of credential registration IDs that are considered duplicates.
    """

    ids: list[CCD_CredentialRegistrationId]


class CCD_RejectReason_NonExistentCredIds(BaseModel):
    """
    Represents a rejection reason for non-existent credential IDs.

    Attributes:
        ids (list[CCD_CredentialRegistrationId]): A list of credential registration IDs that do not exist.
    """

    ids: list[CCD_CredentialRegistrationId]


class CCD_RejectReason(BaseModel):
    """
    CCD_RejectReason is a model representing various reasons for rejecting a CCD (Concordium) transaction or operation.

    Attributes:
        module_not_wf (Optional[CCD_Empty]): Indicates the module is not well-formed.
        module_hash_already_exists (Optional[CCD_ModuleRef]): Indicates the module hash already exists.
        invalid_account_reference (Optional[CCD_AccountAddress]): Indicates the account reference is invalid.
        invalid_init_method (Optional[CCD_RejectReason_InvalidInitMethod]): Indicates the initialization method is invalid.
        invalid_receive_method (Optional[CCD_RejectReason_InvalidReceiveMethod]): Indicates the receive method is invalid.
        invalid_module_reference (Optional[CCD_ModuleRef]): Indicates the module reference is invalid.
        invalid_contract_address (Optional[CCD_ContractAddress]): Indicates the contract address is invalid.
        runtime_failure (Optional[CCD_Empty]): Indicates a runtime failure occurred.
        amount_too_large (Optional[CCD_RejectReason_AmountTooLarge]): Indicates the amount is too large.
        serialization_failure (Optional[CCD_Empty]): Indicates a serialization failure occurred.
        out_of_energy (Optional[CCD_Empty]): Indicates the operation ran out of energy.
        rejected_init (Optional[CCD_RejectReason_RejectedInit]): Indicates the initialization was rejected.
        rejected_receive (Optional[CCD_RejectReason_RejectedReceive]): Indicates the receive operation was rejected.
        invalid_proof (Optional[CCD_Empty]): Indicates the proof is invalid.
        already_a_baker (Optional[CCD_BakerId]): Indicates the account is already a baker.
        not_a_baker (Optional[CCD_AccountAddress]): Indicates the account is not a baker.
        insufficient_balance_for_baker_stake (Optional[CCD_Empty]): Indicates insufficient balance for baker stake.
        stake_under_minimum_threshold_for_baking (Optional[CCD_Empty]): Indicates the stake is under the minimum threshold for baking.
        baker_in_cooldown (Optional[CCD_Empty]): Indicates the baker is in cooldown.
        duplicate_aggregation_key (Optional[CCD_BakerAggregationVerifyKey]): Indicates a duplicate aggregation key.
        non_existent_credential_id (Optional[CCD_Empty]): Indicates a non-existent credential ID.
        key_index_already_in_use (Optional[CCD_Empty]): Indicates the key index is already in use.
        invalid_account_threshold (Optional[CCD_Empty]): Indicates the account threshold is invalid.
        invalid_credential_key_sign_threshold (Optional[CCD_Empty]): Indicates the credential key sign threshold is invalid.
        invalid_encrypted_amount_transfer_proof (Optional[CCD_Empty]): Indicates the encrypted amount transfer proof is invalid.
        invalid_transfer_to_public_proof (Optional[CCD_Empty]): Indicates the transfer to public proof is invalid.
        encrypted_amount_self_transfer (Optional[CCD_AccountAddress]): Indicates an encrypted amount self-transfer.
        invalid_index_on_encrypted_transfer (Optional[CCD_Empty]): Indicates an invalid index on encrypted transfer.
        zero_scheduledAmount (Optional[CCD_Empty]): Indicates a zero scheduled amount.
        non_increasing_schedule (Optional[CCD_Empty]): Indicates a non-increasing schedule.
        first_scheduled_release_expired (Optional[CCD_Empty]): Indicates the first scheduled release has expired.
        scheduled_self_transfer (Optional[CCD_AccountAddress]): Indicates a scheduled self-transfer.
        invalid_credentials (Optional[CCD_Empty]): Indicates invalid credentials.
        duplicate_cred_ids (Optional[CCD_RejectReason_DuplicateCredIds]): Indicates duplicate credential IDs.
        non_existent_cred_ids (Optional[CCD_RejectReason_NonExistentCredIds]): Indicates non-existent credential IDs.
        remove_first_credential (Optional[CCD_Empty]): Indicates the first credential cannot be removed.
        credential_holder_did_not_sign (Optional[CCD_Empty]): Indicates the credential holder did not sign.
        not_allowed_multiple_credentials (Optional[CCD_Empty]): Indicates multiple credentials are not allowed.
        not_allowed_to_receive_encrypted (Optional[CCD_Empty]): Indicates receiving encrypted amounts is not allowed.
        not_allowed_to_handle_encrypted (Optional[CCD_Empty]): Indicates handling encrypted amounts is not allowed.
        missing_baker_add_parameters (Optional[CCD_Empty]): Indicates missing parameters for adding a baker.
        finalization_reward_commission_not_in_range (Optional[CCD_Empty]): Indicates the finalization reward commission is not in range.
        baking_reward_commission_not_in_range (Optional[CCD_Empty]): Indicates the baking reward commission is not in range.
        transaction_fee_commission_not_in_range (Optional[CCD_Empty]): Indicates the transaction fee commission is not in range.
        already_a_delegator (Optional[CCD_Empty]): Indicates the account is already a delegator.
        insufficient_balance_for_delegation_stake (Optional[CCD_Empty]): Indicates insufficient balance for delegation stake.
        missing_delegation_add_parameters (Optional[CCD_Empty]): Indicates missing parameters for adding a delegation.
        insufficient_delegation_stake (Optional[CCD_Empty]): Indicates insufficient delegation stake.
        delegator_in_cooldown (Optional[CCD_Empty]): Indicates the delegator is in cooldown.
        not_a_delegator (Optional[CCD_AccountAddress]): Indicates the account is not a delegator.
        delegation_target_not_a_baker (Optional[CCD_BakerId]): Indicates the delegation target is not a baker.
        stake_over_maximum_threshold_for_pool (Optional[CCD_Empty]): Indicates the stake is over the maximum threshold for the pool.
        pool_would_become_over_delegated (Optional[CCD_Empty]): Indicates the pool would become over-delegated.
        pool_closed (Optional[CCD_Empty]): Indicates the pool is closed.
    """

    module_not_wf: Optional[CCD_Empty] = None
    module_hash_already_exists: Optional[CCD_ModuleRef] = None
    invalid_account_reference: Optional[CCD_AccountAddress] = None
    invalid_init_method: Optional[CCD_RejectReason_InvalidInitMethod] = None
    invalid_receive_method: Optional[CCD_RejectReason_InvalidReceiveMethod] = None
    invalid_module_reference: Optional[CCD_ModuleRef] = None
    invalid_contract_address: Optional[CCD_ContractAddress] = None
    runtime_failure: Optional[CCD_Empty] = None
    amount_too_large: Optional[CCD_RejectReason_AmountTooLarge] = None
    serialization_failure: Optional[CCD_Empty] = None
    out_of_energy: Optional[CCD_Empty] = None
    rejected_init: Optional[CCD_RejectReason_RejectedInit] = None
    rejected_receive: Optional[CCD_RejectReason_RejectedReceive] = None
    invalid_proof: Optional[CCD_Empty] = None
    already_a_baker: Optional[CCD_BakerId] = None
    not_a_baker: Optional[CCD_AccountAddress] = None
    insufficient_balance_for_baker_stake: Optional[CCD_Empty] = None
    stake_under_minimum_threshold_for_baking: Optional[CCD_Empty] = None
    baker_in_cooldown: Optional[CCD_Empty] = None
    duplicate_aggregation_key: Optional[CCD_BakerAggregationVerifyKey] = None
    non_existent_credential_id: Optional[CCD_Empty] = None
    key_index_already_in_use: Optional[CCD_Empty] = None
    invalid_account_threshold: Optional[CCD_Empty] = None
    invalid_credential_key_sign_threshold: Optional[CCD_Empty] = None
    invalid_encrypted_amount_transfer_proof: Optional[CCD_Empty] = None
    invalid_transfer_to_public_proof: Optional[CCD_Empty] = None
    encrypted_amount_self_transfer: Optional[CCD_AccountAddress] = None
    invalid_index_on_encrypted_transfer: Optional[CCD_Empty] = None
    zero_scheduledAmount: Optional[CCD_Empty] = None
    non_increasing_schedule: Optional[CCD_Empty] = None
    first_scheduled_release_expired: Optional[CCD_Empty] = None
    scheduled_self_transfer: Optional[CCD_AccountAddress] = None
    invalid_credentials: Optional[CCD_Empty] = None
    duplicate_cred_ids: Optional[CCD_RejectReason_DuplicateCredIds] = None
    non_existent_cred_ids: Optional[CCD_RejectReason_NonExistentCredIds] = None
    remove_first_credential: Optional[CCD_Empty] = None
    credential_holder_did_not_sign: Optional[CCD_Empty] = None
    not_allowed_multiple_credentials: Optional[CCD_Empty] = None
    not_allowed_to_receive_encrypted: Optional[CCD_Empty] = None
    not_allowed_to_handle_encrypted: Optional[CCD_Empty] = None
    missing_baker_add_parameters: Optional[CCD_Empty] = None
    finalization_reward_commission_not_in_range: Optional[CCD_Empty] = None
    baking_reward_commission_not_in_range: Optional[CCD_Empty] = None
    transaction_fee_commission_not_in_range: Optional[CCD_Empty] = None
    already_a_delegator: Optional[CCD_Empty] = None
    insufficient_balance_for_delegation_stake: Optional[CCD_Empty] = None
    missing_delegation_add_parameters: Optional[CCD_Empty] = None
    insufficient_delegation_stake: Optional[CCD_Empty] = None
    delegator_in_cooldown: Optional[CCD_Empty] = None
    not_a_delegator: Optional[CCD_AccountAddress] = None
    delegation_target_not_a_baker: Optional[CCD_BakerId] = None
    stake_over_maximum_threshold_for_pool: Optional[CCD_Empty] = None
    pool_would_become_over_delegated: Optional[CCD_Empty] = None
    pool_closed: Optional[CCD_Empty] = None


class CCD_CredentialType(Enum):
    """
    Enum representing different types of CCD credentials.

    Attributes:
        initial (int): Represents the initial credential type with a value of 0.
        normal (int): Represents the normal credential type with a value of 1.
    """

    initial = 0
    normal = 1


class CCD_StakePendingChange_Reduce(BaseModel):
    """
    Represents a pending change to reduce the stake in CCD.

    Attributes:
        new_stake (microCCD): The new stake amount in microCCD.
        effective_time (CCD_TimeStamp): The timestamp when the change becomes effective.
    """

    new_stake: microCCD
    effective_time: CCD_TimeStamp


class CCD_StakePendingChange(BaseModel):
    """
    Represents a pending change in CCD stake.

    Attributes:
        reduce (Optional[CCD_StakePendingChange_Reduce]): An optional attribute representing a reduction in stake.
        remove (Optional[CCD_StakePendingChange_Remove]): An optional attribute representing the removal of stake.
    """

    reduce: Optional[CCD_StakePendingChange_Reduce] = None
    remove: Optional[CCD_StakePendingChange_Remove] = None


class CCD_BakerStakePendingChange_Reduce(BaseModel):
    """
    Represents a pending change to reduce the baker stake.

    Attributes:
        reduced_equity_capital (microCCD): The amount by which the equity capital is reduced.
        effective_time (CCD_TimeStamp): The timestamp when the reduction becomes effective.
    """

    reduced_equity_capital: microCCD
    effective_time: CCD_TimeStamp


class CCD_BakerStakePendingChange_Remove(BaseModel):
    """
    Represents a pending change to remove a baker's stake in the CCD system.

    Attributes:
        effective_time (CCD_TimeStamp): The timestamp when the change will take effect.
    """

    effective_time: CCD_TimeStamp


class CCD_BakerStakePendingChange(BaseModel):
    """
    Represents a pending change in the baker's stake.

    Attributes:
        reduce (Optional[CCD_BakerStakePendingChange_Reduce]): An optional reduction in the baker's stake.
        remove (Optional[CCD_BakerStakePendingChange_Remove]): An optional removal of the baker's stake.
    """

    reduce: Optional[CCD_BakerStakePendingChange_Reduce] = None
    remove: Optional[CCD_BakerStakePendingChange_Remove] = None


class CCD_DelegatorInfo(BaseModel):
    """
    CCD_DelegatorInfo represents the information of a delegator in the CCD system.

    Attributes:
        account (CCD_AccountAddress): The account address of the delegator.
        stake (microCCD): The amount of stake the delegator has.
        pending_change (Optional[CCD_StakePendingChange]): Any pending changes to the delegator's stake. Defaults to None.
    """

    account: CCD_AccountAddress
    stake: microCCD
    pending_change: Optional[CCD_StakePendingChange] = None


class CCD_DelegatorRewardPeriodInfo(BaseModel):
    """
    CCD_DelegatorRewardPeriodInfo represents the reward period information for a delegator.

    Attributes:
        account (CCD_AccountAddress): The account address of the delegator.
        stake (microCCD): The amount of stake in microCCD.
    """

    account: CCD_AccountAddress
    stake: microCCD


class CCD_CurrentPaydayStatus(BaseModel):
    """
    CCD_CurrentPaydayStatus represents the current payday status of a validator.

    Attributes:
        baker_equity_capital (microCCD): The equity capital of the baker in microCCD.
        blocks_baked (int): The number of blocks baked by the baker.
        delegated_capital (microCCD): The capital delegated to the baker in microCCD.
        effective_stake (microCCD): The effective stake of the baker in microCCD.
        finalization_live (bool): Indicates if the finalization is live.
        lottery_power (float): The lottery power of the baker.
        transaction_fees_earned (microCCD): The transaction fees earned by the baker in microCCD.
        is_primed_for_suspension (Optional[bool]): Indicates if the baker is primed for suspension (default is None).
        missed_rounds (Optional[int]): The number of rounds missed by the baker (default is None).
    """

    baker_equity_capital: microCCD
    blocks_baked: int
    delegated_capital: microCCD
    effective_stake: microCCD
    finalization_live: bool
    lottery_power: float
    transaction_fees_earned: microCCD
    is_primed_for_suspension: Optional[bool] = None
    missed_rounds: Optional[int] = None


class CCD_CommissionRates(BaseModel):
    """
    CCD_CommissionRates is a data model representing commission rates for various activities.

    Attributes:
        baking (float): The commission rate for baking.
        finalization (float): The commission rate for finalization.
        transaction (float): The commission rate for transactions.
    """

    baking: float
    finalization: float
    transaction: float


class CCD_BakerPoolInfo(BaseModel):
    """
    CCD_BakerPoolInfo represents the information about a baker pool in the CCD network.

    Attributes:
        commission_rates (CCD_CommissionRates): The commission rates associated with the baker pool.
        url (str): The URL of the baker pool.
        open_status (str): The open status of the baker pool.
    """

    commission_rates: CCD_CommissionRates
    url: str
    open_status: str


class CCD_PoolInfo(BaseModel):
    """
    CCD_PoolInfo represents the information about a CCD pool.

    Attributes:
        all_pool_total_capital (microCCD): The total capital of all pools.
        address (CCD_AccountAddress): The account address associated with the pool.
        equity_capital (Optional[microCCD]): The equity capital of the pool. Default is None.
        baker (int): The baker ID associated with the pool.
        equity_pending_change (Optional[CCD_BakerStakePendingChange]): The pending change in equity capital. Default is None.
        current_payday_info (Optional[CCD_CurrentPaydayStatus]): The current payday status information. Default is None.
        delegated_capital (Optional[microCCD]): The capital delegated to the pool. Default is None.
        delegated_capital_cap (Optional[microCCD]): The cap on the delegated capital. Default is None.
        pool_info (Optional[CCD_BakerPoolInfo]): Additional information about the baker pool. Default is None.
    """

    all_pool_total_capital: microCCD
    address: CCD_AccountAddress
    equity_capital: Optional[microCCD] = None
    baker: int
    equity_pending_change: Optional[CCD_BakerStakePendingChange] = None
    current_payday_info: Optional[CCD_CurrentPaydayStatus] = None
    delegated_capital: Optional[microCCD] = None
    delegated_capital_cap: Optional[microCCD] = None
    pool_info: Optional[CCD_BakerPoolInfo] = None
    is_suspended: Optional[bool] = None
    # poolType: str = None


class CCD_PassiveDelegationInfo(BaseModel):
    """
    CCD_PassiveDelegationInfo represents the passive delegation information for a CCD (Concordium) account.

    Attributes:
        all_pool_total_capital (microCCD): The total capital of all pools.
        delegated_capital (microCCD): The capital that has been delegated.
        current_payday_transaction_fees_earned (microCCD): The transaction fees earned in the current payday.
        current_payday_delegated_capital (microCCD): The capital delegated in the current payday.
        commission_rates (CCD_CommissionRates): The commission rates applicable.
    """

    all_pool_total_capital: microCCD
    delegated_capital: microCCD
    current_payday_transaction_fees_earned: microCCD
    current_payday_delegated_capital: microCCD
    commission_rates: CCD_CommissionRates


class CCD_ArrivedBlockInfo(BaseModel):
    """
    CCD_ArrivedBlockInfo represents information about an arrived block in the CCD blockchain.

    Attributes:
        hash (CCD_BlockHash): The hash of the block.
        height (int): The height of the block in the blockchain.
    """

    hash: CCD_BlockHash
    height: int


class CCD_FinalizedBlockInfo(BaseModel):
    """
    CCD_FinalizedBlockInfo is a data model representing the finalized block information in the CCD blockchain.

    Attributes:
        hash (CCD_BlockHash): The hash of the finalized block.
        height (int): The height of the finalized block in the blockchain.
    """

    hash: CCD_BlockHash
    height: int


class CCD_BlockInfo(BaseModel):
    """
    CCD_BlockInfo represents the information of a CCD block.

    Attributes:
        arrive_time (Optional[CCD_TimeStamp]): The time the block arrived.
        baker (Optional[int]): The identifier of the baker who baked the block.
        hash (CCD_BlockHash): The hash of the block.
        height (int): The height of the block in the blockchain.
        last_finalized_block (CCD_BlockHash): The hash of the last finalized block.
        parent_block (CCD_BlockHash): The hash of the parent block.
        receive_time (Optional[CCD_TimeStamp]): The time the block was received.
        slot_number (Optional[int]): The slot number of the block.
        slot_time (CCD_TimeStamp): The time of the slot in which the block was created.
        era_block_height (int): The height of the block in the current era.
        finalized (bool): Indicates if the block is finalized.
        genesis_index (int): The index of the genesis block.
        transaction_count (int): The number of transactions in the block.
        transactions_energy_cost (int): The total energy cost of the transactions in the block.
        transactions_size (int): The total size of the transactions in the block.
        transaction_hashes (Optional[list[CCD_TransactionHash]]): The hashes of the transactions in the block.
        state_hash (Optional[CCD_StateHash]): The state hash of the block.
        protocol_version (Optional[str]): The protocol version of the block. Note that this is not optional in the specification, but it is optional here because it may not be stored for all blocks in MongoDB.
        round (Optional[CCD_Round]): The round in which the block was created.
        epoch (Optional[CCD_Epoch]): The epoch in which the block was created.
    """

    arrive_time: Optional[CCD_TimeStamp] = None
    baker: Optional[int] = None
    hash: CCD_BlockHash
    height: int
    last_finalized_block: CCD_BlockHash
    parent_block: CCD_BlockHash
    receive_time: Optional[CCD_TimeStamp] = None
    slot_number: Optional[int] = None
    slot_time: CCD_TimeStamp
    era_block_height: int
    finalized: bool
    genesis_index: int
    transaction_count: int
    transactions_energy_cost: int
    transactions_size: int
    transaction_hashes: Optional[list[CCD_TransactionHash]] = None
    state_hash: Optional[CCD_StateHash] = None
    protocol_version: Optional[str] = (
        None  # note this is not optional from the specification,
    )
    # but this type is also used in retrieving blockInfo from MongoDB, where protocol_version
    # isn't stored for all blocks (currently).
    round: Optional[CCD_Round] = None
    epoch: Optional[CCD_Epoch] = None


class CCD_AccountTransactionEffects_None(BaseModel):
    """
    CCD_AccountTransactionEffects_None represents the effects of a rejected account transaction.

    Attributes:
        transaction_type (Optional[int]): The type of the transaction. Defaults to None.
        reject_reason (CCD_RejectReason): The reason for rejecting the transaction.
    """

    transaction_type: Optional[int] = None
    reject_reason: CCD_RejectReason


class CCD_ContractInitializedEvent(BaseModel):
    """
    Represents an event that is triggered when a CCD contract is initialized.

    Attributes:
        contract_version (int): The version of the contract.
        origin_ref (CCD_ModuleRef): Reference to the originating module.
        address (CCD_ContractAddress): The address of the contract.
        amount (microCCD): The amount associated with the contract, default is 0.
        init_name (str): The name of the initialization function.
        events (list[CCD_ContractEvent]): A list of contract events.
        parameter (CCD_Parameter): The parameter associated with the contract.
    """

    contract_version: int
    origin_ref: CCD_ModuleRef
    address: CCD_ContractAddress
    amount: microCCD = 0
    init_name: str
    events: list[CCD_ContractEvent]
    parameter: Optional[CCD_Parameter] = None


class CCD_InstanceUpdatedEvent(BaseModel):
    """
    Represents an event where a CCD instance has been updated.

    Attributes:
        contract_version (int): The version of the contract.
        address (CCD_ContractAddress): The address of the contract.
        instigator (CCD_Address): The address of the entity that initiated the update.
        amount (microCCD): The amount involved in the update.
        parameter (CCD_Parameter): The parameters associated with the update.
        receive_name (CCD_ReceiveName): The name of the receive function.
        events (Optional[list[CCD_ContractEvent]]): A list of contract events associated with the update, if any.
    """

    contract_version: int
    address: CCD_ContractAddress
    instigator: CCD_Address
    amount: microCCD
    parameter: CCD_Parameter
    receive_name: CCD_ReceiveName
    events: Optional[list[CCD_ContractEvent]] = None


class CCD_ContractTraceElement_Interrupted(BaseModel):
    """
    Represents an interrupted contract trace element.

    Attributes:
        address (CCD_ContractAddress): The address of the contract.
        events (list[CCD_ContractEvent]): A list of contract events associated with the trace element.
    """

    address: CCD_ContractAddress
    events: list[CCD_ContractEvent]


class CCD_ContractTraceElement_Resumed(BaseModel):
    """
    Represents a resumed contract trace element.

    Attributes:
        address (CCD_ContractAddress): The address of the contract.
        success (bool): Indicates whether the contract trace was successful.
    """

    address: CCD_ContractAddress
    success: bool


class CCD_ContractTraceElement_Transferred(BaseModel):
    """
    Represents a transferred contract trace element.

    Attributes:
        sender (CCD_ContractAddress): The address of the sender contract.
        amount (microCCD): The amount of microCCD transferred.
        receiver (CCD_AccountAddress): The address of the receiver account.
    """

    sender: CCD_ContractAddress
    amount: microCCD
    receiver: CCD_AccountAddress


class CCD_ContractTraceElement_Upgraded(BaseModel):
    """
    CCD_ContractTraceElement_Upgraded represents an upgraded contract trace element.

    Attributes:
        address (CCD_ContractAddress): The address of the contract.
        from_module (CCD_ModuleRef): The module reference from which the contract is upgraded. This field is aliased as "from".
        to_module (CCD_ModuleRef): The module reference to which the contract is upgraded. This field is aliased as "to".
    """

    model_config = ConfigDict(populate_by_name=True)
    address: CCD_ContractAddress
    from_module: CCD_ModuleRef = Field(..., alias="from")
    to_module: CCD_ModuleRef = Field(..., alias="to")


class CCD_ContractTraceElement(BaseModel):
    """
    Represents a contract trace element.

    Attributes:
        updated (Optional[CCD_InstanceUpdatedEvent]): Event indicating that the instance has been updated.
        transferred (Optional[CCD_ContractTraceElement_Transferred]): Event indicating that the contract has been transferred.
        interrupted (Optional[CCD_ContractTraceElement_Interrupted]): Event indicating that the contract has been interrupted.
        resumed (Optional[CCD_ContractTraceElement_Resumed]): Event indicating that the contract has been resumed.
        upgraded (Optional[CCD_ContractTraceElement_Upgraded]): Event indicating that the contract has been upgraded.
    """

    updated: Optional[CCD_InstanceUpdatedEvent] = None
    transferred: Optional[CCD_ContractTraceElement_Transferred] = None
    interrupted: Optional[CCD_ContractTraceElement_Interrupted] = None
    resumed: Optional[CCD_ContractTraceElement_Resumed] = None
    upgraded: Optional[CCD_ContractTraceElement_Upgraded] = None


class CCD_ContractUpdateIssued(BaseModel):
    """
    Represents an update issued for a CCD contract.

    Attributes:
        effects (list[CCD_ContractTraceElement]): A list of contract trace elements that describe the effects of the update.
    """

    effects: list[CCD_ContractTraceElement]


class CCD_EncryptedAmountRemovedEvent(BaseModel):
    """
    Represents an event where an encrypted amount is removed from a CCD account.

    Attributes:
        account (CCD_AccountAddress): The address of the CCD account.
        new_amount (CCD_EncryptedAmount): The new encrypted amount after removal.
        input_amount (CCD_EncryptedAmount): The input encrypted amount before removal.
        up_to_index (int): The index up to which the amount is removed.
    """

    account: CCD_AccountAddress
    new_amount: CCD_EncryptedAmount
    input_amount: CCD_EncryptedAmount
    up_to_index: int


class CCD_NewEncryptedAmountEvent(BaseModel):
    """
    Represents a new encrypted amount event in the CCD system.

    Attributes:
        receiver (CCD_AccountAddress): The account address of the receiver.
        new_index (int): The new index associated with the encrypted amount.
        encrypted_amount (CCD_EncryptedAmount): The encrypted amount.
    """

    receiver: CCD_AccountAddress
    new_index: int
    encrypted_amount: CCD_EncryptedAmount


class CCD_AccountTransactionEffects_EncryptedAmountTransferred(BaseModel):
    """
    Represents the effects of an account transaction involving encrypted amounts in the CCD system.

    Attributes:
        removed (Optional[CCD_EncryptedAmountRemovedEvent]): The event indicating an encrypted amount was removed.
        added (Optional[CCD_NewEncryptedAmountEvent]): The event indicating a new encrypted amount was added.
        memo (Optional[CCD_Memo]): An optional memo associated with the transaction.
    """

    removed: Optional[CCD_EncryptedAmountRemovedEvent] = None
    added: Optional[CCD_NewEncryptedAmountEvent] = None
    memo: Optional[CCD_Memo] = None


class CCD_EncryptedSelfAmountAddedEvent(BaseModel):
    """
    CCD_EncryptedSelfAmountAddedEvent represents an event where an encrypted self amount is added to an account.

    Attributes:
        account (CCD_AccountAddress): The address of the account.
        new_amount (CCD_EncryptedAmount): The new encrypted amount added to the account.
        amount (microCCD): The amount in microCCD.
    """

    account: CCD_AccountAddress
    new_amount: CCD_EncryptedAmount
    amount: microCCD


class CCD_AccountTransactionEffects_TransferredToPublic(BaseModel):
    """
    Represents the effects of an account transaction where an amount is transferred to the public.

    Attributes:
        removed (CCD_EncryptedAmountRemovedEvent): The event indicating the removal of an encrypted amount.
        amount (microCCD): The amount transferred to the public in microCCD units.
    """

    removed: CCD_EncryptedAmountRemovedEvent
    amount: microCCD


class CCD_AccountTransactionEffects_CredentialsUpdated(BaseModel):
    """
    Represents the effects of updating credentials on a CCD account transaction.

    Attributes:
        new_cred_ids (list[CCD_CredentialRegistrationId]): A list of new credential registration IDs added to the account.
        removed_cred_ids (list[CCD_CredentialRegistrationId]): A list of credential registration IDs removed from the account.
        new_threshold (CCD_AccountThreshold): The new threshold for the account after the update.
    """

    new_cred_ids: list[CCD_CredentialRegistrationId]
    removed_cred_ids: list[CCD_CredentialRegistrationId]
    new_threshold: CCD_AccountThreshold


class CCD_BakerKeysEvent(BaseModel):
    """
    Represents an event containing keys related to a CCD baker.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        account (CCD_AccountAddress): The account address associated with the baker.
        sign_key (CCD_BakerSignatureVerifyKey): The signature verification key for the baker.
        election_key (CCD_BakerElectionVerifyKey): The election verification key for the baker.
        aggregation_key (CCD_BakerAggregationVerifyKey): The aggregation verification key for the baker.
    """

    baker_id: CCD_BakerId
    account: CCD_AccountAddress
    sign_key: CCD_BakerSignatureVerifyKey
    election_key: CCD_BakerElectionVerifyKey
    aggregation_key: CCD_BakerAggregationVerifyKey


class CCD_BakerAdded(BaseModel):
    """
    CCD_BakerAdded represents an event where a baker is added to the CCD network.

    Attributes:
        keys_event (CCD_BakerKeysEvent): The event containing the keys for the baker.
        stake (microCCD): The amount of stake assigned to the baker.
        restake_earnings (bool): A flag indicating whether the baker's earnings should be restaked.
    """

    keys_event: CCD_BakerKeysEvent
    stake: microCCD
    restake_earnings: bool


class CCD_AccountTransfer(BaseModel):
    """
    Represents an account transfer in the CCD system.

    Attributes:
        amount (microCCD): The amount to be transferred. Defaults to 0.
        receiver (CCD_AccountAddress): The address of the receiver account.
        memo (Optional[CCD_Memo]): An optional memo for the transfer. Defaults to None.
    """

    amount: microCCD = 0
    receiver: CCD_AccountAddress
    memo: Optional[CCD_Memo] = None


class CCD_NewRelease(BaseModel):
    """
    CCD_NewRelease represents a new release of CCD (Concordium Cryptocurrency).

    Attributes:
        timestamp (CCD_TimeStamp): The timestamp of the new release.
        amount (microCCD): The amount of CCD released, measured in microCCD.
    """

    timestamp: CCD_TimeStamp
    amount: microCCD


class CCD_TransferredWithSchedule(BaseModel):
    """
    Represents a CCD transfer with a schedule.

    Attributes:
        receiver (CCD_AccountAddress): The address of the receiver.
        amount (list[CCD_NewRelease]): A list of new releases associated with the transfer.
        memo (Optional[CCD_Memo]): An optional memo for the transfer.
    """

    receiver: CCD_AccountAddress
    amount: list[CCD_NewRelease]
    memo: Optional[CCD_Memo] = None


class CCD_BakerStakeUpdatedData(BaseModel):
    """
    CCD_BakerStakeUpdatedData represents the data structure for an updated baker stake in the CCD system.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        new_stake (microCCD): The new stake amount for the baker.
        increased (bool): A flag indicating whether the stake has increased.
    """

    baker_id: CCD_BakerId
    new_stake: microCCD
    increased: bool


class CCD_BakerStakeUpdated(BaseModel):
    """
    Represents an update to a baker's stake in the CCD blockchain.

    Attributes:
        update (CCD_BakerStakeUpdatedData): The data related to the baker stake update.
    """

    update: CCD_BakerStakeUpdatedData


class CCD_BakerStakeIncreased(BaseModel):
    """
    Represents an event where a baker's stake has increased.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        new_stake (microCCD): The new stake amount for the baker.
    """

    baker_id: CCD_BakerId
    new_stake: microCCD


class CCD_BakerStakeDecreased(BaseModel):
    """
    Represents a decrease in the stake of a baker.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        new_stake (microCCD): The new stake amount after the decrease.
    """

    baker_id: CCD_BakerId
    new_stake: microCCD


class CCD_BakerRestakeEarningsUpdated(BaseModel):
    """
    Represents an update to a baker's restake earnings setting.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        restake_earnings (bool): Indicates whether the baker has chosen to restake their earnings.
    """

    baker_id: CCD_BakerId
    restake_earnings: bool


class CCD_BakerSetOpenStatus(BaseModel):
    """
    CCD_BakerSetOpenStatus is a data model representing the open status of a baker.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        open_status (CCD_OpenStatus): The open status of the baker.
    """

    baker_id: CCD_BakerId
    open_status: CCD_OpenStatus


class CCD_BakerSetMetadataUrl(BaseModel):
    """
    CCD_BakerSetMetadataUrl is a model representing the metadata URL for a baker.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        url (str): The metadata URL associated with the baker.
    """

    baker_id: CCD_BakerId
    url: str


class CCD_BakerSetTransactionFeeCommission(BaseModel):
    """
    Represents a transaction fee commission setting for a baker in the CCD network.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        transaction_fee_commission (CCD_AmountFraction): The commission rate for transaction fees.
    """

    baker_id: CCD_BakerId
    transaction_fee_commission: CCD_AmountFraction


class CCD_BakerSetBakingRewardCommission(BaseModel):
    """
    Represents the commission settings for a baker's baking rewards in the CCD blockchain.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        baking_reward_commission (CCD_AmountFraction): The fraction of the baking rewards that the baker takes as commission.
    """

    baker_id: CCD_BakerId
    baking_reward_commission: CCD_AmountFraction


class CCD_BakerSetFinalizationRewardCommission(BaseModel):
    """
    Represents the finalization reward commission settings for a baker.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        finalization_reward_commission (CCD_AmountFraction): The fraction of the finalization reward that the baker takes as commission.
    """

    baker_id: CCD_BakerId
    finalization_reward_commission: CCD_AmountFraction


class CCD_BakerEvent(BaseModel):
    """
    Represents an event related to a CCD baker.

    Attributes:
        baker_added (Optional[CCD_BakerAdded]): Event when a baker is added.
        baker_removed (Optional[CCD_BakerId]): Event when a baker is removed.
        delegation_removed (Optional[CCD_DelegatorId]): Event when a delegation is removed.
        baker_stake_increased (Optional[CCD_BakerStakeIncreased]): Event when a baker's stake is increased.
        baker_stake_decreased (Optional[CCD_BakerStakeDecreased]): Event when a baker's stake is decreased.
        baker_restake_earnings_updated (Optional[CCD_BakerRestakeEarningsUpdated]): Event when a baker's restake earnings are updated.
        baker_keys_updated (Optional[CCD_BakerKeysEvent]): Event when a baker's keys are updated.
        baker_set_open_status (Optional[CCD_BakerSetOpenStatus]): Event when a baker's open status is set.
        baker_set_metadata_url (Optional[CCD_BakerSetMetadataUrl]): Event when a baker's metadata URL is set.
        baker_set_transaction_fee_commission (Optional[CCD_BakerSetTransactionFeeCommission]): Event when a baker's transaction fee commission is set.
        baker_set_baking_reward_commission (Optional[CCD_BakerSetBakingRewardCommission]): Event when a baker's baking reward commission is set.
        baker_set_finalization_reward_commission (Optional[CCD_BakerSetFinalizationRewardCommission]): Event when a baker's finalization reward commission is set.
        baker_suspended (Optional[CCD_BakerId]): Event when a baker is suspended.
        baker_resumed (Optional[CCD_BakerId]): Event when a baker is resumed.
    """

    baker_added: Optional[CCD_BakerAdded] = None
    baker_removed: Optional[CCD_BakerId] = None
    delegation_removed: Optional[CCD_DelegatorId] = None
    baker_stake_increased: Optional[CCD_BakerStakeIncreased] = None
    baker_stake_decreased: Optional[CCD_BakerStakeDecreased] = None
    baker_restake_earnings_updated: Optional[CCD_BakerRestakeEarningsUpdated] = None
    baker_keys_updated: Optional[CCD_BakerKeysEvent] = None
    baker_set_open_status: Optional[CCD_BakerSetOpenStatus] = None
    baker_set_metadata_url: Optional[CCD_BakerSetMetadataUrl] = None
    baker_set_transaction_fee_commission: Optional[
        CCD_BakerSetTransactionFeeCommission
    ] = None
    baker_set_baking_reward_commission: Optional[CCD_BakerSetBakingRewardCommission] = (
        None
    )
    baker_set_finalization_reward_commission: Optional[
        CCD_BakerSetFinalizationRewardCommission
    ] = None
    baker_suspended: Optional[CCD_BakerId] = None
    baker_resumed: Optional[CCD_BakerId] = None


class CCD_BakerConfigured(BaseModel):
    """
    CCD_BakerConfigured is a model representing the configuration of a CCD Baker.

    Attributes:
        events (list[CCD_BakerEvent]): A list of events associated with the CCD Baker.
    """

    events: list[CCD_BakerEvent]


class CCD_DelegationStakeIncreased(BaseModel):
    """
    Represents an event where a delegator's stake has increased.

    Attributes:
        delegator_id (CCD_DelegatorId): The ID of the delegator whose stake has increased.
        new_stake (microCCD): The new stake amount in microCCD.
    """

    delegator_id: CCD_DelegatorId
    new_stake: microCCD


class CCD_DelegationStakeDecreased(BaseModel):
    """
    Represents a decrease in the delegation stake for a specific delegator.

    Attributes:
        delegator_id (CCD_DelegatorId): The unique identifier of the delegator whose stake has decreased.
        new_stake (microCCD): The new stake amount after the decrease, represented in microCCD.
    """

    delegator_id: CCD_DelegatorId
    new_stake: microCCD


class CCD_DelegationSetRestakeEarnings(BaseModel):
    """
    Represents a delegation set restake earnings configuration.

    Attributes:
        delegator_id (CCD_DelegatorId): The ID of the delegator.
        restake_earnings (bool): A flag indicating whether to restake earnings.
    """

    delegator_id: CCD_DelegatorId
    restake_earnings: bool


class CCD_DelegationTarget(BaseModel):
    """
    CCD_DelegationTarget represents the delegation target for a CCD (Concordium) account.

    Attributes:
        passive_delegation (Optional[bool]): Indicates if the delegation is passive.
        baker (Optional[CCD_BakerId]): The baker ID to which the delegation is assigned.
    """

    passive_delegation: Optional[bool] = None
    baker: Optional[CCD_BakerId] = None


class CCD_DelegationSetDelegationTarget(BaseModel):
    """
    Represents a delegation set delegation target in the CCD system.

    Attributes:
        delegator_id (CCD_DelegatorId): The ID of the delegator.
        delegation_target (CCD_DelegationTarget): The target of the delegation.
    """

    delegator_id: CCD_DelegatorId
    delegation_target: CCD_DelegationTarget


class CCD_DelegationEvent(BaseModel):
    """
    Represents a CCD delegation event.

    Attributes:
        delegation_added (Optional[CCD_DelegatorId]): The ID of the delegator who was added.
        delegation_removed (Optional[CCD_DelegatorId]): The ID of the delegator who was removed.
        baker_removed (Optional[CCD_BakerId]): The ID of the baker who was removed.
        delegation_stake_increased (Optional[CCD_DelegationStakeIncreased]): Details of the delegation stake increase.
        delegation_stake_decreased (Optional[CCD_DelegationStakeDecreased]): Details of the delegation stake decrease.
        delegation_set_restake_earnings (Optional[CCD_DelegationSetRestakeEarnings]): Details of the restake earnings setting.
        delegation_set_delegation_target (Optional[CCD_DelegationSetDelegationTarget]): Details of the delegation target setting.
    """

    delegation_added: Optional[CCD_DelegatorId] = None
    delegation_removed: Optional[CCD_DelegatorId] = None
    baker_removed: Optional[CCD_BakerId] = None
    delegation_stake_increased: Optional[CCD_DelegationStakeIncreased] = None
    delegation_stake_decreased: Optional[CCD_DelegationStakeDecreased] = None
    delegation_set_restake_earnings: Optional[CCD_DelegationSetRestakeEarnings] = None
    delegation_set_delegation_target: Optional[CCD_DelegationSetDelegationTarget] = None


class CCD_DelegationConfigured(BaseModel):
    """
    CCD_DelegationConfigured is a model representing the configuration of CCD delegation.

    Attributes:
        events (list[CCD_DelegationEvent]): A list of CCD delegation events.
    """

    events: list[CCD_DelegationEvent]


class CCD_BakerEvent_BakerRestakeEarningsUpdated(BaseModel):
    """
    Represents an event where a baker's restake earnings setting has been updated.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        restake_earnings (bool): Indicates whether the baker has chosen to restake their earnings.
    """

    baker_id: CCD_BakerId
    restake_earnings: bool


class CCD_AccountTransactionEffects(BaseModel):
    """
    CCD_AccountTransactionEffects represents the various effects that can occur as a result of an account transaction in the CCD system.

    Attributes:
        none (Optional[CCD_AccountTransactionEffects_None]): Represents no effect.
        module_deployed (Optional[CCD_ModuleRef]): Represents a module deployment effect.
        contract_initialized (Optional[CCD_ContractInitializedEvent]): Represents a contract initialization effect.
        contract_update_issued (Optional[CCD_ContractUpdateIssued]): Represents a contract update issuance effect.
        account_transfer (Optional[CCD_AccountTransfer]): Represents an account transfer effect.
        baker_added (Optional[CCD_BakerAdded]): Represents a baker addition effect.
        baker_removed (Optional[CCD_BakerId]): Represents a baker removal effect.
        baker_stake_updated (Optional[CCD_BakerStakeUpdated]): Represents a baker stake update effect.
        baker_restake_earnings_updated (Optional[CCD_BakerEvent_BakerRestakeEarningsUpdated]): Represents a baker restake earnings update effect.
        baker_keys_updated (Optional[CCD_BakerKeysEvent]): Represents a baker keys update effect.
        encrypted_amount_transferred (Optional[CCD_AccountTransactionEffects_EncryptedAmountTransferred]): Represents an encrypted amount transfer effect.
        transferred_to_encrypted (Optional[CCD_EncryptedSelfAmountAddedEvent]): Represents a transfer to encrypted amount effect.
        transferred_to_public (Optional[CCD_AccountTransactionEffects_TransferredToPublic]): Represents a transfer to public amount effect.
        transferred_with_schedule (Optional[CCD_TransferredWithSchedule]): Represents a transfer with schedule effect.
        credential_keys_updated (Optional[CCD_CredentialRegistrationId]): Represents a credential keys update effect.
        credentials_updated (Optional[CCD_AccountTransactionEffects_CredentialsUpdated]): Represents a credentials update effect.
        data_registered (Optional[CCD_RegisteredData]): Represents a data registration effect.
        baker_configured (Optional[CCD_BakerConfigured]): Represents a baker configuration effect.
        delegation_configured (Optional[CCD_DelegationConfigured]): Represents a delegation configuration effect.
    """

    none: Optional[CCD_AccountTransactionEffects_None] = None
    module_deployed: Optional[CCD_ModuleRef] = None
    contract_initialized: Optional[CCD_ContractInitializedEvent] = None
    contract_update_issued: Optional[CCD_ContractUpdateIssued] = None
    account_transfer: Optional[CCD_AccountTransfer] = None
    baker_added: Optional[CCD_BakerAdded] = None
    baker_removed: Optional[CCD_BakerId] = None
    baker_stake_updated: Optional[CCD_BakerStakeUpdated] = None
    baker_restake_earnings_updated: Optional[
        CCD_BakerEvent_BakerRestakeEarningsUpdated
    ] = None
    baker_keys_updated: Optional[CCD_BakerKeysEvent] = None
    encrypted_amount_transferred: Optional[
        CCD_AccountTransactionEffects_EncryptedAmountTransferred
    ] = None
    transferred_to_encrypted: Optional[CCD_EncryptedSelfAmountAddedEvent] = None
    transferred_to_public: Optional[
        CCD_AccountTransactionEffects_TransferredToPublic
    ] = None
    transferred_with_schedule: Optional[CCD_TransferredWithSchedule] = None
    credential_keys_updated: Optional[CCD_CredentialRegistrationId] = None
    credentials_updated: Optional[CCD_AccountTransactionEffects_CredentialsUpdated] = (
        None
    )
    data_registered: Optional[CCD_RegisteredData] = None
    baker_configured: Optional[CCD_BakerConfigured] = None
    delegation_configured: Optional[CCD_DelegationConfigured] = None


class CCD_AccountTransactionDetails(BaseModel):
    """
    Represents the details of an account transaction in the CCD system.

    Attributes:
        cost (microCCD): The cost of the transaction in microCCD.
        sender (CCD_AccountAddress): The address of the sender of the transaction.
        outcome (str): The outcome of the transaction.
        effects (CCD_AccountTransactionEffects): The effects of the transaction.
    """

    cost: microCCD
    sender: CCD_AccountAddress
    outcome: str
    effects: CCD_AccountTransactionEffects


class CCD_AccountCreationDetails(BaseModel):
    """
    CCD_AccountCreationDetails is a model representing the details required for creating a CCD account.

    Attributes:
        credential_type (int): The type of credential.
        address (CCD_AccountAddress): The address associated with the account.
        reg_id (CCD_CredentialRegistrationId): The registration ID for the credential.
    """

    credential_type: int
    address: CCD_AccountAddress
    reg_id: CCD_CredentialRegistrationId


class CCD_ProtocolUpdate(BaseModel):
    """
    CCD_ProtocolUpdate is a data model representing an update to a CCD protocol.

    Attributes:
        message_ (str): A message describing the update.
        specification_url (str): The URL to the specification of the update.
        specificationHash (CCD_Sha256Hash): The SHA-256 hash of the specification.
        specification_auxiliary_data (Optional[bytes]): Optional auxiliary data related to the specification.
    """

    message_: str
    specification_url: str
    specificationHash: CCD_Sha256Hash
    specification_auxiliary_data: Optional[bytes] = None


class CCD_Ratio(BaseModel):
    """
    CCD_Ratio is a data model representing a ratio with a numerator and a denominator.

    Attributes:
        numerator (str): The numerator of the ratio, stored as a string to handle large integer values.
        denominator (str): The denominator of the ratio, stored as a string to handle large integer values.
    """

    # note these are ints, but need to convert to str
    # as the int amounts are sometimes too big (for MongoDB)
    numerator: str
    denominator: str


class CCD_ExchangeRate(BaseModel):
    """
    CCD_ExchangeRate is a model representing an exchange rate between two currencies.

    Attributes:
        numerator (str): The currency code for the numerator in the exchange rate.
        denominator (str): The currency code for the denominator in the exchange rate.
    """

    numerator: str
    denominator: str


class CCD_MintRate(BaseModel):
    """
    CCD_MintRate represents a mint rate with a mantissa and an exponent.

    Attributes:
        mantissa (int): The significant digits of the mint rate.
        exponent (int): The exponent part of the mint rate, representing the scale.
    """

    mantissa: int
    exponent: int


class CCD_MintDistributionCpv0(BaseModel):
    """
    CCD_MintDistributionCpv0 represents the mint distribution configuration for a specific slot.

    Attributes:
        mint_per_slot (CCD_MintRate): The rate at which CCD is minted per slot.
        baking_reward (CCD_AmountFraction): The fraction of the minted CCD that is rewarded for baking.
        finalization_reward (CCD_AmountFraction): The fraction of the minted CCD that is rewarded for finalization.
    """

    mint_per_slot: CCD_MintRate
    baking_reward: CCD_AmountFraction
    finalization_reward: CCD_AmountFraction


class CCD_TransactionFeeDistribution(BaseModel):
    """
    Represents the distribution of transaction fees in the CCD system.

    Attributes:
        baker (Optional[CCD_AmountFraction]): The fraction of the transaction fee allocated to the baker.
        gas_account (Optional[CCD_AmountFraction]): The fraction of the transaction fee allocated to the gas account.
    """

    baker: Optional[CCD_AmountFraction] = None
    gas_account: Optional[CCD_AmountFraction] = None


class CCD_GasRewards(BaseModel):
    """
    CCD_GasRewards represents the gas rewards structure in the CCD system.

    Attributes:
        baker (CCD_AmountFraction): The fraction of gas rewards allocated to the baker.
        finalization_proof (CCD_AmountFraction): The fraction of gas rewards allocated for finalization proof.
        account_creation (CCD_AmountFraction): The fraction of gas rewards allocated for account creation.
        chain_update (CCD_AmountFraction): The fraction of gas rewards allocated for chain updates.
    """

    baker: CCD_AmountFraction
    finalization_proof: CCD_AmountFraction
    account_creation: CCD_AmountFraction
    chain_update: CCD_AmountFraction


class CCD_HigherLevelKeys(BaseModel):
    """
    CCD_HigherLevelKeys is a model representing higher-level keys in the CCD (Concordium) system.

    Attributes:
        keys (list[CCD_UpdatePublicKey]): A list of public keys used for updates.
        threshold (CCD_UpdateKeysThreshold): The threshold required for updates.
    """

    keys: list[CCD_UpdatePublicKey]
    threshold: CCD_UpdateKeysThreshold


class CCD_AccessStructure(BaseModel):
    """
    CCD_AccessStructure is a data model representing the access structure for CCD.

    Attributes:
        access_public_keys (list[CCD_UpdateKeysIndex]): A list of public keys used for access.
        access_threshold (CCD_UpdateKeysThreshold): The threshold value for access.
    """

    access_public_keys: list[CCD_UpdateKeysIndex]
    access_threshold: CCD_UpdateKeysThreshold


class CCD_AuthorizationsV0(BaseModel):
    """
    CCD_AuthorizationsV0 is a model representing various authorization parameters for CCD.

    Attributes:
        keys (list[CCD_UpdatePublicKey]): A list of public keys for updates.
        emergency (CCD_AccessStructure): Access structure for emergency situations.
        protocol (CCD_AccessStructure): Access structure for protocol-related operations.
        parameter_election_difficulty (Optional[CCD_AccessStructure]): Access structure for election difficulty parameter.
        parameter_euro_per_energy (CCD_AccessStructure): Access structure for euro per energy parameter.
        parameter_micro_CCD_per_euro (CCD_AccessStructure): Access structure for micro CCD per euro parameter.
        parameter_foundation_account (CCD_AccessStructure): Access structure for foundation account parameter.
        parameter_mint_distribution (CCD_AccessStructure): Access structure for mint distribution parameter.
        parameter_transaction_fee_distribution (CCD_AccessStructure): Access structure for transaction fee distribution parameter.
        parameter_gas_rewards (CCD_AccessStructure): Access structure for gas rewards parameter.
        pool_parameters (CCD_AccessStructure): Access structure for pool parameters.
        add_anonymity_revoker (CCD_AccessStructure): Access structure for adding an anonymity revoker.
        add_identity_provider (CCD_AccessStructure): Access structure for adding an identity provider.
    """

    keys: list[CCD_UpdatePublicKey]
    emergency: CCD_AccessStructure
    protocol: CCD_AccessStructure
    parameter_election_difficulty: Optional[CCD_AccessStructure] = None
    parameter_euro_per_energy: CCD_AccessStructure
    parameter_micro_CCD_per_euro: CCD_AccessStructure
    parameter_foundation_account: CCD_AccessStructure
    parameter_mint_distribution: CCD_AccessStructure
    parameter_transaction_fee_distribution: CCD_AccessStructure
    parameter_gas_rewards: CCD_AccessStructure
    pool_parameters: CCD_AccessStructure
    add_anonymity_revoker: CCD_AccessStructure
    add_identity_provider: CCD_AccessStructure


class CCD_AuthorizationsV1(BaseModel):
    """
    CCD_AuthorizationsV1 is a data model representing the authorizations for CCD (Charge Coupled Device) operations.

    Attributes:
        v0 (CCD_AuthorizationsV0): The version 0 of CCD authorizations.
        parameter_cooldown (CCD_AccessStructure): The access structure for cooldown parameters.
        parameter_time (CCD_AccessStructure): The access structure for time parameters.
    """

    v0: CCD_AuthorizationsV0
    parameter_cooldown: CCD_AccessStructure
    parameter_time: CCD_AccessStructure


class CCD_RootUpdate(BaseModel):
    """
    CCD_RootUpdate is a model representing updates to various levels of CCD keys.

    Attributes:
        root_keys_update (CCD_HigherLevelKeys): Updates to the root level keys.
        level_1_keys_update (CCD_HigherLevelKeys): Updates to the level 1 keys.
        level_2_keys_update_v0 (CCD_AuthorizationsV0): Updates to the level 2 keys for version 0.
        level_2_keys_update_v1 (CCD_AuthorizationsV1): Updates to the level 2 keys for version 1.
    """

    root_keys_update: CCD_HigherLevelKeys
    level_1_keys_update: CCD_HigherLevelKeys
    level_2_keys_update_v0: CCD_AuthorizationsV0
    level_2_keys_update_v1: CCD_AuthorizationsV1


class CCD_Level1Update(BaseModel):
    """
    Represents an update to CCD Level 1 data.

    Attributes:
        level_1_keys_update (Optional[CCD_HigherLevelKeys]): An optional update to higher level keys.
        level_2_keys_update_v0 (Optional[CCD_AuthorizationsV0]): An optional update to level 2 keys for version 0 authorizations.
        level_2_keys_update_v1 (Optional[CCD_AuthorizationsV1]): An optional update to level 2 keys for version 1 authorizations.
    """

    level_1_keys_update: Optional[CCD_HigherLevelKeys] = None
    level_2_keys_update_v0: Optional[CCD_AuthorizationsV0] = None
    level_2_keys_update_v1: Optional[CCD_AuthorizationsV1] = None


class CCD_Description(BaseModel):
    """
    CCD_Description is a model representing the description.

    Attributes:
        name (str): The name of the CCD.
        url (str): The URL where more information about the CCD can be found.
        description (str): A brief description of the CCD.
    """

    name: str
    url: str
    description: str


class CCD_ArInfo(BaseModel):
    """
    CCD_ArInfo is a data model representing information about AR.

    Attributes:
        identity (CCD_ArIdentity): The unique identity of the AR entity.
        description (CCD_Description): A textual description of the AR entity.
        public_key (CCD_ArPublicKey): The public key associated with the AR entity.
    """

    identity: CCD_ArIdentity
    description: CCD_Description
    public_key: CCD_ArPublicKey


class CCD_IpInfo(BaseModel):
    """
    CCD_IpInfo is a model representing the IP information of IP.

    Attributes:
        identity (CCD_IpIdentity): The identity information of the CCD IP.
        description (CCD_Description): A description of the CCD IP.
        verify_key (CCD_IpVerifyKey): The verification key for the CCD IP.
        cdi_verify_key (CCD_IpCdiVerifyKey): The CDI (Component Device Interface) verification key for the CCD IP.
    """

    identity: CCD_IpIdentity
    description: CCD_Description
    verify_key: CCD_IpVerifyKey
    cdi_verify_key: CCD_IpCdiVerifyKey


class CCD_CooldownParametersCpv1(BaseModel):
    """
    CCD_CooldownParametersCpv1 represents the cooldown parameters for a CCD pool owner and delegator.

    Attributes:
        pool_owner_cooldown (Optional[CCD_DurationSeconds]): The cooldown duration for the pool owner.
        delegator_cooldown (Optional[CCD_DurationSeconds]): The cooldown duration for the delegator.
    """

    pool_owner_cooldown: Optional[CCD_DurationSeconds] = None
    delegator_cooldown: Optional[CCD_DurationSeconds] = None


class CCD_InclusiveRangeAmountFraction(BaseModel):
    """
    CCD_InclusiveRangeAmountFraction represents a range with minimum and maximum values of type CCD_AmountFraction.

    Attributes:
        min (CCD_AmountFraction): The minimum value of the range.
        max_ (CCD_AmountFraction): The maximum value of the range.
    """

    min: CCD_AmountFraction
    max_: CCD_AmountFraction


class CCD_CommissionRanges(BaseModel):
    """
    CCD_CommissionRanges represents the commission ranges for different types of transactions.

    Attributes:
        finalization (CCD_InclusiveRangeAmountFraction): The commission range for finalization transactions.
        baking (CCD_InclusiveRangeAmountFraction): The commission range for baking transactions.
        transaction (CCD_InclusiveRangeAmountFraction): The commission range for general transactions.
    """

    finalization: CCD_InclusiveRangeAmountFraction
    baking: CCD_InclusiveRangeAmountFraction
    transaction: CCD_InclusiveRangeAmountFraction


class CCD_CapitalBound(BaseModel):
    """
    CCD_CapitalBound represents a model for capital bound with a specific value.

    Attributes:
        value (CCD_AmountFraction): The amount fraction representing the capital bound.
    """

    value: CCD_AmountFraction


class CCD_LeverageFactor(BaseModel):
    """
    CCD_LeverageFactor represents a leverage factor in the CCD system.

    Attributes:
        value (CCD_Ratio): The ratio value representing the leverage factor.
    """

    value: CCD_Ratio


class CCD_PoolParametersCpv1(BaseModel):
    """
    CCD_PoolParametersCpv1 is a model representing the parameters for a CCD pool.

    Attributes:
        passive_finalization_commission (CCD_AmountFraction): The commission for passive finalization.
        passive_baking_commission (CCD_AmountFraction): The commission for passive baking.
        passive_transaction_commission (CCD_AmountFraction): The commission for passive transactions.
        commission_bounds (CCD_CommissionRanges): The bounds for the commission rates.
        minimum_equity_capital (microCCD): The minimum equity capital required.
        capital_bound (CCD_CapitalBound): The bound for the capital.
        leverage_bound (CCD_LeverageFactor): The bound for the leverage factor.
    """

    passive_finalization_commission: CCD_AmountFraction
    passive_baking_commission: CCD_AmountFraction
    passive_transaction_commission: CCD_AmountFraction
    commission_bounds: CCD_CommissionRanges
    minimum_equity_capital: microCCD
    capital_bound: CCD_CapitalBound
    leverage_bound: CCD_LeverageFactor


class CCD_RewardPeriodLength(BaseModel):
    """
    CCD_RewardPeriodLength represents the length of a reward period in CCD.

    Attributes:
        value (CCD_Epoch): The epoch value representing the length of the reward period.
    """

    value: CCD_Epoch


class CCD_TimeParametersCpv1(BaseModel):
    """
    CCD_TimeParametersCpv1 is a model that represents the time parameters for a CCD (Concordium) client.

    Attributes:
        reward_period_length (CCD_Epoch): The length of the reward period in epochs.
        mint_per_payday (CCD_MintRate): The mint rate per payday.
    """

    reward_period_length: CCD_Epoch
    mint_per_payday: CCD_MintRate


class CCD_MintDistributionCpv1(BaseModel):
    """
    CCD_MintDistributionCpv1 represents the distribution of minting rewards in the CCD system.

    Attributes:
        baking_reward (CCD_AmountFraction): The fraction of the total reward allocated for baking.
        finalization_reward (CCD_AmountFraction): The fraction of the total reward allocated for finalization.
    """

    baking_reward: CCD_AmountFraction
    finalization_reward: CCD_AmountFraction


class CCD_BakerStakeThreshold(BaseModel):
    """
    CCD_BakerStakeThreshold represents the threshold for a baker's stake in microCCD.

    Attributes:
        baker_stake_threshold (microCCD): The minimum stake required for a baker in microCCD.
    """

    baker_stake_threshold: microCCD


class CCD_TransactionType(BaseModel):
    """
    CCD_TransactionType represents a transaction type in the CCD system.

    Attributes:
        type (str): The type of the transaction.
        contents (str): The contents or details of the transaction.
    """

    type: str
    contents: str


class CCD_FinalizationCommitteeParameters(BaseModel):
    """
    CCD_FinalizationCommitteeParameters is a model representing the parameters for the finalization committee.

    Attributes:
        minimum_finalizers (int): The minimum number of finalizers required.
        maximum_finalizers (int): The maximum number of finalizers allowed.
        finalizer_relative_stake_threshold (CCD_AmountFraction): The relative stake threshold for finalizers.
    """

    minimum_finalizers: int
    maximum_finalizers: int
    finalizer_relative_stake_threshold: CCD_AmountFraction


class CCD_ValidatorScoreParameters(BaseModel):
    """
    CCD_ValidatorScoreParameters is a model that represents the parameters used to validate the score of a CCD (Concordium) validator.

    Attributes:
        maximum_missed_rounds (int): The maximum number of rounds a validator is allowed to miss.
    """

    maximum_missed_rounds: int


class CCD_UpdatePayload(BaseModel):
    """
    CCD_UpdatePayload is a data model representing various optional updates that can be applied to a CCD (Concordium) system.

    Attributes:
        protocol_update (Optional[CCD_ProtocolUpdate]): Update related to the protocol.
        election_difficulty_update (Optional[CCD_ElectionDifficulty]): Update related to election difficulty.
        euro_per_energy_update (Optional[CCD_ExchangeRate]): Update for the exchange rate of euros per energy unit.
        micro_ccd_per_euro_update (Optional[CCD_ExchangeRate]): Update for the exchange rate of micro CCD per euro.
        foundation_account_update (Optional[CCD_AccountAddress]): Update for the foundation account address.
        mint_distribution_update (Optional[CCD_MintDistributionCpv0]): Update for mint distribution parameters (CPv0).
        transaction_fee_distribution_update (Optional[CCD_TransactionFeeDistribution]): Update for transaction fee distribution.
        baker_stake_threshold_update (Optional[CCD_BakerStakeThreshold]): Update for the baker stake threshold.
        root_update (Optional[CCD_RootUpdate]): Update for the root parameters.
        level_1_update (Optional[CCD_Level1Update]): Update for level 1 parameters.
        add_anonymity_revoker_update (Optional[CCD_ArInfo]): Update to add an anonymity revoker.
        add_identity_provider_update (Optional[CCD_IpInfo]): Update to add an identity provider.
        cooldown_parameters_cpv_1_update (Optional[CCD_CooldownParametersCpv1]): Update for cooldown parameters (CPv1).
        pool_parameters_cpv_1_update (Optional[CCD_PoolParametersCpv1]): Update for pool parameters (CPv1).
        time_parameters_cpv_1_update (Optional[CCD_TimeParametersCpv1]): Update for time parameters (CPv1).
        mint_distribution_cpv_1_update (Optional[CCD_MintDistributionCpv1]): Update for mint distribution parameters (CPv1).
        finalization_committee_parameters_update (Optional[CCD_FinalizationCommitteeParameters]): Update for finalization committee parameters.
        validator_score_parameters_update (Optional[CCD_ValidatorScoreParameters]): Update for validator score parameters.
    """

    protocol_update: Optional[CCD_ProtocolUpdate] = None
    election_difficulty_update: Optional[CCD_ElectionDifficulty] = None
    euro_per_energy_update: Optional[CCD_ExchangeRate] = None
    micro_ccd_per_euro_update: Optional[CCD_ExchangeRate] = None
    foundation_account_update: Optional[CCD_AccountAddress] = None
    mint_distribution_update: Optional[CCD_MintDistributionCpv0] = None
    transaction_fee_distribution_update: Optional[CCD_TransactionFeeDistribution] = None
    baker_stake_threshold_update: Optional[CCD_BakerStakeThreshold] = None
    root_update: Optional[CCD_RootUpdate] = None
    level_1_update: Optional[CCD_Level1Update] = None
    add_anonymity_revoker_update: Optional[CCD_ArInfo] = None
    add_identity_provider_update: Optional[CCD_IpInfo] = None
    cooldown_parameters_cpv_1_update: Optional[CCD_CooldownParametersCpv1] = None
    pool_parameters_cpv_1_update: Optional[CCD_PoolParametersCpv1] = None
    time_parameters_cpv_1_update: Optional[CCD_TimeParametersCpv1] = None
    mint_distribution_cpv_1_update: Optional[CCD_MintDistributionCpv1] = None
    finalization_committee_parameters_update: Optional[
        CCD_FinalizationCommitteeParameters
    ] = None
    validator_score_parameters_update: Optional[CCD_ValidatorScoreParameters] = None


class CCD_UpdateDetails(BaseModel):
    """
    CCD_UpdateDetails is a model representing the details required for updating a CCD (Closed Circuit Device).

    Attributes:
        effective_time (Optional[CCD_TransactionTime]): The time at which the update becomes effective. Defaults to None.
        payload (CCD_UpdatePayload): The payload containing the update information.
    """

    effective_time: Optional[CCD_TransactionTime] = None
    payload: CCD_UpdatePayload


class CCD_ShortBlockInfo(BaseModel):
    """
    CCD_ShortBlockInfo represents a short block information model.

    Attributes:
        height (int): The height of the block in the blockchain.
        hash (CCD_BlockHash): The hash of the block.
        slot_time (CCD_TimeStamp): The timestamp of the block slot.
    """

    height: int
    hash: CCD_BlockHash
    slot_time: CCD_TimeStamp


class CCD_BlockItemSummary(BaseModel):
    """
    CCD_BlockItemSummary represents a summary of a block item in the CCD system.

    Attributes:
        index (int): The index of the block item. Defaults to 0.
        energy_cost (Optional[int]): The energy cost associated with the block item. Defaults to None.
        hash (CCD_TransactionHash): The hash of the transaction.
        type (Optional[CCD_TransactionType]): The type of the transaction. Defaults to None.
        account_transaction (Optional[CCD_AccountTransactionDetails]): Details of the account transaction. Defaults to None.
        account_creation (Optional[CCD_AccountCreationDetails]): Details of the account creation. Defaults to None.
        update (Optional[CCD_UpdateDetails]): Details of the update. Defaults to None.
        block_info (Optional[CCD_ShortBlockInfo]): Short information about the block. Defaults to None.
        recognized_sender_id (Optional[str]): The recognized sender ID. Defaults to None.
    """

    index: int = 0
    energy_cost: Optional[int] = None
    hash: CCD_TransactionHash
    type: Optional[CCD_TransactionType] = None
    account_transaction: Optional[CCD_AccountTransactionDetails] = None
    account_creation: Optional[CCD_AccountCreationDetails] = None
    update: Optional[CCD_UpdateDetails] = None
    block_info: Optional[CCD_ShortBlockInfo] = None
    recognized_sender_id: Optional[str] = None


class CCD_Block(BaseModel):
    """
    CCD_Block represents a block in the CCD system.

    Attributes:
        transaction_summaries (list[CCD_BlockItemSummary]): A list of summaries for each transaction in the block.
    """

    transaction_summaries: list[CCD_BlockItemSummary]


class CCD_Release(BaseModel):
    """
    CCD_Release represents a release of CCD (Concordium cryptocurrency).

    Attributes:
        timestamp (CCD_TimeStamp): The timestamp of the release.
        amount (microCCD): The amount of CCD released, in microCCD.
        transactions (list[CCD_TransactionHash]): A list of transaction hashes associated with the release.
    """

    timestamp: CCD_TimeStamp
    amount: microCCD
    transactions: list[CCD_TransactionHash]


class CCD_ReleaseSchedule(BaseModel):
    """
    A model representing a release schedule for CCD (Common Core Data).

    Attributes:
        schedules (list[CCD_Release]): A list of CCD_Release objects representing individual release schedules.
        total (int): The total number of release schedules.
    """

    schedules: list[CCD_Release]
    total: int


class CCD_BakerInfo(BaseModel):
    """
    CCD_BakerInfo is a data model representing information about a baker in the CCD system.

    Attributes:
        aggregation_key (str): The key used for aggregation.
        election_key (str): The key used for election.
        baker_id (int): The unique identifier for the baker.
        signature_key (str): The key used for signing.
    """

    aggregation_key: str
    election_key: str
    baker_id: int
    signature_key: str


class CCD_AccountStakingInfo_Baker(BaseModel):
    """
    Represents the staking information for a CCD account that is a baker.

    Attributes:
        baker_info (CCD_BakerInfo): Information about the baker.
        pool_info (CCD_BakerPoolInfo): Information about the baker's pool.
        pending_change (CCD_StakePendingChange): Information about any pending changes to the stake.
        restake_earnings (bool): Indicates whether earnings are restaked.
        staked_amount (microCCD): The amount of CCD staked.
        is_suspended (bool): Indicates whether the baker is suspended.
    """

    baker_info: CCD_BakerInfo
    pool_info: CCD_BakerPoolInfo
    pending_change: CCD_StakePendingChange
    restake_earnings: bool
    staked_amount: microCCD
    is_suspended: Optional[bool] = None


# class CCD_DelegationTarget(BaseModel):
#     baker_id: int = None
#     passive: str = None


class CCD_AccountStakingInfo_Delegator(BaseModel):
    """
    Represents the staking information of a delegator account in the CCD system.

    Attributes:
        target (CCD_DelegationTarget): The delegation target for the account.
        pending_change (CCD_StakePendingChange): Any pending changes to the stake.
        restake_earnings (bool): Indicates whether earnings are restaked.
        staked_amount (microCCD): The amount of CCD staked by the account.
    """

    target: CCD_DelegationTarget
    pending_change: CCD_StakePendingChange
    restake_earnings: bool
    staked_amount: microCCD


class CCD_AccountStakingInfo(BaseModel):
    """
    Represents the staking information for a CCD account.

    Attributes:
        baker (Optional[CCD_AccountStakingInfo_Baker]): Information about the baker if the account is a baker.
        delegator (Optional[CCD_AccountStakingInfo_Delegator]): Information about the delegator if the account is a delegator.
    """

    baker: Optional[CCD_AccountStakingInfo_Baker] = None
    delegator: Optional[CCD_AccountStakingInfo_Delegator] = None


class CCD_AccountVerifyKey(BaseModel):
    """
    CCD_AccountVerifyKey is a model representing an account verification key.

    Attributes:
        ed25519_key (str): The ED25519 public key as a string.
    """

    ed25519_key: str


# class CCD_KeysEntry(BaseModel):
#     key: int
#     value: CCD_AccountVerifyKey


class CCD_CredentialPublicKeys(BaseModel):
    """
    CCD_CredentialPublicKeys is a model representing the public keys and signature threshold for a CCD credential.

    Attributes:
        keys (dict[str, CCD_AccountVerifyKey]): A dictionary mapping key identifiers to their corresponding CCD account verify keys.
        threshold (CCD_SignatureThreshold): The signature threshold required for the credential.
    """

    keys: dict[str, CCD_AccountVerifyKey]
    threshold: CCD_SignatureThreshold


class CCD_YearMonth(BaseModel):
    """
    CCD_YearMonth is a data model representing a specific year and month.

    Attributes:
        year (int): The year component of the date.
        month (int): The month component of the date, represented as an integer (1-12).
    """

    year: int
    month: int


class CCD_Policy(BaseModel):
    """
    CCD_Policy represents a policy with a creation date, a validity period, and a set of attributes.

    Attributes:
        created_at (CCD_YearMonth): The date when the policy was created.
        valid_to (CCD_YearMonth): The date until which the policy is valid.
        attributes (dict[str, CCD_Policy_Attributes]): A dictionary of attributes associated with the policy.
    """

    created_at: CCD_YearMonth
    valid_to: CCD_YearMonth
    attributes: dict[str, CCD_Policy_Attributes]


class CCD_InitialCredentialValues(BaseModel):
    """
    CCD_InitialCredentialValues is a data model representing the initial credential values required for a CCD (Concordium Credential Deployment).

    Attributes:
        credential_public_keys (CCD_CredentialPublicKeys): The public keys associated with the credential.
        cred_id (CCD_CredentialRegistrationId): The unique identifier for the credential registration.
        ip_id (CCD_IdentityProviderIdentity): The identity of the identity provider.
        policy (CCD_Policy): The policy associated with the credential.
    """

    credential_public_keys: CCD_CredentialPublicKeys
    cred_id: CCD_CredentialRegistrationId
    ip_id: CCD_IdentityProviderIdentity
    policy: CCD_Policy


class CCD_ChainArData(BaseModel):
    """
    CCD_ChainArData is a data model representing the chain AR data.

    Attributes:
        enc_id_cred_pub_share (str): Encrypted ID credential public share.
    """

    enc_id_cred_pub_share: str


# class CCD_ArDataEntry(BaseModel):
#     key: int
#     value: CCD_ChainArData


class CCD_CredentialCommitments_AttributesEntry(BaseModel):
    """
    Represents an entry in the credential commitments attributes.

    Attributes:
        key (int): The key for the attribute entry.
        value (CCD_Commitment): The value associated with the key, representing a commitment.
    """

    key: int
    value: CCD_Commitment


class CCD_CredentialCommitments(BaseModel):
    """
    CCD_CredentialCommitments is a model representing the commitments related to a credential.

    Attributes:
        prf (CCD_Commitment): The commitment for the pseudorandom function.
        cred_counter (CCD_Commitment): The commitment for the credential counter.
        max_accounts (CCD_Commitment): The commitment for the maximum number of accounts.
        attributes (dict[str, CCD_Commitment]): A dictionary mapping attribute names to their respective commitments.
        id_cred_sec_sharing_coeff (list[CCD_Commitment]): A list of commitments for the identity credential security sharing coefficients.
    """

    prf: CCD_Commitment
    cred_counter: CCD_Commitment
    max_accounts: CCD_Commitment
    attributes: dict[str, CCD_Commitment]
    id_cred_sec_sharing_coeff: list[CCD_Commitment]


class CCD_NormalCredentialValues(BaseModel):
    """
    CCD_NormalCredentialValues is a model representing the normal credential values in the CCD system.

    Attributes:
        credential_public_keys (CCD_CredentialPublicKeys): The public keys associated with the credential.
        cred_id (CCD_CredentialRegistrationId): The registration ID of the credential.
        ip_id (CCD_IdentityProviderIdentity): The identity of the identity provider.
        policy (CCD_Policy): The policy associated with the credential.
        ar_threshold (CCD_ArThreshold): The threshold for the attribute release.
        ar_data (dict[str, CCD_ChainArData]): The attribute release data.
        commitments (CCD_CredentialCommitments): The commitments associated with the credential.
    """

    credential_public_keys: CCD_CredentialPublicKeys
    cred_id: CCD_CredentialRegistrationId
    ip_id: CCD_IdentityProviderIdentity
    policy: CCD_Policy
    ar_threshold: CCD_ArThreshold
    ar_data: dict[str, CCD_ChainArData]
    commitments: CCD_CredentialCommitments


class CCD_AccountCredential(BaseModel):
    """
    CCD_AccountCredential is a model that represents the credentials for a CCD account.

    Attributes:
        initial (Optional[CCD_InitialCredentialValues]): The initial credential values for the CCD account.
        normal (Optional[CCD_NormalCredentialValues]): The normal credential values for the CCD account.
    """

    initial: Optional[CCD_InitialCredentialValues] = None
    normal: Optional[CCD_NormalCredentialValues] = None


class CCD_EncryptedBalance(BaseModel):
    """
    Represents an encrypted balance in the CCD system.

    Attributes:
        self_amount (CCD_EncryptedAmount): The encrypted amount for the balance itself.
        start_index (int): The starting index for the balance.
        aggregated_amount (CCD_EncryptedAmount, optional): The aggregated encrypted amount, if any. Defaults to None.
        num_aggregated (Optional[int], optional): The number of aggregated amounts, if any. Defaults to None.
        incoming_amounts (list[CCD_EncryptedAmount]): A list of incoming encrypted amounts.
    """

    self_amount: CCD_EncryptedAmount
    start_index: int
    aggregated_amount: CCD_EncryptedAmount = None
    num_aggregated: Optional[int] = None
    incoming_amounts: list[CCD_EncryptedAmount]


class CCD_Cooldown(BaseModel):
    """
    Represents a cooldown period for a CCD (Charge-Coupled Device).

    Attributes:
        end_time (CCD_TimeStamp): The timestamp indicating when the cooldown period ends.
        amount (microCCD): The amount of cooldown applied.
        status (CoolDownStatus): The current status of the cooldown.
    """

    end_time: CCD_TimeStamp
    amount: microCCD
    status: CoolDownStatus


class CCD_AccountInfo(BaseModel):
    """
    CCD_AccountInfo represents the account information in the CCD system.

    Attributes:
        address (str): The address of the account.
        amount (microCCD): The amount of microCCD in the account.
        stake (Optional[CCD_AccountStakingInfo]): The staking information of the account, if any.
        credentials (dict[str, CCD_AccountCredential]): The credentials associated with the account.
        encrypted_balance (CCD_EncryptedBalance): The encrypted balance of the account.
        encryption_key (str): The encryption key for the account.
        index (int): The index of the account.
        schedule (Optional[CCD_ReleaseSchedule]): The release schedule of the account, if any.
        threshold (int): The threshold for the account.
        sequence_number (Optional[CCD_SequenceNumber]): The sequence number of the account, if any.
        available_balance (Optional[microCCD]): The available balance of the account, if any.
        cooldowns (Optional[list[CCD_Cooldown]]): The cooldowns associated with the account, if any.
    """

    address: str
    amount: microCCD
    stake: Optional[CCD_AccountStakingInfo] = None
    credentials: dict[str, CCD_AccountCredential]
    encrypted_balance: CCD_EncryptedBalance
    encryption_key: str
    index: int
    schedule: Optional[CCD_ReleaseSchedule] = None
    threshold: int
    sequence_number: Optional[CCD_SequenceNumber] = None
    available_balance: Optional[microCCD] = None
    cooldowns: Optional[list[CCD_Cooldown]] = None


class CCD_TokenomicsInfo_V0(BaseModel):
    """
    CCD_TokenomicsInfo_V0 is a data model representing tokenomics information for a specific version.

    Attributes:
        total_amount (microCCD): The total amount of tokens.
        total_encrypted_amount (microCCD): The total amount of encrypted tokens.
        baking_reward_account (microCCD): The amount allocated to the baking reward account.
        finalization_reward_account (microCCD): The amount allocated to the finalization reward account.
        gas_account (microCCD): The amount allocated to the gas account.
        protocol_version (int): The version of the protocol.
    """

    total_amount: microCCD
    total_encrypted_amount: microCCD
    baking_reward_account: microCCD
    finalization_reward_account: microCCD
    gas_account: microCCD
    protocol_version: int


class CCD_TokenomicsInfo_V1(BaseModel):
    """
    CCD_TokenomicsInfo_V1 is a data model representing the tokenomics information of a CCD (Concordium) network.

    Attributes:
        total_amount (microCCD): The total amount of CCD tokens.
        total_encrypted_amount (microCCD): The total amount of encrypted CCD tokens.
        baking_reward_account (microCCD): The amount allocated for baking rewards.
        finalization_reward_account (microCCD): The amount allocated for finalization rewards.
        gas_account (microCCD): The amount allocated for gas fees.
        foundation_transaction_rewards (microCCD): The amount allocated for foundation transaction rewards.
        next_payday_time (CCD_TimeStamp): The timestamp for the next payday.
        next_payday_mint_rate (CCD_MintRate): The mint rate for the next payday.
        total_staked_capital (microCCD): The total amount of staked capital.
        protocol_version (int): The version of the protocol.
    """

    total_amount: microCCD
    total_encrypted_amount: microCCD
    baking_reward_account: microCCD
    finalization_reward_account: microCCD
    gas_account: microCCD
    foundation_transaction_rewards: microCCD
    next_payday_time: CCD_TimeStamp
    next_payday_mint_rate: CCD_MintRate
    total_staked_capital: microCCD
    protocol_version: int


class CCD_TokenomicsInfo(BaseModel):
    """
    CCD_TokenomicsInfo is a model representing tokenomics information for CCD.

    Attributes:
        v0 (Optional[CCD_TokenomicsInfo_V0]): An optional attribute representing version 0 of the tokenomics information.
        v1 (Optional[CCD_TokenomicsInfo_V1]): An optional attribute representing version 1 of the tokenomics information.
    """

    v0: Optional[CCD_TokenomicsInfo_V0] = None
    v1: Optional[CCD_TokenomicsInfo_V1] = None


class CCD_InstanceInfo_V0(BaseModel):
    """
    CCD_InstanceInfo_V0 represents the information of a CCD instance.

    Attributes:
        model (CCD_ContractStateV0): The state of the contract.
        owner (CCD_AccountAddress): The address of the account that owns the instance.
        amount (microCCD): The amount associated with the instance.
        methods (list[CCD_ReceiveName]): A list of methods that can be received by the instance.
        name (CCD_InitName): The name of the instance.
        source_module (CCD_ModuleRef): The reference to the source module of the instance.
    """

    model: CCD_ContractStateV0
    owner: CCD_AccountAddress
    amount: microCCD
    methods: list[CCD_ReceiveName]
    name: CCD_InitName
    source_module: CCD_ModuleRef


class CCD_InstanceInfo_V1(BaseModel):
    """
    CCD_InstanceInfo_V1 represents the information of a CCD instance in version 1.

    Attributes:
        owner (CCD_AccountAddress): The address of the account that owns the CCD instance.
        amount (microCCD): The amount of microCCD associated with the instance.
        methods (list[CCD_ReceiveName]): A list of method names that the instance can receive.
        name (CCD_InitName): The initialization name of the CCD instance.
        source_module (CCD_ModuleRef): The reference to the source module of the CCD instance.
    """

    owner: CCD_AccountAddress
    amount: microCCD
    methods: list[CCD_ReceiveName]
    name: CCD_InitName
    source_module: CCD_ModuleRef


class CCD_InstanceInfo(BaseModel):
    """
    CCD_InstanceInfo is a model that represents information about a CCD instance.

    Attributes:
        v0 (CCD_InstanceInfo_V0): The version 0 information of the CCD instance.
        v1 (CCD_InstanceInfo_V1): The version 1 information of the CCD instance.
    """

    v0: CCD_InstanceInfo_V0
    v1: CCD_InstanceInfo_V1


class CCD_BlocksAtHeightResponse(BaseModel):
    """
    CCD_BlocksAtHeightResponse is a model representing the response containing blocks at a specific height.

    Attributes:
        blocks (list[CCD_BlockHash]): A list of block hashes at the specified height.
    """

    blocks: list[CCD_BlockHash]


class CCD_BlockSpecialEvent_PaydayPoolReward(BaseModel):
    """
    Represents a special event for payday pool rewards in the CCD blockchain.

    Attributes:
        pool_owner (Optional[CCD_BakerId]): The ID of the pool owner. Defaults to None.
        transaction_fees (microCCD): The transaction fees associated with the reward.
        baker_reward (microCCD): The reward given to the baker.
        finalization_reward (microCCD): The reward given for finalization.
    """

    pool_owner: Optional[CCD_BakerId] = None
    transaction_fees: microCCD
    baker_reward: microCCD
    finalization_reward: microCCD


class CCD_BlockSpecialEvent_BlockAccrueReward(BaseModel):
    """
    Represents a special event block that accrues rewards in the CCD blockchain.

    Attributes:
        transaction_fees (microCCD): The transaction fees associated with the block.
        old_gas_account (microCCD): The gas account balance before the block.
        new_gas_account (microCCD): The gas account balance after the block.
        baker_reward (microCCD): The reward given to the baker for this block.
        passive_reward (microCCD): The passive reward associated with the block.
        foundation_charge (microCCD): The charge taken by the foundation.
        baker (CCD_BakerId): The identifier of the baker.
    """

    transaction_fees: microCCD
    old_gas_account: microCCD
    new_gas_account: microCCD
    baker_reward: microCCD
    passive_reward: microCCD
    foundation_charge: microCCD
    baker: CCD_BakerId


class CCD_BlockSpecialEvent_PaydayAccountReward(BaseModel):
    """
    Represents a special event for payday account rewards in the CCD blockchain.

    Attributes:
        account (CCD_AccountAddress): The address of the account receiving the reward.
        transaction_fees (microCCD): The transaction fees associated with the reward.
        baker_reward (microCCD): The reward given to the baker.
        finalization_reward (microCCD): The reward given for finalizing the block.
    """

    account: CCD_AccountAddress
    transaction_fees: microCCD
    baker_reward: microCCD
    finalization_reward: microCCD


class CCD_BlockSpecialEvent_PaydayFoundationReward(BaseModel):
    """
    Represents a special event for payday foundation rewards in the CCD blockchain.

    Attributes:
        foundation_account (CCD_AccountAddress): The account address of the foundation receiving the reward.
        development_charge (microCCD): The amount of microCCD charged for development.
    """

    foundation_account: CCD_AccountAddress
    development_charge: microCCD


class CCD_BlockSpecialEvent_BlockReward(BaseModel):
    """
    Represents a special event block reward in the CCD blockchain.

    Attributes:
        transaction_fees (microCCD): The transaction fees associated with the block.
        old_gas_account (microCCD): The old gas account balance before the block reward.
        new_gas_account (microCCD): The new gas account balance after the block reward.
        baker_reward (microCCD): The reward given to the baker for processing the block.
        foundation_charge (microCCD): The charge allocated to the foundation.
        foundation_account (CCD_AccountAddress): The account address of the foundation.
        baker (CCD_AccountAddress): The account address of the baker.
    """

    transaction_fees: microCCD
    old_gas_account: microCCD
    new_gas_account: microCCD
    baker_reward: microCCD
    foundation_charge: microCCD
    foundation_account: CCD_AccountAddress
    baker: CCD_AccountAddress


class CCD_BlockSpecialEvent_AccountAmounts_Entry(BaseModel):
    """
    Represents an entry for account amounts in a special event block.

    Attributes:
        account (CCD_AccountAddress): The address of the account.
        amount (microCCD): The amount associated with the account.
    """

    account: CCD_AccountAddress
    amount: microCCD


class CCD_BlockSpecialEvent_AccountAmounts(BaseModel):
    """
    CCD_BlockSpecialEvent_AccountAmounts is a model representing account amounts for a special event block.

    Attributes:
        entries (list[CCD_BlockSpecialEvent_AccountAmounts_Entry]): A list of entries representing account amounts.
    """

    entries: list[CCD_BlockSpecialEvent_AccountAmounts_Entry]


class CCD_BlockSpecialEvent_FinalizationRewards(BaseModel):
    """
    Represents the finalization rewards for a special event in a CCD block.

    Attributes:
        finalization_rewards (CCD_BlockSpecialEvent_AccountAmounts): The account amounts associated with the finalization rewards.
        remainder (microCCD): The remaining microCCD after distributing the finalization rewards.
    """

    finalization_rewards: CCD_BlockSpecialEvent_AccountAmounts
    remainder: microCCD


class CCD_BlockSpecialEvent_BakingRewards(BaseModel):
    """
    CCD_BlockSpecialEvent_BakingRewards represents a special event in the CCD blockchain
    related to baking rewards.

    Attributes:
        baker_rewards (CCD_BlockSpecialEvent_AccountAmounts): The rewards distributed to bakers.
        remainder (microCCD): The remaining amount after distributing the baker rewards.
    """

    baker_rewards: CCD_BlockSpecialEvent_AccountAmounts
    remainder: microCCD


class CCD_BlockSpecialEvent_Mint(BaseModel):
    """
    Represents a special event in a CCD block related to minting.

    Attributes:
        mint_baking_reward (microCCD): The reward for baking in microCCD.
        mint_finalization_reward (microCCD): The reward for finalization in microCCD.
        mint_platform_development_charge (microCCD): The charge for platform development in microCCD.
        foundation_account (CCD_AccountAddress): The account address of the foundation.
    """

    mint_baking_reward: microCCD
    mint_finalization_reward: microCCD
    mint_platform_development_charge: microCCD
    foundation_account: CCD_AccountAddress


class CCD_BlockSpecialEvent_ValidatorSuspended(BaseModel):
    """
    CCD_BlockSpecialEvent_ValidatorSuspended represents an event where a validator is suspended.

    Attributes:
        baker_id (CCD_BakerId): The ID of the baker (validator) who is suspended.
        account (CCD_AccountAddress): The account address associated with the suspended validator.
    """

    baker_id: CCD_BakerId
    account: CCD_AccountAddress


class CCD_BlockSpecialEvent_ValidatorPrimedForSuspension(BaseModel):
    """
    CCD_BlockSpecialEvent_ValidatorPrimedForSuspension represents an event where a validator is primed for suspension.

    Attributes:
        baker_id (CCD_BakerId): The unique identifier of the baker.
        account (CCD_AccountAddress): The account address associated with the baker.
    """

    baker_id: CCD_BakerId
    account: CCD_AccountAddress


class CCD_BlockSpecialEvent(BaseModel):
    """
    CCD_BlockSpecialEvent represents a special event in a CCD block.

    Attributes:
        baking_rewards (Optional[CCD_BlockSpecialEvent_BakingRewards]): Rewards for baking.
        mint (Optional[CCD_BlockSpecialEvent_Mint]): Minting details.
        finalization_rewards (Optional[CCD_BlockSpecialEvent_FinalizationRewards]): Rewards for finalization.
        block_reward (Optional[CCD_BlockSpecialEvent_BlockReward]): Reward for the block.
        payday_foundation_reward (Optional[CCD_BlockSpecialEvent_PaydayFoundationReward]): Foundation reward for payday.
        payday_account_reward (Optional[CCD_BlockSpecialEvent_PaydayAccountReward]): Account reward for payday.
        block_accrue_reward (Optional[CCD_BlockSpecialEvent_BlockAccrueReward]): Accrued reward for the block.
        payday_pool_reward (Optional[CCD_BlockSpecialEvent_PaydayPoolReward]): Pool reward for payday.
        validator_suspended (Optional[CCD_BlockSpecialEvent_ValidatorSuspended]): Details of a suspended validator.
        validator_primed_for_suspension (Optional[CCD_BlockSpecialEvent_ValidatorPrimedForSuspension]): Details of a validator primed for suspension.
    """

    baking_rewards: Optional[CCD_BlockSpecialEvent_BakingRewards] = None
    mint: Optional[CCD_BlockSpecialEvent_Mint] = None
    finalization_rewards: Optional[CCD_BlockSpecialEvent_FinalizationRewards] = None
    block_reward: Optional[CCD_BlockSpecialEvent_BlockReward] = None
    payday_foundation_reward: Optional[CCD_BlockSpecialEvent_PaydayFoundationReward] = (
        None
    )
    payday_account_reward: Optional[CCD_BlockSpecialEvent_PaydayAccountReward] = None
    block_accrue_reward: Optional[CCD_BlockSpecialEvent_BlockAccrueReward] = None
    payday_pool_reward: Optional[CCD_BlockSpecialEvent_PaydayPoolReward] = None
    validator_suspended: Optional[CCD_BlockSpecialEvent_ValidatorSuspended] = None
    validator_primed_for_suspension: Optional[
        CCD_BlockSpecialEvent_ValidatorPrimedForSuspension
    ] = None


class CCD_PendingUpdate(BaseModel):
    """
    Represents a pending update in the CCD system.

    Attributes:
        effective_time (CCD_TransactionTime): The time when the update becomes effective.
        root_keys (Optional[CCD_HigherLevelKeys]): The root keys for the update.
        level1_keys (Optional[CCD_HigherLevelKeys]): The level 1 keys for the update.
        level2_keys_cpc_0 (Optional[CCD_AuthorizationsV0]): The level 2 keys for CPC version 0.
        level2_keys_cpc_1 (Optional[CCD_AuthorizationsV1]): The level 2 keys for CPC version 1.
        protocol (Optional[CCD_ProtocolUpdate]): The protocol update information.
        election_difficulty (Optional[CCD_ElectionDifficulty]): The election difficulty parameters.
        euro_per_energy (Optional[CCD_ExchangeRate]): The exchange rate of euros per energy unit.
        micro_ccd_per_euro (Optional[CCD_ExchangeRate]): The exchange rate of micro CCD per euro.
        foundation_account (Optional[CCD_AccountAddress]): The foundation account address.
        mint_distribution_cpv_0 (Optional[CCD_MintDistributionCpv0]): The mint distribution for CPV version 0.
        mint_distribution_cpv_1 (Optional[CCD_MintDistributionCpv1]): The mint distribution for CPV version 1.
        transaction_fee_distribution (Optional[CCD_TransactionFeeDistribution]): The transaction fee distribution parameters.
        gas_rewards (CCD_GasRewards): The gas rewards parameters.
        pool_parameters_cpv_0 (Optional[CCD_BakerStakeThreshold]): The pool parameters for CPV version 0.
        pool_parameters_cpv_1 (Optional[CCD_PoolParametersCpv1]): The pool parameters for CPV version 1.
        add_anonymity_revoker (Optional[CCD_ArInfo]): Information about the anonymity revoker to be added.
        add_identity_provider (Optional[CCD_IpInfo]): Information about the identity provider to be added.
        cooldown_parameters (Optional[CCD_CooldownParametersCpv1]): The cooldown parameters for CPV version 1.
        pool_parameters_cpv_1_update (Optional[CCD_PoolParametersCpv1]): The updated pool parameters for CPV version 1.
        time_parameters (Optional[CCD_TimeParametersCpv1]): The time parameters for CPV version 1.
        validator_score_parameters (Optional[CCD_ValidatorScoreParameters]): The validator score parameters.
    """

    effective_time: CCD_TransactionTime
    root_keys: Optional[CCD_HigherLevelKeys] = None
    level1_keys: Optional[CCD_HigherLevelKeys] = None
    level2_keys_cpc_0: Optional[CCD_AuthorizationsV0] = None
    level2_keys_cpc_1: Optional[CCD_AuthorizationsV1] = None
    protocol: Optional[CCD_ProtocolUpdate] = None
    election_difficulty: Optional[CCD_ElectionDifficulty] = None
    euro_per_energy: Optional[CCD_ExchangeRate] = None
    micro_ccd_per_euro: Optional[CCD_ExchangeRate] = None
    foundation_account: Optional[CCD_AccountAddress] = None
    mint_distribution_cpv_0: Optional[CCD_MintDistributionCpv0] = None
    mint_distribution_cpv_1: Optional[CCD_MintDistributionCpv1] = None
    transaction_fee_distribution: Optional[CCD_TransactionFeeDistribution] = None
    gas_rewards: CCD_GasRewards
    pool_parameters_cpv_0: Optional[CCD_BakerStakeThreshold] = None
    pool_parameters_cpv_1: Optional[CCD_PoolParametersCpv1] = None
    add_anonymity_revoker: Optional[CCD_ArInfo] = None
    add_identity_provider: Optional[CCD_IpInfo] = None
    cooldown_parameters: Optional[CCD_CooldownParametersCpv1] = None
    pool_parameters_cpv_1_update: Optional[CCD_PoolParametersCpv1] = None
    time_parameters: Optional[CCD_TimeParametersCpv1] = None
    validator_score_parameters: Optional[CCD_ValidatorScoreParameters] = None


class CCD_ElectionInfo_Baker(BaseModel):
    """
    CCD_ElectionInfo_Baker represents the election information for a baker in the CCD system.

    Attributes:
        baker (CCD_BakerId): The unique identifier for the baker.
        account (CCD_AccountAddress): The account address associated with the baker.
        lottery_power (float): The lottery power of the baker.
    """

    baker: CCD_BakerId
    account: CCD_AccountAddress
    lottery_power: float


class CCD_ElectionInfo(BaseModel):
    """
    CCD_ElectionInfo represents the information related to an election in the CCD system.

    Attributes:
        election_difficulty (Optional[CCD_ElectionDifficulty]): The difficulty level of the election. Default is None.
        election_nonce (CCD_LeadershipElectionNonce): The nonce used for the leadership election.
        baker_election_info (list[CCD_ElectionInfo_Baker]): A list containing information about the bakers participating in the election.
    """

    election_difficulty: Optional[CCD_ElectionDifficulty] = None
    election_nonce: CCD_LeadershipElectionNonce
    baker_election_info: list[CCD_ElectionInfo_Baker]


class CCD_ConsensusInfo(BaseModel):
    """
    CCD_ConsensusInfo is a data model representing the consensus information of a CCD network.

    Attributes:
        best_block (CCD_BlockHash): The hash of the best block.
        genesis_block (CCD_BlockHash): The hash of the genesis block.
        genesis_time (CCD_TimeStamp): The timestamp of the genesis block.
        slot_duration (Optional[CCD_Duration]): The duration of a slot, if available.
        epoch_duration (CCD_Duration): The duration of an epoch.
        last_finalized_block (CCD_BlockHash): The hash of the last finalized block.
        best_block_height (int): The height of the best block.
        last_finalized_block_height (int): The height of the last finalized block.
        blocks_received_count (int): The count of blocks received.
        block_last_received_time (Optional[CCD_TimeStamp]): The timestamp of the last received block, if available.
        block_receive_latency_ema (float): The exponential moving average of block receive latency.
        block_receive_latency_emsd (float): The exponential moving standard deviation of block receive latency.
        block_receive_period_ema (Optional[float]): The exponential moving average of block receive period, if available.
        block_receive_period_emsd (Optional[float]): The exponential moving standard deviation of block receive period, if available.
        blocks_verified_count (int): The count of blocks verified.
        block_last_arrived_time (Optional[CCD_TimeStamp]): The timestamp of the last arrived block, if available.
        block_arrive_latency_ema (float): The exponential moving average of block arrive latency.
        block_arrive_latency_emsd (float): The exponential moving standard deviation of block arrive latency.
        block_arrive_period_ema (Optional[float]): The exponential moving average of block arrive period, if available.
        block_arrive_period_emsd (Optional[float]): The exponential moving standard deviation of block arrive period, if available.
        transactions_per_block_ema (float): The exponential moving average of transactions per block.
        transactions_per_block_emsd (float): The exponential moving standard deviation of transactions per block.
        finalization_count (int): The count of finalizations.
        last_finalized_time (Optional[CCD_TimeStamp]): The timestamp of the last finalized block, if available.
        finalization_period_ema (Optional[float]): The exponential moving average of finalization period, if available.
        finalization_period_emsd (Optional[float]): The exponential moving standard deviation of finalization period, if available.
        protocol_version (str): The version of the protocol.
        genesis_index (int): The index of the genesis block.
        current_era_genesis_block (CCD_BlockHash): The hash of the current era genesis block.
        current_era_genesis_time (CCD_TimeStamp): The timestamp of the current era genesis block.
        current_timeout_duration (Optional[CCD_Duration]): The current timeout duration, if available.
        current_round (Optional[CCD_Round]): The current round, if available.
        current_epoch (Optional[int]): The current epoch, if available.
        trigger_block_time (Optional[CCD_TimeStamp]): The timestamp of the trigger block, if available.
    """

    best_block: CCD_BlockHash
    genesis_block: CCD_BlockHash
    genesis_time: CCD_TimeStamp
    slot_duration: Optional[CCD_Duration] = None
    epoch_duration: CCD_Duration
    last_finalized_block: CCD_BlockHash
    best_block_height: int
    last_finalized_block_height: int
    blocks_received_count: int
    block_last_received_time: Optional[CCD_TimeStamp] = None
    block_receive_latency_ema: float
    block_receive_latency_emsd: float
    block_receive_period_ema: Optional[float] = None
    block_receive_period_emsd: Optional[float] = None
    blocks_verified_count: int
    block_last_arrived_time: Optional[CCD_TimeStamp] = None
    block_arrive_latency_ema: float
    block_arrive_latency_emsd: float
    block_arrive_period_ema: Optional[float] = None
    block_arrive_period_emsd: Optional[float] = None
    transactions_per_block_ema: float
    transactions_per_block_emsd: float
    finalization_count: int
    last_finalized_time: Optional[CCD_TimeStamp] = None
    finalization_period_ema: Optional[float] = None
    finalization_period_emsd: Optional[float] = None
    protocol_version: str
    genesis_index: int
    current_era_genesis_block: CCD_BlockHash
    current_era_genesis_time: CCD_TimeStamp
    current_timeout_duration: Optional[CCD_Duration] = None
    current_round: Optional[CCD_Round] = None
    current_epoch: Optional[int] = None
    trigger_block_time: Optional[CCD_TimeStamp] = None


class CCD_VersionedModuleSource(BaseModel):
    """
    CCD_VersionedModuleSource is a model that represents a versioned module source.

    Attributes:
        v0 (Optional[CCD_VersionedModuleSource_ModuleSourceV0]): The version 0 of the module source.
        v1 (Optional[CCD_VersionedModuleSource_ModuleSourceV1]): The version 1 of the module source.
    """

    v0: Optional[CCD_VersionedModuleSource_ModuleSourceV0] = None
    v1: Optional[CCD_VersionedModuleSource_ModuleSourceV1] = None


class CCD_NextUpdateSequenceNumbers(BaseModel):
    """
    CCD_NextUpdateSequenceNumbers is a model representing the next update sequence numbers for various CCD parameters.

    Attributes:
        root_keys (Optional[CCD_SequenceNumber]): The sequence number for root keys.
        level1_keys (Optional[CCD_SequenceNumber]): The sequence number for level 1 keys.
        level2_keys (Optional[CCD_SequenceNumber]): The sequence number for level 2 keys.
        protocol (Optional[CCD_SequenceNumber]): The sequence number for the protocol.
        election_difficulty (Optional[CCD_SequenceNumber]): The sequence number for election difficulty.
        euro_per_energy (Optional[CCD_SequenceNumber]): The sequence number for euro per energy.
        micro_ccd_per_euro (Optional[CCD_SequenceNumber]): The sequence number for micro CCD per euro.
        foundation_account (Optional[CCD_SequenceNumber]): The sequence number for the foundation account.
        mint_distribution (Optional[CCD_SequenceNumber]): The sequence number for mint distribution.
        transaction_fee_distribution (Optional[CCD_SequenceNumber]): The sequence number for transaction fee distribution.
        gas_rewards (Optional[CCD_SequenceNumber]): The sequence number for gas rewards.
        pool_parameters (Optional[CCD_SequenceNumber]): The sequence number for pool parameters.
        add_anonymity_revoker (Optional[CCD_SequenceNumber]): The sequence number for adding an anonymity revoker.
        add_identity_provider (Optional[CCD_SequenceNumber]): The sequence number for adding an identity provider.
        cooldown_parameters (Optional[CCD_SequenceNumber]): The sequence number for cooldown parameters.
        time_parameters (Optional[CCD_SequenceNumber]): The sequence number for time parameters.
        timeout_parameters (Optional[CCD_SequenceNumber]): The sequence number for timeout parameters.
        min_block_time (Optional[CCD_SequenceNumber]): The sequence number for minimum block time.
        block_energy_limit (Optional[CCD_SequenceNumber]): The sequence number for block energy limit.
        finalization_committee_parameters (Optional[CCD_SequenceNumber]): The sequence number for finalization committee parameters.
        validator_score_parameters (Optional[CCD_SequenceNumber]): The sequence number for validator score parameters.
    """

    root_keys: Optional[CCD_SequenceNumber] = None
    level1_keys: Optional[CCD_SequenceNumber] = None
    level2_keys: Optional[CCD_SequenceNumber] = None
    protocol: Optional[CCD_SequenceNumber] = None
    election_difficulty: Optional[CCD_SequenceNumber] = None
    euro_per_energy: Optional[CCD_SequenceNumber] = None
    micro_ccd_per_euro: Optional[CCD_SequenceNumber] = None
    foundation_account: Optional[CCD_SequenceNumber] = None
    mint_distribution: Optional[CCD_SequenceNumber] = None
    transaction_fee_distribution: Optional[CCD_SequenceNumber] = None
    gas_rewards: Optional[CCD_SequenceNumber] = None
    pool_parameters: Optional[CCD_SequenceNumber] = None
    add_anonymity_revoker: Optional[CCD_SequenceNumber] = None
    add_identity_provider: Optional[CCD_SequenceNumber] = None
    cooldown_parameters: Optional[CCD_SequenceNumber] = None
    time_parameters: Optional[CCD_SequenceNumber] = None
    timeout_parameters: Optional[CCD_SequenceNumber] = None
    min_block_time: Optional[CCD_SequenceNumber] = None
    block_energy_limit: Optional[CCD_SequenceNumber] = None
    finalization_committee_parameters: Optional[CCD_SequenceNumber] = None
    validator_score_parameters: Optional[CCD_SequenceNumber] = None


class CCD_ChainParametersV0(BaseModel):
    """
    CCD_ChainParametersV0 is a data model representing the parameters of a CCD chain.

    Attributes:
        election_difficulty (CCD_ElectionDifficulty): The difficulty level for elections.
        euro_per_energy (CCD_ExchangeRate): The exchange rate of euros per unit of energy.
        micro_ccd_per_euro (CCD_ExchangeRate): The exchange rate of micro CCD per euro.
        baker_cooldown_epochs (CCD_Epoch): The number of epochs a baker must wait before cooling down.
        account_creation_limit (CCD_CredentialsPerBlockLimit): The limit on the number of accounts that can be created per block.
        mint_distribution (CCD_MintDistributionCpv0): The distribution of minted CCD.
        transaction_fee_distribution (CCD_TransactionFeeDistribution): The distribution of transaction fees.
        gas_rewards (CCD_GasRewards): The rewards for gas usage.
        foundation_account (CCD_AccountAddress): The address of the foundation account.
        minimum_threshold_for_baking (microCCD): The minimum threshold required for baking.
        root_keys (CCD_HigherLevelKeys): The root keys for the chain.
        level1_keys (CCD_HigherLevelKeys): The level 1 keys for the chain.
        level2_keys (CCD_AuthorizationsV0): The level 2 keys for the chain.
    """

    election_difficulty: CCD_ElectionDifficulty
    euro_per_energy: CCD_ExchangeRate
    micro_ccd_per_euro: CCD_ExchangeRate
    baker_cooldown_epochs: CCD_Epoch
    account_creation_limit: CCD_CredentialsPerBlockLimit
    mint_distribution: CCD_MintDistributionCpv0
    transaction_fee_distribution: CCD_TransactionFeeDistribution
    gas_rewards: CCD_GasRewards
    foundation_account: CCD_AccountAddress
    minimum_threshold_for_baking: microCCD
    root_keys: CCD_HigherLevelKeys
    level1_keys: CCD_HigherLevelKeys
    level2_keys: CCD_AuthorizationsV0


class CCD_ChainParametersV1(BaseModel):
    """
    CCD_ChainParametersV1 is a model representing the chain parameters for a CCD (Concordium) blockchain.

    Attributes:
        election_difficulty (CCD_ElectionDifficulty): The difficulty level for elections.
        euro_per_energy (CCD_ExchangeRate): The exchange rate of euros per unit of energy.
        micro_ccd_per_euro (CCD_ExchangeRate): The exchange rate of micro CCD per euro.
        cooldown_parameters (CCD_CooldownParametersCpv1): Parameters for cooldown periods.
        time_parameters (CCD_TimeParametersCpv1): Parameters related to time settings.
        account_creation_limit (CCD_CredentialsPerBlockLimit): Limit on the number of accounts that can be created per block.
        mint_distribution (CCD_MintDistributionCpv1): Distribution parameters for minting.
        transaction_fee_distribution (CCD_TransactionFeeDistribution): Distribution parameters for transaction fees.
        gas_rewards (CCD_GasRewards): Rewards for gas usage.
        foundation_account (CCD_AccountAddress): The account address of the foundation.
        pool_parameters (CCD_PoolParametersCpv1): Parameters for the pool.
        root_keys (CCD_HigherLevelKeys): Higher level keys for root access.
        level1_keys (CCD_HigherLevelKeys): Higher level keys for level 1 access.
        level2_keys (CCD_AuthorizationsV1): Authorization keys for level 2 access.
    """

    election_difficulty: CCD_ElectionDifficulty
    euro_per_energy: CCD_ExchangeRate
    micro_ccd_per_euro: CCD_ExchangeRate
    cooldown_parameters: CCD_CooldownParametersCpv1
    time_parameters: CCD_TimeParametersCpv1
    account_creation_limit: CCD_CredentialsPerBlockLimit
    mint_distribution: CCD_MintDistributionCpv1
    transaction_fee_distribution: CCD_TransactionFeeDistribution
    gas_rewards: CCD_GasRewards
    foundation_account: CCD_AccountAddress
    pool_parameters: CCD_PoolParametersCpv1
    root_keys: CCD_HigherLevelKeys
    level1_keys: CCD_HigherLevelKeys
    level2_keys: CCD_AuthorizationsV1


class CCD_TimeOutParameters(BaseModel):
    """
    CCD_TimeOutParameters is a model that defines the parameters for timeout configurations.

    Attributes:
        timeout_base (CCD_Duration): The base duration for the timeout.
        timeout_increase (CCD_Ratio): The ratio by which the timeout increases.
        timeout_decrease (CCD_Ratio): The ratio by which the timeout decreases.
    """

    timeout_base: CCD_Duration
    timeout_increase: CCD_Ratio
    timeout_decrease: CCD_Ratio


class CCD_ConsensusParametersV1(BaseModel):
    """
    CCD_ConsensusParametersV1 is a model representing the consensus parameters for CCD.

    Attributes:
        timeout_parameters (CCD_TimeOutParameters): The timeout parameters for the consensus.
        min_block_time (CCD_Duration): The minimum block time for the consensus.
        block_energy_limit (CCD_Energy): The energy limit per block for the consensus.
    """

    timeout_parameters: CCD_TimeOutParameters
    min_block_time: CCD_Duration
    block_energy_limit: CCD_Energy


class CCD_GasRewardsV2(BaseModel):
    """
    CCD_GasRewardsV2 represents the gas rewards structure for version 2.

    Attributes:
        baker (CCD_AmountFraction): The fraction of gas rewards allocated to bakers.
        account_creation (CCD_AmountFraction): The fraction of gas rewards allocated for account creation.
        chain_update (CCD_AmountFraction): The fraction of gas rewards allocated for chain updates.
    """

    baker: CCD_AmountFraction
    account_creation: CCD_AmountFraction
    chain_update: CCD_AmountFraction


class CCD_ChainParametersV2(BaseModel):
    """
    CCD_ChainParametersV2 is a data model representing the parameters for a CCD chain.

    Attributes:
        consensus_parameters (CCD_ConsensusParametersV1): Parameters related to the consensus mechanism.
        euro_per_energy (CCD_ExchangeRate): Exchange rate from euro to energy.
        micro_ccd_per_euro (CCD_ExchangeRate): Exchange rate from micro CCD to euro.
        cooldown_parameters (CCD_CooldownParametersCpv1): Parameters related to cooldown periods.
        time_parameters (CCD_TimeParametersCpv1): Parameters related to time settings.
        account_creation_limit (CCD_CredentialsPerBlockLimit): Limit on the number of accounts that can be created per block.
        mint_distribution (CCD_MintDistributionCpv1): Distribution parameters for minting.
        transaction_fee_distribution (CCD_TransactionFeeDistribution): Distribution parameters for transaction fees.
        gas_rewards (CCD_GasRewardsV2): Parameters for gas rewards.
        foundation_account (CCD_AccountAddress): Address of the foundation account.
        pool_parameters (CCD_PoolParametersCpv1): Parameters for the pool.
        root_keys (CCD_HigherLevelKeys): Higher level keys for root access.
        level1_keys (CCD_HigherLevelKeys): Higher level keys for level 1 access.
        level2_keys (CCD_AuthorizationsV1): Authorization keys for level 2 access.
        finalization_committee_parameters (CCD_FinalizationCommitteeParameters): Parameters for the finalization committee.
    """

    consensus_parameters: CCD_ConsensusParametersV1
    euro_per_energy: CCD_ExchangeRate
    micro_ccd_per_euro: CCD_ExchangeRate
    cooldown_parameters: CCD_CooldownParametersCpv1
    time_parameters: CCD_TimeParametersCpv1
    account_creation_limit: CCD_CredentialsPerBlockLimit
    mint_distribution: CCD_MintDistributionCpv1
    transaction_fee_distribution: CCD_TransactionFeeDistribution
    gas_rewards: CCD_GasRewardsV2
    foundation_account: CCD_AccountAddress
    pool_parameters: CCD_PoolParametersCpv1
    root_keys: CCD_HigherLevelKeys
    level1_keys: CCD_HigherLevelKeys
    level2_keys: CCD_AuthorizationsV1
    finalization_committee_parameters: CCD_FinalizationCommitteeParameters


class CCD_ChainParametersV3(BaseModel):
    """
    CCD_ChainParametersV3 is a data model representing the chain parameters for CCD version 3.

    Attributes:
        consensus_parameters (CCD_ConsensusParametersV1): Parameters related to the consensus mechanism.
        euro_per_energy (CCD_ExchangeRate): Exchange rate from euro to energy.
        micro_ccd_per_euro (CCD_ExchangeRate): Exchange rate from micro CCD to euro.
        cooldown_parameters (CCD_CooldownParametersCpv1): Parameters related to cooldown periods.
        time_parameters (CCD_TimeParametersCpv1): Parameters related to time settings.
        account_creation_limit (CCD_CredentialsPerBlockLimit): Limit on the number of accounts that can be created per block.
        mint_distribution (CCD_MintDistributionCpv1): Distribution parameters for minting.
        transaction_fee_distribution (CCD_TransactionFeeDistribution): Distribution parameters for transaction fees.
        gas_rewards (CCD_GasRewardsV2): Parameters for gas rewards.
        foundation_account (CCD_AccountAddress): Address of the foundation account.
        pool_parameters (CCD_PoolParametersCpv1): Parameters related to the pool.
        root_keys (CCD_HigherLevelKeys): Higher level keys for root access.
        level1_keys (CCD_HigherLevelKeys): Higher level keys for level 1 access.
        level2_keys (CCD_AuthorizationsV1): Authorization keys for level 2 access.
        finalization_committee_parameters (CCD_FinalizationCommitteeParameters): Parameters for the finalization committee.
        validator_score_parameters (CCD_ValidatorScoreParameters): Parameters for validator scoring.
    """

    consensus_parameters: CCD_ConsensusParametersV1
    euro_per_energy: CCD_ExchangeRate
    micro_ccd_per_euro: CCD_ExchangeRate
    cooldown_parameters: CCD_CooldownParametersCpv1
    time_parameters: CCD_TimeParametersCpv1
    account_creation_limit: CCD_CredentialsPerBlockLimit
    mint_distribution: CCD_MintDistributionCpv1
    transaction_fee_distribution: CCD_TransactionFeeDistribution
    gas_rewards: CCD_GasRewardsV2
    foundation_account: CCD_AccountAddress
    pool_parameters: CCD_PoolParametersCpv1
    root_keys: CCD_HigherLevelKeys
    level1_keys: CCD_HigherLevelKeys
    level2_keys: CCD_AuthorizationsV1
    finalization_committee_parameters: CCD_FinalizationCommitteeParameters
    validator_score_parameters: CCD_ValidatorScoreParameters


class CCD_ChainParameters(BaseModel):
    """
    CCD_ChainParameters is a model that represents the chain parameters for different versions.

    Attributes:
        v0 (Optional[CCD_ChainParametersV0]): Chain parameters for version 0.
        v1 (Optional[CCD_ChainParametersV1]): Chain parameters for version 1.
        v2 (Optional[CCD_ChainParametersV2]): Chain parameters for version 2.
        v3 (Optional[CCD_ChainParametersV3]): Chain parameters for version 3.
    """

    v0: Optional[CCD_ChainParametersV0] = None
    v1: Optional[CCD_ChainParametersV1] = None
    v2: Optional[CCD_ChainParametersV2] = None
    v3: Optional[CCD_ChainParametersV3] = None


class CCD_InvokeInstanceResponse_Success(BaseModel):
    """
    Represents a successful response from invoking a CCD instance.

    Attributes:
        return_value (bytes): The return value of the invoked instance.
        used_energy (CCD_Energy): The amount of energy used during the invocation.
        effects (list[CCD_ContractTraceElement]): A list of contract trace elements that describe the effects of the invocation.
    """

    return_value: bytes
    used_energy: CCD_Energy
    effects: list[CCD_ContractTraceElement]


class CCD_InvokeInstanceResponse_Failure(BaseModel):
    """
    Represents a failure response for invoking a CCD instance.

    Attributes:
        return_value (bytes): The return value of the invocation.
        used_energy (CCD_Energy): The amount of energy used during the invocation.
        reason (CCD_RejectReason): The reason for the failure.
    """

    return_value: bytes
    used_energy: CCD_Energy
    reason: CCD_RejectReason


class CCD_InvokeInstanceResponse(BaseModel):
    """
    CCD_InvokeInstanceResponse is a model that represents the response of invoking an instance.

    Attributes:
        success (CCD_InvokeInstanceResponse_Success): Represents a successful invocation response.
        failure (CCD_InvokeInstanceResponse_Failure): Represents a failed invocation response.
    """

    success: CCD_InvokeInstanceResponse_Success
    failure: CCD_InvokeInstanceResponse_Failure


class CCD_BlockComplete(BaseModel):
    """
    CCD_BlockComplete represents a complete block in the CCD system.

    Attributes:
        block_info (CCD_BlockInfo): Information about the block.
        transaction_summaries (list[CCD_BlockItemSummary]): Summaries of the transactions in the block.
        special_events (list[CCD_BlockSpecialEvent]): Special events associated with the block.
        logged_events (Optional[list]): Logged events related to the block. This attribute is optional and may lead to circular imports if specific types are used.
        net (Optional[str]): Network identifier. This attribute is optional.
    """

    block_info: CCD_BlockInfo
    transaction_summaries: list[CCD_BlockItemSummary]
    special_events: list[CCD_BlockSpecialEvent]
    # This leads to circular import
    # logged_events: Optional[list[MongoTypeLoggedEvent]] = None
    logged_events: Optional[list] = None

    net: Optional[str] = None


class CCD_FinalizerIndex(BaseModel):
    """
    CCD_FinalizerIndex is a model representing an index for a finalizer.

    Attributes:
        value (Optional[int]): An optional integer representing the index value.
    """

    value: Optional[int] = None


class CCD_QuorumSignature(BaseModel):
    """
    CCD_QuorumSignature represents a quorum signature in the CCD system.

    Attributes:
        value (bytes): The byte representation of the quorum signature.
    """

    value: bytes


class CCD_TimeoutSignature(BaseModel):
    """
    CCD_TimeoutSignature is a model representing a timeout signature in CCD.

    Attributes:
        value (bytes): The byte representation of the timeout signature.
    """

    value: bytes


class CCD_SuccessorProof(BaseModel):
    """
    CCD_SuccessorProof is a model representing a successor proof in the CCD system.

    Attributes:
        value (bytes): The byte representation of the successor proof.
    """

    value: bytes


class CCD_QuorumMessage(BaseModel):
    """
    CCD_QuorumMessage represents a message in the CCD quorum.

    Attributes:
        signature (Optional[CCD_QuorumSignature]): The signature of the quorum message.
        block (Optional[CCD_BlockHash]): The hash of the block associated with the quorum message.
        finalizer (Optional[CCD_FinalizerIndex]): The index of the finalizer.
        round (Optional[CCD_Round]): The round number of the quorum message.
        epoch (Optional[CCD_Epoch]): The epoch number of the quorum message.
    """

    signature: Optional[CCD_QuorumSignature] = None
    block: Optional[CCD_BlockHash] = None
    finalizer: Optional[CCD_FinalizerIndex] = None
    round: Optional[CCD_Round] = None
    epoch: Optional[CCD_Epoch] = None


class CCD_RawQuorumCertificate(BaseModel):
    """
    CCD_RawQuorumCertificate represents a raw quorum certificate in the CCD system.

    Attributes:
        block (Optional[CCD_BlockHash]): The hash of the block associated with the quorum certificate.
        round (Optional[CCD_Round]): The round number in which the quorum certificate was created.
        epoch (Optional[CCD_Epoch]): The epoch number in which the quorum certificate was created.
        aggregate_signature (Optional[CCD_QuorumSignature]): The aggregate signature of the quorum certificate.
        signatories (Optional[list[CCD_FinalizerIndex]]): The list of finalizer indices that signed the quorum certificate.
    """

    block: Optional[CCD_BlockHash] = None
    round: Optional[CCD_Round] = None
    epoch: Optional[CCD_Epoch] = None
    aggregate_signature: Optional[CCD_QuorumSignature] = None
    signatories: Optional[list[CCD_FinalizerIndex]] = None


class CCD_BlockSignature(BaseModel):
    """
    CCD_BlockSignature represents a block signature in the CCD system.

    Attributes:
        value (bytes): The signature value in bytes.
    """

    value: bytes


class CCD_TimeoutMessage(BaseModel):
    """
    CCD_TimeoutMessage represents a timeout message in the CCD protocol.

    Attributes:
        finalizer (Optional[CCD_FinalizerIndex]): The finalizer index associated with the timeout message.
        round (Optional[CCD_Round]): The round number at which the timeout occurred.
        epoch (Optional[CCD_Epoch]): The epoch number at which the timeout occurred.
        quorum_certificate (Optional[CCD_RawQuorumCertificate]): The quorum certificate associated with the timeout message.
        signature (Optional[CCD_TimeoutSignature]): The signature of the timeout message.
        message_signature (Optional[CCD_BlockSignature]): The block signature of the timeout message.
    """

    finalizer: Optional[CCD_FinalizerIndex] = None
    round: Optional[CCD_Round] = None
    epoch: Optional[CCD_Epoch] = None
    quorum_certificate: Optional[CCD_RawQuorumCertificate] = None
    signature: Optional[CCD_TimeoutSignature] = None
    message_signature: Optional[CCD_BlockSignature] = None


class CCD_RawFinalizerRound(BaseModel):
    """
    CCD_RawFinalizerRound represents a model for a raw finalizer round in the CCD system.

    Attributes:
        round (Optional[CCD_Round]): The round information, which may be None.
        finalizers (Optional[list[CCD_FinalizerIndex]]): A list of finalizer indices, which may be None.
    """

    round: Optional[CCD_Round] = None
    finalizers: Optional[list[CCD_FinalizerIndex]] = None


class CCD_RawTimeoutCertificate(BaseModel):
    """
    CCD_RawTimeoutCertificate represents a raw timeout certificate in the CCD system.

    Attributes:
        round (Optional[CCD_Round]): The round associated with the timeout certificate.
        min_epoch (Optional[CCD_Epoch]): The minimum epoch associated with the timeout certificate.
        qc_rounds_first_epoch (Optional[list[CCD_RawFinalizerRound]]): List of finalizer rounds for the first epoch.
        qc_rounds_second_epoch (Optional[list[CCD_RawFinalizerRound]]): List of finalizer rounds for the second epoch.
    """

    round: Optional[CCD_Round] = None
    min_epoch: Optional[CCD_Epoch] = None
    qc_rounds_first_epoch: Optional[list[CCD_RawFinalizerRound]] = None
    qc_rounds_second_epoch: Optional[list[CCD_RawFinalizerRound]] = None


class CCD_PersistentRoundStatus(BaseModel):
    """
    CCD_PersistentRoundStatus is a data model representing the persistent status of a round in the CCD system.

    Attributes:
        last_signed_quorum_message (Optional[CCD_QuorumMessage]): The last signed quorum message.
        last_signed_timeout_message (Optional[CCD_TimeoutMessage]): The last signed timeout message.
        last_baked_round (Optional[CCD_Round]): The last baked round.
        latest_timeout (Optional[CCD_RawTimeoutCertificate]): The latest timeout certificate.
    """

    last_signed_quorum_message: Optional[CCD_QuorumMessage] = None
    last_signed_timeout_message: Optional[CCD_TimeoutMessage] = None
    last_baked_round: Optional[CCD_Round] = None
    latest_timeout: Optional[CCD_RawTimeoutCertificate] = None


class CCD_RoundTimeout(BaseModel):
    """
    CCD_RoundTimeout represents a timeout event in the CCD system.

    Attributes:
        timeout_certificate (Optional[CCD_RawTimeoutCertificate]): The certificate indicating a timeout has occurred.
        quorum_certificate (Optional[CCD_RawQuorumCertificate]): The certificate indicating a quorum has been reached.
    """

    timeout_certificate: Optional[CCD_RawTimeoutCertificate] = None
    quorum_certificate: Optional[CCD_RawQuorumCertificate] = None


class CCD_RawFinalizationEntry(BaseModel):
    """
    Represents a raw finalization entry in the CCD system.

    Attributes:
        finalized_qc (Optional[CCD_RawQuorumCertificate]): The finalized quorum certificate.
        successor_qc (Optional[CCD_RawQuorumCertificate]): The successor quorum certificate.
        successor_proof (Optional[CCD_SuccessorProof]): The proof of the successor.
    """

    finalized_qc: Optional[CCD_RawQuorumCertificate] = None
    successor_qc: Optional[CCD_RawQuorumCertificate] = None
    successor_proof: Optional[CCD_SuccessorProof] = None


class CCD_RoundStatus(BaseModel):
    """
    CCD_RoundStatus represents the status of a round in the CCD system.

    Attributes:
        current_round (Optional[CCD_Round]): The current round in progress.
        highest_certified_block (Optional[CCD_RawQuorumCertificate]): The highest certified block in the current round.
        previous_round_timeout (Optional[CCD_RoundTimeout]): The timeout of the previous round.
        round_eligible_to_bake (bool): Indicates if the current round is eligible to bake.
        current_epoch (Optional[CCD_Epoch]): The current epoch in progress.
        last_epoch_finalization_entry (Optional[CCD_RawFinalizationEntry]): The finalization entry of the last epoch.
        current_timeout (Optional[CCD_Duration]): The current timeout duration.
    """

    current_round: Optional[CCD_Round] = None
    highest_certified_block: Optional[CCD_RawQuorumCertificate] = None
    previous_round_timeout: Optional[CCD_RoundTimeout] = None
    round_eligible_to_bake: bool
    current_epoch: Optional[CCD_Epoch] = None
    last_epoch_finalization_entry: Optional[CCD_RawFinalizationEntry] = None
    current_timeout: Optional[CCD_Duration] = None


class CCD_BlockTableSummary(BaseModel):
    """
    CCD_BlockTableSummary represents a summary of the block table in the CCD system.

    Attributes:
        dead_block_cache_size (Optional[int]): The size of the dead block cache. Defaults to None.
        live_blocks (Optional[list[CCD_BlockHash]]): A list of live block hashes. Defaults to None.
    """

    dead_block_cache_size: Optional[int] = None
    live_blocks: Optional[list[CCD_BlockHash]] = None


class CCD_BranchBlocks(BaseModel):
    """
    CCD_BranchBlocks is a model representing the blocks at a specific branch height in a CCD (Concordium) blockchain.

    Attributes:
        blocks_at_branch_height (Optional[list[CCD_BlockHash]]): A list of block hashes at the branch height. Defaults to None.
    """

    blocks_at_branch_height: Optional[list[CCD_BlockHash]] = None


class CCD_RoundExistingBlock(BaseModel):
    """
    CCD_RoundExistingBlock represents an existing block in a CCD round.

    Attributes:
        round (Optional[CCD_Round]): The round associated with the block.
        baker (Optional[CCD_BakerId]): The baker ID associated with the block.
        block (Optional[CCD_BlockHash]): The hash of the block.
    """

    round: Optional[CCD_Round] = None
    baker: Optional[CCD_BakerId] = None
    block: Optional[CCD_BlockHash] = None


class CCD_RoundExistingQC(BaseModel):
    """
    CCD_RoundExistingQC is a model representing the existing quality control data for a CCD round.

    Attributes:
        round (Optional[CCD_Round]): The CCD round information. Defaults to None.
        epoch (Optional[CCD_Epoch]): The CCD epoch information. Defaults to None.
    """

    round: Optional[CCD_Round] = None
    epoch: Optional[CCD_Epoch] = None


class CCD_FullBakerInfo(BaseModel):
    """
    CCD_FullBakerInfo is a model representing the full information of a baker in the CCD system.

    Attributes:
        baker_identity (Optional[CCD_BakerId]): The identity of the baker.
        election_verify_key (Optional[CCD_BakerElectionVerifyKey]): The election verification key of the baker.
        signature_verify_key (Optional[CCD_BakerSignatureVerifyKey]): The signature verification key of the baker.
        aggregation_verify_key (Optional[CCD_BakerAggregationVerifyKey]): The aggregation verification key of the baker.
        stake (Optional[microCCD]): The stake of the baker in microCCD.
    """

    baker_identity: Optional[CCD_BakerId] = None
    election_verify_key: Optional[CCD_BakerElectionVerifyKey] = None
    signature_verify_key: Optional[CCD_BakerSignatureVerifyKey] = None
    aggregation_verify_key: Optional[CCD_BakerAggregationVerifyKey] = None
    stake: Optional[microCCD] = None


class CCD_FinalizationCommitteeHash(BaseModel):
    """
    CCD_FinalizationCommitteeHash is a model representing a hash value used by the finalization committee.

    Attributes:
        value (bytes): The hash value as a byte sequence.
    """

    value: bytes


class CCD_BakersAndFinalizers(BaseModel):
    """
    CCD_BakersAndFinalizers represents the information about bakers and finalizers in the CCD network.

    Attributes:
        bakers (Optional[list[CCD_FullBakerInfo]]): A list of full baker information.
        finalizers (Optional[list[CCD_BakerId]]): A list of finalizer IDs.
        baker_total_stake (Optional[microCCD]): The total stake of all bakers.
        finalizer_total_stake (Optional[microCCD]): The total stake of all finalizers.
        finalization_committee_hash (Optional[CCD_FinalizationCommitteeHash]): The hash of the finalization committee.
    """

    bakers: Optional[list[CCD_FullBakerInfo]] = None
    finalizers: Optional[list[CCD_BakerId]] = None
    baker_total_stake: Optional[microCCD] = None
    finalizer_total_stake: Optional[microCCD] = None
    finalization_committee_hash: Optional[CCD_FinalizationCommitteeHash] = None


class CCD_EpochBakers(BaseModel):
    """
    CCD_EpochBakers is a model representing the bakers and finalizers for different epochs in a CCD (Concordium) blockchain.

    Attributes:
        previous_epoch_bakers (Optional[CCD_BakersAndFinalizers]): Bakers and finalizers for the previous epoch.
        current_epoch_bakers (Optional[CCD_BakersAndFinalizers]): Bakers and finalizers for the current epoch.
        next_epoch_bakers (Optional[CCD_BakersAndFinalizers]): Bakers and finalizers for the next epoch.
        next_payday (Optional[CCD_Epoch]): The next payday epoch.
    """

    previous_epoch_bakers: Optional[CCD_BakersAndFinalizers] = None
    current_epoch_bakers: Optional[CCD_BakersAndFinalizers] = None
    next_epoch_bakers: Optional[CCD_BakersAndFinalizers] = None
    next_payday: Optional[CCD_Epoch] = None


class CCD_TimeoutMessages(BaseModel):
    """
    CCD_TimeoutMessages is a model representing timeout messages for different epochs.

    Attributes:
        first_epoch (Optional[CCD_Epoch]): The first epoch associated with the timeout messages.
        first_epoch_timeouts (Optional[list[CCD_TimeoutMessage]]): List of timeout messages for the first epoch.
        second_epoch_timeouts (Optional[list[CCD_TimeoutMessage]]): List of timeout messages for the second epoch.
    """

    first_epoch: Optional[CCD_Epoch] = None
    first_epoch_timeouts: Optional[list[CCD_TimeoutMessage]] = None
    second_epoch_timeouts: Optional[list[CCD_TimeoutMessage]] = None


class CCD_AggregatedSignatures(BaseModel):
    """
    CCD_AggregatedSignatures represents the aggregated signatures in a CCD (Concordium) blockchain context.

    Attributes:
        signed_block (Optional[CCD_BlockHash]): The hash of the signed block.
        signature_weight (Optional[microCCD]): The weight of the signature.
        aggregate_signature (Optional[CCD_QuorumSignature]): The aggregate signature.
        signatories (Optional[list[CCD_FinalizerIndex]]): The list of finalizer indices who signed the block.
    """

    signed_block: Optional[CCD_BlockHash] = None
    signature_weight: Optional[microCCD] = None
    aggregate_signature: Optional[CCD_QuorumSignature] = None
    signatories: Optional[list[CCD_FinalizerIndex]] = None


class CCD_QuorumMessages(BaseModel):
    """
    CCD_QuorumMessages is a model representing quorum messages and aggregated signatures.

    Attributes:
        quorum_messages (Optional[list[CCD_QuorumMessage]]): A list of quorum messages.
        aggregated_signatures (Optional[list[CCD_AggregatedSignatures]]): A list of aggregated signatures.
    """

    quorum_messages: Optional[list[CCD_QuorumMessage]] = None
    aggregated_signatures: Optional[list[CCD_AggregatedSignatures]] = None


class CCD_ConsensusDetailedStatusQuery(BaseModel):
    """
    CCD_ConsensusDetailedStatusQuery is a model representing a detailed status query for CCD consensus.

    Attributes:
        genesis_index (Optional[int]): The index of the genesis block. Defaults to None.
    """

    genesis_index: Optional[int] = None


class CCD_ConsensusDetailedStatus(BaseModel):
    """
    Represents the detailed status of the CCD consensus.

    Attributes:
        genesis_block (Optional[CCD_BlockHash]): The hash of the genesis block.
        persistent_round_status (Optional[CCD_PersistentRoundStatus]): The status of the persistent round.
        round_status (Optional[CCD_RoundStatus]): The status of the current round.
        non_finalized_transaction_count (Optional[int]): The count of non-finalized transactions.
        transaction_table_purge_counter (Optional[int]): The counter for purging the transaction table.
        block_table (Optional[CCD_BlockTableSummary]): Summary of the block table.
        branches (Optional[list[CCD_BranchBlocks]]): List of branch blocks.
        round_existing_blocks (Optional[list[CCD_RoundExistingBlock]]): List of existing blocks in the current round.
        round_existing_qcs (Optional[list[CCD_RoundExistingQC]]): List of existing QCs in the current round.
        genesis_block_height (Optional[int]): The height of the genesis block.
        last_finalized_block (Optional[CCD_BlockHash]): The hash of the last finalized block.
        last_finalized_block_height (Optional[int]): The height of the last finalized block.
        latest_finalization_entry (Optional[CCD_RawFinalizationEntry]): The latest finalization entry.
        epoch_bakers (Optional[CCD_EpochBakers]): The epoch bakers.
        timeout_messages (Optional[CCD_TimeoutMessages]): The timeout messages.
        terminal_block (Optional[CCD_BlockHash]): The hash of the terminal block.
    """

    genesis_block: Optional[CCD_BlockHash] = None
    persistent_round_status: Optional[CCD_PersistentRoundStatus] = None
    round_status: Optional[CCD_RoundStatus] = None
    non_finalized_transaction_count: Optional[int] = None
    transaction_table_purge_counter: Optional[int] = None
    block_table: Optional[CCD_BlockTableSummary] = None
    branches: Optional[list[CCD_BranchBlocks]] = None
    round_existing_blocks: Optional[list[CCD_RoundExistingBlock]] = None
    round_existing_qcs: Optional[list[CCD_RoundExistingQC]] = None
    genesis_block_height: Optional[int] = None
    last_finalized_block: Optional[CCD_BlockHash] = None
    last_finalized_block_height: Optional[int] = None
    latest_finalization_entry: Optional[CCD_RawFinalizationEntry] = None
    epoch_bakers: Optional[CCD_EpochBakers] = None
    timeout_messages: Optional[CCD_TimeoutMessages] = None
    terminal_block: Optional[CCD_BlockHash] = None


class CCD_AccountPending(BaseModel):
    """
    CCD_AccountPending represents an account that is pending with optional attributes.

    Attributes:
        account_index (Optional[CCD_AccountIndex]): The index of the account.
        first_timestamp (Optional[CCD_TimeStamp]): The first timestamp associated with the account.
    """

    account_index: Optional[CCD_AccountIndex] = None
    first_timestamp: Optional[CCD_TimeStamp] = None
