-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add v3.1.0 upgrade handler (#827)
## Description This PR adds the upgrade handler for the upcoming `v3.1.0` Desmos version. Depends-On: #843 Depends-On: #844 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [ ] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
Showing
7 changed files
with
155 additions
and
35 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,13 @@ | ||
package upgrades | ||
|
||
import ( | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// Upgrade represents a generic on-chain upgrade | ||
type Upgrade interface { | ||
Name() string | ||
Handler() upgradetypes.UpgradeHandler | ||
StoreUpgrades() *storetypes.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,66 @@ | ||
package v300 | ||
|
||
import ( | ||
"github.com/CosmWasm/wasmd/x/wasm" | ||
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/desmos-labs/desmos/v3/app/upgrades" | ||
relationshipstypes "github.com/desmos-labs/desmos/v3/x/relationships/types" | ||
subspacestypes "github.com/desmos-labs/desmos/v3/x/subspaces/types" | ||
) | ||
|
||
var ( | ||
_ upgrades.Upgrade = &Upgrade{} | ||
) | ||
|
||
// Upgrade represents the v3.0.0 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 "v3.0.0" | ||
} | ||
|
||
// Handler implements upgrades.Upgrade | ||
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
// Set the initial version of the x/relationships module to 1 so that we can migrate to 2 | ||
fromVM[relationshipstypes.ModuleName] = 1 | ||
|
||
// Nothing to do here for the x/subspaces module since the InitGenesis will be called | ||
return u.mm.RunMigrations(ctx, u.configurator, fromVM) | ||
} | ||
} | ||
|
||
// StoreUpgrades implements upgrades.Upgrade | ||
func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades { | ||
return &storetypes.StoreUpgrades{ | ||
Added: []string{ | ||
wasm.StoreKey, | ||
relationshipstypes.StoreKey, | ||
}, | ||
|
||
// The subspaces key is here because it was already registered (due to an error) inside v2.3.1 | ||
// https://github.com/desmos-labs/desmos/blob/v2.3.1/app/app.go#L270 | ||
Renamed: []storetypes.StoreRename{ | ||
{ | ||
OldKey: "subspaces", | ||
NewKey: subspacestypes.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package v310 | ||
|
||
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/desmos-labs/desmos/v3/app/upgrades" | ||
feestypes "github.com/desmos-labs/desmos/v3/x/fees/types" | ||
) | ||
|
||
var ( | ||
_ upgrades.Upgrade = &Upgrade{} | ||
) | ||
|
||
// Upgrade represents the v3.1.0 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 "v3.1.0" | ||
} | ||
|
||
// Handler implements upgrades.Upgrade | ||
func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
// Nothing to do here for the x/fees module since the InitGenesis will be called | ||
return u.mm.RunMigrations(ctx, u.configurator, fromVM) | ||
} | ||
} | ||
|
||
// StoreUpgrades implements upgrades.Upgrade | ||
func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades { | ||
return &storetypes.StoreUpgrades{ | ||
Added: []string{ | ||
feestypes.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
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