diff --git a/incubator/reseeding/alias.go b/incubator/reseeding/alias.go index 6822274..ab1d78f 100644 --- a/incubator/reseeding/alias.go +++ b/incubator/reseeding/alias.go @@ -6,7 +6,8 @@ import ( ) type ( - Keeper = keeper.Keeper + Keeper = keeper.Keeper + GenesisState = types.GenesisState ) const ( @@ -14,11 +15,15 @@ const ( ModuleName = types.ModuleName StoreKey = types.StoreKey RouterKey = types.RouterKey + QuerierRoute = types.QuerierRoute ) var ( + NewQuerier = keeper.NewQuerier + RegisterInvariants = keeper.RegisterInvariants NewGenesisState = types.NewGenesisState DefaultGenesisState = types.DefaultGenesisState ValidateGenesis = types.ValidateGenesis RegisterCodec = types.RegisterCodec + ModuleCdc = types.ModuleCdc ) diff --git a/incubator/reseeding/handler.go b/incubator/reseeding/handler.go index e0bb609..91e8c6a 100644 --- a/incubator/reseeding/handler.go +++ b/incubator/reseeding/handler.go @@ -22,6 +22,7 @@ func GenericHandler(k Keeper, stakingKeeper staking.Keeper) sdk.Handler { errMsg := fmt.Sprintf("unrecognized reseeding message type: %T", msg) return sdk.ErrUnknownRequest(errMsg).Result() } + return sdk.Result{} } } diff --git a/incubator/reseeding/internal/keeper/invariants.go b/incubator/reseeding/internal/keeper/invariants.go new file mode 100644 index 0000000..e6b6bf8 --- /dev/null +++ b/incubator/reseeding/internal/keeper/invariants.go @@ -0,0 +1,30 @@ +package keeper + +// DONTCOVER + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/modules/incubator/reseeding/internal/types" +) + +// RegisterInvariants registers all supply invariants +func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { + ir.RegisterRoute( + types.ModuleName, "supply", + SupplyInvariant(k), + ) +} + +// AllInvariants runs all invariants of the nfts module. +func AllInvariants(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + return SupplyInvariant(k)(ctx) + } +} + +// SupplyInvariant checks that the total amount of nfts on collections matches the total amount owned by addresses +func SupplyInvariant(k Keeper) sdk.Invariant { + return func(ctx sdk.Context) (string, bool) { + return "", false + } +} diff --git a/incubator/reseeding/internal/keeper/keeper.go b/incubator/reseeding/internal/keeper/keeper.go index b040f4d..61d659f 100644 --- a/incubator/reseeding/internal/keeper/keeper.go +++ b/incubator/reseeding/internal/keeper/keeper.go @@ -4,6 +4,8 @@ import ( "encoding/json" "fmt" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -80,3 +82,9 @@ func (k Keeper) GetCurrentSeed(ctx sdk.Context) []byte { func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func NewQuerier(k Keeper) sdk.Querier { + return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err sdk.Error) { + return nil, nil + } +} diff --git a/incubator/reseeding/internal/types/keys.go b/incubator/reseeding/internal/types/keys.go index cfb6d4d..8e3c3f9 100644 --- a/incubator/reseeding/internal/types/keys.go +++ b/incubator/reseeding/internal/types/keys.go @@ -7,4 +7,10 @@ const ( DefaultCodespace sdk.CodespaceType = ModuleName StoreKey = ModuleName RouterKey = ModuleName + QuerierRoute = ModuleName +) + +var ( + CollectionsKeyPrefix = []byte{0x00} // key for reseeding collections + OwnersKeyPrefix = []byte{0x01} // key for balance of NFTs held by an address ) diff --git a/incubator/reseeding/module.go b/incubator/reseeding/module.go index 4409d0d..f022e8f 100644 --- a/incubator/reseeding/module.go +++ b/incubator/reseeding/module.go @@ -6,6 +6,8 @@ import ( "encoding/json" "math/rand" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -97,7 +99,8 @@ type AppModule struct { AppModuleBasic AppModuleSimulation - keeper Keeper + stakingKeeper staking.Keeper + keeper Keeper } // NewAppModule creates a new AppModule object @@ -126,7 +129,7 @@ func (AppModule) Route() string { // NewHandler module handler func (am AppModule) NewHandler() sdk.Handler { - return GenericHandler(am.keeper) + return GenericHandler(am.keeper, am.stakingKeeper) } // QuerierRoute module querier route name diff --git a/incubator/reseeding/simulation/decoder.go b/incubator/reseeding/simulation/decoder.go new file mode 100644 index 0000000..d6be688 --- /dev/null +++ b/incubator/reseeding/simulation/decoder.go @@ -0,0 +1,11 @@ +package simulation + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cmn "github.com/tendermint/tendermint/libs/common" +) + +// DecodeStore unmarshals the KVPair's Value to the corresponding gov type +func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string { + return "" +} diff --git a/incubator/reseeding/simulation/genesis.go b/incubator/reseeding/simulation/genesis.go new file mode 100644 index 0000000..002494b --- /dev/null +++ b/incubator/reseeding/simulation/genesis.go @@ -0,0 +1,10 @@ +package simulation + +import ( + "github.com/cosmos/cosmos-sdk/types/module" +) + +// RandomizedGenState generates a random GenesisState for nft +func RandomizedGenState(simState *module.SimulationState) { + +}