Skip to content

Commit dc3ac6a

Browse files
committed
feat: add start_at field for subscription
1 parent b2deb3f commit dc3ac6a

File tree

4 files changed

+88
-37
lines changed

4 files changed

+88
-37
lines changed

proto/sentinel/subscription/v3/subscription.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ message Subscription {
2222
(gogoproto.nullable) = false,
2323
(gogoproto.stdtime) = true
2424
];
25-
google.protobuf.Timestamp status_at = 8 [
25+
google.protobuf.Timestamp start_at = 8 [
26+
(gogoproto.nullable) = false,
27+
(gogoproto.stdtime) = true
28+
];
29+
google.protobuf.Timestamp status_at = 9 [
2630
(gogoproto.nullable) = false,
2731
(gogoproto.stdtime) = true
2832
];

x/plan/types/v3/plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (m *Plan) GetBytes() sdkmath.Int {
1515
return base.Gigabyte.MulRaw(m.Gigabytes)
1616
}
1717

18-
func (m *Plan) GetDuration() time.Duration {
18+
func (m *Plan) GetHours() time.Duration {
1919
return time.Duration(m.Hours) * time.Hour
2020
}
2121

x/subscription/keeper/msg_handler.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ func (k *Keeper) HandleMsgRenewSubscription(ctx sdk.Context, msg *v3.MsgRenewSub
123123
Price: price,
124124
RenewalPricePolicy: subscription.RenewalPricePolicy,
125125
Status: v1base.StatusActive,
126-
InactiveAt: ctx.BlockTime().Add(plan.GetDuration()),
126+
InactiveAt: ctx.BlockTime().Add(plan.GetHours()),
127+
StartAt: ctx.BlockTime(),
127128
StatusAt: ctx.BlockTime(),
128129
}
129130

@@ -277,7 +278,8 @@ func (k *Keeper) HandleMsgStartSubscription(ctx sdk.Context, msg *v3.MsgStartSub
277278
Price: price,
278279
RenewalPricePolicy: msg.RenewalPricePolicy,
279280
Status: v1base.StatusActive,
280-
InactiveAt: ctx.BlockTime().Add(plan.GetDuration()),
281+
InactiveAt: ctx.BlockTime().Add(plan.GetHours()),
282+
StartAt: ctx.BlockTime(),
281283
StatusAt: ctx.BlockTime(),
282284
}
283285

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

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

0 commit comments

Comments
 (0)