diff --git a/modules/nft/handler.go b/modules/nft/handler.go deleted file mode 100644 index d5c9c408..00000000 --- a/modules/nft/handler.go +++ /dev/null @@ -1,47 +0,0 @@ -package nft - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/irisnet/irismod/modules/nft/keeper" - "github.com/irisnet/irismod/modules/nft/types" -) - -// NewHandler routes the messages to the handlers -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgIssueDenom: - res, err := msgServer.IssueDenom(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgMintNFT: - res, err := msgServer.MintNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgTransferNFT: - res, err := msgServer.TransferNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgEditNFT: - res, err := msgServer.EditNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgBurnNFT: - res, err := msgServer.BurnNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgTransferDenom: - res, err := msgServer.TransferDenom(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized nft message type: %T", msg) - } - } -} diff --git a/modules/nft/genesis.go b/modules/nft/keeper/genesis.go similarity index 58% rename from modules/nft/genesis.go rename to modules/nft/keeper/genesis.go index c4e50ff1..819a9736 100644 --- a/modules/nft/genesis.go +++ b/modules/nft/keeper/genesis.go @@ -1,14 +1,13 @@ -package nft +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/irisnet/irismod/modules/nft/keeper" "github.com/irisnet/irismod/modules/nft/types" ) // InitGenesis stores the NFT genesis. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { +func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { if err := types.ValidateGenesis(data); err != nil { panic(err.Error()) } @@ -24,11 +23,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { } // ExportGenesis returns a GenesisState for a given context and keeper. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return types.NewGenesisState(k.GetCollections(ctx)) } - -// DefaultGenesisState returns a default genesis state -func DefaultGenesisState() *types.GenesisState { - return types.NewGenesisState([]types.Collection{}) -} diff --git a/modules/nft/module.go b/modules/nft/module/module.go similarity index 91% rename from modules/nft/module.go rename to modules/nft/module/module.go index 870fee9c..607e895e 100644 --- a/modules/nft/module.go +++ b/modules/nft/module/module.go @@ -1,4 +1,4 @@ -package nft +package module import ( "context" @@ -44,7 +44,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // DefaultGenesis returns default genesis state as raw bytes for the NFT module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(DefaultGenesisState()) + return cdc.MustMarshalJSON(types.NewGenesisState([]types.Collection{})) } // ValidateGenesis performs genesis state validation for the NFT module. @@ -130,27 +130,19 @@ func (am AppModule) InitGenesis( cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, genesisState) + am.keeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the NFT module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } -// BeginBlock performs a no-op. -func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock returns the end blocker for the NFT module. It returns no validator updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} - // ____________________________________________________________________________ // AppModuleSimulation functions diff --git a/simapp/app.go b/simapp/app.go index b6ed2eef..775ac27b 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -104,8 +104,8 @@ import ( "github.com/irisnet/irismod/modules/mt" mtkeeper "github.com/irisnet/irismod/modules/mt/keeper" mttypes "github.com/irisnet/irismod/modules/mt/types" - "github.com/irisnet/irismod/modules/nft" nftkeeper "github.com/irisnet/irismod/modules/nft/keeper" + nft "github.com/irisnet/irismod/modules/nft/module" nfttypes "github.com/irisnet/irismod/modules/nft/types" "github.com/irisnet/irismod/modules/oracle" oracleKeeper "github.com/irisnet/irismod/modules/oracle/keeper"