From 7b5f1abe0ee06a0e4347cddcf7706a8e32b054c5 Mon Sep 17 00:00:00 2001 From: vishal Date: Thu, 14 Dec 2023 12:45:52 +0530 Subject: [PATCH] feat: upgraded the app with treasury module to SDK v0.50 --- app/app.go | 72 +++++++++---------- .../palomachain/paloma/treasury/params.proto | 4 +- x/treasury/genesis.go | 19 +++-- x/treasury/keeper/grpc_query_fees_test.go | 2 +- x/treasury/keeper/keeper.go | 23 +++--- x/treasury/keeper/keeper_test.go | 2 +- x/treasury/module.go | 23 ++++-- x/treasury/module_simulation.go | 3 +- x/treasury/types/errors.go | 2 +- x/treasury/types/expected_keepers.go | 27 +++---- x/treasury/types/mocks/TreasuryStore.go | 28 ++++---- x/treasury/types/params.go | 7 -- x/treasury/types/params.pb.go | 21 +++--- x/treasury/types/store.go | 19 +++-- 14 files changed, 134 insertions(+), 118 deletions(-) diff --git a/app/app.go b/app/app.go index f179ebb3..f9e1dc13 100644 --- a/app/app.go +++ b/app/app.go @@ -121,8 +121,9 @@ import ( ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" + ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client" + ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" palomamempool "github.com/palomachain/paloma/app/mempool" - appparams "github.com/palomachain/paloma/app/params" // xchain "github.com/palomachain/paloma/internal/x-chain" // consensusmodule "github.com/palomachain/paloma/x/consensus" @@ -143,10 +144,10 @@ import ( // schedulermodule "github.com/palomachain/paloma/x/scheduler" // schedulermodulekeeper "github.com/palomachain/paloma/x/scheduler/keeper" // schedulermoduletypes "github.com/palomachain/paloma/x/scheduler/types" - // treasurymodule "github.com/palomachain/paloma/x/treasury" - // treasuryclient "github.com/palomachain/paloma/x/treasury/client" - // treasurymodulekeeper "github.com/palomachain/paloma/x/treasury/keeper" - // treasurymoduletypes "github.com/palomachain/paloma/x/treasury/types" + treasurymodule "github.com/palomachain/paloma/x/treasury" + treasuryclient "github.com/palomachain/paloma/x/treasury/client" + treasurymodulekeeper "github.com/palomachain/paloma/x/treasury/keeper" + treasurymoduletypes "github.com/palomachain/paloma/x/treasury/types" // valsetmodule "github.com/palomachain/paloma/x/valset" // valsetmodulekeeper "github.com/palomachain/paloma/x/valset/keeper" @@ -166,6 +167,9 @@ func getGovProposalHandlers() []govclient.ProposalHandler { return []govclient.ProposalHandler{ paramsclient.ProposalHandler, evmclient.ProposalHandler, + // gravityclient.ProposalHandler, + //ibcclientclient has been removed ,because it is deprecated + treasuryclient.ProposalHandler, } } @@ -181,10 +185,12 @@ var ( stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, + // gravitymoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, ibcfeetypes.ModuleName: nil, icatypes.ModuleName: nil, - evmmoduletypes.ModuleName: {authtypes.Burner, authtypes.Minter}, + wasmtypes.ModuleName: {authtypes.Burner}, + treasurymoduletypes.ModuleName: {authtypes.Burner, authtypes.Minter}, } ) @@ -247,8 +253,8 @@ type App struct { // ConsensusKeeper consensusmodulekeeper.Keeper // ValsetKeeper valsetmodulekeeper.Keeper // PalomaKeeper palomamodulekeeper.Keeper - // TreasuryKeeper treasurymodulekeeper.Keeper - EvmKeeper evmmodulekeeper.Keeper + TreasuryKeeper treasurymodulekeeper.Keeper + EvmKeeper evmmodulekeeper.Keeper // GravityKeeper gravitymodulekeeper.Keeper wasmKeeper wasmkeeper.Keeper @@ -268,7 +274,6 @@ func New( db dbm.DB, traceStore io.Writer, loadLatest bool, - encodingCfg appparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *App { @@ -324,11 +329,9 @@ func New( // schedulermoduletypes.StoreKey, // consensusmoduletypes.StoreKey, // valsetmoduletypes.StoreKey, - // treasurymoduletypes.StoreKey, - // // wasm.StoreKey, - evmmoduletypes.StoreKey, + treasurymoduletypes.StoreKey, wasmtypes.StoreKey, - // evmmoduletypes.StoreKey, + evmmoduletypes.StoreKey, // gravitymoduletypes.StoreKey, // consensusparamtypes.StoreKey, crisistypes.StoreKey, @@ -340,7 +343,7 @@ func New( // consensusmoduletypes.MemStoreKey, evmmoduletypes.MemStoreKey, // schedulermoduletypes.MemStoreKey, - // treasurymoduletypes.MemStoreKey, + treasurymoduletypes.MemStoreKey, // palomamoduletypes.MemStoreKey, ) @@ -610,15 +613,14 @@ func New( // }, // ) - // app.TreasuryKeeper = *treasurymodulekeeper.NewKeeper( - // appCodec, - // keys[treasurymoduletypes.StoreKey], - // memKeys[treasurymoduletypes.MemStoreKey], - // app.GetSubspace("" /*schedulermoduletypes.ModuleName*/), - // app.BankKeeper, - // app.AccountKeeper, - // nil, // app.SchedulerKeeper, - // ) + app.TreasuryKeeper = *treasurymodulekeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[treasurymoduletypes.StoreKey]), + app.GetSubspace("" /*schedulermoduletypes.ModuleName*/), + app.BankKeeper, + app.AccountKeeper, + nil, // app.SchedulerKeeper, + ) // app.ScopedConsensusKeeper = scopedConsensusKeeper @@ -626,7 +628,10 @@ func New( govRouter. AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). - AddRoute(evmmoduletypes.RouterKey, evm.NewReferenceChainReferenceIDProposalHandler(app.EvmKeeper)) + AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). + AddRoute(evmmoduletypes.RouterKey, evm.NewReferenceChainReferenceIDProposalHandler(app.EvmKeeper)). + // AddRoute(gravitymoduletypes.RouterKey, gravitymodulekeeper.NewGravityProposalHandler(app.GravityKeeper)). + AddRoute(treasurymoduletypes.RouterKey, treasurymodule.NewFeeProposalHandler(app.TreasuryKeeper)) // Example of setting gov params: govKeeper := govkeeper.NewKeeper( @@ -740,7 +745,7 @@ func New( // schedulerModule := schedulermodule.NewAppModule(appCodec, app.SchedulerKeeper, app.AccountKeeper, app.BankKeeper) // palomaModule := palomamodule.NewAppModule(appCodec, app.PalomaKeeper, app.AccountKeeper, app.BankKeeper) // gravityModule := gravitymodule.NewAppModule(appCodec, app.GravityKeeper, app.BankKeeper) - // treasuryModule := treasurymodule.NewAppModule(appCodec, app.TreasuryKeeper, app.AccountKeeper, app.BankKeeper) + treasuryModule := treasurymodule.NewAppModule(appCodec, app.TreasuryKeeper, app.AccountKeeper, app.BankKeeper) app.ModuleManager = module.NewManager( genutil.NewAppModule( app.AccountKeeper, @@ -768,7 +773,7 @@ func New( evmModule, // gravityModule, // palomaModule, - // treasuryModule, + treasuryModule, wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasm.ModuleName)), ibc.NewAppModule(app.IBCKeeper), transfer.NewAppModule(app.TransferKeeper), @@ -787,6 +792,7 @@ func New( }, ), }) + app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) // During begin block slashing happens after distr.BeginBlocker so that @@ -813,12 +819,10 @@ func New( genutiltypes.ModuleName, // valsetmoduletypes.ModuleName, // palomamoduletypes.ModuleName, - // wasm.ModuleName, evmmoduletypes.ModuleName, wasmtypes.ModuleName, - // evmmoduletypes.ModuleName, // gravitymoduletypes.ModuleName, - // treasurymoduletypes.ModuleName, + treasurymoduletypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, icatypes.ModuleName, @@ -847,16 +851,14 @@ func New( genutiltypes.ModuleName, // valsetmoduletypes.ModuleName, // palomamoduletypes.ModuleName, - // wasm.ModuleName, evmmoduletypes.ModuleName, wasmtypes.ModuleName, - // evmmoduletypes.ModuleName, // gravitymoduletypes.ModuleName, ibctransfertypes.ModuleName, ibcexported.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, - // treasurymoduletypes.ModuleName, + treasurymoduletypes.ModuleName, consensusparamtypes.ModuleName, ) @@ -890,12 +892,10 @@ func New( ibcexported.ModuleName, icatypes.ModuleName, ibcfeetypes.ModuleName, - // wasm.ModuleName, evmmoduletypes.ModuleName, wasmtypes.ModuleName, - // evmmoduletypes.ModuleName, // gravitymoduletypes.ModuleName, - // treasurymoduletypes.ModuleName, + treasurymoduletypes.ModuleName, consensusparamtypes.ModuleName, ) @@ -1142,7 +1142,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // paramsKeeper.Subspace(consensusmoduletypes.ModuleName) // paramsKeeper.Subspace(valsetmoduletypes.ModuleName) paramsKeeper.Subspace(wasmtypes.ModuleName) - // paramsKeeper.Subspace(evmmoduletypes.ModuleName) + paramsKeeper.Subspace(evmmoduletypes.ModuleName) // paramsKeeper.Subspace(gravitymoduletypes.ModuleName) return paramsKeeper diff --git a/proto/palomachain/paloma/treasury/params.proto b/proto/palomachain/paloma/treasury/params.proto index 4c8473ad..5b9e1604 100644 --- a/proto/palomachain/paloma/treasury/params.proto +++ b/proto/palomachain/paloma/treasury/params.proto @@ -1,11 +1,9 @@ syntax = "proto3"; package palomachain.paloma.treasury; -import "gogoproto/gogo.proto"; option go_package = "github.com/palomachain/paloma/x/treasury/types"; // Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; +message Params { } \ No newline at end of file diff --git a/x/treasury/genesis.go b/x/treasury/genesis.go index 0c3c4c42..7ececfaa 100644 --- a/x/treasury/genesis.go +++ b/x/treasury/genesis.go @@ -1,6 +1,8 @@ package treasury import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/palomachain/paloma/x/treasury/keeper" "github.com/palomachain/paloma/x/treasury/types" @@ -8,26 +10,29 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { - k.SetParams(ctx, genState.Params) +func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisState) { + sdkctx := sdk.UnwrapSDKContext(ctx) + k.SetParams(sdkctx, genState.Params) - err := k.SetCommunityFundFee(ctx, "0.01") + err := k.SetCommunityFundFee(sdkctx, "0.01") if err != nil { panic(err) } - err = k.SetSecurityFee(ctx, "0.01") + err = k.SetSecurityFee(sdkctx, "0.01") if err != nil { panic(err) } } // ExportGenesis returns the capability module's exported genesis. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func ExportGenesis(ctx context.Context, k keeper.Keeper) *types.GenesisState { + sdkctx := sdk.UnwrapSDKContext(ctx) + genesis := types.DefaultGenesis() - genesis.Params = k.GetParams(ctx) + genesis.Params = k.GetParams(sdkctx) - fees, err := k.GetFees(ctx) + fees, err := k.GetFees(sdkctx) if err != nil { panic(err) } diff --git a/x/treasury/keeper/grpc_query_fees_test.go b/x/treasury/keeper/grpc_query_fees_test.go index 78c3befe..3443fb70 100644 --- a/x/treasury/keeper/grpc_query_fees_test.go +++ b/x/treasury/keeper/grpc_query_fees_test.go @@ -3,7 +3,7 @@ package keeper import ( "testing" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" keeperutilmocks "github.com/palomachain/paloma/util/keeper/mocks" diff --git a/x/treasury/keeper/keeper.go b/x/treasury/keeper/keeper.go index 7edf6972..efad3887 100644 --- a/x/treasury/keeper/keeper.go +++ b/x/treasury/keeper/keeper.go @@ -1,12 +1,13 @@ package keeper import ( + "context" "errors" "fmt" - "github.com/cometbft/cometbft/libs/log" + cosmosstore "cosmossdk.io/core/store" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" xchain "github.com/palomachain/paloma/internal/x-chain" @@ -18,7 +19,6 @@ const storeKey = "treasury" type Keeper struct { cdc codec.BinaryCodec - memKey storetypes.StoreKey paramstore paramtypes.Subspace bank types.BankKeeper account types.AccountKeeper @@ -30,8 +30,7 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, - storeKey, - memKey storetypes.StoreKey, + storeKey cosmosstore.KVStoreService, ps paramtypes.Subspace, bank types.BankKeeper, account types.AccountKeeper, @@ -44,7 +43,6 @@ func NewKeeper( return &Keeper{ cdc: cdc, - memKey: memKey, paramstore: ps, bank: bank, account: account, @@ -58,11 +56,12 @@ func NewKeeper( func (k Keeper) ModuleName() string { return types.ModuleName } -func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +func (k Keeper) Logger(ctx context.Context) log.Logger { + sdkCtx := sdk.UnwrapSDKContext(ctx) + return sdkCtx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) SetCommunityFundFee(ctx sdk.Context, fee string) error { +func (k Keeper) SetCommunityFundFee(ctx context.Context, fee string) error { fees, err := k.GetFees(ctx) if err != nil { return err @@ -75,7 +74,7 @@ func (k Keeper) SetCommunityFundFee(ctx sdk.Context, fee string) error { return err } -func (k Keeper) SetSecurityFee(ctx sdk.Context, fee string) error { +func (k Keeper) SetSecurityFee(ctx context.Context, fee string) error { fees, err := k.GetFees(ctx) if err != nil { return err @@ -88,7 +87,7 @@ func (k Keeper) SetSecurityFee(ctx sdk.Context, fee string) error { return err } -func (k Keeper) GetFees(ctx sdk.Context) (*types.Fees, error) { +func (k Keeper) GetFees(ctx context.Context) (*types.Fees, error) { res, err := k.KeeperUtil.Load(k.Store.TreasuryStore(ctx), k.cdc, []byte(storeKey)) if errors.Is(err, keeperutil.ErrNotFound) { return &types.Fees{}, nil @@ -99,6 +98,6 @@ func (k Keeper) GetFees(ctx sdk.Context) (*types.Fees, error) { return res, nil } -func (k Keeper) setFees(ctx sdk.Context, fees *types.Fees) error { +func (k Keeper) setFees(ctx context.Context, fees *types.Fees) error { return k.KeeperUtil.Save(k.Store.TreasuryStore(ctx), k.cdc, []byte(storeKey), fees) } diff --git a/x/treasury/keeper/keeper_test.go b/x/treasury/keeper/keeper_test.go index 44cc58c0..850eaa74 100644 --- a/x/treasury/keeper/keeper_test.go +++ b/x/treasury/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" keeperutil "github.com/palomachain/paloma/util/keeper" diff --git a/x/treasury/module.go b/x/treasury/module.go index 075b5097..f37499cb 100644 --- a/x/treasury/module.go +++ b/x/treasury/module.go @@ -1,9 +1,11 @@ package treasury import ( + "context" "encoding/json" "fmt" + "cosmossdk.io/core/appmodule" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -19,14 +21,25 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + _ module.HasABCIGenesis = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasName = AppModule{} + + _ appmodule.HasEndBlocker = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} + _ appmodule.AppModule = AppModule{} ) // ---------------------------------------------------------------------------- // AppModuleBasic // ---------------------------------------------------------------------------- +func (m AppModule) IsOnePerModuleType() {} +func (m AppModule) IsAppModule() {} + // AppModuleBasic implements the AppModuleBasic interface for the capability module. type AppModuleBasic struct { cdc codec.BinaryCodec @@ -153,10 +166,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} +func (am AppModule) BeginBlock(_ context.Context) error { return nil } // EndBlock executes all ABCI EndBlock logic respective to the capability module. It // returns no validator updates. -func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} +func (am AppModule) EndBlock(_ context.Context) error { + return nil } diff --git a/x/treasury/module_simulation.go b/x/treasury/module_simulation.go index 5441995b..b1cce468 100644 --- a/x/treasury/module_simulation.go +++ b/x/treasury/module_simulation.go @@ -2,7 +2,6 @@ package treasury import ( "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -37,7 +36,7 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP } // RegisterStoreDecoder registers a decoder -func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { diff --git a/x/treasury/types/errors.go b/x/treasury/types/errors.go index e69d2a3c..05e043b5 100644 --- a/x/treasury/types/errors.go +++ b/x/treasury/types/errors.go @@ -3,7 +3,7 @@ package types // DONTCOVER import ( - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "cosmossdk.io/errors" ) // x/treasury module sentinel errors diff --git a/x/treasury/types/expected_keepers.go b/x/treasury/types/expected_keepers.go index 26eeaa17..420f9c60 100644 --- a/x/treasury/types/expected_keepers.go +++ b/x/treasury/types/expected_keepers.go @@ -1,33 +1,34 @@ package types import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" schedulertypes "github.com/palomachain/paloma/x/scheduler/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - NewAccount(ctx sdk.Context, acc types.AccountI) types.AccountI - HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool - SetAccount(ctx sdk.Context, acc types.AccountI) + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + NewAccount(ctx context.Context, acc sdk.AccountI) sdk.AccountI + HasAccount(ctx context.Context, addr sdk.AccAddress) bool + SetAccount(ctx context.Context, acc sdk.AccountI) // Methods imported from account should be defined here } // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin + HasBalance(ctx context.Context, addr sdk.AccAddress, amt sdk.Coin) bool + GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx context.Context, moduleName string, amt sdk.Coins) error } type Scheduler interface { - GetJob(ctx sdk.Context, jobID string) (*schedulertypes.Job, error) + GetJob(ctx context.Context, jobID string) (*schedulertypes.Job, error) } diff --git a/x/treasury/types/mocks/TreasuryStore.go b/x/treasury/types/mocks/TreasuryStore.go index db4e0d43..ec4503b5 100644 --- a/x/treasury/types/mocks/TreasuryStore.go +++ b/x/treasury/types/mocks/TreasuryStore.go @@ -1,12 +1,13 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" + context "context" + mock "github.com/stretchr/testify/mock" - types "github.com/cosmos/cosmos-sdk/types" + types "cosmossdk.io/store/types" ) // TreasuryStore is an autogenerated mock type for the TreasuryStore type @@ -15,28 +16,31 @@ type TreasuryStore struct { } // TreasuryStore provides a mock function with given fields: ctx -func (_m *TreasuryStore) TreasuryStore(ctx types.Context) storetypes.KVStore { +func (_m *TreasuryStore) TreasuryStore(ctx context.Context) types.KVStore { ret := _m.Called(ctx) - var r0 storetypes.KVStore - if rf, ok := ret.Get(0).(func(types.Context) storetypes.KVStore); ok { + if len(ret) == 0 { + panic("no return value specified for TreasuryStore") + } + + var r0 types.KVStore + if rf, ok := ret.Get(0).(func(context.Context) types.KVStore); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(storetypes.KVStore) + r0 = ret.Get(0).(types.KVStore) } } return r0 } -type mockConstructorTestingTNewTreasuryStore interface { +// NewTreasuryStore creates a new instance of TreasuryStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTreasuryStore(t interface { mock.TestingT Cleanup(func()) -} - -// NewTreasuryStore creates a new instance of TreasuryStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewTreasuryStore(t mockConstructorTestingTNewTreasuryStore) *TreasuryStore { +}) *TreasuryStore { mock := &TreasuryStore{} mock.Mock.Test(t) diff --git a/x/treasury/types/params.go b/x/treasury/types/params.go index 357196ad..4f3215e3 100644 --- a/x/treasury/types/params.go +++ b/x/treasury/types/params.go @@ -2,7 +2,6 @@ package types import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" ) var _ paramtypes.ParamSet = (*Params)(nil) @@ -31,9 +30,3 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { func (p Params) Validate() error { return nil } - -// String implements the Stringer interface. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} diff --git a/x/treasury/types/params.pb.go b/x/treasury/types/params.pb.go index 79908e28..62345cd1 100644 --- a/x/treasury/types/params.pb.go +++ b/x/treasury/types/params.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -27,8 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { } -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_beaa29e219eae478, []int{0} } @@ -68,17 +68,16 @@ func init() { } var fileDescriptor_beaa29e219eae478 = []byte{ - // 154 bytes of a gzipped FileDescriptorProto + // 135 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x48, 0xcc, 0xc9, 0xcf, 0x4d, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x87, 0xb0, 0xf5, 0x4b, 0x8a, 0x52, 0x13, 0x8b, 0x4b, 0x8b, 0x2a, 0xf5, 0x0b, 0x12, 0x8b, 0x12, 0x73, 0x8b, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, - 0x85, 0xa4, 0x91, 0x54, 0xea, 0x41, 0xd8, 0x7a, 0x30, 0x95, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, - 0x60, 0x75, 0xfa, 0x20, 0x16, 0x44, 0x8b, 0x12, 0x1f, 0x17, 0x5b, 0x00, 0xd8, 0x08, 0x2b, 0x96, - 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, - 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, - 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x8b, 0x8b, 0x2a, - 0x10, 0x6e, 0x2a, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x5b, 0x60, 0x0c, 0x08, 0x00, 0x00, - 0xff, 0xff, 0xb4, 0x62, 0xcc, 0x5b, 0xbf, 0x00, 0x00, 0x00, + 0x85, 0xa4, 0x91, 0x54, 0xea, 0x41, 0xd8, 0x7a, 0x30, 0x95, 0x4a, 0x1c, 0x5c, 0x6c, 0x01, 0x60, + 0xc5, 0x4e, 0x1e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, + 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x97, 0x9e, + 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x8f, 0xc5, 0xd6, 0x0a, 0x84, 0xbd, 0x25, + 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x38, + 0x9a, 0x75, 0x4c, 0xa3, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/treasury/types/store.go b/x/treasury/types/store.go index 2e062fa2..bc1ad20e 100644 --- a/x/treasury/types/store.go +++ b/x/treasury/types/store.go @@ -1,19 +1,24 @@ package types import ( - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" + "context" + + cosmosstore "cosmossdk.io/core/store" + "cosmossdk.io/store" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" ) +//go:generate mockery --name=TreasuryStore + type TreasuryStore interface { - TreasuryStore(ctx sdk.Context) sdk.KVStore + TreasuryStore(ctx context.Context) storetypes.KVStore } type Store struct { - StoreKey storetypes.StoreKey + StoreKey cosmosstore.KVStoreService } -func (sg Store) TreasuryStore(ctx sdk.Context) sdk.KVStore { - return prefix.NewStore(ctx.KVStore(sg.StoreKey), []byte("treasury")) +func (sg Store) TreasuryStore(ctx context.Context) store.KVStore { + return runtime.KVStoreAdapter(sg.StoreKey.OpenKVStore(ctx)) }