Skip to content

Commit

Permalink
add one year to all periodic accounts that have not started yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroms committed Dec 4, 2024
1 parent c57c9f8 commit 18c395b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 35 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_3_1_0,
upgrades.Upgrade_4_0_0,
upgrades.Upgrade_4_1_0,
upgrades.Upgrade_4_2_0,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/empty_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ var Upgrade_4_1_0 = Upgrade{
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

var Upgrade_4_2_0 = Upgrade{
UpgradeName: "v4.2.0",
CreateUpgradeHandler: v_4_2_0,
StoreUpgrades: store.StoreUpgrades{},
}
35 changes: 0 additions & 35 deletions app/upgrades/upgrade_0_35_0.go

This file was deleted.

32 changes: 32 additions & 0 deletions app/upgrades/upgrade_4_2_0.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package upgrades

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/lavanet/lava/v4/app/keepers"
)

func v_4_2_0(
m *module.Manager,
c module.Configurator,
_ BaseAppParamManager,
lk *keepers.LavaKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
accounts := lk.AccountKeeper.GetAllAccounts(ctx)
year := int64(12 * 30 * 24 * 60 * 60)
for _, account := range accounts {
if vaccount, ok := account.(*authtypes.PeriodicVestingAccount); ok {
if vaccount.StartTime > ctx.BlockTime().Unix() {
vaccount.StartTime += year
vaccount.EndTime += year
lk.AccountKeeper.SetAccount(ctx, vaccount)
}
}
}

return m.RunMigrations(ctx, c, vm)
}
}

0 comments on commit 18c395b

Please sign in to comment.