planetmint-go/x/dao/keeper/query_get_distribution.go
Jürgen Eckel 75ed13b357
Eckelj/reducing code smell (#325)
* aggregating error messages
* removed duplicate err msgs
* removed obsolete test (two times equal behaviour )
* added global error msg module
* refactored test utils to have sample types and sample objects by keepers separated
* excluded auto-generated code from sonarcube analysis


Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-02-26 16:44:00 +01:00

27 lines
759 B
Go

package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/errormsg"
"github.com/planetmint/planetmint-go/x/dao/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k Keeper) GetDistribution(goCtx context.Context, req *types.QueryGetDistributionRequest) (*types.QueryGetDistributionResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, errormsg.InvalidRequest)
}
ctx := sdk.UnwrapSDKContext(goCtx)
distribution, found := k.LookupDistributionOrder(ctx, req.GetHeight())
if !found {
return nil, status.Error(codes.NotFound, "distribution not found")
}
return &types.QueryGetDistributionResponse{Distribution: &distribution}, nil
}