-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
marketplace: auctions & upgrade handler (#23)
marketplace: auctions & upgrade handler
- Loading branch information
Showing
9 changed files
with
322 additions
and
133 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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.idea | ||
secret.yml | ||
.build/* | ||
._build/* | ||
.envrc | ||
/build | ||
/_build | ||
.vscode |
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
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 app | ||
|
||
import ( | ||
"fmt" | ||
|
||
marketplacetypes "github.com/OmniFlix/marketplace/x/marketplace/types" | ||
store "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" | ||
) | ||
|
||
// next upgrade name | ||
const upgradeName = "v2" | ||
|
||
// RegisterUpgradeHandlers returns upgrade handlers | ||
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) { | ||
app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { | ||
app.MarketplaceKeeper.SetParams(ctx, marketplacetypes.DefaultParams()) | ||
app.MarketplaceKeeper.SetNextAuctionNumber(ctx, 1) | ||
|
||
fromVM := app.mm.GetVersionMap() | ||
ctx.Logger().Info("running migrations ...") | ||
return app.mm.RunMigrations(ctx, cfg, fromVM) | ||
}) | ||
|
||
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err)) | ||
} | ||
|
||
if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { | ||
storeUpgrades := store.StoreUpgrades{ | ||
Added: []string{}, | ||
} | ||
// configure store loader that checks if hight == upgradeHeight and applies store upgrades | ||
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades)) | ||
} | ||
} |
Oops, something went wrong.