Skip to content

Commit

Permalink
feat: add parse gov params command
Browse files Browse the repository at this point in the history
  • Loading branch information
dadamu committed Apr 17, 2024
1 parent 0a688b2 commit 1835e03
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/parse/gov/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func NewGovCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {

cmd.AddCommand(
proposalCmd(parseConfig),
paramsCmd(parseConfig),
)

return cmd
Expand Down
52 changes: 52 additions & 0 deletions cmd/parse/gov/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package gov

import (
"github.com/spf13/cobra"

"github.com/forbole/callisto/v4/database"
"github.com/forbole/callisto/v4/modules/distribution"
"github.com/forbole/callisto/v4/modules/gov"
"github.com/forbole/callisto/v4/modules/mint"
"github.com/forbole/callisto/v4/modules/slashing"
"github.com/forbole/callisto/v4/modules/staking"
modulestypes "github.com/forbole/callisto/v4/modules/types"
parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types"
"github.com/forbole/juno/v5/types/config"
)

func paramsCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
return &cobra.Command{
Use: "params",
Short: "Get the current parameters of the gov module",
RunE: func(cmd *cobra.Command, args []string) error {
parseCtx, err := parsecmdtypes.GetParserContext(config.Cfg, parseConfig)
if err != nil {
return err
}

sources, err := modulestypes.BuildSources(config.Cfg.Node, parseCtx.EncodingConfig)
if err != nil {
return err
}

// Get the database
db := database.Cast(parseCtx.Database)

// Build expected modules of gov modules
distrModule := distribution.NewModule(sources.DistrSource, parseCtx.EncodingConfig.Codec, db)
mintModule := mint.NewModule(sources.MintSource, parseCtx.EncodingConfig.Codec, db)
slashingModule := slashing.NewModule(sources.SlashingSource, parseCtx.EncodingConfig.Codec, db)
stakingModule := staking.NewModule(sources.StakingSource, parseCtx.EncodingConfig.Codec, db)

// Build the gov module
govModule := gov.NewModule(sources.GovSource, distrModule, mintModule, slashingModule, stakingModule, parseCtx.EncodingConfig.Codec, db)

height, err := parseCtx.Node.LatestHeight()
if err != nil {
return err
}

return govModule.UpdateParams(height)
},
}
}

0 comments on commit 1835e03

Please sign in to comment.