-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.2.0 Upgrade Handlers & Info (#281)
- Loading branch information
Showing
19 changed files
with
246 additions
and
82 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
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,64 @@ | ||
package beta7 | ||
|
||
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/app/upgrades" | ||
"github.com/jackalLabs/canine-chain/types" | ||
notificationkeeper "github.com/jackalLabs/canine-chain/x/notifications/keeper" | ||
notificationtypes "github.com/jackalLabs/canine-chain/x/notifications/types" | ||
rnstypes "github.com/jackalLabs/canine-chain/x/rns/types" | ||
) | ||
|
||
var _ upgrades.Upgrade = &Upgrade{} | ||
|
||
// Upgrade represents the v4 upgrade | ||
type Upgrade struct { | ||
mm *module.Manager | ||
configurator module.Configurator | ||
notificationKeeper notificationkeeper.Keeper | ||
} | ||
|
||
// NewUpgrade returns a new Upgrade instance | ||
func NewUpgrade(mm *module.Manager, configurator module.Configurator, notificationKeeper notificationkeeper.Keeper) *Upgrade { | ||
return &Upgrade{ | ||
mm: mm, | ||
configurator: configurator, | ||
notificationKeeper: notificationKeeper, | ||
} | ||
} | ||
|
||
// Name implements upgrades.Upgrade | ||
func (u *Upgrade) Name() string { | ||
return "beta7" | ||
} | ||
|
||
// Handler implements upgrades.Upgrade | ||
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
if types.IsTestnet(ctx.ChainID()) || ctx.ChainID() == "test" { | ||
|
||
fromVM[notificationtypes.ModuleName] = 1 | ||
fromVM[rnstypes.ModuleName] = 2 | ||
|
||
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{ | ||
notificationtypes.StoreKey, | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.