From 5b06c756e43ad1eac25bca34fef86cebfbbff9c2 Mon Sep 17 00:00:00 2001 From: ivivanov Date: Wed, 9 Aug 2023 16:34:30 +0300 Subject: [PATCH] chore(app): fixing errors in app/ --- app/app.go | 12 +++---- app/modules.go | 89 +++++++++++++++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/app/app.go b/app/app.go index f3eda4a7..142fb124 100644 --- a/app/app.go +++ b/app/app.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" @@ -168,8 +167,7 @@ func New( // can do so safely. app.mm.SetOrderInitGenesis(orderInitBlockers()...) - app.mm.RegisterInvariants(&app.CrisisKeeper) - app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) + app.mm.RegisterInvariants(app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) app.mm.RegisterServices(app.configurator) @@ -353,17 +351,17 @@ func (app *App) SimulationManager() *module.SimulationManager { // API server. func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx - rpc.RegisterRoutes(clientCtx, apiSvr.Router) + // Register legacy tx routes. // refactor DECIDE IF WE WANT TO KEEP THIS // authrest.RegisterTxRoutes(clientCtx, apiSvr.Router) + // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register new tendermint queries routes from grpc-gateway. tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register legacy and grpc-gateway routes for all modules. - ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register app's OpenAPI routes. @@ -378,7 +376,7 @@ func (app *App) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *App) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) + tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query) } // GetMaccPerms returns a copy of the module account permissions. diff --git a/app/modules.go b/app/modules.go index 40ae5529..abb48a07 100644 --- a/app/modules.go +++ b/app/modules.go @@ -41,8 +41,7 @@ import ( icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" - ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" "github.com/Nolus-Protocol/nolus-core/x/mint" minttypes "github.com/Nolus-Protocol/nolus-core/x/mint/types" @@ -52,6 +51,10 @@ import ( vestingstypes "github.com/Nolus-Protocol/nolus-core/x/vestings/types" "github.com/CosmWasm/wasmd/x/wasm" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + // refactor: this pkg does not exist any more + // wasmclient "github.com/CosmWasm/wasmd/x/wasm/client" "github.com/neutron-org/neutron/x/contractmanager" contractmanagermoduletypes "github.com/neutron-org/neutron/x/contractmanager/types" @@ -64,23 +67,25 @@ import ( transferSudo "github.com/neutron-org/neutron/x/transfer" ) -func getGovProposalHandlers() []govclient.ProposalHandler { - var govProposalHandlers []govclient.ProposalHandler +// refactor: currently this func is unused because we init +// the legacy handlers directly in NewBasicManager below +// func getGovProposalHandlers() []govclient.ProposalHandler { +// var govProposalHandlers []govclient.ProposalHandler - govProposalHandlers = append( - govProposalHandlers, - paramsclient.ProposalHandler, - // distrclient.ProposalHandler, - upgradeclient.ProposalHandler, - upgradeclient.CancelProposalHandler, - ibcclientclient.UpdateClientProposalHandler, - ibcclientclient.UpgradeProposalHandler, - ) +// govProposalHandlers = append( +// govProposalHandlers, +// paramsclient.ProposalHandler, +// // distrclient.ProposalHandler, +// upgradeclient.LegacyProposalHandler, +// upgradeclient.LegacyCancelProposalHandler, +// ibcclientclient.UpdateClientProposalHandler, +// ibcclientclient.UpgradeProposalHandler, +// ) - govProposalHandlers = append(govProposalHandlers, wasmclient.ProposalHandlers...) +// govProposalHandlers = append(govProposalHandlers, wasmclient.ProposalHandlers...) - return govProposalHandlers -} +// return govProposalHandlers +// } // module account permissions. var maccPerms = map[string][]string{ @@ -109,7 +114,13 @@ var ModuleBasics = module.NewBasicManager( staking.AppModuleBasic{}, mint.AppModuleBasic{}, distribution.AppModuleBasic{}, - gov.AppModuleBasic{}, + gov.NewAppModuleBasic( + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + upgradeclient.LegacyProposalHandler, + upgradeclient.LegacyCancelProposalHandler, + }, + ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, @@ -144,24 +155,21 @@ func appModules( encodingConfig.TxConfig, ), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, encodingConfig.InterfaceRegistry), - auth.NewAppModule(appCodec, app.AccountKeeper, nil), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), - gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - distribution.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), + auth.NewAppModule(appCodec, *app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + vesting.NewAppModule(*app.AccountKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, *app.BankKeeper, *app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), + crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + mint.NewAppModule(appCodec, *app.MintKeeper, app.AccountKeeper), + slashing.NewAppModule(appCodec, *app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + distribution.NewAppModule(appCodec, *app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), upgrade.NewAppModule(app.UpgradeKeeper), - wasm.NewAppModule( - appCodec, &app.WasmKeeper, - app.AccountKeeper, app.BankKeeper, - ), - evidence.NewAppModule(app.EvidenceKeeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), + evidence.NewAppModule(*app.EvidenceKeeper), ibc.NewAppModule(app.IBCKeeper), - params.NewAppModule(app.ParamsKeeper), + params.NewAppModule(*app.ParamsKeeper), app.AppKeepers.TransferModule, app.AppKeepers.VestingsModule, app.AppKeepers.TaxModule, @@ -183,6 +191,7 @@ func simulationModules( appCodec := encodingConfig.Marshaler return []module.AppModuleSimulation{ +<<<<<<< HEAD auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, encodingConfig.InterfaceRegistry), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), @@ -199,6 +208,20 @@ func simulationModules( appCodec, &app.WasmKeeper, app.AccountKeeper, app.BankKeeper, ), +======= + auth.NewAppModule(appCodec, *app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + bank.NewAppModule(appCodec, *app.BankKeeper, *app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), + gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), + mint.NewAppModule(appCodec, *app.MintKeeper, app.AccountKeeper), + tax.NewAppModule(appCodec, *app.TaxKeeper, app.AccountKeeper, app.BankKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + distribution.NewAppModule(appCodec, *app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), + slashing.NewAppModule(appCodec, *app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), + params.NewAppModule(*app.ParamsKeeper), + evidence.NewAppModule(*app.EvidenceKeeper), + wasm.NewAppModule(appCodec, &app.WasmKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), +>>>>>>> 532593d (chore(app): fixing errors in app/) ibc.NewAppModule(app.IBCKeeper), app.AppKeepers.TransferModule, app.AppKeepers.InterchainQueriesModule,