Skip to content

Commit

Permalink
Included upgrade handler for VPN module
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Dec 8, 2022
1 parent fea81c7 commit be948cf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func NewApp(
authtypes.FeeCollectorName,
)

wasmDir := filepath.Join(homePath, "wasm")
wasmDir := filepath.Join(homePath, "data")

wasmConfig, err := wasm.ReadWasmConfig(appOpts)
if err != nil {
Expand Down Expand Up @@ -668,7 +668,7 @@ func NewApp(

app.upgradeKeeper.SetUpgradeHandler(
hubupgrades.Name,
hubupgrades.Handler(app.moduleManager, app.configurator, app.wasmKeeper),
hubupgrades.Handler(app.moduleManager, app.configurator, app.vpnKeeper, app.wasmKeeper),
)

upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down
56 changes: 35 additions & 21 deletions upgrades/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@ import (
ibcicacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
ibcicahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
ibcicatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"

vpnkeeper "github.com/sentinel-official/hub/x/vpn/keeper"
)

func Handler(mm *module.Manager, configurator module.Configurator, wasmKeeper wasmkeeper.Keeper) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
controllerParams := ibcicacontrollertypes.Params{}
hostParams := ibcicahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
sdk.MsgTypeURL(&authz.MsgExec{}),
sdk.MsgTypeURL(&authz.MsgGrant{}),
sdk.MsgTypeURL(&authz.MsgRevoke{}),
sdk.MsgTypeURL(&banktypes.MsgSend{}),
sdk.MsgTypeURL(&distributiontypes.MsgFundCommunityPool{}),
sdk.MsgTypeURL(&distributiontypes.MsgSetWithdrawAddress{}),
sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{}),
sdk.MsgTypeURL(&distributiontypes.MsgWithdrawValidatorCommission{}),
sdk.MsgTypeURL(&govtypes.MsgVote{}),
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}),
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}),
},
}
func Handler(mm *module.Manager, configurator module.Configurator, vpnKeeper vpnkeeper.Keeper, wasmKeeper wasmkeeper.Keeper) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
var (
controllerParams = ibcicacontrollertypes.Params{}
hostParams = ibcicahosttypes.Params{
HostEnabled: true,
AllowMessages: []string{
sdk.MsgTypeURL(&authz.MsgExec{}),
sdk.MsgTypeURL(&authz.MsgGrant{}),
sdk.MsgTypeURL(&authz.MsgRevoke{}),
sdk.MsgTypeURL(&banktypes.MsgSend{}),
sdk.MsgTypeURL(&distributiontypes.MsgFundCommunityPool{}),
sdk.MsgTypeURL(&distributiontypes.MsgSetWithdrawAddress{}),
sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{}),
sdk.MsgTypeURL(&distributiontypes.MsgWithdrawValidatorCommission{}),
sdk.MsgTypeURL(&govtypes.MsgVote{}),
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}),
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}),
},
}
)

icaModule, ok := mm.Modules[ibcicatypes.ModuleName].(ibcica.AppModule)
if !ok {
Expand All @@ -46,6 +50,16 @@ func Handler(mm *module.Manager, configurator module.Configurator, wasmKeeper wa

icaModule.InitModule(ctx, controllerParams, hostParams)

providerParams := vpnKeeper.Provider.GetParams(ctx)
providerParams.StakingShare = sdk.NewDecWithPrec(2, 1)
vpnKeeper.Provider.SetParams(ctx, providerParams)

nodeParams := vpnKeeper.Node.GetParams(ctx)
nodeParams.MaxPrice = sdk.NewCoins(sdk.NewInt64Coin("udvpn", 1000*1e6))
nodeParams.MinPrice = sdk.NewCoins(sdk.NewInt64Coin("udvpn", 100*1e6))
nodeParams.StakingShare = sdk.NewDecWithPrec(2, 1)
vpnKeeper.Node.SetParams(ctx, nodeParams)

wasmParams := wasmKeeper.GetParams(ctx)
wasmParams.CodeUploadAccess = wasmtypes.AllowNobody
wasmKeeper.SetParams(ctx, wasmParams)
Expand Down

0 comments on commit be948cf

Please sign in to comment.