Files
sonr/x/dwn/depinject.go
T

93 lines
2.3 KiB
Go
Raw Normal View History

2024-09-25 19:45:28 -04:00
package module
import (
"os"
2025-10-03 14:45:52 -04:00
"github.com/cosmos/cosmos-sdk/client"
2024-11-26 22:05:50 -05:00
"github.com/cosmos/cosmos-sdk/codec"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
2024-09-25 19:45:28 -04:00
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
2025-10-03 14:45:52 -04:00
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
2024-09-25 19:45:28 -04:00
2025-10-03 14:45:52 -04:00
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
modulev1 "github.com/sonr-io/sonr/api/dwn/module/v1"
didkeeper "github.com/sonr-io/sonr/x/did/keeper"
"github.com/sonr-io/sonr/x/dwn/keeper"
svckeeper "github.com/sonr-io/sonr/x/svc/keeper"
2024-09-25 19:45:28 -04:00
)
var _ appmodule.AppModule = AppModule{}
// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
2025-10-03 14:45:52 -04:00
func (a AppModule) IsOnePerModuleType() {}
2024-09-25 19:45:28 -04:00
// IsAppModule implements the appmodule.AppModule interface.
2025-10-03 14:45:52 -04:00
func (a AppModule) IsAppModule() {}
2024-09-25 19:45:28 -04:00
func init() {
appmodule.Register(
&modulev1.Module{},
appmodule.Provide(ProvideModule),
)
}
type ModuleInputs struct {
depinject.In
Cdc codec.Codec
StoreService store.KVStoreService
AddressCodec address.Codec
2025-10-03 14:45:52 -04:00
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
2024-09-25 19:45:28 -04:00
SlashingKeeper slashingkeeper.Keeper
2025-10-03 14:45:52 -04:00
FeegrantKeeper feegrantkeeper.Keeper
DIDKeeper didkeeper.Keeper
ServiceKeeper svckeeper.Keeper
2024-09-25 19:45:28 -04:00
}
type ModuleOutputs struct {
depinject.Out
Module appmodule.AppModule
Keeper keeper.Keeper
}
func ProvideModule(in ModuleInputs) ModuleOutputs {
govAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String()
2025-10-03 14:45:52 -04:00
// Create a default client context for transaction building
// Note: TxConfig will need to be set when available in the app initialization
clientCtx := client.Context{}
clientCtx = clientCtx.WithCodec(in.Cdc)
k := keeper.NewKeeper(
in.Cdc,
in.StoreService,
log.NewLogger(os.Stderr),
govAddr,
in.AccountKeeper,
in.BankKeeper,
in.FeegrantKeeper,
in.StakingKeeper,
in.DIDKeeper,
in.ServiceKeeper,
clientCtx,
)
2024-11-26 22:05:50 -05:00
m := NewAppModule(in.Cdc, k)
2024-09-25 19:45:28 -04:00
return ModuleOutputs{Module: m, Keeper: k, Out: depinject.Out{}}
}