Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate x/genutil to app wiring #12124

Merged
merged 9 commits into from
Jun 10, 2022
Merged
Changes from 7 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
503 changes: 503 additions & 0 deletions api/cosmos/genutil/module/v1/module.pulsar.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions proto/cosmos/genutil/module/v1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package cosmos.genutil.module.v1;

import "cosmos/app/v1alpha1/module.proto";

// Module is the config object for the genutil module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/x/genutil"
};
}
8 changes: 8 additions & 0 deletions runtime/module.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/std"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/types/module"
abci "github.com/tendermint/tendermint/abci/types"
)

// BaseAppOption is a depinject.AutoGroupType which can be used to pass
@@ -34,6 +35,7 @@ func init() {
provideKVStoreKey,
provideTransientStoreKey,
provideMemoryStoreKey,
provideDeliverTx,
),
)
}
@@ -131,3 +133,9 @@ func provideMemoryStoreKey(key depinject.ModuleKey, app appWrapper) *storetypes.
registerStoreKey(app, storeKey)
return storeKey
}

func provideDeliverTx(app appWrapper) func(abci.RequestDeliverTx) abci.ResponseDeliverTx {
return func(tx abci.RequestDeliverTx) abci.ResponseDeliverTx {
return app.BaseApp.DeliverTx(tx)
}
}
4 changes: 0 additions & 4 deletions simapp/app.go
Original file line number Diff line number Diff line change
@@ -314,10 +314,6 @@ func NewSimApp(
// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
if err := app.RegisterModules(
genutil.NewAppModule(
app.AccountKeeper, app.StakingKeeper, app.BaseApp.DeliverTx,
encodingConfig.TxConfig,
),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
gov.NewAppModule(app.appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
4 changes: 4 additions & 0 deletions simapp/app.yaml
Original file line number Diff line number Diff line change
@@ -111,3 +111,7 @@ modules:
- name: slashing
config:
"@type": cosmos.slashing.module.v1.Module

- name: genutil
config:
"@type": cosmos.genutil.module.v1.Module
32 changes: 30 additions & 2 deletions x/genutil/module.go
Original file line number Diff line number Diff line change
@@ -4,14 +4,18 @@ import (
"encoding/json"
"fmt"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"

abci "github.com/tendermint/tendermint/abci/types"

modulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/depinject"
"github.com/cosmos/cosmos-sdk/runtime"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/genutil/types"
@@ -53,7 +57,7 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, txEncodingConfig cl
}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {
func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *gwruntime.ServeMux) {
}

// GetTxCmd returns no root tx command for the genutil module.
@@ -106,3 +110,27 @@ func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMe

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 1 }

func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(provideModuleBasic, provideModule),
)
}

func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}

type genutilInputs struct {
depinject.In

AccountKeeper types.AccountKeeper `key:"cosmos.auth.v1.AccountKeeper"`
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
StakingKeeper types.StakingKeeper `key:"cosmos.staking.v1.Keeper"`
blushi marked this conversation as resolved.
Show resolved Hide resolved
tac0turtle marked this conversation as resolved.
Show resolved Hide resolved
DeliverTx func(abci.RequestDeliverTx) abci.ResponseDeliverTx
Config client.TxConfig
}

func provideModule(in genutilInputs) runtime.AppModuleWrapper {
m := NewAppModule(in.AccountKeeper, in.StakingKeeper, in.DeliverTx, in.Config)
return runtime.WrapAppModule(m)
}