# generated by datamodel-codegen:
#   filename:  cardano.json
#   timestamp: 2023-10-18T20:09:32+00:00

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union

from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr


class Cardano(BaseModel):
    __root__: Any = Field(..., title='Cardano')


class Address(BaseModel):
    __root__: constr(regex=r'[1-9A-HJ-NP-Za-km-z]*') = Field(
        ...,
        description='A Cardano address (either legacy format or new format).',
        examples=[
            'addr1q9d34spgg2kdy47n82e7x9pdd6vql6d2engxmpj20jmhuc2047yqd4xnh7u6u5jp4t0q3fkxzckph4tgnzvamlu7k5psuahzcp',
            'DdzFFzCqrht8mbSTZHqpM2u4HeND2mdspsaBhdQ1BowPJBMzbDeBMeKgqdoKqo1D4sdPusEdZJVrFJRBBxX1jUEofNDYCJSZLg8MkyCE',
        ],
        title='Address',
    )


class AddressAttributes(BaseModel):
    __root__: str = Field(
        ...,
        description='Extra attributes carried by Byron addresses (network magic and/or HD payload).',
        title='AddressAttributes',
    )


class DigestAny(BaseModel):
    __root__: str = Field(
        ...,
        description='A hash digest from an unspecified algorithm and length.',
        examples=['90181c517a5beadc9c3fe64bf8'],
        title='Digest<Any>',
    )


class AssetQuantity(BaseModel):
    __root__: int = Field(
        ...,
        description='A number of asset, can be negative went burning assets.',
        title='AssetQuantity',
    )


class Assets(BaseModel):
    __root__: Optional[Dict[str, Dict[str, AssetQuantity]]] = None


class Type(Enum):
    ebb = 'ebb'


class Era(Enum):
    byron = 'byron'


class DigestBlake2b256(BaseModel):
    __root__: constr(min_length=64, max_length=64) = Field(
        ...,
        description='A Blake2b 32-byte hash digest, encoded in base16.',
        examples=['c248757d390181c517a5beadc9c3fe64bf821d3e889a963fc717003ec248757d'],
        title='Digest<Blake2b, 256>',
    )


class Type1(Enum):
    bft = 'bft'


class BlockHeight(BaseModel):
    __root__: conint(ge=0, le=18446744073709552999) = Field(
        ...,
        description='A block number, the i-th block to be minted is number i.',
        title='BlockHeight',
    )


class Type2(Enum):
    praos = 'praos'


class Era2(Enum):
    shelley = 'shelley'
    allegra = 'allegra'
    mary = 'mary'
    alonzo = 'alonzo'
    babbage = 'babbage'


class AncestorEnum(Enum):
    genesis = 'genesis'


class VrfProof(BaseModel):
    __root__: str = Field(..., title='VrfProof')


class UInt32(BaseModel):
    __root__: conint(ge=0, le=4294967295) = Field(..., title='UInt32')


class VerificationKey(BaseModel):
    __root__: constr(min_length=64, max_length=64) = Field(
        ..., description='An Ed25519 verification key.', title='VerificationKey'
    )


class BootstrapProtocolId(BaseModel):
    __root__: conint(ge=0, le=4294967295) = Field(
        ..., examples=[764824073], title='BootstrapProtocolId'
    )


class Ratio(BaseModel):
    __root__: constr(regex=r'^-?[0-9]+/[0-9]+$') = Field(
        ...,
        description='A ratio of two integers, to express exact fractions.',
        examples=['2/3', '7/8'],
        title='Ratio',
    )


class Voter(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: ExtendedVerificationKey  # Edited


class Proposal1(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b256


class BootstrapVote(BaseModel):
    class Config:
        extra = Extra.forbid

    voter: Voter
    proposal: Proposal1


class RelativeTime(BaseModel):
    class Config:
        extra = Extra.forbid

    seconds: int


class Type3(Enum):
    stakeDelegation = 'stakeDelegation'


class Type4(Enum):
    stakeCredentialRegistration = 'stakeCredentialRegistration'


class Type5(Enum):
    stakeCredentialDeregistration = 'stakeCredentialDeregistration'


class Type6(Enum):
    stakePoolRegistration = 'stakePoolRegistration'


class Type7(Enum):
    stakePoolRetirement = 'stakePoolRetirement'


class Type8(Enum):
    genesisDelegation = 'genesisDelegation'


class Type9(Enum):
    constitutionalCommitteeHotKeyRegistration = 'constitutionalCommitteeHotKeyRegistration'


class Type10(Enum):
    constitutionalCommitteeRetirement = 'constitutionalCommitteeRetirement'


class Type11(Enum):
    delegateRepresentativeRegistration = 'delegateRepresentativeRegistration'


class Type12(Enum):
    delegateRepresentativeRetirement = 'delegateRepresentativeRetirement'


class DigestBlake2b224(BaseModel):
    __root__: constr(min_length=56, max_length=56) = Field(
        ...,
        description='A Blake2b 28-byte hash digest, encoded in base16.',
        examples=['90181c517a5beadc9c3fe64bf821d3e889a963fc717003ec248757d3'],
        title='Digest<Blake2b, 224>',
    )


class ChainCode(BaseModel):
    __root__: str = Field(
        ..., description='An Ed25519-BIP32 chain-code for key deriviation.', title='ChainCode'
    )


class ConstitutionalCommitteeMember(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224


class Int64(BaseModel):
    __root__: conint(ge=-9223372036854775808, le=9223372036854775807) = Field(..., title='Int64')


class Datum(BaseModel):
    __root__: str = Field(..., title='Datum')


class Type13(Enum):
    registered = 'registered'


class DelegateRepresentativeItem(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224
    type: Type13


class Type14(Enum):
    noConfidence = 'noConfidence'


class DelegateRepresentativeItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type14 = Field(
        ...,
        description='A special delegate representative which always vote no, except on votes of no-confidence.',
    )


class Type15(Enum):
    abstain = 'abstain'


class DelegateRepresentativeItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type15 = Field(..., description='A special delegate representative which always abstain.')


class DelegateRepresentative(BaseModel):
    __root__: Union[
        DelegateRepresentativeItem, DelegateRepresentativeItem1, DelegateRepresentativeItem2
    ] = Field(..., title='DelegateRepresentative')


class Epoch(BaseModel):
    __root__: conint(ge=0, le=18446744073709552000) = Field(
        ..., description='An epoch number or length.', title='Epoch'
    )


class Era3(Enum):
    byron = 'byron'
    shelley = 'shelley'
    allegra = 'allegra'
    mary = 'mary'
    alonzo = 'alonzo'
    babbage = 'babbage'
    conway = 'conway'


class EraWithGenesis(Enum):
    byron = 'byron'
    shelley = 'shelley'
    alonzo = 'alonzo'
    conway = 'conway'


class SlotLength(BaseModel):
    class Config:
        extra = Extra.forbid

    milliseconds: int


class UInt64(BaseModel):
    __root__: conint(ge=0, le=18446744073709552999) = Field(..., title='UInt64')


class Era4(Enum):
    byron = 'byron'


class UtcTime(BaseModel):
    __root__: datetime = Field(..., title='UtcTime')


class Era5(Enum):
    shelley = 'shelley'


class NetworkMagic(BaseModel):
    __root__: conint(ge=0, le=4294967296) = Field(
        ...,
        description='A magic number for telling networks apart. (e.g. 764824073)',
        examples=[764824073],
        title='NetworkMagic',
    )


class Era6(Enum):
    alonzo = 'alonzo'


class NumberOfBytes(BaseModel):
    class Config:
        extra = Extra.forbid

    bytes: Int64


class Era7(Enum):
    conway = 'conway'


class Issuer4(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224


class GenesisDelegate(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224
    vrfVerificationKeyHash: DigestBlake2b256


class StakePoolId(BaseModel):
    __root__: constr(regex=r'^pool1[0-9a-z]*$') = Field(
        ...,
        description="A Blake2b 32-byte hash digest of a pool's verification key.",
        examples=[
            'pool1qqqqpanw9zc0rzh0yp247nzf2s35uvnsm7aaesfl2nnejaev0uc',
            'pool1qqqqqdk4zhsjuxxd8jyvwncf5eucfskz0xjjj64fdmlgj735lr9',
        ],
        title='StakePoolId',
    )


class Type16(Enum):
    protocolParametersUpdate = 'protocolParametersUpdate'


class Type17(Enum):
    hardForkInitiation = 'hardForkInitiation'


class Type18(Enum):
    treasuryTransfer = 'treasuryTransfer'


class Source(Enum):
    reserves = 'reserves'
    treasury = 'treasury'


class Target(Enum):
    reserves = 'reserves'
    treasury = 'treasury'


class Type19(Enum):
    treasuryWithdrawals = 'treasuryWithdrawals'


class Type20(Enum):
    constitutionalCommittee = 'constitutionalCommittee'


class GovernanceActionItem4(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type20
    members: ConstitutionalCommitteeMember
    quorum: Ratio


class Type21(Enum):
    constitution = 'constitution'


class GovernanceActionItem5(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type21
    hash: DigestBlake2b256


class Type22(Enum):
    noConfidence = 'noConfidence'


class GovernanceActionItem6(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type22


class Type23(Enum):
    information = 'information'


class GovernanceActionItem7(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type23


class Lovelace(BaseModel):
    class Config:
        extra = Extra.forbid

    lovelace: int = Field(..., description='A number of lovelace, possibly large when summed up.')


class TransactionId(BaseModel):
    __root__: constr(min_length=64, max_length=64) = Field(
        ...,
        description='A Blake2b 32-byte hash digest of a transaction body',
        title='TransactionId',
    )


class Vote(Enum):
    yes = 'yes'
    no = 'no'
    abstain = 'abstain'


class Role(Enum):
    genesisDelegate = 'genesisDelegate'


class GovernanceVoterItem(BaseModel):
    class Config:
        extra = Extra.forbid

    role: Role
    id: DigestBlake2b224


class Role1(Enum):
    constitutionalCommittee = 'constitutionalCommittee'


class GovernanceVoterItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    role: Role1
    id: DigestBlake2b224


class Role2(Enum):
    delegateRepresentative = 'delegateRepresentative'


class GovernanceVoterItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    role: Role2
    id: DigestBlake2b224


class Role3(Enum):
    stakePoolOperator = 'stakePoolOperator'


class GovernanceVoterItem3(BaseModel):
    class Config:
        extra = Extra.forbid

    role: Role3
    id: StakePoolId


class GovernanceVoter(BaseModel):
    __root__: Union[
        GovernanceVoterItem, GovernanceVoterItem1, GovernanceVoterItem2, GovernanceVoterItem3
    ]


class ExtendedVerificationKey(BaseModel):
    __root__: constr(min_length=128, max_length=128) = Field(
        ...,
        description='An Ed25519-BIP32 Byron genesis delegate verification key with chain-code.',
        title='ExtendedVerificationKey',
    )


class InputSource(Enum):
    inputs = 'inputs'
    collaterals = 'collaterals'


class Language(Enum):
    plutus_v1 = 'plutus:v1'
    plutus_v2 = 'plutus:v2'
    plutus_v3 = 'plutus:v3'


class LovelaceDelta(BaseModel):
    class Config:
        extra = Extra.forbid

    lovelace: conint(ge=-9223372036854775808, le=9223372036854775807) = Field(
        ..., description='An amount, possibly negative, in Lovelace (1e6 Lovelace = 1 Ada).'
    )


class KesVerificationKey(BaseModel):
    __root__: str = Field(..., title='KesVerificationKey')


class Metadatum(BaseModel):
    __root__: Union[int, str, List[Metadatum], Dict[str, Metadatum]] = Field(..., title='Metadatum')


class Network(Enum):
    mainnet = 'mainnet'
    testnet = 'testnet'


class NonceEnum(Enum):
    neutral = 'neutral'


class Nonce(BaseModel):
    __root__: Union[NonceEnum, DigestBlake2b256] = Field(..., title='Nonce')


class Null(BaseModel):
    __root__: None


class Kes(BaseModel):
    class Config:
        extra = Extra.forbid

    period: UInt64
    verificationKey: KesVerificationKey


class OperationalCertificate(BaseModel):
    class Config:
        extra = Extra.forbid

    count: UInt64
    kes: Kes


class Origin(Enum):
    origin = 'origin'


class PolicyId(BaseModel):
    __root__: DigestBlake2b224 = Field(..., title='PolicyId')


class ScriptExecutionPrices(BaseModel):
    class Config:
        extra = Extra.forbid

    memory: Ratio
    cpu: Ratio


class RedeemerData(BaseModel):
    __root__: str = Field(..., description='Plutus data, CBOR-serialised.', title='RedeemerData')


class RedeemerPointer(BaseModel):
    __root__: constr(regex=r'^(spend|mint|certificate|withdrawal):[0-9]+$') = Field(
        ..., title='RedeemerPointer'
    )


class Type24(Enum):
    ipAddress = 'ipAddress'


class RelayItem(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type24
    ipv4: Optional[str] = None
    ipv6: Optional[str] = None
    port: Optional[conint(ge=0, le=65535)] = None


class Type25(Enum):
    hostname = 'hostname'


class RelayItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type25
    hostname: str
    port: Optional[conint(ge=0, le=65535)] = None


class Relay(BaseModel):
    __root__: Union[RelayItem, RelayItem1] = Field(..., title='Relay')


class RewardAccount(BaseModel):
    __root__: constr(regex=r'^stake(_test)?1[0-9a-z]+$') = Field(
        ...,
        description="A reward account, also known as 'stake address'.",
        examples=['stake1ux7pt9adw8z46tgqn2f8fvurrhk325gcm4mf75mkmmxpx6gae9mzv'],
        title='RewardAccount',
    )


class RewardTransfer(BaseModel):
    __root__: Optional[Dict[str, LovelaceDelta]] = None


class SafeZone(BaseModel):
    __root__: conint(ge=0, le=18446744073709552999) = Field(
        ...,
        description='Number of slots from the tip of the ledger in which it is guaranteed that no hard fork can take place. This should be (at least) the number of slots in which we are guaranteed to have k blocks.',
        title='SafeZone',
    )


class Language1(Enum):
    native = 'native'


class Language2(Enum):
    plutus_v1 = 'plutus:v1'
    plutus_v2 = 'plutus:v2'
    plutus_v3 = 'plutus:v3'


class ScriptItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    language: Language2
    cbor: str


class Clause(Enum):
    signature = 'signature'


class ScriptNativeItem(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause
    from_: DigestBlake2b224 = Field(..., alias='from')


class Clause1(Enum):
    any = 'any'


class Clause2(Enum):
    all = 'all'


class Clause3(Enum):
    some = 'some'


class Clause4(Enum):
    before = 'before'


class Clause5(Enum):
    after = 'after'


class Slot(BaseModel):
    __root__: conint(ge=0, le=18446744073709552000) = Field(
        ..., description='An absolute slot number.', title='Slot'
    )


class Purpose(Enum):
    spend = 'spend'


class Purpose1(Enum):
    mint = 'mint'


class ScriptPurposeItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    purpose: Purpose1
    policy: PolicyId


class Purpose2(Enum):
    publish = 'publish'


class Purpose3(Enum):
    withdraw = 'withdraw'


class ScriptPurposeItem3(BaseModel):
    class Config:
        extra = Extra.forbid

    purpose: Purpose3
    rewardAccount: RewardAccount


class Transaction2(BaseModel):
    class Config:
        extra = Extra.forbid

    id: TransactionId


class TransactionOutputReference(BaseModel):
    class Config:
        extra = Extra.forbid

    transaction: Transaction2
    index: UInt32


class Signature(BaseModel):
    __root__: constr(min_length=128, max_length=128) = Field(
        ..., description='An EdDSA signature.', title='Signature'
    )


class Signatory(BaseModel):
    class Config:
        extra = Extra.forbid

    key: VerificationKey
    signature: Signature
    chainCode: Optional[ChainCode] = None
    addressAttributes: Optional[AddressAttributes] = None


class SoftwareVersion(BaseModel):
    class Config:
        extra = Extra.forbid

    appName: str
    number: UInt32


class StakeAddress(BaseModel):
    __root__: constr(regex=r'^(stake|stake_test)1[0-9a-z]*$') = Field(
        ...,
        description='A stake address (a.k.a reward account)',
        examples=['stake179kzq4qulejydh045yzxwk4ksx780khkl4gdve9kzwd9vjcek9u8h'],
        title='StakeAddress',
    )


class Tip(BaseModel):
    class Config:
        extra = Extra.forbid

    slot: Slot
    id: DigestBlake2b256
    height: BlockHeight


class Ada(BaseModel):
    class Config:
        extra = Extra.forbid

    lovelace: int


class Value(BaseModel):
    ada: Ada


class UInt8(BaseModel):
    __root__: conint(ge=0, le=255) = Field(..., title='UInt8')


class ValidityInterval(BaseModel):
    class Config:
        extra = Extra.forbid

    invalidBefore: Optional[Slot] = None
    invalidAfter: Optional[Slot] = None


class VotingPeriod(Enum):
    voteForThisEpoch = 'voteForThisEpoch'
    voteForNextEpoch = 'voteForNextEpoch'


class VrfOutput(BaseModel):
    __root__: str = Field(..., title='VrfOutput')


class Withdrawals(BaseModel):
    __root__: Optional[Dict[str, Lovelace]] = None


class Anchor(BaseModel):
    class Config:
        extra = Extra.forbid

    hash: DigestAny
    url: AnyUrl


class BlockEBB(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type
    era: Era
    id: DigestBlake2b256
    ancestor: DigestBlake2b256
    height: BlockHeight


class Issuer(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: ExtendedVerificationKey


class Delegate(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: ExtendedVerificationKey


class CertifiedVrf(BaseModel):
    class Config:
        extra = Extra.forbid

    proof: Optional[VrfProof] = None
    output: Optional[VrfOutput] = None


class ProtocolVersion(BaseModel):
    class Config:
        extra = Extra.forbid

    major: UInt32
    minor: UInt32
    patch: Optional[UInt32] = None


class Issuer2(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: VerificationKey


class Delegate1(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: VerificationKey


class BootstrapOperationalCertificate(BaseModel):
    class Config:
        extra = Extra.forbid

    issuer: Issuer2
    delegate: Delegate1


class BootstrapProtocolParameters(BaseModel):
    class Config:
        extra = Extra.forbid

    heavyDelegationThreshold: Optional[Ratio] = None
    maxBlockBodySize: Optional[NumberOfBytes] = None
    maxBlockHeaderSize: Optional[NumberOfBytes] = None
    maxUpdateProposalSize: Optional[NumberOfBytes] = None
    maxTransactionSize: Optional[NumberOfBytes] = None
    multiPartyComputationThreshold: Optional[Ratio] = None
    scriptVersion: Optional[UInt64] = None
    slotDuration: Optional[UInt64] = None
    unlockStakeEpoch: Optional[UInt64] = None
    updateProposalThreshold: Optional[Ratio] = None
    updateProposalTimeToLive: Optional[UInt64] = None
    updateVoteThreshold: Optional[Ratio] = None
    softForkInitThreshold: Optional[Ratio] = None
    softForkMinThreshold: Optional[Ratio] = None
    softForkDecrementThreshold: Optional[Ratio] = None
    minFeeCoefficient: Optional[UInt64] = None
    minFeeConstant: Optional[Lovelace] = None


class Bound(BaseModel):
    class Config:
        extra = Extra.forbid

    time: RelativeTime
    slot: Slot
    epoch: Epoch


class StakePool(BaseModel):
    class Config:
        extra = Extra.forbid

    id: StakePoolId


class CertificateItem(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type3
    credential: DigestBlake2b224
    stakePool: Optional[StakePool] = None
    delegateRepresentative: Optional[DelegateRepresentative] = None


class CertificateItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type4
    credential: DigestBlake2b224
    deposit: Optional[Lovelace] = None


class CertificateItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type5
    credential: DigestBlake2b224
    deposit: Optional[Lovelace] = None


class StakePool1(BaseModel):
    class Config:
        extra = Extra.forbid

    retirementEpoch: Epoch
    id: StakePoolId


class CertificateItem4(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type7
    stakePool: StakePool1


class Delegate2(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224


class Issuer3(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b224
    vrfVerificationKeyHash: DigestBlake2b256


class CertificateItem5(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type8
    delegate: Delegate2
    issuer: Issuer3


class CertificateItem6(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type9
    member: ConstitutionalCommitteeMember
    hotKey: DigestBlake2b224


class CertificateItem7(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type10
    member: ConstitutionalCommitteeMember


class CertificateItem8(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type11
    delegateRepresentative: DelegateRepresentative
    deposit: Lovelace


class CertificateItem9(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type12
    delegateRepresentative: DelegateRepresentative
    deposit: Lovelace


class CostModel(BaseModel):
    __root__: List[Int64] = Field(..., title='CostModel')


class EraParameters(BaseModel):
    class Config:
        extra = Extra.forbid

    epochLength: Epoch
    slotLength: SlotLength
    safeZone: Optional[SafeZone]


class EraSummary(BaseModel):
    class Config:
        extra = Extra.forbid

    start: Bound
    end: Optional[Bound] = None
    parameters: EraParameters


class ExecutionUnits(BaseModel):
    class Config:
        extra = Extra.forbid

    memory: UInt64
    cpu: UInt64


class InitialDelegate(BaseModel):
    class Config:
        extra = Extra.forbid

    issuer: Issuer4
    delegate: GenesisDelegate


class InitialDelegates(BaseModel):
    __root__: List[InitialDelegate] = Field(..., title='InitialDelegates')


class StakePoolModel(BaseModel):
    class Config:
        extra = Extra.forbid

    id: StakePoolId
    vrfVerificationKeyHash: DigestBlake2b256
    owners: List[DigestBlake2b224]
    cost: Lovelace
    margin: Ratio
    pledge: Lovelace
    rewardAccount: RewardAccount
    metadata: Optional[Anchor] = None
    relays: List[Relay]


class GovernanceActionItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type17
    version: ProtocolVersion


class GovernanceActionItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type18
    source: Source
    target: Target
    value: Lovelace


class GovernanceActionItem3(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type19
    withdrawals: RewardTransfer


class GovernanceProposalReference(BaseModel):
    class Config:
        extra = Extra.forbid

    transaction: Transaction2
    index: UInt32


class GovernanceVote(BaseModel):
    class Config:
        extra = Extra.forbid

    issuer: GovernanceVoter
    anchor: Optional[Anchor] = None
    vote: Vote
    proposal: Optional[GovernanceProposalReference] = None


class MetadataLabels1(BaseModel):
    class Config:
        extra = Extra.forbid

    cbor: Optional[constr(regex=r'^[0-9a-f]*$')] = None
    json_: Optional[Metadatum] = Field(None, alias='json')


class MetadataLabels(BaseModel):
    __root__: Optional[Dict[str, MetadataLabels1]] = Field(
        None,
        description="An associated metadatum, as a CBOR bytestring or a JSON object if possible. Some binary representations cannot be represented in plain JSON and the 'json' field is therefore omitted.",
    )


class Redeemer(BaseModel):
    class Config:
        extra = Extra.forbid

    redeemer: RedeemerData
    executionUnits: ExecutionUnits


class ScriptNativeItem4(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause4
    slot: Slot


class ScriptNativeItem5(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause5
    slot: Slot


class ScriptPurposeItem(BaseModel):
    class Config:
        extra = Extra.forbid

    purpose: Purpose
    outputReference: TransactionOutputReference


class Protocol1(BaseModel):
    class Config:
        extra = Extra.forbid

    version: ProtocolVersion


class Issuer1(BaseModel):
    class Config:
        extra = Extra.forbid

    verificationKey: VerificationKey
    vrfVerificationKey: VerificationKey
    operationalCertificate: OperationalCertificate
    leaderValue: CertifiedVrf


class Proposal(BaseModel):
    class Config:
        extra = Extra.forbid

    version: ProtocolVersion
    software: SoftwareVersion
    parameters: BootstrapProtocolParameters
    metadata: Dict[str, str]


class BootstrapProtocolUpdate(BaseModel):
    class Config:
        extra = Extra.forbid

    proposal: Optional[Proposal] = None
    votes: List[BootstrapVote]


class CertificateItem3(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type6
    stakePool: StakePoolModel


class Certificate(BaseModel):
    __root__: Union[
        CertificateItem,
        CertificateItem1,
        CertificateItem2,
        CertificateItem3,
        CertificateItem4,
        CertificateItem5,
        CertificateItem6,
        CertificateItem7,
        CertificateItem8,
        CertificateItem9,
    ] = Field(..., title='Certificate')


class CostModels(BaseModel):
    __root__: Optional[Dict[str, CostModel]] = None


class InitialParameters(BaseModel):
    class Config:
        extra = Extra.forbid

    minUtxoDepositCoefficient: UInt64
    collateralPercentage: UInt64
    plutusCostModels: CostModels
    maxCollateralInputs: UInt64
    maxExecutionUnitsPerBlock: ExecutionUnits
    maxExecutionUnitsPerTransaction: ExecutionUnits
    maxValueSize: NumberOfBytes
    scriptExecutionPrices: ScriptExecutionPrices


class GenesisAlonzo(BaseModel):
    class Config:
        extra = Extra.forbid

    era: Era6
    initialParameters: InitialParameters


class GenesisConway(BaseModel):
    class Config:
        extra = Extra.forbid

    era: Era7
    initialDelegates: InitialDelegates


class GenesisStakePools(BaseModel):
    class Config:
        extra = Extra.forbid

    stakePools: Dict[str, StakePoolModel]
    delegators: Dict[str, StakePoolId]


class ProposedProtocolParameters(BaseModel):
    class Config:
        extra = Extra.forbid

    minFeeCoefficient: Optional[UInt64] = None
    minFeeConstant: Optional[Lovelace] = None
    minUtxoDepositCoefficient: Optional[UInt64] = None
    minUtxoDepositConstant: Optional[Lovelace] = None
    maxBlockBodySize: Optional[NumberOfBytes] = None
    maxBlockHeaderSize: Optional[NumberOfBytes] = None
    maxTransactionSize: Optional[NumberOfBytes] = None
    maxValueSize: Optional[NumberOfBytes] = None
    extraEntropy: Optional[Nonce] = None
    stakeCredentialDeposit: Optional[Lovelace] = None
    stakePoolDeposit: Optional[Lovelace] = None
    stakePoolRetirementEpochBound: Optional[UInt64] = None
    stakePoolPledgeInfluence: Optional[Ratio] = None
    minStakePoolCost: Optional[Lovelace] = None
    desiredNumberOfStakePools: Optional[UInt64] = None
    federatedBlockProductionRatio: Optional[Ratio] = None
    monetaryExpansion: Optional[Ratio] = None
    treasuryExpansion: Optional[Ratio] = None
    collateralPercentage: Optional[UInt64] = None
    maxCollateralInputs: Optional[UInt64] = None
    plutusCostModels: Optional[CostModels] = None
    scriptExecutionPrices: Optional[ScriptExecutionPrices] = None
    maxExecutionUnitsPerTransaction: Optional[ExecutionUnits] = None
    maxExecutionUnitsPerBlock: Optional[ExecutionUnits] = None
    version: Optional[ProtocolVersion] = None


class Metadata(BaseModel):
    class Config:
        extra = Extra.forbid

    hash: DigestBlake2b256
    labels: MetadataLabels


class ProtocolParameters(BaseModel):
    class Config:
        extra = Extra.forbid

    minFeeCoefficient: UInt64
    minFeeConstant: Lovelace
    minUtxoDepositCoefficient: UInt64
    minUtxoDepositConstant: Lovelace
    maxBlockBodySize: NumberOfBytes
    maxBlockHeaderSize: NumberOfBytes
    maxTransactionSize: Optional[NumberOfBytes] = None
    maxValueSize: Optional[NumberOfBytes] = None
    extraEntropy: Optional[Nonce] = None
    stakeCredentialDeposit: Lovelace
    stakePoolDeposit: Lovelace
    stakePoolRetirementEpochBound: UInt64
    stakePoolPledgeInfluence: Ratio
    minStakePoolCost: Lovelace
    desiredNumberOfStakePools: UInt64
    federatedBlockProductionRatio: Optional[Ratio] = None
    monetaryExpansion: Ratio
    treasuryExpansion: Ratio
    collateralPercentage: Optional[UInt64] = None
    maxCollateralInputs: Optional[UInt64] = None
    plutusCostModels: Optional[CostModels] = None
    scriptExecutionPrices: Optional[ScriptExecutionPrices] = None
    maxExecutionUnitsPerTransaction: Optional[ExecutionUnits] = None
    maxExecutionUnitsPerBlock: Optional[ExecutionUnits] = None
    version: ProtocolVersion


class ScriptPurposeItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    purpose: Purpose2
    certificate: Certificate


class ScriptPurpose(BaseModel):
    __root__: Union[
        ScriptPurposeItem, ScriptPurposeItem1, ScriptPurposeItem2, ScriptPurposeItem3
    ] = Field(..., title='ScriptPurpose')


class Protocol(BaseModel):
    class Config:
        extra = Extra.forbid

    id: BootstrapProtocolId
    version: ProtocolVersion
    software: SoftwareVersion
    update: Optional[BootstrapProtocolUpdate] = None


class GenesisByron(BaseModel):
    class Config:
        extra = Extra.forbid

    era: Era4
    genesisKeyHashes: List[DigestBlake2b224]
    genesisDelegations: Dict[str, BootstrapOperationalCertificate]
    startTime: UtcTime
    initialFunds: Dict[str, Lovelace]
    initialVouchers: Dict[str, Lovelace]
    securityParameter: UInt64
    networkMagic: NetworkMagic
    updatableParameters: Optional[ProtocolParameters] = None


class GenesisShelley(BaseModel):
    class Config:
        extra = Extra.forbid

    era: Era5
    startTime: UtcTime
    networkMagic: NetworkMagic
    network: Network
    activeSlotsCoefficient: Ratio
    securityParameter: UInt64
    epochLength: Epoch
    slotsPerKesPeriod: UInt64
    maxKesEvolutions: UInt64
    slotLength: SlotLength
    updateQuorum: UInt64
    maxLovelaceSupply: UInt64
    initialParameters: ProtocolParameters
    initialDelegates: InitialDelegates
    initialFunds: Dict[str, Lovelace] = Field(..., title='InitialFunds')
    initialStakePools: GenesisStakePools


class GovernanceActionItem(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type16
    parameters: ProposedProtocolParameters


class GovernanceAction(BaseModel):
    __root__: Union[
        GovernanceActionItem,
        GovernanceActionItem1,
        GovernanceActionItem2,
        GovernanceActionItem3,
        GovernanceActionItem4,
        GovernanceActionItem5,
        GovernanceActionItem6,
        GovernanceActionItem7,
    ]


class GovernanceProposal(BaseModel):
    class Config:
        extra = Extra.forbid

    deposit: Optional[Lovelace] = None
    returnAccount: Optional[DigestBlake2b224] = None
    anchor: Optional[Anchor] = None
    action: GovernanceAction


class Block(BaseModel):
    __root__: Union[BlockEBB, BlockBFT, BlockPraos] = Field(..., title='Block')


class BlockBFT(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type1
    era: Era
    id: DigestBlake2b256
    ancestor: DigestBlake2b256
    height: BlockHeight
    slot: Slot
    size: NumberOfBytes
    transactions: Optional[List[Transaction]] = None
    operationalCertificates: Optional[List[BootstrapOperationalCertificate]] = None
    protocol: Protocol
    issuer: Issuer
    delegate: Delegate


class BlockPraos(BaseModel):
    class Config:
        extra = Extra.forbid

    type: Type2
    era: Era2
    id: DigestBlake2b256
    ancestor: Union[DigestBlake2b256, AncestorEnum]
    nonce: Optional[CertifiedVrf] = None
    height: BlockHeight
    size: NumberOfBytes
    slot: Slot
    transactions: Optional[List[Transaction]] = None
    protocol: Protocol1
    issuer: Issuer1


class ScriptItem(BaseModel):
    class Config:
        extra = Extra.forbid

    language: Language1
    json_: ScriptNative = Field(..., alias='json')
    cbor: Optional[str] = None


class Script(BaseModel):
    __root__: Union[ScriptItem, ScriptItem1] = Field(..., title='Script')


class ScriptNativeItem1(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause1
    from_: List[ScriptNative] = Field(..., alias='from')


class ScriptNativeItem2(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause2
    from_: List[ScriptNative] = Field(..., alias='from')


class ScriptNativeItem3(BaseModel):
    class Config:
        extra = Extra.forbid

    clause: Clause3
    atLeast: int
    from_: List[ScriptNative] = Field(..., alias='from')


class ScriptNative(BaseModel):
    __root__: Union[
        ScriptNativeItem,
        ScriptNativeItem1,
        ScriptNativeItem2,
        ScriptNativeItem3,
        ScriptNativeItem4,
        ScriptNativeItem5,
    ] = Field(
        ...,
        description='A phase-1 monetary script. Timelocks constraints are only supported since Allegra.',
        examples=[
            {
                'clause': 'signature',
                'from': '3c07030e36bfff7cd2f004356ef320f3fe3c07030e7cd2f004356437',
            },
            {
                'clause': 'all',
                'from': [
                    {
                        'clause': 'signature',
                        'from': 'ec09e5293d384637cd2f004356ef320f3fe3c07030e36bfffe67e2e2',
                    },
                    {
                        'clause': 'signature',
                        'from': '3c07030e36bfff7cd2f004356ef320f3fe3c07030e7cd2f004356437',
                    },
                ],
            },
            {
                'clause': 'some',
                'atLeast': 2,
                'from': [
                    {
                        'clause': 'signature',
                        'from': 'ec09e5293d384637cd2f004356ef320f3fe3c07030e36bfffe67e2e2',
                    },
                    {
                        'clause': 'signature',
                        'from': '3c07030e36bfff7cd2f004356ef320f3fe3c07030e7cd2f004356437',
                    },
                    {'clause': 'after', 'slot': 42},
                ],
            },
        ],
        title='Script<Native>',
    )


class Transaction(BaseModel):
    class Config:
        extra = Extra.forbid

    id: DigestBlake2b256
    spends: InputSource
    inputs: List[TransactionOutputReference]
    references: Optional[List[TransactionOutputReference]] = None
    collaterals: Optional[List[TransactionOutputReference]] = None
    totalCollateral: Optional[Lovelace] = None
    collateralReturn: Optional[TransactionOutput] = None
    outputs: List[TransactionOutput]
    certificates: Optional[List[Certificate]] = None
    withdrawals: Optional[Withdrawals] = None
    fee: Optional[Lovelace] = None
    validityInterval: Optional[ValidityInterval] = None
    mint: Optional[Assets] = None
    network: Optional[Network] = None
    scriptIntegrityHash: Optional[DigestBlake2b256] = None
    requiredExtraSignatories: Optional[List[DigestBlake2b224]] = None
    requiredExtraScripts: Optional[List[DigestBlake2b224]] = None
    proposals: Optional[List[GovernanceProposal]] = None
    votes: Optional[List[GovernanceVote]] = None
    metadata: Optional[Metadata] = None
    signatories: List[Signatory]
    scripts: Optional[Dict[str, Script]] = None
    datums: Optional[Dict[str, Datum]] = None
    redeemers: Optional[Dict[str, Redeemer]] = None
    cbor: Optional[str] = Field(
        None, description='The raw serialized (CBOR) transaction, as found on-chain.'
    )


class TransactionOutput(BaseModel):
    class Config:
        extra = Extra.forbid

    address: Address
    value: Value
    datumHash: Optional[DigestBlake2b256] = None
    datum: Optional[Datum] = None
    script: Optional[Script] = None


class UtxoItem(BaseModel):
    class Config:
        extra = Extra.forbid

    transaction: Transaction2
    index: UInt32
    address: Address
    value: Value
    datumHash: Optional[DigestBlake2b256] = None
    datum: Optional[Datum] = None
    script: Optional[Script] = None


class Utxo(BaseModel):
    __root__: List[UtxoItem] = Field(..., title='Utxo')


Metadatum.update_forward_refs()
Voter.update_forward_refs()  # Edited
Block.update_forward_refs()
BlockBFT.update_forward_refs()
BlockPraos.update_forward_refs()
ScriptItem.update_forward_refs()
ScriptNativeItem1.update_forward_refs()
ScriptNativeItem2.update_forward_refs()
ScriptNativeItem3.update_forward_refs()
Transaction.update_forward_refs()
