Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
v1_1_6 "github.com/onomyprotocol/onomy/app/upgrades/v1.1.6"
v2_0_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.0.0"
v2_1_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.1.0"
v2_2_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.2.0"

"github.com/onomyprotocol/onomy/docs"
)
Expand Down Expand Up @@ -463,6 +464,7 @@ func (app *OnomyApp) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(v1_1_6.Name, v1_1_6.UpgradeHandler)
app.UpgradeKeeper.SetUpgradeHandler(v2_0_0.Name, v2_0_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))
app.UpgradeKeeper.SetUpgradeHandler(v2_1_0.Name, v2_1_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))
app.UpgradeKeeper.SetUpgradeHandler(v2_2_0.Name, v2_2_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand All @@ -485,6 +487,10 @@ func (app *OnomyApp) setupUpgradeHandlers() {
storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{"dao"},
}
case v2_2_0.Name:
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{"vaults", "oracle", "auction", "psm"},
}
default:
// no store upgrades.
}
Expand Down
81 changes: 78 additions & 3 deletions app/keepers/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ import (
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

auctionKeeper "github.com/onomyprotocol/reserve/x/auction/keeper"
auctiontypes "github.com/onomyprotocol/reserve/x/auction/types"
oracleKeeper "github.com/onomyprotocol/reserve/x/oracle/keeper"
oraclemodule "github.com/onomyprotocol/reserve/x/oracle/module"
oracletypes "github.com/onomyprotocol/reserve/x/oracle/types"
psmKeeper "github.com/onomyprotocol/reserve/x/psm/keeper"
psm "github.com/onomyprotocol/reserve/x/psm/module"
psmtypes "github.com/onomyprotocol/reserve/x/psm/types"
vaultsKeeper "github.com/onomyprotocol/reserve/x/vaults/keeper"
vaults "github.com/onomyprotocol/reserve/x/vaults/module"
vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types"
)

type AppKeepers struct {
Expand Down Expand Up @@ -86,9 +98,16 @@ type AppKeepers struct {
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedICSproviderkeeper capabilitykeeper.ScopedKeeper
ScopedOracleKeeper capabilitykeeper.ScopedKeeper

// Modules.
TransferModule transfer.AppModule

// Reserve module
PSMKeeper psmKeeper.Keeper
AuctionKeeper auctionKeeper.Keeper
VaultsKeeper vaultsKeeper.Keeper
OracleKeeper oracleKeeper.Keeper
}

func NewAppKeeper(
Expand Down Expand Up @@ -145,6 +164,7 @@ func NewAppKeeper(

appKeepers.ScopedIBCKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
appKeepers.ScopedOracleKeeper = appKeepers.CapabilityKeeper.ScopeToModule(oracletypes.ModuleName)

// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
// their scoped modules in `NewApp` with `ScopeToModule`.
Expand Down Expand Up @@ -288,7 +308,9 @@ func NewAppKeeper(
govRouter.
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(appKeepers.ParamsKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper))
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(appKeepers.IBCKeeper.ClientKeeper)).
AddRoute(psmtypes.RouterKey, psm.NewPSMProposalHandler(&appKeepers.PSMKeeper)).
AddRoute(vaultstypes.RouterKey, vaults.NewVaultsProposalHandler(&appKeepers.VaultsKeeper))

// Set legacy router for backwards compatibility with gov v1beta1.
appKeepers.GovKeeper.SetLegacyRouter(govRouter)
Expand Down Expand Up @@ -319,11 +341,52 @@ func NewAppKeeper(

appKeepers.TransferModule = transfer.NewAppModule(appKeepers.TransferKeeper)

appKeepers.OracleKeeper = oracleKeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[oracletypes.StoreKey]),
logger,
appKeepers.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.IBCKeeper.ChannelKeeper,
appKeepers.IBCKeeper.PortKeeper,
appKeepers.ScopedOracleKeeper,
)

appKeepers.PSMKeeper = psmKeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[psmtypes.ModuleName]),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
appKeepers.BankKeeper,
appKeepers.AccountKeeper,
appKeepers.OracleKeeper,
)

appKeepers.VaultsKeeper = *vaultsKeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[vaultstypes.ModuleName]),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.OracleKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.AuctionKeeper = auctionKeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[auctiontypes.ModuleName]),
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
&appKeepers.VaultsKeeper,
logger,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

ibcmodule := transfer.NewIBCModule(appKeepers.TransferKeeper)

// Create static IBC router, add transfer route, then set and seal it.
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, ibcmodule)
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, ibcmodule).
AddRoute(oracletypes.ModuleName, oraclemodule.NewIBCModule(appKeepers.OracleKeeper))

appKeepers.IBCKeeper.SetRouter(ibcRouter)

return appKeepers
Expand Down Expand Up @@ -355,6 +418,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(crisistypes.ModuleName).WithKeyTable(crisistypes.ParamKeyTable()) //nolint: staticcheck // SA1019
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
paramsKeeper.Subspace(psmtypes.ModuleName)
paramsKeeper.Subspace(auctiontypes.ModuleName)
paramsKeeper.Subspace(oracletypes.ModuleName).WithKeyTable(oracletypes.ParamKeyTable())
paramsKeeper.Subspace(vaultstypes.ModuleName)

return paramsKeeper
}
Expand All @@ -372,3 +439,11 @@ func (r *DefaultFeemarketDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.D
func (r *DefaultFeemarketDenomResolver) ExtraDenoms(_ sdk.Context) ([]string, error) {
return []string{}, nil
}

func (a AppKeepers) GetIBCKeeper() *ibckeeper.Keeper {
return a.IBCKeeper
}

func (a AppKeepers) GetScopedIBCKeeper(string) capabilitykeeper.ScopedKeeper {
return a.ScopedIBCKeeper
}
9 changes: 9 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import (
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"

auctiontypes "github.com/onomyprotocol/reserve/x/auction/types"
oracletypes "github.com/onomyprotocol/reserve/x/oracle/types"
psmtypes "github.com/onomyprotocol/reserve/x/psm/types"
vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types"
)

func (appKeepers *AppKeepers) GenerateKeys() {
Expand All @@ -42,6 +47,10 @@ func (appKeepers *AppKeepers) GenerateKeys() {
feegrant.StoreKey,
authzkeeper.StoreKey,
consensusparamtypes.StoreKey,
auctiontypes.StoreKey,
oracletypes.StoreKey,
psmtypes.StoreKey,
vaultstypes.StoreKey,
)

// Define transient store keys.
Expand Down
31 changes: 31 additions & 0 deletions app/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ import (
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"

auctiontypes "github.com/onomyprotocol/reserve/x/auction/types"
oracletypes "github.com/onomyprotocol/reserve/x/oracle/types"
psmtypes "github.com/onomyprotocol/reserve/x/psm/types"
vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types"

auction "github.com/onomyprotocol/reserve/x/auction/module"
oracle "github.com/onomyprotocol/reserve/x/oracle/module"
psm "github.com/onomyprotocol/reserve/x/psm/module"
vaults "github.com/onomyprotocol/reserve/x/vaults/module"
)

var (
Expand All @@ -57,6 +67,11 @@ var (
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
auctiontypes.ModuleName: {authtypes.Minter, authtypes.Burner},
vaultstypes.ModuleName: {authtypes.Minter, authtypes.Burner},
vaultstypes.ReserveModuleName: {authtypes.Burner},
psmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: nil,
}

// module accounts that are allowed to receive tokens.
Expand Down Expand Up @@ -93,6 +108,10 @@ func appModules(
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
genutil.NewAppModule(app.AccountKeeper, app.StakingKeeper, app, txConfig),
app.TransferModule,
auction.NewAppModule(appCodec, app.AuctionKeeper, app.AccountKeeper, app.BankKeeper),
vaults.NewAppModule(appCodec, app.VaultsKeeper, app.AccountKeeper, app.BankKeeper),
oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper),
psm.NewAppModule(appCodec, app.PSMKeeper, app.AccountKeeper, app.BankKeeper),
// and.
}
}
Expand Down Expand Up @@ -133,6 +152,10 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
oracletypes.ModuleName,
vaultstypes.ModuleName,
auctiontypes.ModuleName,
psmtypes.ModuleName,
}
}

Expand All @@ -157,6 +180,10 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
oracletypes.ModuleName,
vaultstypes.ModuleName,
auctiontypes.ModuleName,
psmtypes.ModuleName,
}
}

Expand All @@ -181,6 +208,10 @@ func orderInitBlockers() []string {
vestingtypes.ModuleName,
consensusparamtypes.ModuleName,
crisistypes.ModuleName,
oracletypes.ModuleName,
vaultstypes.ModuleName,
auctiontypes.ModuleName,
psmtypes.ModuleName,
}
}

Expand Down
35 changes: 35 additions & 0 deletions app/upgrades/v2.2.0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Package v1_1_4 is contains chain upgrade of the corresponding version.
package v2_2_0 //nolint:revive,stylecheck // app version

import (
"context"

upgradetypes "cosmossdk.io/x/upgrade/types"
// "github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
// paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"

"github.com/onomyprotocol/onomy/app/keepers"
)

// Name is migration name.
const Name = "v2.2.0"

// UpgradeHandler is an x/upgrade handler.
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {

return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)
vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

return vm, nil
}
}
Loading
Loading