github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/token/module_basic.go (about) 1 package token 2 3 import ( 4 "encoding/json" 5 6 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/client/context" 7 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 8 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module" 9 "github.com/gorilla/mux" 10 "github.com/spf13/cobra" 11 12 "github.com/fibonacci-chain/fbc/x/token/client/cli" 13 "github.com/fibonacci-chain/fbc/x/token/client/rest" 14 tokenTypes "github.com/fibonacci-chain/fbc/x/token/types" 15 ) 16 17 var ( 18 _ module.AppModuleBasic = AppModuleBasic{} 19 ) 20 21 // nolint 22 type AppModuleBasic struct{} 23 24 // nolint 25 func (AppModuleBasic) Name() string { 26 return tokenTypes.ModuleName 27 } 28 29 // nolint 30 func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { 31 RegisterCodec(cdc) 32 } 33 34 // nolint 35 func (AppModuleBasic) DefaultGenesis() json.RawMessage { 36 return tokenTypes.ModuleCdc.MustMarshalJSON(defaultGenesisState()) 37 } 38 39 // validateGenesis module validate genesis from json raw message 40 func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { 41 var data GenesisState 42 err := tokenTypes.ModuleCdc.UnmarshalJSON(bz, &data) 43 if err != nil { 44 return err 45 } 46 return validateGenesis(data) 47 } 48 49 // RegisterRESTRoutes register rest routes 50 func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { 51 rest.RegisterRoutes(ctx, rtr, ModuleName) 52 } 53 54 // GetTxCmd gets the root tx command of this module 55 func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { 56 return cli.GetTxCmd(tokenTypes.StoreKey, cdc) 57 } 58 59 // GetQueryCmd gets the root query command of this module 60 func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { 61 return cli.GetQueryCmd(tokenTypes.StoreKey, cdc) 62 }