Skip to content

Commit

Permalink
chore: call x/staking msg server
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Jan 24, 2025
1 parent 0bda564 commit 9664732
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 68 deletions.
2 changes: 2 additions & 0 deletions proto/babylon/epoching/v1/epoching.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ message QueuedMessage {
cosmos.staking.v1beta1.MsgUndelegate msg_undelegate = 7;
cosmos.staking.v1beta1.MsgBeginRedelegate msg_begin_redelegate = 8;
cosmos.staking.v1beta1.MsgCancelUnbondingDelegation msg_cancel_unbonding_delegation = 9;
cosmos.staking.v1beta1.MsgEditValidator msg_edit_validator = 10;
cosmos.staking.v1beta1.MsgUpdateParams msg_update_params = 11;
}
}

Expand Down
28 changes: 27 additions & 1 deletion x/epoching/keeper/epoch_msg_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
if err != nil {
return nil, err
}

// handle self-delegation
// Delegator and Validator address are the same
delAddr, err := sdk.AccAddressFromBech32(unwrappedMsg.MsgCreateValidator.ValidatorAddress)
Expand All @@ -163,6 +162,10 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
return nil, err
}
case *types.QueuedMessage_MsgDelegate:
_, err := k.stkMsgServer.Delegate(ctx, unwrappedMsg.MsgDelegate)
if err != nil {
return nil, err
}
delAddr, err := sdk.AccAddressFromBech32(unwrappedMsg.MsgDelegate.DelegatorAddress)
if err != nil {
return nil, err
Expand All @@ -180,6 +183,10 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
return nil, err
}
case *types.QueuedMessage_MsgUndelegate:
_, err := k.stkMsgServer.Undelegate(ctx, unwrappedMsg.MsgUndelegate)
if err != nil {
return nil, err
}
delAddr, err := sdk.AccAddressFromBech32(unwrappedMsg.MsgUndelegate.DelegatorAddress)
if err != nil {
return nil, err
Expand All @@ -195,6 +202,10 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
return nil, err
}
case *types.QueuedMessage_MsgBeginRedelegate:
_, err := k.stkMsgServer.BeginRedelegate(ctx, unwrappedMsg.MsgBeginRedelegate)
if err != nil {
return nil, err
}
delAddr, err := sdk.AccAddressFromBech32(unwrappedMsg.MsgBeginRedelegate.DelegatorAddress)
if err != nil {
return nil, err
Expand All @@ -210,6 +221,10 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
return nil, err
}
case *types.QueuedMessage_MsgCancelUnbondingDelegation:
_, err := k.stkMsgServer.CancelUnbondingDelegation(ctx, unwrappedMsg.MsgCancelUnbondingDelegation)
if err != nil {
return nil, err
}
delAddr, err := sdk.AccAddressFromBech32(unwrappedMsg.MsgCancelUnbondingDelegation.DelegatorAddress)
if err != nil {
return nil, err
Expand All @@ -223,6 +238,17 @@ func (k Keeper) HandleQueuedMsg(goCtx context.Context, msg *types.QueuedMessage)
if err := k.RecordNewDelegationState(goCtx, delAddr, valAddr, amount, types.BondState_BONDED); err != nil {
return nil, err
}
case *types.QueuedMessage_MsgEditValidator:
_, err := k.stkMsgServer.EditValidator(ctx, unwrappedMsg.MsgEditValidator)
if err != nil {
return nil, err
}
case *types.QueuedMessage_MsgUpdateParams:
_, err := k.stkMsgServer.UpdateParams(ctx, unwrappedMsg.MsgUpdateParams)
if err != nil {
return nil, err
}

default:
panic(errorsmod.Wrap(types.ErrInvalidQueuedMessageType, msg.String()))
}
Expand Down
Loading

0 comments on commit 9664732

Please sign in to comment.