-
Notifications
You must be signed in to change notification settings - Fork 17
/
upgrades.go
52 lines (43 loc) · 1.31 KB
/
upgrades.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package alpha13
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{}
// Upgrade represents the v4 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 "alpha13"
}
// 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()) {
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{}
}