11package cli
22
33import (
4+ "fmt"
45 "strconv"
6+ "time"
57
8+ sdkmath "cosmossdk.io/math"
69 "github.com/cosmos/cosmos-sdk/client"
710 "github.com/cosmos/cosmos-sdk/client/flags"
811 "github.com/cosmos/cosmos-sdk/client/tx"
@@ -15,21 +18,21 @@ import (
1518
1619func txCreatePlan () * cobra.Command {
1720 cmd := & cobra.Command {
18- Use : "create-plan [gigabytes ] [hours ]" ,
19- Short : "Create a new subscription plan with gigabytes, hours and pricing details" ,
21+ Use : "create-plan [bytes ] [duration ]" ,
22+ Short : "Create a new subscription plan with bytes, duration and pricing details" ,
2023 Args : cobra .ExactArgs (2 ),
2124 RunE : func (cmd * cobra.Command , args []string ) error {
2225 ctx , err := client .GetClientTxContext (cmd )
2326 if err != nil {
2427 return err
2528 }
2629
27- gigabytes , err := strconv . ParseInt (args [0 ], 10 , 64 )
28- if err != nil {
29- return err
30+ bytes , ok := sdkmath . NewIntFromString (args [0 ])
31+ if ! ok {
32+ return fmt . Errorf ( "invalid bytes %s" , args [ 0 ])
3033 }
3134
32- hours , err := strconv . ParseInt (args [1 ], 10 , 64 )
35+ duration , err := time . ParseDuration (args [1 ])
3336 if err != nil {
3437 return err
3538 }
@@ -41,8 +44,8 @@ func txCreatePlan() *cobra.Command {
4144
4245 msg := v3 .NewMsgCreatePlanRequest (
4346 ctx .FromAddress .Bytes (),
44- gigabytes ,
45- hours ,
47+ bytes ,
48+ duration ,
4649 prices ,
4750 )
4851 if err := msg .ValidateBasic (); err != nil {
0 commit comments