package keeper import ( "context" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" onboardingtypes "git.vdb.to/cerc-io/laconicd/x/onboarding" ) var _ onboardingtypes.QueryServer = queryServer{} type queryServer struct { k *Keeper } // NewQueryServerImpl returns an implementation of the module QueryServer. func NewQueryServerImpl(k *Keeper) onboardingtypes.QueryServer { return queryServer{k} } // Participants implements Participants.QueryServer. func (qs queryServer) Participants( c context.Context, _ *onboardingtypes.QueryParticipantsRequest, ) (*onboardingtypes.QueryParticipantsResponse, error) { ctx := sdk.UnwrapSDKContext(c) resp, err := qs.k.ListParticipants(ctx) if err != nil { return nil, err } return &onboardingtypes.QueryParticipantsResponse{Participants: resp}, nil } // GetParticipantByAddress implements the GetParticipantByAddress query. func (qs queryServer) GetParticipantByAddress( c context.Context, req *onboardingtypes.QueryGetParticipantByAddressRequest, ) (*onboardingtypes.QueryGetParticipantByAddressResponse, error) { ctx := sdk.UnwrapSDKContext(c) if req.Address == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "cosmos (laconic) address is required") } participant, err := qs.k.GetParticipantByAddress(ctx, req.Address) if err != nil { return nil, err } return &onboardingtypes.QueryGetParticipantByAddressResponse{Participant: &participant}, nil } // GetParticipantByNitroAddress implements the GetParticipantByNitroAddress query. func (qs queryServer) GetParticipantByNitroAddress( c context.Context, req *onboardingtypes.QueryGetParticipantByNitroAddressRequest, ) (*onboardingtypes.QueryGetParticipantByNitroAddressResponse, error) { ctx := sdk.UnwrapSDKContext(c) if req.NitroAddress == "" { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "nitro address is required") } participant, err := qs.k.GetParticipantByNitroAddress(ctx, req.NitroAddress) if err != nil { return nil, err } return &onboardingtypes.QueryGetParticipantByNitroAddressResponse{Participant: &participant}, nil }