File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,17 +62,18 @@ func InitCmd() *cobra.Command {
6262
6363 // Initialize genesis without app state
6464 err = rollgenesis .CreateGenesis (homePath , chainID , 1 , proposerAddress )
65+ genesisPath := rollgenesis .GenesisPath (homePath )
6566 if errors .Is (err , rollgenesis .ErrGenesisExists ) {
6667 // check if existing genesis file is valid
67- if genesis , err := rollgenesis .LoadGenesis (homePath ); err == nil {
68+ if genesis , err := rollgenesis .LoadGenesis (genesisPath ); err == nil {
6869 if err := genesis .Validate (); err != nil {
6970 return fmt .Errorf ("existing genesis file is invalid: %w" , err )
7071 }
7172 } else {
7273 return fmt .Errorf ("error loading existing genesis file: %w" , err )
7374 }
7475
75- cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , homePath )
76+ cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , genesisPath )
7677 } else if err != nil {
7778 return fmt .Errorf ("error initializing genesis file: %w" , err )
7879 }
Original file line number Diff line number Diff line change @@ -62,17 +62,18 @@ func InitCmd() *cobra.Command {
6262
6363 // Initialize genesis without app state
6464 err = rollgenesis .CreateGenesis (homePath , chainID , 1 , proposerAddress )
65+ genesisPath := rollgenesis .GenesisPath (homePath )
6566 if errors .Is (err , rollgenesis .ErrGenesisExists ) {
6667 // check if existing genesis file is valid
67- if genesis , err := rollgenesis .LoadGenesis (homePath ); err == nil {
68+ if genesis , err := rollgenesis .LoadGenesis (genesisPath ); err == nil {
6869 if err := genesis .Validate (); err != nil {
6970 return fmt .Errorf ("existing genesis file is invalid: %w" , err )
7071 }
7172 } else {
7273 return fmt .Errorf ("error loading existing genesis file: %w" , err )
7374 }
7475
75- cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , homePath )
76+ cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , genesisPath )
7677 } else if err != nil {
7778 return fmt .Errorf ("error initializing genesis file: %w" , err )
7879 }
Original file line number Diff line number Diff line change @@ -62,17 +62,18 @@ func InitCmd() *cobra.Command {
6262
6363 // Initialize genesis without app state
6464 err = rollgenesis .CreateGenesis (homePath , chainID , 1 , proposerAddress )
65+ genesisPath := rollgenesis .GenesisPath (homePath )
6566 if errors .Is (err , rollgenesis .ErrGenesisExists ) {
6667 // check if existing genesis file is valid
67- if genesis , err := rollgenesis .LoadGenesis (homePath ); err == nil {
68+ if genesis , err := rollgenesis .LoadGenesis (genesisPath ); err == nil {
6869 if err := genesis .Validate (); err != nil {
6970 return fmt .Errorf ("existing genesis file is invalid: %w" , err )
7071 }
7172 } else {
7273 return fmt .Errorf ("error loading existing genesis file: %w" , err )
7374 }
7475
75- cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , homePath )
76+ cmd .Printf ("Genesis file already exists at %s, skipping creation.\n " , genesisPath )
7677 } else if err != nil {
7778 return fmt .Errorf ("error initializing genesis file: %w" , err )
7879 }
Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ import (
1010
1111var ErrGenesisExists = fmt .Errorf ("genesis file already exists" )
1212
13+ // GenesisPath returns the genesis file path from a home directory.
14+ func GenesisPath (homePath string ) string {
15+ configDir := filepath .Join (homePath , "config" )
16+ return filepath .Join (configDir , "genesis.json" )
17+ }
18+
1319// CreateGenesis creates and saves a genesis file with the given app state.
1420// If the genesis file already exists, it skips the creation and returns ErrGenesisExists.
1521// The genesis file is saved in the config directory of the specified home path.
You can’t perform that action at this time.
0 commit comments