Fixup stake hooks (hopefully...)
This commit is contained in:
parent
6c9ad8c031
commit
2e8f354367
|
@ -114,8 +114,6 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k
|
|||
}
|
||||
|
||||
k.OnValidatorCreated(ctx, validator.OperatorAddr)
|
||||
accAddr := sdk.AccAddress(validator.OperatorAddr)
|
||||
k.OnDelegationCreated(ctx, accAddr, validator.OperatorAddr)
|
||||
|
||||
tags := sdk.NewTags(
|
||||
tags.Action, tags.ActionCreateValidator,
|
||||
|
@ -150,6 +148,8 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
|
|||
return err.Result()
|
||||
}
|
||||
validator.Commission = commission
|
||||
// call the hook if present
|
||||
k.OnValidatorCommissionChange(ctx, msg.ValidatorAddr)
|
||||
}
|
||||
|
||||
k.SetValidator(ctx, validator)
|
||||
|
@ -185,9 +185,6 @@ func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper)
|
|||
return err.Result()
|
||||
}
|
||||
|
||||
// call the hook if present
|
||||
k.OnDelegationCreated(ctx, msg.DelegatorAddr, validator.OperatorAddr)
|
||||
|
||||
tags := sdk.NewTags(
|
||||
tags.Action, tags.ActionDelegate,
|
||||
tags.Delegator, []byte(msg.DelegatorAddr.String()),
|
||||
|
|
|
@ -359,6 +359,13 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Co
|
|||
}
|
||||
}
|
||||
|
||||
// call the appropriate hook if present
|
||||
if found {
|
||||
k.OnDelegationSharesModified(ctx, delAddr, validator.OperatorAddr)
|
||||
} else {
|
||||
k.OnDelegationCreated(ctx, delAddr, validator.OperatorAddr)
|
||||
}
|
||||
|
||||
if subtractAccount {
|
||||
// Account new shares, save
|
||||
_, _, err = k.bankKeeper.SubtractCoins(ctx, delegation.DelegatorAddr, sdk.Coins{bondAmt})
|
||||
|
@ -373,6 +380,7 @@ func (k Keeper) Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Co
|
|||
delegation.Shares = delegation.Shares.Add(newShares)
|
||||
delegation.Height = ctx.BlockHeight()
|
||||
k.SetDelegation(ctx, delegation)
|
||||
|
||||
return newShares, nil
|
||||
}
|
||||
|
||||
|
@ -567,7 +575,6 @@ func (k Keeper) BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress,
|
|||
if err != nil {
|
||||
return types.Redelegation{}, err
|
||||
}
|
||||
k.OnDelegationCreated(ctx, delAddr, valDstAddr)
|
||||
|
||||
// create the unbonding delegation
|
||||
minTime, height, completeNow := k.getBeginInfo(ctx, valSrcAddr)
|
||||
|
|
Loading…
Reference in New Issue