Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ioctl] fix nil point panic #3642

Merged
merged 2 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ioctl/cmd/node/nodedelegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func delegates() error {
if err != nil {
return output.NewError(0, "failed to get epoch meta", err)
}
if response.EpochData == nil {
return output.NewError(0, "ROLLDPOS is not registered", nil)
}
epochData := response.EpochData
aliases := alias.GetAliasMap()
message := delegatesMessage{
Expand Down
3 changes: 3 additions & 0 deletions ioctl/cmd/node/nodeprobationlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func probationlist() error {
if err != nil {
return output.NewError(0, "failed to get epoch meta", err)
}
if response.EpochData == nil {
return output.NewError(0, "ROLLDPOS is not registered", nil)
}
probationlist, err := getProbationList(_epochNum, response.EpochData.Height)
if err != nil {
return output.NewError(0, "failed to get probation list", err)
Expand Down
1 change: 1 addition & 0 deletions ioctl/newcmd/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func NewNodeCmd(client ioctl.Client) *cobra.Command {
}
nc.AddCommand(NewNodeDelegateCmd(client))
nc.AddCommand(NewNodeRewardCmd(client))
nc.AddCommand(NewNodeProbationlistCmd(client))

client.SetEndpointWithFlag(nc.PersistentFlags().StringVar)
client.SetInsecureWithFlag(nc.PersistentFlags().BoolVar)
Expand Down
3 changes: 3 additions & 0 deletions ioctl/newcmd/node/nodedelegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ func NewNodeDelegateCmd(client ioctl.Client) *cobra.Command {
if err != nil {
return errors.Wrap(err, "failed to get epoch meta")
}
if response.EpochData == nil {
return errors.New("ROLLDPOS is not registered")
}
epochData := response.EpochData
aliases := client.AliasMap()
message := delegatesMessage{
Expand Down
3 changes: 3 additions & 0 deletions ioctl/newcmd/node/nodeprobationlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func NewNodeProbationlistCmd(client ioctl.Client) *cobra.Command {
if err != nil {
return errors.Wrap(err, "failed to get epoch meta")
}
if response.EpochData == nil {
return errors.New("ROLLDPOS is not registered")
}
probationlist, err := getProbationList(client, epochNum, response.EpochData.Height)
if err != nil {
return errors.Wrap(err, "failed to get probation list")
Expand Down
4 changes: 4 additions & 0 deletions ioctl/newcmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/iotexproject/iotex-core/ioctl"
"github.com/iotexproject/iotex-core/ioctl/config"
"github.com/iotexproject/iotex-core/ioctl/newcmd/account"
"github.com/iotexproject/iotex-core/ioctl/newcmd/bc"
"github.com/iotexproject/iotex-core/ioctl/newcmd/node"
)

// Multi-language support
Expand Down Expand Up @@ -47,6 +49,8 @@ func NewIoctl(client ioctl.Client) *cobra.Command {

rootCmd.AddCommand(config.ConfigCmd)
rootCmd.AddCommand(account.NewAccountCmd(client))
rootCmd.AddCommand(bc.NewBCCmd(client))
rootCmd.AddCommand(node.NewNodeCmd(client))

return rootCmd
}
Expand Down