Skip to content

Commit ce5762a

Browse files
committed
feat: renamed field status_change_delay to inactive_pending_duration in subscription params
1 parent 21ad688 commit ce5762a

File tree

7 files changed

+75
-75
lines changed

7 files changed

+75
-75
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ proto-gen:
7676

7777
.PHONY: proto-lint
7878
proto-lint:
79-
find proto -name *.proto -exec buf format -w {} \;
79+
@find proto -name *.proto -exec buf format -w {} \;
8080

8181
.PHONY: build-image
8282
build-image:

proto/sentinel/subscription/v3/params.proto

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ option (gogoproto.equal_all) = false;
99
option (gogoproto.goproto_getters_all) = false;
1010

1111
message Params {
12-
string staking_share = 1 [
13-
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
14-
(gogoproto.nullable) = false
15-
];
16-
google.protobuf.Duration status_change_delay = 2 [
12+
google.protobuf.Duration inactive_pending_duration = 1 [
1713
(gogoproto.nullable) = false,
1814
(gogoproto.stdduration) = true
1915
];
16+
string staking_share = 2 [
17+
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
18+
(gogoproto.nullable) = false
19+
];
2020
}

x/subscription/keeper/msg_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (k *Keeper) HandleMsgCancelSubscription(ctx sdk.Context, msg *v3.MsgCancelS
4242

4343
// Clear renewal policy and mark subscription as inactive pending
4444
subscription.RenewalPricePolicy = v1base.RenewalPricePolicyUnspecified
45-
subscription.InactiveAt = k.GetInactiveAt(ctx)
45+
subscription.InactiveAt = k.GetInactivePendingAt(ctx)
4646
subscription.Status = v1base.StatusInactivePending
4747
subscription.StatusAt = ctx.BlockTime()
4848

x/subscription/keeper/params.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ func (k *Keeper) GetParams(ctx sdk.Context) (v v3.Params) {
3030
return v
3131
}
3232

33+
// InactivePendingDuration returns the inactive pending duration from the module's parameters.
34+
func (k *Keeper) InactivePendingDuration(ctx sdk.Context) time.Duration {
35+
return k.GetParams(ctx).InactivePendingDuration
36+
}
37+
3338
// StakingShare retrieves the staking share parameter from the module's parameters.
3439
func (k *Keeper) StakingShare(ctx sdk.Context) sdkmath.LegacyDec {
3540
return k.GetParams(ctx).StakingShare
3641
}
3742

38-
// StatusChangeDelay returns the delay for status changes from the module's parameters.
39-
func (k *Keeper) StatusChangeDelay(ctx sdk.Context) time.Duration {
40-
return k.GetParams(ctx).StatusChangeDelay
41-
}
42-
43-
// GetInactiveAt returns the inactive time by adding StatusChangeDelay to the current block time.
44-
func (k *Keeper) GetInactiveAt(ctx sdk.Context) time.Time {
45-
d := k.StatusChangeDelay(ctx)
43+
// GetInactivePendingAt returns the inactive pending time by adding InactivePendingDuration to the current block time.
44+
func (k *Keeper) GetInactivePendingAt(ctx sdk.Context) time.Time {
45+
d := k.InactivePendingDuration(ctx)
4646

4747
return ctx.BlockTime().Add(d)
4848
}

x/subscription/migrations/migrator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ func (k *Migrator) deleteKeys(ctx sdk.Context, keyPrefix []byte) (keys [][]byte)
7676

7777
func (k *Migrator) setParams(ctx sdk.Context) {
7878
params := v3.Params{
79-
StakingShare: sdkmath.LegacyMustNewDecFromStr("0.2"),
80-
StatusChangeDelay: 4 * time.Hour,
79+
InactivePendingDuration: 4 * time.Hour,
80+
StakingShare: sdkmath.LegacyMustNewDecFromStr("0.2"),
8181
}
8282

8383
k.subscription.SetParams(ctx, params)

x/subscription/types/v3/params.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,36 @@ import (
1010

1111
// Default parameter values for the Params struct.
1212
var (
13-
DefaultStakingShare = sdkmath.LegacyMustNewDecFromStr("0.1") // Default staking share: 0.1
14-
DefaultStatusChangeDelay = 2 * time.Minute // Default delay before status change
13+
DefaultInactivePendingDuration = 2 * time.Minute // Default inactive pending duration
14+
DefaultStakingShare = sdkmath.LegacyMustNewDecFromStr("0.1") // Default staking share: 0.1
1515
)
1616

1717
// Validate checks whether the Params fields are valid according to defined rules.
1818
func (m *Params) Validate() error {
19-
if err := validateStakingShare(m.StakingShare); err != nil {
20-
return fmt.Errorf("invalid staking_share: %w", err)
19+
if err := validateInactivePendingDuration(m.InactivePendingDuration); err != nil {
20+
return fmt.Errorf("invalid inactive_pending_duration: %w", err)
2121
}
2222

23-
if err := validateStatusChangeDelay(m.StatusChangeDelay); err != nil {
24-
return fmt.Errorf("invalid status_change_delay: %w", err)
23+
if err := validateStakingShare(m.StakingShare); err != nil {
24+
return fmt.Errorf("invalid staking_share: %w", err)
2525
}
2626

2727
return nil
2828
}
2929

3030
// NewParams creates a new Params instance with custom values.
31-
func NewParams(stakingShare sdkmath.LegacyDec, statusChangeDelay time.Duration) Params {
31+
func NewParams(inactivePendingDuration time.Duration, stakingShare sdkmath.LegacyDec) Params {
3232
return Params{
33-
StakingShare: stakingShare,
34-
StatusChangeDelay: statusChangeDelay,
33+
InactivePendingDuration: inactivePendingDuration,
34+
StakingShare: stakingShare,
3535
}
3636
}
3737

3838
// DefaultParams returns a Params struct initialized with default values.
3939
func DefaultParams() Params {
4040
return NewParams(
41+
DefaultInactivePendingDuration,
4142
DefaultStakingShare,
42-
DefaultStatusChangeDelay,
4343
)
4444
}
4545

@@ -63,8 +63,8 @@ func validateStakingShare(v sdkmath.LegacyDec) error {
6363
return nil
6464
}
6565

66-
// validateStatusChangeDelay checks that statusChangeDelay is a positive duration.
67-
func validateStatusChangeDelay(v time.Duration) error {
66+
// validateInactivePendingDuration checks that InactivePendingDuration is a positive duration.
67+
func validateInactivePendingDuration(v time.Duration) error {
6868
if v == 0 {
6969
return errors.New("value cannot be zero")
7070
}

x/subscription/types/v3/params.pb.go

Lines changed: 46 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)