Skip to content

Commit

Permalink
Add CancelUnlocking message, fix Unlock message
Browse files Browse the repository at this point in the history
  • Loading branch information
iverc committed Dec 2, 2024
1 parent 64b66b8 commit b2a94dd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions x/tier/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/sourcenetwork/sourcehub/x/tier/types"
)
Expand All @@ -22,7 +20,6 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
}

func (m msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {

authority := m.Keeper.GetAuthority()
if msg.Authority != authority {
return nil, types.ErrUnauthorized.Wrapf("expected authority: %s, got: %s", authority, msg.Authority)
Expand All @@ -42,7 +39,6 @@ func (m msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams)
}

func (m msgServer) Lock(ctx context.Context, msg *types.MsgLock) (*types.MsgLockResponse, error) {

// Input validation has been done by ValidateBasic.
delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress)
valAddr := types.MustValAddressFromBech32(msg.ValidatorAddress)
Expand All @@ -56,12 +52,11 @@ func (m msgServer) Lock(ctx context.Context, msg *types.MsgLock) (*types.MsgLock
}

func (m msgServer) Unlock(ctx context.Context, msg *types.MsgUnlock) (*types.MsgUnlockResponse, error) {

// Input validation has been done by ValidateBasic.
delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress)
valAddr := types.MustValAddressFromBech32(msg.ValidatorAddress)

_, unlockTime, err := m.Keeper.Unlock(ctx, delAddr, valAddr, msg.Stake.Amount)
_, unlockTime, _, err := m.Keeper.Unlock(ctx, delAddr, valAddr, msg.Stake.Amount)
if err != nil {
return nil, errorsmod.Wrap(err, "undelegate")
}
Expand All @@ -70,13 +65,18 @@ func (m msgServer) Unlock(ctx context.Context, msg *types.MsgUnlock) (*types.Msg
}

func (m msgServer) CancelUnlocking(ctx context.Context, msg *types.MsgCancelUnlocking) (*types.MsgCancelUnlockingResponse, error) {
delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress)
valAddr := types.MustValAddressFromBech32(msg.ValidatorAddress)

// TODO: Implement MsgCancelUnlocking
return &types.MsgCancelUnlockingResponse{}, status.Error(codes.Unimplemented, "not implemented")
err := m.Keeper.CancelUnlocking(ctx, delAddr, valAddr, msg.Stake.Amount)
if err != nil {
return nil, errorsmod.Wrap(err, "cancel unlocking")
}

return &types.MsgCancelUnlockingResponse{}, nil
}

func (m msgServer) Redelegate(ctx context.Context, msg *types.MsgRedelegate) (*types.MsgRedelegateResponse, error) {

// Input validation has been done by ValidateBasic.
delAddr := sdk.MustAccAddressFromBech32(msg.DelegatorAddress)
srcValAddr := types.MustValAddressFromBech32(msg.SrcValidatorAddress)
Expand Down

0 comments on commit b2a94dd

Please sign in to comment.