refactor(core,x/**): simplify core service api and embed environment in keepers (#20071)
This commit is contained in:
@@ -150,7 +150,7 @@ func (k msgServer) CreateValidator(ctx context.Context, msg *types.MsgCreateVali
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeCreateValidator,
|
||||
event.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
|
||||
event.NewAttribute(sdk.AttributeKeyAmount, msg.Value.String()),
|
||||
@@ -239,7 +239,7 @@ func (k msgServer) EditValidator(ctx context.Context, msg *types.MsgEditValidato
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeEditValidator,
|
||||
event.NewAttribute(types.AttributeKeyCommissionRate, validator.Commission.String()),
|
||||
event.NewAttribute(types.AttributeKeyMinSelfDelegation, validator.MinSelfDelegation.String()),
|
||||
@@ -302,7 +302,7 @@ func (k msgServer) Delegate(ctx context.Context, msg *types.MsgDelegate) (*types
|
||||
}()
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeDelegate,
|
||||
event.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
|
||||
event.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress),
|
||||
@@ -375,7 +375,7 @@ func (k msgServer) BeginRedelegate(ctx context.Context, msg *types.MsgBeginRedel
|
||||
}()
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeRedelegate,
|
||||
event.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress),
|
||||
event.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress),
|
||||
@@ -445,7 +445,7 @@ func (k msgServer) Undelegate(ctx context.Context, msg *types.MsgUndelegate) (*t
|
||||
}()
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeUnbond,
|
||||
event.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
|
||||
event.NewAttribute(types.AttributeKeyDelegator, msg.DelegatorAddress),
|
||||
@@ -544,7 +544,7 @@ func (k msgServer) CancelUnbondingDelegation(ctx context.Context, msg *types.Msg
|
||||
return nil, sdkerrors.ErrInvalidRequest.Wrap("amount is greater than the unbonding delegation entry balance")
|
||||
}
|
||||
|
||||
headerInfo := k.environment.HeaderService.GetHeaderInfo(ctx)
|
||||
headerInfo := k.HeaderService.HeaderInfo(ctx)
|
||||
if unbondEntry.CompletionTime.Before(headerInfo.Time) {
|
||||
return nil, sdkerrors.ErrInvalidRequest.Wrap("unbonding delegation is already processed")
|
||||
}
|
||||
@@ -576,7 +576,7 @@ func (k msgServer) CancelUnbondingDelegation(ctx context.Context, msg *types.Msg
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := k.environment.EventService.EventManager(ctx).EmitKV(
|
||||
if err := k.EventService.EventManager(ctx).EmitKV(
|
||||
types.EventTypeCancelUnbondingDelegation,
|
||||
event.NewAttribute(sdk.AttributeKeyAmount, msg.Amount.String()),
|
||||
event.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress),
|
||||
@@ -628,7 +628,7 @@ func (k msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams)
|
||||
val.Commission.CommissionRates.MaxRate = minRate
|
||||
}
|
||||
|
||||
val.Commission.UpdateTime = k.environment.HeaderService.GetHeaderInfo(ctx).Time
|
||||
val.Commission.UpdateTime = k.HeaderService.HeaderInfo(ctx).Time
|
||||
if err := k.SetValidator(ctx, val); err != nil {
|
||||
return nil, fmt.Errorf("failed to set validator after MinCommissionRate param change: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user