Skip to content

Commit

Permalink
feat: upgrade handler for params
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpioborn committed Nov 13, 2023
1 parent 1a74c2a commit 83a970e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/upgrades/v2/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

sdkmath "cosmossdk.io/math"
"github.com/sge-network/sge/app/keepers"
housetypes "github.com/sge-network/sge/x/house/types"
)

func CreateUpgradeHandler(
Expand All @@ -14,6 +16,24 @@ func CreateUpgradeHandler(
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
housePS := keepers.GetSubspace(housetypes.ModuleName)

if !housePS.Has(ctx, []byte("MaxWithdrawalCount")) {
var minDeposit sdkmath.Int
housePS.Get(ctx, []byte("MinDeposit"), &minDeposit)

var houseParticipationFee sdk.Dec
housePS.Get(ctx, []byte("HouseParticipationFee"), &houseParticipationFee)

p := housetypes.NewParams(
minDeposit,
houseParticipationFee,
housetypes.DefaultMaxWithdrawalCount,
)

keepers.HouseKeeper.SetParams(ctx, p)
}

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

0 comments on commit 83a970e

Please sign in to comment.