Skip to content

Commit

Permalink
Merge pull request #171 from notional-labs/unlock-vesting-accounts
Browse files Browse the repository at this point in the history
add UnlockAllVestingAccounts func to upgrade handler
  • Loading branch information
vuong177 authored Apr 11, 2022
2 parents e7e1d13 + 4c4004f commit 7c4c52c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func (app *DigApp) setupUpgradeStoreLoaders() {
func (app *DigApp) setupUpgradeHandlers(ICAModule ica.AppModule) {
app.UpgradeKeeper.SetUpgradeHandler(
v2.UpgradeName,
v2.CreateUpgradeHandler(app.mm, app.configurator, &app.StakingKeeper, ICAModule, &app.wasmKeeper))
v2.CreateUpgradeHandler(app.mm, app.configurator, &app.AccountKeeper, &app.StakingKeeper, ICAModule, &app.wasmKeeper))
}

// Name returns the name of the App
Expand Down
20 changes: 15 additions & 5 deletions app/upgrade/v2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/types/module"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

// Fixes an error where validators can be created with a commission rate
Expand All @@ -37,9 +40,20 @@ func FixMinCommisionRate(ctx sdk.Context, staking *stakingkeeper.Keeper) {
}
}

func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, staking *stakingkeeper.Keeper, icaModule icamodule.AppModule, wasmKeeper *wasmkeeper.Keeper) upgradetypes.UpgradeHandler {
func UnlockAllVestingAccounts(ctx sdk.Context, accKeeper *authkeeper.AccountKeeper) {
accounts := accKeeper.GetAllAccounts(ctx)
for _, acc := range accounts {
vestingAcc, ok := acc.(*vestingtypes.BaseVestingAccount)
if ok {
accKeeper.SetAccount(ctx, vestingAcc.BaseAccount)
}
}
}

func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator, accKeeper *authkeeper.AccountKeeper, staking *stakingkeeper.Keeper, icaModule icamodule.AppModule, wasmKeeper *wasmkeeper.Keeper) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion()
UnlockAllVestingAccounts(ctx, accKeeper)
FixMinCommisionRate(ctx, staking)
// Set wasm old version to 1 if we want to call wasm's InitGenesis ourselves
// in this upgrade logic ourselves
Expand Down Expand Up @@ -84,10 +98,6 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.vesting.v1beta1.MsgCreateVestingAccount",
"/ibc.applications.transfer.v1.MsgTransfer",
"/tendermint.liquidity.v1beta1.MsgCreatePool",
"/tendermint.liquidity.v1beta1.MsgSwapWithinBatch",
"/tendermint.liquidity.v1beta1.MsgDepositWithinBatch",
"/tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch",
},
}

Expand Down

0 comments on commit 7c4c52c

Please sign in to comment.