Skip to content

Commit

Permalink
feat: update inflation following mint param change proposal passed (#432
Browse files Browse the repository at this point in the history
)

## Description

Closes: #XXXX



---
Test: 
- parse block 4114861 for getting proposal 15
- parse block 4213603 when the proposal is passed, the inflation will be updated

### 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)
  • Loading branch information
huichiaotsou authored Jul 6, 2022
1 parent 49e3089 commit 52ce0df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unreleased
### Changes
#### Mint module
- ([\#432](https://github.com/forbole/bdjuno/pull/432)) Update inflation rate when mint param change proposal is passed

#### Gov module
- ([\#401](https://github.com/forbole/bdjuno/pull/401)) Update the proposal status to the latest in `bdjuno parse gov proposal [id]` command
- ([\#430](https://github.com/forbole/bdjuno/pull/430)) Update the proposals that have invalid status but can still be in voting or deposit periods
Expand Down
1 change: 1 addition & 0 deletions modules/gov/expected_modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type DistrModule interface {

type MintModule interface {
UpdateParams(height int64) error
UpdateInflation() error
}

type SlashingModule interface {
Expand Down
6 changes: 6 additions & 0 deletions modules/gov/utils_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ func (m *Module) handleParamChangeProposal(height int64, proposal govtypes.Propo
if err != nil {
return fmt.Errorf("error while updating ParamChangeProposal %s params : %s", minttypes.ModuleName, err)
}

// Update the inflation
err = m.mintModule.UpdateInflation()
if err != nil {
return fmt.Errorf("error while updating inflation with ParamChangeProposal: %s", err)
}
case slashingtypes.ModuleName:
err = m.slashingModule.UpdateParams(height)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions modules/mint/handle_periodic_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (m *Module) RegisterPeriodicOperations(scheduler *gocron.Scheduler) error {

// Setup a cron job to run every midnight
if _, err := scheduler.Every(1).Day().At("00:00").Do(func() {
utils.WatchMethod(m.updateInflation)
utils.WatchMethod(m.UpdateInflation)
}); err != nil {
return err
}
Expand All @@ -23,7 +23,7 @@ func (m *Module) RegisterPeriodicOperations(scheduler *gocron.Scheduler) error {

// updateInflation fetches from the REST APIs the latest value for the
// inflation, and saves it inside the database.
func (m *Module) updateInflation() error {
func (m *Module) UpdateInflation() error {
log.Debug().
Str("module", "mint").
Str("operation", "inflation").
Expand Down

0 comments on commit 52ce0df

Please sign in to comment.