Skip to content

Commit

Permalink
Merge pull request #294 from scorpioborn/feature/upgrade-handler-params
Browse files Browse the repository at this point in the history
Fix / Upgrade handler for max withdraw count
  • Loading branch information
3eyedraga authored Nov 14, 2023
2 parents 2e80f0f + 83a970e commit 2cb274e
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 2cb274e

Please sign in to comment.