/
root.go
71 lines (60 loc) · 2.1 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/konstellation/konstellation/app"
"github.com/konstellation/konstellation/const"
"github.com/spf13/cobra"
"github.com/tendermint/spm/cosmoscmd"
"os"
)
// NewRootCmd creates a new root command for cosmodrome. It is called once in the
// main function.
func NewRootCmd(
accountAddressPrefix string,
moduleBasics module.BasicManager,
) (*cobra.Command, cosmoscmd.EncodingConfig) {
// Set config for prefixes
cosmoscmd.SetPrefixes(accountAddressPrefix)
_const.RegisterNativeCoinUnits()
encodingConfig := cosmoscmd.MakeEncodingConfig(moduleBasics)
//types.RegisterBech32Prefix()
initClientCtx := client.Context{}.
WithJSONMarshaler(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(authtypes.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(app.DefaultNodeHome)
rootCmd := &cobra.Command{
Use: version.AppName,
Short: "cosmodrome",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
return server.InterceptConfigsPreRunHandler(cmd)
},
}
initRootCmd(rootCmd, encodingConfig)
return rootCmd, encodingConfig
}
func initRootCmd(rootCmd *cobra.Command, encodingConfig cosmoscmd.EncodingConfig) {
authclient.Codec = encodingConfig.Marshaler
rootCmd.AddCommand(
GenNetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}),
version.NewVersionCommand(),
)
}
//func addModuleInitFlags(startCmd *cobra.Command) {
// crisis.AddModuleInitFlags(startCmd)
// wasm.AddModuleInitFlags(startCmd)
//}