Skip to content

Commit

Permalink
add update handler
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Nov 13, 2023
1 parent 839dc72 commit c7ee57a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/upgrades/v3/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package v3

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/x/group"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
"github.com/sge-network/sge/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the v1.1.2 upgrade.
const UpgradeName = "v1.1.2"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{
group.ModuleName,
ibcfeetypes.StoreKey,
},
Deleted: []string{},
},
}
33 changes: 33 additions & 0 deletions app/upgrades/v3/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package v3

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/sge-network/sge/app/keepers"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
depositParams := keepers.GovKeeper.GetDepositParams(ctx)
depositParams.MinExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("sge", v1.DefaultMinExpeditedDepositTokens))
keepers.GovKeeper.SetDepositParams(ctx, depositParams)

tallyParams := keepers.GovKeeper.GetTallyParams(ctx)
tallyParams.ExpeditedThreshold = v1.DefaultExpeditedThreshold.String()
tallyParams.ExpeditedQuorum = v1.DefaultExpeditedQuorum.String()
keepers.GovKeeper.SetTallyParams(ctx, tallyParams)

votingParams := keepers.GovKeeper.GetVotingParams(ctx)
expeditedPeriod := v1.DefaultExpeditedPeriod
votingParams.ExpeditedVotingPeriod = &expeditedPeriod
keepers.GovKeeper.SetVotingParams(ctx, votingParams)

return mm.RunMigrations(ctx, configurator, fromVM)
}
}

0 comments on commit c7ee57a

Please sign in to comment.