Skip to content

Commit

Permalink
fix: fix init command bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Oct 19, 2023
1 parent fd984df commit eae4e2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cmd/seda-chaind/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -119,12 +120,13 @@ func downloadAndApplyNetworkConfig(network, moniker string, config *cfg.Config)
seedsBytes, err := os.ReadFile(seedsFile)
if err != nil {
if !os.IsNotExist(err) {
return "", "", err
return "", "", errors.Wrapf(err, "error reading seeds file at %s", seedsFile)
}
} else {
seeds = strings.TrimRight(string(seedsBytes), " \n")
config.P2P.Seeds = seeds
}
seeds = string(seedsBytes)

config.P2P.Seeds = seeds
config.Moniker = moniker
cfg.WriteConfigFile(filepath.Join(configDir, "config.toml"), config)

Expand Down
16 changes: 13 additions & 3 deletions cmd/seda-chaind/cmd/init_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -18,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/genutil"

"github.com/sedaprotocol/seda-chain/app/params"
Expand Down Expand Up @@ -141,10 +143,18 @@ func newNetworkCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Comma

func joinNetworkCommand(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
cmd := &cobra.Command{
Use: "join [moniker] [network]",
Use: "join [moniker]",
Short: "Grabs an existing network configuration and initializes node based on it",
Long: `Initialize validator and node configuration files for an existing network.`,
Args: cobra.ExactArgs(1),
Long: strings.TrimSpace(
fmt.Sprintf(`Initialize validator and node configuration files for an existing network.
Example:
$ %s init join moniker --network devnet
`,
version.AppName,
),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
serverCtx := server.GetServerContextFromCmd(cmd)
Expand Down

0 comments on commit eae4e2b

Please sign in to comment.