-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrades.go
38 lines (33 loc) · 1.17 KB
/
upgrades.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package v1
import (
"time"
"github.com/AstraProtocol/astra/v2/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)
// CreateUpgradeHandler creates an SDK upgrade handler for v1
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
gk govkeeper.Keeper,
pk paramskeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
if types.IsTestnet(ctx.ChainID()) {
logger.Info("updating gov params...")
UpdateGovParams(ctx, gk, pk)
}
// Leave modules are as-is to avoid running InitGenesis.
logger.Info("running module migrations ...")
return mm.RunMigrations(ctx, configurator, vm)
}
}
func UpdateGovParams(ctx sdk.Context, gk govkeeper.Keeper, pk paramskeeper.Keeper) {
votingParams := gk.GetVotingParams(ctx)
votingParams.VotingPeriod = time.Hour
gk.SetVotingParams(ctx, votingParams)
}