Skip to content

Commit 868bbd5

Browse files
authored
feat: add parse gov params command (#735)
## Description Closes: #XXXX This PR adds parse gov params command for updating gov params easily after the schema upgrade. <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
1 parent 09f92fa commit 868bbd5

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.idea/
22
build/
3+
vendor/
34

45
# Configuration
56
*.toml

cmd/parse/gov/cmd.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func NewGovCmd(parseConfig *parsecmdtypes.Config) *cobra.Command {
1414

1515
cmd.AddCommand(
1616
proposalCmd(parseConfig),
17+
paramsCmd(parseConfig),
1718
)
1819

1920
return cmd

cmd/parse/gov/params.go

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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

Comments
 (0)