space-pussy/x/graph/module.go

package graph

import (
	"encoding/json"
	//"fmt"

	"context"

	"github.com/cosmos/cosmos-sdk/client"
	codectypes "github.com/cosmos/cosmos-sdk/codec/types"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/cosmos/cosmos-sdk/types/module"
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
	bandwidthkeeper "github.com/joinresistance/space-pussy/x/bandwidth/keeper"
	abci "github.com/tendermint/tendermint/abci/types"
	//"github.com/gogo/protobuf/codec"
	"github.com/cosmos/cosmos-sdk/codec"
	//"github.com/cosmos/cosmos-sdk/types/module"
	authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
	"github.com/gorilla/mux"
	"github.com/spf13/cobra"
	//"github.com/tendermint/tendermint/abci/types"

	cyberbankkeeper "github.com/joinresistance/space-pussy/x/cyberbank/keeper"
	"github.com/joinresistance/space-pussy/x/graph/client/cli"
	"github.com/joinresistance/space-pussy/x/graph/client/rest"
	"github.com/joinresistance/space-pussy/x/graph/keeper"
	"github.com/joinresistance/space-pussy/x/graph/types"
)

var (
	_ module.AppModule      = AppModule{}
	_ module.AppModuleBasic = AppModuleBasic{}
)

type AppModuleBasic struct {
	cdc codec.Codec
}

func (AppModuleBasic) Name() string { return types.ModuleName }

func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
	types.RegisterLegacyAminoCodec(cdc)
}

func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { return nil }

func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error {
	return nil
}

func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
	rest.RegisterRoutes(clientCtx, rtr)
}

func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
	if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil {
		panic(err)
	}
}

func (AppModuleBasic) GetTxCmd() *cobra.Command {
	return cli.NewTxCmd()
}

func (AppModuleBasic) GetQueryCmd() *cobra.Command {
	return cli.GetQueryCmd()
}

func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) {
	types.RegisterInterfaces(registry)
}

type AppModule struct {
	AppModuleBasic

	gk *keeper.GraphKeeper
	ik *keeper.IndexKeeper
	ak authkeeper.AccountKeeper
	bk *cyberbankkeeper.IndexedKeeper
	bm *bandwidthkeeper.BandwidthMeter
}

func NewAppModule(
	cdc codec.Codec,
	graphKeeper *keeper.GraphKeeper,
	indexKeeper *keeper.IndexKeeper,
	accountKeeper authkeeper.AccountKeeper,
	bankKeeper *cyberbankkeeper.IndexedKeeper,
	bandwidthKeeper *bandwidthkeeper.BandwidthMeter,
) AppModule {
	return AppModule{
		AppModuleBasic: AppModuleBasic{cdc: cdc},
		gk:             graphKeeper,
		ik:             indexKeeper,
		ak:             accountKeeper,
		bk:             bankKeeper,
		bm:             bandwidthKeeper,
	}
}

func (AppModule) Name() string { return types.ModuleName }

func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}

func (am AppModule) Route() sdk.Route {
	return sdk.Route{}
}

func (am AppModule) QuerierRoute() string {
	return types.QuerierRoute
}

func (am AppModule) RegisterServices(cfg module.Configurator) {
	types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.gk, am.ik, am.ak, am.bk, am.bm))
	types.RegisterQueryServer(cfg.QueryServer(), am.gk)
}

func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
	return keeper.NewQuerier(*am.gk, legacyQuerierCdc)
}

func (am AppModule) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate {
	return []abci.ValidatorUpdate{}
}

func (am AppModule) ExportGenesis(ctx sdk.Context, _ codec.JSONCodec) json.RawMessage {
	err := keeper.WriteGenesis(ctx, *am.gk, am.ik)
	if err != nil {
		panic(err)
	}
	return nil
}

func (am AppModule) ConsensusVersion() uint64 {
	return 1
}

func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}

func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
	EndBlocker(ctx, am.gk, am.ik)
	return []abci.ValidatorUpdate{}
}

Synonyms

go-cyber/x/liquidity/module.go
cyberindex/modules/graph/module.go
cyberindex/modules/grid/module.go
space-pussy/x/grid/module.go
cyberindex/modules/liquidity/module.go
go-cyber/x/rank/module.go
space-pussy/x/resources/module.go
go-cyber/x/dmn/module.go
go-cyber/x/graph/module.go
go-cyber/x/tokenfactory/module.go
cyberindex/modules/resources/module.go
go-cyber/x/clock/module.go
space-pussy/x/rank/module.go
cyberindex/modules/bank/module.go
space-pussy/x/bandwidth/module.go
go-cyber/x/cyberbank/module.go
space-pussy/x/cyberbank/module.go
go-cyber/x/resources/module.go
space-pussy/x/dmn/module.go
go-cyber/x/staking/module.go
cyberindex/modules/wasm/module.go
space-pussy/x/staking/module.go
go-cyber/x/bandwidth/module.go
go-cyber/x/grid/module.go

Neighbours