Skip to content

Commit

Permalink
Refactored Keeper into Querier
Browse files Browse the repository at this point in the history
  • Loading branch information
CmpHDL committed Apr 19, 2022
1 parent d09b708 commit 7a830c6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions x/lockup/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,22 @@ func (q Querier) AccountLockedLongerDurationDenom(goCtx context.Context, req *ty
}

// AccountLockedDuration Returns account locked with the duration specified
func (k Keeper) AccountLockedDuration(goCtx context.Context, req *types.AccountLockedDurationRequest) (*types.AccountLockedDurationResponse, error) {
func (q Querier) AccountLockedDuration(goCtx context.Context, req *types.AccountLockedDurationRequest) (*types.AccountLockedDurationResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
if len(req.Owner) == 0 {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "empty owner")
}

ctx := sdk.UnwrapSDKContext(goCtx)

owner, err := sdk.AccAddressFromBech32(req.Owner)
if req.Owner == "" {
return nil, errors.New("empty address")
} else if err != nil {
if err != nil {
return nil, err
}
locks := k.GetAccountLockedDuration(ctx, owner, req.Duration)

locks := q.Keeper.GetAccountLockedDuration(ctx, owner, req.Duration)
return &types.AccountLockedDurationResponse{Locks: locks}, nil
}

Expand Down

0 comments on commit 7a830c6

Please sign in to comment.