Skip to content

Commit aac0eeb

Browse files
committed
feat: subscription plan details should not be updated
1 parent d7364da commit aac0eeb

File tree

9 files changed

+83
-608
lines changed

9 files changed

+83
-608
lines changed

proto/sentinel/plan/v3/events.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ message EventUnlinkNode {
3636
message EventUpdate {
3737
uint64 id = 1 [(gogoproto.customname) = "ID"];
3838
string prov_address = 2;
39-
bool private = 3;
40-
sentinel.types.v1.Status status = 4;
39+
sentinel.types.v1.Status status = 3;
4140
}

proto/sentinel/plan/v3/msg.proto

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ message MsgUnlinkNodeRequest {
3939
string node_address = 3;
4040
}
4141

42-
message MsgUpdatePlanDetailsRequest {
43-
string from = 1;
44-
uint64 id = 2 [(gogoproto.customname) = "ID"];
45-
bool private = 3;
46-
}
47-
4842
message MsgUpdatePlanStatusRequest {
4943
string from = 1;
5044
uint64 id = 2 [(gogoproto.customname) = "ID"];
@@ -67,8 +61,6 @@ message MsgLinkNodeResponse {}
6761

6862
message MsgUnlinkNodeResponse {}
6963

70-
message MsgUpdatePlanDetailsResponse {}
71-
7264
message MsgUpdatePlanStatusResponse {}
7365

7466
message MsgStartSessionResponse {
@@ -79,7 +71,6 @@ service MsgService {
7971
rpc MsgCreatePlan(MsgCreatePlanRequest) returns (MsgCreatePlanResponse);
8072
rpc MsgLinkNode(MsgLinkNodeRequest) returns (MsgLinkNodeResponse);
8173
rpc MsgUnlinkNode(MsgUnlinkNodeRequest) returns (MsgUnlinkNodeResponse);
82-
rpc MsgUpdatePlanDetails(MsgUpdatePlanDetailsRequest) returns (MsgUpdatePlanDetailsResponse);
8374
rpc MsgUpdatePlanStatus(MsgUpdatePlanStatusRequest) returns (MsgUpdatePlanStatusResponse);
8475
rpc MsgStartSession(MsgStartSessionRequest) returns (MsgStartSessionResponse);
8576
}

x/plan/client/cli/cli.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func GetTxCommands() []*cobra.Command {
2121
txCreatePlan(),
2222
txLinkNode(),
2323
txUnlinkNode(),
24-
txUpdatePlanDetails(),
2524
txUpdatePlanStatus(),
2625
)
2726

x/plan/client/cli/tx.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -146,45 +146,6 @@ func txUnlinkNode() *cobra.Command {
146146
return cmd
147147
}
148148

149-
func txUpdatePlanDetails() *cobra.Command {
150-
cmd := &cobra.Command{
151-
Use: "update-plan-details [id] [private]",
152-
Short: "Update the details of an existing subscription plan",
153-
Args: cobra.ExactArgs(2),
154-
RunE: func(cmd *cobra.Command, args []string) error {
155-
ctx, err := client.GetClientTxContext(cmd)
156-
if err != nil {
157-
return err
158-
}
159-
160-
id, err := strconv.ParseUint(args[0], 10, 64)
161-
if err != nil {
162-
return err
163-
}
164-
165-
private, err := strconv.ParseBool(args[1])
166-
if err != nil {
167-
return err
168-
}
169-
170-
msg := v3.NewMsgUpdatePlanDetailsRequest(
171-
ctx.FromAddress.Bytes(),
172-
id,
173-
private,
174-
)
175-
if err := msg.ValidateBasic(); err != nil {
176-
return err
177-
}
178-
179-
return tx.GenerateOrBroadcastTxCLI(ctx, cmd.Flags(), msg)
180-
},
181-
}
182-
183-
flags.AddTxFlagsToCmd(cmd)
184-
185-
return cmd
186-
}
187-
188149
func txUpdatePlanStatus() *cobra.Command {
189150
cmd := &cobra.Command{
190151
Use: "update-plan-status [id] [status]",

x/plan/keeper/msg_handler.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,6 @@ func (k *Keeper) HandleMsgUnlinkNode(ctx sdk.Context, msg *v3.MsgUnlinkNodeReque
108108
return &v3.MsgUnlinkNodeResponse{}, nil
109109
}
110110

111-
func (k *Keeper) HandleMsgUpdatePlanDetails(ctx sdk.Context, msg *v3.MsgUpdatePlanDetailsRequest) (*v3.MsgUpdatePlanDetailsResponse, error) {
112-
plan, found := k.GetPlan(ctx, msg.ID)
113-
if !found {
114-
return nil, types.NewErrorPlanNotFound(msg.ID)
115-
}
116-
if msg.From != plan.ProvAddress {
117-
return nil, types.NewErrorUnauthorized(msg.From)
118-
}
119-
120-
plan.Private = msg.Private
121-
122-
k.SetPlan(ctx, plan)
123-
ctx.EventManager().EmitTypedEvent(
124-
&v3.EventUpdate{
125-
ID: plan.ID,
126-
ProvAddress: plan.ProvAddress,
127-
Private: plan.Private,
128-
},
129-
)
130-
131-
return &v3.MsgUpdatePlanDetailsResponse{}, nil
132-
}
133-
134111
func (k *Keeper) HandleMsgUpdatePlanStatus(ctx sdk.Context, msg *v3.MsgUpdatePlanStatusRequest) (*v3.MsgUpdatePlanStatusResponse, error) {
135112
plan, found := k.GetPlan(ctx, msg.ID)
136113
if !found {

x/plan/services/v3/msg_server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ func (m *msgServer) MsgUnlinkNode(c context.Context, req *v3.MsgUnlinkNodeReques
3636
return m.HandleMsgUnlinkNode(ctx, req)
3737
}
3838

39-
func (m *msgServer) MsgUpdatePlanDetails(c context.Context, req *v3.MsgUpdatePlanDetailsRequest) (*v3.MsgUpdatePlanDetailsResponse, error) {
40-
ctx := sdk.UnwrapSDKContext(c)
41-
return m.HandleMsgUpdatePlanDetails(ctx, req)
42-
}
43-
4439
func (m *msgServer) MsgUpdatePlanStatus(c context.Context, req *v3.MsgUpdatePlanStatusRequest) (*v3.MsgUpdatePlanStatusResponse, error) {
4540
ctx := sdk.UnwrapSDKContext(c)
4641
return m.HandleMsgUpdatePlanStatus(ctx, req)

x/plan/types/v3/events.pb.go

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

x/plan/types/v3/msg.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -148,37 +148,6 @@ func (m *MsgUnlinkNodeRequest) GetSigners() []sdk.AccAddress {
148148
return []sdk.AccAddress{from.Bytes()}
149149
}
150150

151-
func NewMsgUpdatePlanDetailsRequest(from base.ProvAddress, id uint64, private bool) *MsgUpdatePlanDetailsRequest {
152-
return &MsgUpdatePlanDetailsRequest{
153-
From: from.String(),
154-
ID: id,
155-
Private: private,
156-
}
157-
}
158-
159-
func (m *MsgUpdatePlanDetailsRequest) ValidateBasic() error {
160-
if m.From == "" {
161-
return sdkerrors.Wrap(types.ErrorInvalidMessage, "from cannot be empty")
162-
}
163-
if _, err := base.ProvAddressFromBech32(m.From); err != nil {
164-
return sdkerrors.Wrap(types.ErrorInvalidMessage, err.Error())
165-
}
166-
if m.ID == 0 {
167-
return sdkerrors.Wrap(types.ErrorInvalidMessage, "id cannot be zero")
168-
}
169-
170-
return nil
171-
}
172-
173-
func (m *MsgUpdatePlanDetailsRequest) GetSigners() []sdk.AccAddress {
174-
from, err := base.ProvAddressFromBech32(m.From)
175-
if err != nil {
176-
panic(err)
177-
}
178-
179-
return []sdk.AccAddress{from.Bytes()}
180-
}
181-
182151
func NewMsgUpdatePlanStatusRequest(from base.ProvAddress, id uint64, status v1base.Status) *MsgUpdatePlanStatusRequest {
183152
return &MsgUpdatePlanStatusRequest{
184153
From: from.String(),

0 commit comments

Comments
 (0)