From c733202eff84600ccce547abbfdad656e7fc66d8 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 12 Nov 2021 19:29:24 -0400 Subject: [PATCH 1/2] add upgrade logic, refactoring, bump version --- app/setup_handlers.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 3c74402f85..7c203d459c 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -4,29 +4,51 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + dispensationtypes "github.com/Sifchain/sifnode/x/dispensation/types" ) -const upgradeName = "0.9.12" +const upgradeName = "0.9.14" + +const distributionVersion = "0.9.14" +const distributionAddress = "sif1ct2s3t8u2kffjpaekhtngzv6yc4vm97xajqyl3" +const distributionAmount = "200000000000000000000000000" // 200m func SetupHandlers(app *SifchainApp) { app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan types.Plan) { app.Logger().Info("Running upgrade handler for " + upgradeName) + if plan.Name == distributionVersion { + mintAmount, ok := sdk.NewIntFromString(distributionAmount) + if !ok { + panic("failed to get mint amount") + } + mintCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), mintAmount)) + err := app.BankKeeper.MintCoins(ctx, dispensationtypes.ModuleName, mintCoins) + if err != nil { + panic(err) + } + address, err := sdk.AccAddressFromBech32(distributionAddress) + if err != nil { + panic(err) + } + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, dispensationtypes.ModuleName, address, mintCoins) + if err != nil { + panic(err) + } + } }) - upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() if err != nil { panic(err) } - if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ Added: []string{}, } - // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, // so that new stores start with the correct version (the current height of chain), // instead the default which is the latest version that store last committed i.e 0 for new stores. app.SetStoreLoader(types.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) } -} +} \ No newline at end of file From 77c46c9771bbe5e53ab440cd5fef91a4fa12c765 Mon Sep 17 00:00:00 2001 From: Ivan Date: Fri, 12 Nov 2021 19:29:39 -0400 Subject: [PATCH 2/2] bump version to 0.9.14 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 583b27acca..6d44d227cf 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.9.12 +0.9.14