# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: band/base/node/v1beta1/query.proto
# plugin: python-betterproto
# This file has been @generated

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

import betterproto
import grpclib
from betterproto.grpc.grpclib_server import ServiceBase


if TYPE_CHECKING:
    import grpclib.server
    from betterproto.grpc.grpclib_client import MetadataLike
    from grpclib.metadata import Deadline


@dataclass(eq=False, repr=False)
class ChainIdRequest(betterproto.Message):
    """ChainIDRequest is request type for the Service/ChainID RPC method."""

    pass


@dataclass(eq=False, repr=False)
class ChainIdResponse(betterproto.Message):
    """ChainIDResponse is response type for the Service/ChainID RPC method."""

    chain_id: str = betterproto.string_field(1)


@dataclass(eq=False, repr=False)
class EvmValidatorsRequest(betterproto.Message):
    """
    EVMValidatorsRequest is request type for the Service/EVMValidators RPC method.
    """

    pass


@dataclass(eq=False, repr=False)
class EvmValidatorsResponse(betterproto.Message):
    """
    EVMValidatorsResponse is response type for the Service/EVMValidators RPC method.
    """

    block_height: int = betterproto.int64_field(1)
    """BlockHeight is the latest block height"""

    validators: List["ValidatorMinimal"] = betterproto.message_field(2)
    """Validators is list of validator's addresss and voting power"""


@dataclass(eq=False, repr=False)
class ValidatorMinimal(betterproto.Message):
    """
    ValidatorMinimal is the data structure for storing validator's address and voting power
    """

    address: str = betterproto.string_field(1)
    voting_power: int = betterproto.int64_field(2)


class ServiceStub(betterproto.ServiceStub):
    async def chain_id(
        self,
        chain_id_request: "ChainIdRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "ChainIdResponse":
        return await self._unary_unary(
            "/band.base.node.v1beta1.Service/ChainID",
            chain_id_request,
            ChainIdResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )

    async def evm_validators(
        self,
        evm_validators_request: "EvmValidatorsRequest",
        *,
        timeout: Optional[float] = None,
        deadline: Optional["Deadline"] = None,
        metadata: Optional["MetadataLike"] = None
    ) -> "EvmValidatorsResponse":
        return await self._unary_unary(
            "/band.base.node.v1beta1.Service/EVMValidators",
            evm_validators_request,
            EvmValidatorsResponse,
            timeout=timeout,
            deadline=deadline,
            metadata=metadata,
        )


class ServiceBase(ServiceBase):

    async def chain_id(self, chain_id_request: "ChainIdRequest") -> "ChainIdResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def evm_validators(
        self, evm_validators_request: "EvmValidatorsRequest"
    ) -> "EvmValidatorsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_chain_id(
        self, stream: "grpclib.server.Stream[ChainIdRequest, ChainIdResponse]"
    ) -> None:
        request = await stream.recv_message()
        response = await self.chain_id(request)
        await stream.send_message(response)

    async def __rpc_evm_validators(
        self,
        stream: "grpclib.server.Stream[EvmValidatorsRequest, EvmValidatorsResponse]",
    ) -> None:
        request = await stream.recv_message()
        response = await self.evm_validators(request)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/band.base.node.v1beta1.Service/ChainID": grpclib.const.Handler(
                self.__rpc_chain_id,
                grpclib.const.Cardinality.UNARY_UNARY,
                ChainIdRequest,
                ChainIdResponse,
            ),
            "/band.base.node.v1beta1.Service/EVMValidators": grpclib.const.Handler(
                self.__rpc_evm_validators,
                grpclib.const.Cardinality.UNARY_UNARY,
                EvmValidatorsRequest,
                EvmValidatorsResponse,
            ),
        }
