Skip to content

Commit

Permalink
Add MaxSupply to upgrade handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Witkowski committed Sep 8, 2023
1 parent b9fd491 commit 5c330df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"fmt"

"cosmossdk.io/math"
icqtypes "github.com/strangelove-ventures/async-icq/v6/types"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -110,6 +111,7 @@ var upgrades = map[string]appUpgrade{

removeInactiveValidatorDelegations(ctx, app)
setupICQ(ctx, app)
updateMaxSupply(ctx, app)

return vm, nil
},
Expand All @@ -128,6 +130,7 @@ var upgrades = map[string]appUpgrade{

removeInactiveValidatorDelegations(ctx, app)
setupICQ(ctx, app)
updateMaxSupply(ctx, app)

return vm, nil
},
Expand Down Expand Up @@ -326,3 +329,12 @@ func setupICQ(ctx sdk.Context, app *App) {
app.ICQKeeper.SetParams(ctx, icqtypes.NewParams(true, []string{"/provenance.oracle.v1.Query/Oracle"}))
ctx.Logger().Info("Done updating ICQ params")
}

// updateMaxSupply sets the value of max supply to the current value of MaxTotalSupply
func updateMaxSupply(ctx sdk.Context, app *App) {
ctx.Logger().Info("Updating MaxSupply marker param")
params := app.MarkerKeeper.GetParams(ctx)
params.MaxSupply = math.NewIntFromUint64(params.MaxTotalSupply)
app.MarkerKeeper.SetParams(ctx, params)
ctx.Logger().Info("Done updating MaxSupply marker param")
}
4 changes: 4 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ func (s *UpgradeTestSuite) TestSaffronRC1() {
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
"INF Updating ICQ params",
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
}

s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil)
Expand All @@ -438,6 +440,8 @@ func (s *UpgradeTestSuite) TestSaffron() {
"INF removing all delegations from validators that have been inactive (unbonded) for 21 days",
"INF Updating ICQ params",
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
}

s.AssertUpgradeHandlerLogs("saffron", expInLog, nil)
Expand Down

0 comments on commit 5c330df

Please sign in to comment.