# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: cosmos/params/v1beta1/params.proto, cosmos/params/v1beta1/query.proto
# plugin: python-betterproto
from dataclasses import dataclass
from typing import Dict, List

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


@dataclass(eq=False, repr=False)
class ParameterChangeProposal(betterproto.Message):
    """
    ParameterChangeProposal defines a proposal to change one or more
    parameters.
    """

    title: str = betterproto.string_field(1)
    description: str = betterproto.string_field(2)
    changes: List["ParamChange"] = betterproto.message_field(3)


@dataclass(eq=False, repr=False)
class ParamChange(betterproto.Message):
    """
    ParamChange defines an individual parameter change, for use in
    ParameterChangeProposal.
    """

    subspace: str = betterproto.string_field(1)
    key: str = betterproto.string_field(2)
    value: str = betterproto.string_field(3)


@dataclass(eq=False, repr=False)
class QueryParamsRequest(betterproto.Message):
    """QueryParamsRequest is request type for the Query/Params RPC method."""

    # subspace defines the module to query the parameter for.
    subspace: str = betterproto.string_field(1)
    # key defines the key of the parameter in the subspace.
    key: str = betterproto.string_field(2)


@dataclass(eq=False, repr=False)
class QueryParamsResponse(betterproto.Message):
    """
    QueryParamsResponse is response type for the Query/Params RPC method.
    """

    # param defines the queried parameter.
    param: "ParamChange" = betterproto.message_field(1)


class QueryStub(betterproto.ServiceStub):
    async def params(
        self, *, subspace: str = "", key: str = ""
    ) -> "QueryParamsResponse":

        request = QueryParamsRequest()
        request.subspace = subspace
        request.key = key

        return await self._unary_unary(
            "/cosmos.params.v1beta1.Query/Params", request, QueryParamsResponse
        )


class QueryBase(ServiceBase):
    async def params(self, subspace: str, key: str) -> "QueryParamsResponse":
        raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)

    async def __rpc_params(self, stream: grpclib.server.Stream) -> None:
        request = await stream.recv_message()

        request_kwargs = {
            "subspace": request.subspace,
            "key": request.key,
        }

        response = await self.params(**request_kwargs)
        await stream.send_message(response)

    def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
        return {
            "/cosmos.params.v1beta1.Query/Params": grpclib.const.Handler(
                self.__rpc_params,
                grpclib.const.Cardinality.UNARY_UNARY,
                QueryParamsRequest,
                QueryParamsResponse,
            ),
        }
