feat(x/auth): app wiring setup (#12019)

This commit is contained in:
Aaron Craelius
2022-05-27 16:54:49 -04:00
committed by GitHub
parent 81ee241a6a
commit dfe29ee2bf
11 changed files with 2227 additions and 74 deletions
+38 -2
View File
@@ -6,11 +6,17 @@ import (
"fmt"
"math/rand"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
abci "github.com/tendermint/tendermint/abci/types"
"cosmossdk.io/core/appmodule"
modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -59,7 +65,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod
}
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auth module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
panic(err)
}
@@ -185,3 +191,33 @@ func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
return nil
}
//
// New App Wiring Setup
//
func init() {
appmodule.Register(&modulev1.Module{},
appmodule.Provide(provideModuleBasic, provideModule),
)
}
func provideModuleBasic() runtime.AppModuleBasicWrapper {
return runtime.WrapAppModuleBasic(AppModuleBasic{})
}
func provideModule(
config *modulev1.Module,
key *store.KVStoreKey,
cdc codec.Codec,
subspace paramtypes.Subspace) (keeper.AccountKeeper, runtime.AppModuleWrapper) {
maccPerms := map[string][]string{}
for _, permission := range config.ModuleAccountPermissions {
maccPerms[permission.Account] = permission.Permissions
}
k := keeper.NewAccountKeeper(cdc, key, subspace, types.ProtoBaseAccount, maccPerms, config.Bech32Prefix)
m := NewAppModule(cdc, k, simulation.RandomGenesisAccounts)
return k, runtime.WrapAppModule(m)
}