Skip to content

Commit

Permalink
refactor: keep the directory structure with the main branch code alwa…
Browse files Browse the repository at this point in the history
…ys (#372)
  • Loading branch information
Dreamer authored Jul 24, 2023
1 parent a9d4976 commit 7b10a08
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 69 deletions.
47 changes: 0 additions & 47 deletions modules/nft/handler.go

This file was deleted.

12 changes: 3 additions & 9 deletions modules/nft/genesis.go → modules/nft/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -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())
}
Expand All @@ -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{})
}
16 changes: 4 additions & 12 deletions modules/nft/module.go → modules/nft/module/module.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nft
package module

import (
"context"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7b10a08

Please sign in to comment.