From 1d963b49921471901b0f3e5d736e7d6d675d3f23 Mon Sep 17 00:00:00 2001 From: Bryan White Date: Mon, 25 Nov 2024 15:48:29 +0100 Subject: [PATCH] fix: outstanding shared module non-status (gRPC) errors --- x/shared/keeper/msg_update_params.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/x/shared/keeper/msg_update_params.go b/x/shared/keeper/msg_update_params.go index 9df191361..c313387f6 100644 --- a/x/shared/keeper/msg_update_params.go +++ b/x/shared/keeper/msg_update_params.go @@ -3,23 +3,34 @@ package keeper import ( "context" - sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/pokt-network/poktroll/x/shared/types" ) func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + logger := k.Logger().With("method", "UpdateParams") + if err := req.ValidateBasic(); err != nil { - return nil, err + return nil, status.Error(codes.InvalidArgument, err.Error()) } if k.GetAuthority() != req.Authority { - return nil, sdkerrors.Wrapf(types.ErrSharedInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + return nil, status.Error( + codes.PermissionDenied, + types.ErrSharedInvalidSigner.Wrapf( + "invalid authority; expected %s, got %s", + k.GetAuthority(), req.Authority, + ).Error(), + ) } ctx := sdk.UnwrapSDKContext(goCtx) if err := k.SetParams(ctx, req.Params); err != nil { - return nil, err + err = types.ErrSharedParamInvalid.Wrapf("unable to set params: %v", err) + logger.Error(err.Error()) + return nil, status.Error(codes.Internal, err.Error()) } return &types.MsgUpdateParamsResponse{}, nil