# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: protocol-level-tokens.proto
# plugin: python-betterproto
# This file has been @generated

from dataclasses import dataclass
from typing import (
    List,
    Optional,
)

import betterproto

from ... import v2 as __v2__


@dataclass(eq=False, repr=False)
class Cbor(betterproto.Message):
    """A CBOR encoded bytestring"""

    value: bytes = betterproto.bytes_field(1)
    """A CBOR encoded byte string."""


@dataclass(eq=False, repr=False)
class TokenId(betterproto.Message):
    """Token ID: a unique symbol and identifier of a protocol level token."""

    value: str = betterproto.string_field(1)
    """
    Unique identifier for the token, guaranteed to be distinct across the
    entire concordium blockchain. The token id must be between 1 and 128 bytes
    long and consist of only a-z, A-Z, 0-9, `.`, `%` and `-`.
    """


@dataclass(eq=False, repr=False)
class TokenModuleRef(betterproto.Message):
    """A token module reference. This is always 32 bytes long."""

    value: bytes = betterproto.bytes_field(1)


@dataclass(eq=False, repr=False)
class TokenAmount(betterproto.Message):
    """
    PLT amount representation. The actual amount is computed as `value *
    10^(-decimals)`.
    """

    value: int = betterproto.uint64_field(1)
    """The digits of the amount."""

    decimals: int = betterproto.uint32_field(2)
    """Number of decimals in the representation"""


@dataclass(eq=False, repr=False)
class TokenState(betterproto.Message):
    """Token state at the block level"""

    token_module_ref: "TokenModuleRef" = betterproto.message_field(1)
    """The reference of the module implementing this token."""

    decimals: int = betterproto.uint32_field(3)
    """Number of decimals in the decimal number representation of amounts."""

    total_supply: "TokenAmount" = betterproto.message_field(4)
    """The total available token supply."""

    module_state: "Cbor" = betterproto.message_field(5)
    """
    Token module specific state, such as token name, feature flags, meta data.
    """


@dataclass(eq=False, repr=False)
class TokenAccountState(betterproto.Message):
    """Token state at the account level"""

    balance: "TokenAmount" = betterproto.message_field(1)
    """The available balance."""

    module_state: Optional["Cbor"] = betterproto.message_field(
        4, optional=True, group="_module_state"
    )
    """
    Token module specific account state, such as whether the account is on the
    allow or deny list.
    """


@dataclass(eq=False, repr=False)
class TokenModuleEvent(betterproto.Message):
    """
    Single token event originating from a token module as part of a token
    transaction.
    """

    type: str = betterproto.string_field(1)
    """The type of the event."""

    details: "Cbor" = betterproto.message_field(2)
    """The CBOR encoded event details."""


@dataclass(eq=False, repr=False)
class TokenHolder(betterproto.Message):
    """
    A token holder is an entity that can hold tokens. Currently, this is
    limited to accounts, but in the future it may be extended to other
    entities.
    """

    account: "__v2__.AccountAddress" = betterproto.message_field(1, group="address")
    """The account address of the holder."""


@dataclass(eq=False, repr=False)
class TokenTransferEvent(betterproto.Message):
    """
    An event emitted when a transfer of tokens from `from` to `to` is
    performed.
    """

    from_: "TokenHolder" = betterproto.message_field(1)
    """The token holder from which the tokens are transferred."""

    to: "TokenHolder" = betterproto.message_field(2)
    """The token holder to which the tokens are transferred."""

    amount: "TokenAmount" = betterproto.message_field(3)
    """The amount of tokens transferred."""

    memo: Optional["__v2__.Memo"] = betterproto.message_field(
        4, optional=True, group="_memo"
    )
    """
    An optional memo field that can be used to attach a message to the token
    transfer.
    """


@dataclass(eq=False, repr=False)
class TokenSupplyUpdateEvent(betterproto.Message):
    """
    An event emitted when the token supply is updated, i.e. by minting/burning
    tokens to/from the balance of the `target`.
    """

    target: "TokenHolder" = betterproto.message_field(1)
    """The token holder the balance update is performed on."""

    amount: "TokenAmount" = betterproto.message_field(2)
    """The balance difference to be applied to the target."""


@dataclass(eq=False, repr=False)
class TokenEvent(betterproto.Message):
    """Token event originating from token transactions."""

    token_id: "TokenId" = betterproto.message_field(1)
    """The Token ID."""

    module_event: "TokenModuleEvent" = betterproto.message_field(2, group="event")
    """An event emitted by the token module."""

    transfer_event: "TokenTransferEvent" = betterproto.message_field(3, group="event")
    """An event emitted when a transfer of tokens is performed."""

    mint_event: "TokenSupplyUpdateEvent" = betterproto.message_field(4, group="event")
    """
    An event emitted when the token supply is updated by minting tokens to a
    token holder.
    """

    burn_event: "TokenSupplyUpdateEvent" = betterproto.message_field(5, group="event")
    """
    An event emitted when the token supply is updated by burning tokens from
    the balance of a token holder.
    """


@dataclass(eq=False, repr=False)
class TokenEffect(betterproto.Message):
    """Token events originating from token transactions."""

    events: List["TokenEvent"] = betterproto.message_field(1)
    """Events emitted by the token."""


@dataclass(eq=False, repr=False)
class TokenModuleRejectReason(betterproto.Message):
    """
    Details provided by the token module in the event of rejecting a
    transaction.
    """

    token_id: "TokenId" = betterproto.message_field(1)
    """The Token ID of the protocol-level token."""

    type: str = betterproto.string_field(2)
    """The type of the reject reason."""

    details: Optional["Cbor"] = betterproto.message_field(
        3, optional=True, group="_details"
    )
    """(Optional) CBOR-encoded details."""


@dataclass(eq=False, repr=False)
class CreatePlt(betterproto.Message):
    """Update payload for creating a new protocol-level token"""

    token_id: "TokenId" = betterproto.message_field(1)
    """The Token ID of the protocol-level token."""

    token_module: "TokenModuleRef" = betterproto.message_field(2)
    """The hash that identifies the token module implementation."""

    decimals: int = betterproto.uint32_field(4)
    """
    The number of decimal places used in the representation of amounts of this
    token. This determines the smallest representable fraction of the token.
    This can be at most 255.
    """

    initialization_parameters: "Cbor" = betterproto.message_field(5)
    """The initialization parameters of the token, encoded in CBOR."""


@dataclass(eq=False, repr=False)
class TokenCreationDetails(betterproto.Message):
    """Details about the creation of a protocol-level token."""

    create_plt: "CreatePlt" = betterproto.message_field(1)
    """The update payload used to create the token."""

    events: List["TokenEvent"] = betterproto.message_field(2)
    """
    The events generated by the token module during the creation of the token.
    """
