Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sin3A committed Jul 24, 2024
1 parent f4802d3 commit 23073a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
31 changes: 11 additions & 20 deletions modules/node/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ import (
"cosmossdk.io/depinject"
"github.com/cosmos/cosmos-sdk/codec"
store "github.com/cosmos/cosmos-sdk/store/types"
cosmosparamstypes "github.com/cosmos/cosmos-sdk/x/params/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
paramskeeper "iritamod.bianjie.ai/modules/params/keeper"

modulev1 "iritamod.bianjie.ai/api/iritamod/node/module/v1"
"iritamod.bianjie.ai/modules/node/keeper"
"iritamod.bianjie.ai/modules/node/types"
nodetypes "iritamod.bianjie.ai/modules/node/types"
)

// App Wiring Setup
func init() {
appmodule.Register(&modulev1.Module{},
// appmodule.Provide(ProvideModule, ProvideKeyTable),
appmodule.Provide(ProvideModule),
appmodule.Provide(ProvideModule, ProvideKeyTable),
//appmodule.Provide(ProvideModule),
appmodule.Invoke(InvokeHooks),
)
}

var _ appmodule.AppModule = AppModule{}

//func ProvideKeyTable() paramstypes.KeyTable {
// return keeper.ParamKeyTable()
//}
func ProvideKeyTable() paramstypes.KeyTable {
return nodetypes.ParamKeyTable()
}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
func (am AppModule) IsOnePerModuleType() {}
Expand All @@ -45,9 +43,9 @@ type HookInputs struct {

type NodeInputs struct {
depinject.In
Cdc codec.Codec
Key *store.KVStoreKey
Paramskeeper paramskeeper.Keeper
Cdc codec.Codec
Key *store.KVStoreKey
LegacySubspace paramstypes.Subspace `optional:"true"`
}

type NodeOutputs struct {
Expand All @@ -58,18 +56,11 @@ type NodeOutputs struct {
}

func ProvideModule(in NodeInputs) NodeOutputs {
var subspace cosmosparamstypes.Subspace
if space, ok := in.Paramskeeper.GetSubspace(types.ModuleName); ok {
subspace = space
} else {
subspace = in.Paramskeeper.Subspace(types.ModuleName)
}
nodekeeper := keeper.NewKeeper(
in.Cdc,
in.Key,
subspace,
in.LegacySubspace,
)
//nodekeeper.SetHooks(in.StakingKeeper.Hooks())
m := NewAppModule(in.Cdc, nodekeeper)

return NodeOutputs{NodeKeeper: nodekeeper, Module: m}
Expand Down
2 changes: 1 addition & 1 deletion modules/node/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Keeper struct {
func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey, ps paramtypes.Subspace) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(ParamKeyTable())
ps = ps.WithKeyTable(types.ParamKeyTable())
}

return &Keeper{
Expand Down
4 changes: 4 additions & 0 deletions modules/node/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func NewParams(historicalEntries uint32) Params {
return Params{HistoricalEntries: historicalEntries}
}

func ParamKeyTable() paramtypes.KeyTable {
return NewKeyTable().RegisterParamSet(&Params{})
}

// Implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
Expand Down

0 comments on commit 23073a8

Please sign in to comment.