Skip to content

Commit

Permalink
fix: seal the config (#61)
Browse files Browse the repository at this point in the history
* seal the config

* tidy
  • Loading branch information
beer-1 authored Sep 13, 2024
1 parent eafd1d6 commit e8a3a64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions cmd/minitiad/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"context"
"errors"
"io"
"os"
Expand All @@ -11,7 +10,6 @@ import (
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/sync/errgroup"

"cosmossdk.io/log"
confixcmd "cosmossdk.io/tools/confix/cmd"
Expand Down Expand Up @@ -95,6 +93,11 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
Use: basename,
Short: "minitia App",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// except for launch command, seal the config
if cmd.Name() != "launch" {
sdk.GetConfig().Seal()
}

// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
cmd.SetErr(cmd.ErrOrStderr())
Expand Down Expand Up @@ -156,13 +159,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b
pruning.Cmd(a.AppCreator(), minitiaapp.DefaultNodeHome),
snapshot.Cmd(a.AppCreator()),
)
server.AddCommandsWithStartCmdOptions(rootCmd, minitiaapp.DefaultNodeHome, a.AppCreator(), a.appExport, server.StartCmdOptions{
AddFlags: addModuleInitFlags,
PostSetup: func(svrCtx *server.Context, clientCtx client.Context, ctx context.Context, g *errgroup.Group) error {
sdk.GetConfig().Seal()
return nil
},
})
server.AddCommands(rootCmd, minitiaapp.DefaultNodeHome, a.AppCreator(), a.appExport, addModuleInitFlags)

// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/sync v0.8.0
)

require (
Expand Down Expand Up @@ -232,6 +231,7 @@ require (
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand Down

0 comments on commit e8a3a64

Please sign in to comment.