Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depinject for the modules/core/<submodule> #7375

Open
QuocThi opened this issue Oct 2, 2024 · 0 comments
Open

depinject for the modules/core/<submodule> #7375

QuocThi opened this issue Oct 2, 2024 · 0 comments

Comments

@QuocThi
Copy link

QuocThi commented Oct 2, 2024

Hi team,
I am using this branch when integrate IBC with support of depinject feature to our code. While other modules of IBC like capability, ica, fee... work fine, but the core's sub-modules still not working and I am facing with this error:

panic: can't resolve type github.com/cosmos/ibc-go/v8/modules/core/02-client/types/types.ConsensusHost for github.com/cosmos/ibc-go/v8/modules/core.ProvideModule (~/workspace/ibc-support-depinjection/ibc-go/modules/core/depinject.go:55):
        while resolving:
                types.ConsensusHost for github.com/cosmos/ibc-go/v8/modules/core.ProvideModule (~/workspace/ibc-support-depinjection/ibc-go/modules/core/depinject.go:55)

After check the code I could see that only the core package have the deinject.go, meanwhile its submodules like 02-client, 03-connection, 04-port ... haven't have any implementation for deinject yet. I think it's because these submodule are not an AppModule.
The modules/core/02-client/types/types.ConsensusHost can be achieved by calling this function, it require the StakingKeeper refer to this line. So can this suggestion possible when modify the modules/core/depinject.go:

// ModuleInputs defines the core module inputs for depinject.
type ModuleInputs struct {
	depinject.In

	Config *modulev1.Module
	Cdc    codec.Codec
	Key    *storetypes.KVStoreKey


        // ConsensusHost clienttypes.ConsensusHost          // <== comment this one
        StakingKeeper StakingKeeper                                     // <== add this one
	UpgradeKeeper clienttypes.UpgradeKeeper
	ScopedKeeper  capabilitykeeper.ScopedKeeper

	// LegacySubspace is used solely for migration of x/params managed parameters
	LegacySubspace paramtypes.Subspace `optional:"true"`
}

// ModuleOutputs defines the core module outputs for depinject.
type ModuleOutputs struct {
	depinject.Out

	IbcKeeper *ibckeeper.Keeper
	Module    appmodule.AppModule
}

func ProvideModule(in ModuleInputs) ModuleOutputs {
        consensusHost := ibctm.NewConsensusHost(in.StakingKeeper)          // <== add this line
	// default to governance authority if not provided
	authority := authtypes.NewModuleAddress(govtypes.ModuleName)
	if in.Config.Authority != "" {
		authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
	}

	keeper := ibckeeper.NewKeeper(
		in.Cdc,
		in.Key,
		in.LegacySubspace,
		// in.ConsensusHost,                     // <== comment this line
                consensusHost,                             // <== replace with this line
		in.UpgradeKeeper,
		in.ScopedKeeper,
		authority.String(),
	)
	m := NewAppModule(keeper)

	return ModuleOutputs{IbcKeeper: keeper, Module: m}
}

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant