-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v11_15_0 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/persistenceOne/persistenceCore/v11/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name. | ||
UpgradeName = "v11.15.0" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package v11_15_0 | ||
|
||
import ( | ||
"cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
"github.com/persistenceOne/persistenceCore/v11/app/upgrades" | ||
) | ||
|
||
func CreateUpgradeHandler(args upgrades.UpgradeHandlerArgs) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("running module migrations...") | ||
err := MigrateVestingAccounts(ctx, args) | ||
if err != nil { | ||
return vm, err | ||
} | ||
return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm) | ||
} | ||
} | ||
|
||
func MigrateVestingAccounts(ctx sdk.Context, args upgrades.UpgradeHandlerArgs) error { | ||
accounts := args.Keepers.AccountKeeper.GetAllAccounts(ctx) | ||
for _, account := range accounts { | ||
switch account.(type) { | ||
case *vestingtypes.PeriodicVestingAccount: | ||
a, ok := account.(*vestingtypes.PeriodicVestingAccount) | ||
if !ok { | ||
return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) | ||
} | ||
args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) | ||
case *vestingtypes.ContinuousVestingAccount: | ||
a, ok := account.(*vestingtypes.ContinuousVestingAccount) | ||
if !ok { | ||
return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) | ||
} | ||
args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) | ||
case *vestingtypes.DelayedVestingAccount: | ||
a, ok := account.(*vestingtypes.DelayedVestingAccount) | ||
if !ok { | ||
return errors.Wrapf(sdkerrors.ErrInvalidType, "invalid account type: %T", account) | ||
} | ||
args.Keepers.AccountKeeper.SetAccount(ctx, a.BaseAccount) | ||
default: | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters