|
| 1 | +package gov |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/spf13/cobra" |
| 5 | + |
| 6 | + "github.com/forbole/callisto/v4/database" |
| 7 | + "github.com/forbole/callisto/v4/modules/distribution" |
| 8 | + "github.com/forbole/callisto/v4/modules/gov" |
| 9 | + "github.com/forbole/callisto/v4/modules/mint" |
| 10 | + "github.com/forbole/callisto/v4/modules/slashing" |
| 11 | + "github.com/forbole/callisto/v4/modules/staking" |
| 12 | + modulestypes "github.com/forbole/callisto/v4/modules/types" |
| 13 | + parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types" |
| 14 | + "github.com/forbole/juno/v5/types/config" |
| 15 | +) |
| 16 | + |
| 17 | +func paramsCmd(parseConfig *parsecmdtypes.Config) *cobra.Command { |
| 18 | + return &cobra.Command{ |
| 19 | + Use: "params", |
| 20 | + Short: "Get the current parameters of the gov module", |
| 21 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 22 | + parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig) |
| 23 | + if err != nil { |
| 24 | + return err |
| 25 | + } |
| 26 | + |
| 27 | + sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig) |
| 28 | + if err != nil { |
| 29 | + return err |
| 30 | + } |
| 31 | + |
| 32 | + // Get the database |
| 33 | + db := database.Cast(parseCtx.Database) |
| 34 | + |
| 35 | + // Build expected modules of gov modules |
| 36 | + distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Codec, db) |
| 37 | + mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Codec, db) |
| 38 | + slashingModule := slashing.NewModule(sources.SlashingSource, parseCtx.EncodingConfig.Codec, db) |
| 39 | + stakingModule := staking.NewModule(sources.StakingSource, parseCtx.EncodingConfig.Codec, db) |
| 40 | + |
| 41 | + // Build the gov module |
| 42 | + govModule := gov.NewModule(sources.GovSource, distrModule, mintModule, slashingModule, stakingModule, parseCtx.EncodingConfig.Codec, db) |
| 43 | + |
| 44 | + height, err := parseCtx.Node.LatestHeight() |
| 45 | + if err != nil { |
| 46 | + return err |
| 47 | + } |
| 48 | + |
| 49 | + return govModule.UpdateParams(height) |
| 50 | + }, |
| 51 | + } |
| 52 | +} |
0 commit comments