Skip to content

Commit

Permalink
Fixed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Jul 27, 2023
1 parent 19bc880 commit 3ac7932
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
7 changes: 3 additions & 4 deletions x/plan/client/cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
plantypes "github.com/sentinel-official/hub/x/plan/types"
"github.com/spf13/cobra"

netutil "github.com/sentinel-official/cli-client/utils/net"
"github.com/sentinel-official/cli-client/x/plan/types"
)

Expand All @@ -21,7 +20,7 @@ var (
"ID",
"Address",
"Prices",
"Bytes",
"Gigabytes",
"Duration",
"Status",
}
Expand Down Expand Up @@ -66,7 +65,7 @@ func QueryPlan() *cobra.Command {
fmt.Sprintf("%d", item.ID),
item.Address,
item.Prices.Raw().String(),
netutil.ToReadable(item.Bytes, 2),
fmt.Sprintf("%d", item.Gigabytes),
item.Duration.String(),
item.Status,
},
Expand Down Expand Up @@ -156,7 +155,7 @@ func QueryPlans() *cobra.Command {
fmt.Sprintf("%d", items[i].ID),
items[i].Address,
items[i].Prices.Raw().String(),
netutil.ToReadable(items[i].Bytes, 2),
fmt.Sprintf("%d", items[i].Gigabytes),
items[i].Duration.String(),
items[i].Status,
},
Expand Down
8 changes: 4 additions & 4 deletions x/plan/client/cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func GetTxCommand() *cobra.Command {

func txCreate() *cobra.Command {
cmd := &cobra.Command{
Use: "create [bytes] [duration] [prices]",
Use: "create [duration] [gigabytes] [prices]",
Short: "Create a plan",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -42,12 +42,12 @@ func txCreate() *cobra.Command {
return err
}

bytes, err := strconv.ParseInt(args[0], 10, 64)
duration, err := time.ParseDuration(args[0])
if err != nil {
return err
}

duration, err := time.ParseDuration(args[1])
gigabytes, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
return err
}
Expand All @@ -59,8 +59,8 @@ func txCreate() *cobra.Command {

msg := plantypes.NewMsgCreateRequest(
ctx.FromAddress.Bytes(),
sdk.NewInt(bytes),
duration,
gigabytes,
prices,
)
if err := msg.ValidateBasic(); err != nil {
Expand Down
28 changes: 14 additions & 14 deletions x/plan/types/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import (
)

type Plan struct {
ID uint64 `json:"id"`
Address string `json:"address"`
Prices clienttypes.Coins `json:"prices"`
Duration time.Duration `json:"duration"`
Bytes int64 `json:"bytes"`
Status string `json:"status"`
StatusAt time.Time `json:"status_at"`
ID uint64 `json:"id"`
Address string `json:"address"`
Prices clienttypes.Coins `json:"prices"`
Duration time.Duration `json:"duration"`
Gigabytes int64 `json:"gigabytes"`
Status string `json:"status"`
StatusAt time.Time `json:"status_at"`
}

func NewPlanFromRaw(v *plantypes.Plan) Plan {
return Plan{
ID: v.ID,
Address: v.Address,
Prices: clienttypes.NewCoinsFromRaw(v.Prices),
Duration: v.Duration,
Bytes: v.Bytes.Int64(),
Status: v.Status.String(),
StatusAt: v.StatusAt,
ID: v.ID,
Address: v.Address,
Prices: clienttypes.NewCoinsFromRaw(v.Prices),
Duration: v.Duration,
Gigabytes: v.Gigabytes,
Status: v.Status.String(),
StatusAt: v.StatusAt,
}
}

Expand Down
6 changes: 3 additions & 3 deletions x/subscription/client/cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
subscriptionHeader = []string{
"ID",
"Address",
"Expiry at",
"Inactive at",
"Status",
"Node",
"Gigabytes",
Expand Down Expand Up @@ -79,7 +79,7 @@ func QuerySubscription() *cobra.Command {
[]string{
fmt.Sprintf("%d", item.ID),
item.Address,
item.ExpiryAt.String(),
item.InactiveAt.String(),
item.Status,
item.NodeAddress,
fmt.Sprintf("%d", item.Gigabytes),
Expand Down Expand Up @@ -183,7 +183,7 @@ func QuerySubscriptions() *cobra.Command {
[]string{
fmt.Sprintf("%d", items[i].ID),
items[i].Address,
items[i].ExpiryAt.String(),
items[i].InactiveAt.String(),
items[i].Status,
items[i].NodeAddress,
fmt.Sprintf("%d", items[i].Gigabytes),
Expand Down
20 changes: 10 additions & 10 deletions x/subscription/types/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
)

type Subscription struct {
ID uint64 `json:"id"`
Address string `json:"address"`
ExpiryAt time.Time `json:"expiry_at"`
Status string `json:"status"`
StatusAt time.Time `json:"status_at"`
ID uint64 `json:"id"`
Address string `json:"address"`
InactiveAt time.Time `json:"inactive_at"`
Status string `json:"status"`
StatusAt time.Time `json:"status_at"`

NodeAddress string `json:"node_address"`
Gigabytes int64 `json:"gigabytes"`
Expand All @@ -24,11 +24,11 @@ type Subscription struct {

func NewSubscriptionFromRaw(v subscriptiontypes.Subscription) Subscription {
s := Subscription{
ID: v.GetID(),
Address: v.GetAddress().String(),
ExpiryAt: v.GetExpiryAt(),
Status: v.GetStatus().String(),
StatusAt: v.GetStatusAt(),
ID: v.GetID(),
Address: v.GetAddress().String(),
InactiveAt: v.GetInactiveAt(),
Status: v.GetStatus().String(),
StatusAt: v.GetStatusAt(),
}

if v.Type() == subscriptiontypes.TypeNode {
Expand Down

0 comments on commit 3ac7932

Please sign in to comment.