Skip to content
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
2 changes: 1 addition & 1 deletion starport/cmd/chain_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func chainInitHandler(cmd *cobra.Command, args []string) error {
return err
}

if err := c.Init(cmd.Context()); err != nil {
if err := c.Init(cmd.Context(), true); err != nil {
return err
}

Expand Down
7 changes: 5 additions & 2 deletions starport/services/chain/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
)

// Init initializes the chain and applies all optional configurations.
func (c *Chain) Init(ctx context.Context) error {
func (c *Chain) Init(ctx context.Context, initAccounts bool) error {
conf, err := c.Config()
if err != nil {
return &CannotBuildAppError{err}
Expand All @@ -28,7 +28,10 @@ func (c *Chain) Init(ctx context.Context) error {
return err
}

return c.InitAccounts(ctx, conf)
if initAccounts {
return c.InitAccounts(ctx, conf)
}
return nil
}

// InitChain initializes the chain.
Expand Down
2 changes: 1 addition & 1 deletion starport/services/chain/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (c *Chain) serve(ctx context.Context, forceReset bool) error {
if !isInit || (appModified && !exportGenesisExists) {
fmt.Fprintln(c.stdLog().out, "💿 Initializing the app...")

if err := c.Init(ctx); err != nil {
if err := c.Init(ctx, true); err != nil {
return err
}
} else if appModified {
Expand Down
12 changes: 12 additions & 0 deletions starport/services/config.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package services

import (
"os"

"github.com/tendermint/starport/starport/pkg/xfilepath"
)

var (
// StarportConfPath returns the Starport Configuration directory
StarportConfPath = xfilepath.JoinFromHome(xfilepath.Path(".starport"))
)

// InitConfig creates config directory if it is not yet created
func InitConfig() error {
confPath, err := StarportConfPath()
if err != nil {
return err
}

return os.MkdirAll(confPath, 0755)
}
2 changes: 1 addition & 1 deletion starport/services/networkbuilder/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (b *Blockchain) init(
if _, err := chain.Build(ctx); err != nil {
return err
}
if err := chain.Init(ctx); err != nil {
if err := chain.Init(ctx, false); err != nil {
return err
}
b.builder.ev.Send(events.New(events.StatusDone, "Blockchain initialized"))
Expand Down
4 changes: 4 additions & 0 deletions starport/services/networkbuilder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func ConfigGet() (*Config, error) {

// ConfigSave saves the current state of Config.
func ConfigSave(c *Config) error {
if err := services.InitConfig(); err != nil {
return err
}

conf, err := confPath()
if err != nil {
return nil
Expand Down
6 changes: 2 additions & 4 deletions starport/services/networkbuilder/networkbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ func (b *Builder) Init(ctx context.Context, chainID string, source SourceOption,
}

// ensure the path for chain source exists
if err := os.MkdirAll(sourcePath, 0700); err != nil && !os.IsExist(err) {
if !os.IsExist(err) {
return nil, err
}
if err := os.MkdirAll(sourcePath, 0755); err != nil {
return nil, err
}

path = filepath.Join(sourcePath, chainID)
Expand Down