From 83a970e014af8deabbfc1ec1426c855867fd6874 Mon Sep 17 00:00:00 2001 From: scorpioborn <97235353+scorpioborn@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:40:37 +0300 Subject: [PATCH] feat: upgrade handler for params --- app/upgrades/v2/upgrades.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/upgrades/v2/upgrades.go b/app/upgrades/v2/upgrades.go index 6c588a6a..e43a64d4 100644 --- a/app/upgrades/v2/upgrades.go +++ b/app/upgrades/v2/upgrades.go @@ -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( @@ -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) } }