Skip to content

Commit

Permalink
feat: load fbridge & fswap store (#365) (#367)
Browse files Browse the repository at this point in the history
* Setup upgrade store loaders

* Update CHANGELOG.md

(cherry picked from commit 70f49fd)

Co-authored-by: Youngtaek Yoon <[email protected]>
  • Loading branch information
mergify[bot] and 0Tech authored May 10, 2024
1 parent 98239cb commit 29db806
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (fbridge) [\#355](https://github.com/Finschia/finschia/pull/355) Bump finschia-sdk v0.49.0-rc1 to v0.49.0-rc2
* (build) [\#357](https://github.com/Finschia/finschia/pull/357) Upgrade to v4
* (fswap, fbridge) [\#359](https://github.com/Finschia/finschia/pull/359) Bump finschia-sdk v0.49.0-rc2 to v0.49.0-rc3
* (fswap, fbridge) [\#365](https://github.com/Finschia/finschia/pull/365) Load fbridge & fswap stores

### Improvements

Expand Down
34 changes: 28 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
servertypes "github.com/Finschia/finschia-sdk/server/types"
"github.com/Finschia/finschia-sdk/simapp"
"github.com/Finschia/finschia-sdk/store/streaming"
storetypes "github.com/Finschia/finschia-sdk/store/types"
sdk "github.com/Finschia/finschia-sdk/types"
"github.com/Finschia/finschia-sdk/types/module"
"github.com/Finschia/finschia-sdk/version"
Expand Down Expand Up @@ -690,12 +691,8 @@ func NewLinkApp(
app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)

// upgrade
app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})
app.setupUpgradeHandlers()
app.setupUpgradeStoreLoaders()

// must be before loading version
// requires the snapshot store to be created and registered as a BaseAppOptions
Expand Down Expand Up @@ -876,6 +873,31 @@ func (app *LinkApp) RegisterNodeService(clientCtx client.Context) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

func (app *LinkApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
fbridgetypes.ModuleName,
fswaptypes.ModuleName,
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

func (app *LinkApp) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(rtr *mux.Router) {
statikFS, err := fs.New()
Expand Down

0 comments on commit 29db806

Please sign in to comment.