mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-04 23:44:24 -08:00
implement query & update return schema
This commit is contained in:
@@ -2,8 +2,11 @@ package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"colinear/x/colinearcore/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -16,8 +19,22 @@ func (k Keeper) LockedFunds(goCtx context.Context, req *types.QueryLockedFundsRe
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
// TODO: Process the query
|
||||
_ = ctx
|
||||
if err := sdk.VerifyAddressFormat([]byte(req.Owner)); err != nil {
|
||||
return nil, fmt.Errorf("address %s is not valid", req.Owner)
|
||||
}
|
||||
|
||||
return &types.QueryLockedFundsResponse{}, nil
|
||||
lockedUsers, ok := k.GetLockedUsers(ctx)
|
||||
if !ok {
|
||||
return nil, errors.New("unable to get locked users")
|
||||
}
|
||||
|
||||
var userAmtStr string
|
||||
userAmtStr, ok = lockedUsers.Users[req.Owner]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("user %s has not locked any funds", req.Owner)
|
||||
}
|
||||
|
||||
return &types.QueryLockedFundsResponse{
|
||||
Amount: userAmtStr,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user