Skip to content

Commit

Permalink
ica test upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarstonConnell committed May 7, 2024
1 parent e08a7de commit 5e93feb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jackalLabs/canine-chain/v3/app/upgrades/testnet/beta7"
v3 "github.com/jackalLabs/canine-chain/v3/app/upgrades/v3"
v4 "github.com/jackalLabs/canine-chain/v3/app/upgrades/v4"
"github.com/jackalLabs/canine-chain/v3/app/upgrades/v4alpha1"
)

func (app *JackalApp) registerTestnetUpgradeHandlers() {
Expand All @@ -19,6 +20,8 @@ func (app *JackalApp) registerTestnetUpgradeHandlers() {
app.registerUpgrade(beta6.NewUpgrade(app.mm, app.configurator, app.StorageKeeper))
app.registerUpgrade(beta7.NewUpgrade(app.mm, app.configurator, app.NotificationsKeeper))
app.registerUpgrade(v121.NewUpgrade(app.mm, app.configurator))

app.registerUpgrade(v4alpha1.NewUpgrade(app.mm, app.configurator))
}

func (app *JackalApp) registerMainnetUpgradeHandlers() {
Expand Down
54 changes: 54 additions & 0 deletions app/upgrades/v4alpha1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package v4alpha1

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/jackalLabs/canine-chain/v3/app/upgrades"
"github.com/jackalLabs/canine-chain/v3/types"
)

var _ upgrades.Upgrade = &Upgrade{}

type Upgrade struct {
mm *module.Manager
configurator module.Configurator
}

// NewUpgrade returns a new Upgrade instance
func NewUpgrade(mm *module.Manager, configurator module.Configurator) *Upgrade {
return &Upgrade{
mm: mm,
configurator: configurator,
}
}

// Name implements upgrades.Upgrade
func (u *Upgrade) Name() string {
return "ica"
}

// Handler implements upgrades.Upgrade
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if types.IsTestnet(ctx.ChainID()) {
newVM, err := u.mm.RunMigrations(ctx, u.configurator, fromVM)
if err != nil {
return newVM, err
}

return newVM, err
}

return fromVM, nil
}
}

// StoreUpgrades implements upgrades.Upgrade
func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades {
return &storetypes.StoreUpgrades{
Added: []string{},
Deleted: []string{},
}
}

0 comments on commit 5e93feb

Please sign in to comment.