-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from neutron-org/fix/upgrade
Fix: upgrade fix
- Loading branch information
Showing
4 changed files
with
134 additions
and
2 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,26 @@ | ||
package upgrades | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
cronkeeper "github.com/neutron-org/neutron/x/cron/keeper" | ||
icqkeeper "github.com/neutron-org/neutron/x/interchainqueries/keeper" | ||
tokenfactorykeeper "github.com/neutron-org/neutron/x/tokenfactory/keeper" | ||
) | ||
|
||
// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal | ||
// must have written, in order for the state migration to go smoothly. | ||
// An upgrade must implement this struct, and then set it in the app.go. | ||
// The app.go will then define the handler. | ||
type Upgrade struct { | ||
// Upgrade version name, for the upgrade handler, e.g. `v7` | ||
UpgradeName string | ||
|
||
// CreateUpgradeHandler defines the function that creates an upgrade handler | ||
CreateUpgradeHandler func(*module.Manager, module.Configurator, icqkeeper.Keeper, cronkeeper.Keeper, *tokenfactorykeeper.Keeper) upgradetypes.UpgradeHandler | ||
|
||
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed. | ||
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,23 @@ | ||
package v3 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
ccvprovider "github.com/cosmos/interchain-security/x/ccv/provider/types" | ||
|
||
"github.com/neutron-org/neutron/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrades name. | ||
UpgradeName = "v0.3.0" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
ccvprovider.ModuleName, | ||
}, | ||
}, | ||
} |
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,39 @@ | ||
package v3 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
|
||
cronkeeper "github.com/neutron-org/neutron/x/cron/keeper" | ||
crontypes "github.com/neutron-org/neutron/x/cron/types" | ||
icqkeeper "github.com/neutron-org/neutron/x/interchainqueries/keeper" | ||
icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types" | ||
tokenfactorykeeper "github.com/neutron-org/neutron/x/tokenfactory/keeper" | ||
tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
icqKeeper icqkeeper.Keeper, | ||
cronKeeper cronkeeper.Keeper, | ||
tokenfactoryKeeper *tokenfactorykeeper.Keeper, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("Starting module migrations...") | ||
|
||
// todo: FIXME | ||
icqKeeper.SetParams(ctx, icqtypes.DefaultParams()) | ||
cronKeeper.SetParams(ctx, crontypes.DefaultParams()) | ||
tokenfactoryKeeper.SetParams(ctx, tokenfactorytypes.DefaultParams()) | ||
|
||
vm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return vm, err | ||
} | ||
|
||
ctx.Logger().Info("Upgrade complete") | ||
return vm, err | ||
} | ||
} |