github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/token/module.go (about) 1 package token 2 3 import ( 4 "encoding/json" 5 6 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 7 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module" 8 authTypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/types" 9 abci "github.com/fibonacci-chain/fbc/libs/tendermint/abci/types" 10 11 "github.com/fibonacci-chain/fbc/x/common/version" 12 tokenTypes "github.com/fibonacci-chain/fbc/x/token/types" 13 ) 14 15 var ( 16 _ module.AppModule = AppModule{} 17 ) 18 19 // AppModule app module 20 type AppModule struct { 21 AppModuleBasic 22 keeper Keeper 23 supplyKeeper authTypes.SupplyKeeper 24 version version.ProtocolVersionType 25 } 26 27 // NewAppModule creates a new AppModule object 28 func NewAppModule(v version.ProtocolVersionType, keeper Keeper, supplyKeeper authTypes.SupplyKeeper) AppModule { 29 return AppModule{ 30 AppModuleBasic: AppModuleBasic{}, 31 keeper: keeper, 32 supplyKeeper: supplyKeeper, 33 version: v, 34 } 35 } 36 37 // nolint 38 func (AppModule) Name() string { 39 return tokenTypes.ModuleName 40 } 41 42 // nolint 43 func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { 44 } 45 46 // Route module message route name 47 func (AppModule) Route() string { 48 return tokenTypes.RouterKey 49 } 50 51 // nolint 52 func (am AppModule) NewHandler() sdk.Handler { 53 return NewTokenHandler(am.keeper, am.version) 54 } 55 56 // nolint 57 func (AppModule) QuerierRoute() string { 58 return tokenTypes.QuerierRoute 59 } 60 61 // nolint 62 func (am AppModule) NewQuerierHandler() sdk.Querier { 63 return NewQuerier(am.keeper) 64 } 65 66 // nolint 67 func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate { 68 var genesisState GenesisState 69 tokenTypes.ModuleCdc.MustUnmarshalJSON(data, &genesisState) 70 initGenesis(ctx, am.keeper, genesisState) 71 return []abci.ValidatorUpdate{} 72 } 73 74 // nolint 75 func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage { 76 gs := ExportGenesis(ctx, am.keeper) 77 return tokenTypes.ModuleCdc.MustMarshalJSON(gs) 78 } 79 80 // nolint 81 func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { 82 beginBlocker(ctx, am.keeper) 83 } 84 85 // nolint 86 func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { 87 return []abci.ValidatorUpdate{} 88 }