Prathamesh Musale
7a88c82816
All checks were successful
Integration Tests / test-integration (push) Successful in 3m5s
E2E Tests / test-e2e (push) Successful in 4m20s
Unit Tests / test-unit (push) Successful in 3m6s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 9m18s
SDK Tests / sdk_tests (push) Successful in 10m33s
SDK Tests / sdk_tests_auctions (push) Successful in 14m29s
Publish on release / Run docker build and publish (release) Successful in 3m11s
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Reviewed-on: #44 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
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
|
|
}
|