Skip to content

Commit

Permalink
fix: prices validation is node params
Browse files Browse the repository at this point in the history
  • Loading branch information
ironman0x7b2 committed Dec 18, 2024
1 parent b0ad886 commit 767e06b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion x/lease/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (k *Keeper) handleLeaseRenewals(ctx sdk.Context) {
// Execute the handler to process the lease renewal
resp, err := handler(cc, msg)
if err != nil {
k.Logger(cc).Error("Failed to handle lease renewal", "id", item.ID, "message", err)
k.Logger(cc).Error("Failed to handle lease renewal", "id", item.ID, "msg", err)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion x/lease/keeper/msg_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (k *Keeper) HandleMsgRenewLease(ctx sdk.Context, msg *v1.MsgRenewLeaseReque
}

if err := lease.ValidateRenewalPolicies(price); err != nil {
return nil, sdkerrors.Wrapf(types.ErrInvalidRenewalPolicy, err.Error())
return nil, sdkerrors.Wrap(types.ErrInvalidRenewalPolicy, err.Error())
}

refund := lease.RefundAmount()
Expand Down
8 changes: 4 additions & 4 deletions x/node/types/v3/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,31 @@ func validateActiveDuration(v interface{}) error {
}

func validateMinGigabytePrices(v interface{}) error {
value, ok := v.(v1base.Prices)
value, ok := v.([]v1base.Price)
if !ok {
return fmt.Errorf("invalid parameter type %T", v)
}

if value == nil {
return nil
}
if !value.IsValid() {
if !v1base.Prices(value).IsValid() {
return fmt.Errorf("min_gigabyte_prices must be valid")
}

return nil
}

func validateMinHourlyPrices(v interface{}) error {
value, ok := v.(v1base.Prices)
value, ok := v.([]v1base.Price)
if !ok {
return fmt.Errorf("invalid parameter type %T", v)
}

if value == nil {
return nil
}
if !value.IsValid() {
if !v1base.Prices(value).IsValid() {
return fmt.Errorf("min_hourly_prices must be valid")
}

Expand Down
2 changes: 1 addition & 1 deletion x/oracle/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (k *Keeper) BeginBlock(ctx sdk.Context) {
// Send the GetProtoRevPool query packet over IBC.
sequence, err := k.SendQueryPacket(ctx, channelCap, portID, channelID, uint64(timeout), req)
if err != nil {
k.Logger(ctx).Error("Failed to send query packet", "asset", item.Denom, "message", err)
k.Logger(ctx).Error("Failed to send query packet", "asset", item.Denom, "msg", err)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion x/subscription/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (k *Keeper) handleSubscriptionRenewals(ctx sdk.Context) {
// Execute the handler to process the subscription renewal
resp, err := handler(cc, msg)
if err != nil {
k.Logger(cc).Error("Failed to handle subscription renewal", "id", item.ID, "message", err)
k.Logger(cc).Error("Failed to handle subscription renewal", "id", item.ID, "msg", err)
return false
}

Expand Down
2 changes: 1 addition & 1 deletion x/subscription/keeper/msg_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (k *Keeper) HandleMsgRenewSubscription(ctx sdk.Context, msg *v3.MsgRenewSub
}

if err := subscription.ValidateRenewalPolicies(price); err != nil {
return nil, sdkerrors.Wrapf(types.ErrInvalidRenewalPolicy, err.Error())
return nil, sdkerrors.Wrap(types.ErrInvalidRenewalPolicy, err.Error())
}

k.DeleteSubscriptionForInactiveAt(ctx, subscription.InactiveAt, subscription.ID)
Expand Down

0 comments on commit 767e06b

Please sign in to comment.