From bde7eb1a4dd73c0aead4a918829400edb93221ff Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 9 Jan 2024 16:14:36 +0100 Subject: [PATCH] refactor(core)!: cleanup dependency graph (#18866) Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com> --- Dockerfile | 1 + UPGRADING.md | 4 + baseapp/utils_test.go | 2 +- client/v2/go.mod | 1 + client/v2/go.sum | 2 - contrib/images/simd-env/Dockerfile | 1 + core/CHANGELOG.md | 1 + core/appmodule/README.md | 232 +----------------- core/appmodule/module.go | 4 - core/go.mod | 18 +- core/go.sum | 67 +---- core/intermodule/client.go | 32 --- {core => depinject}/appconfig/config.go | 2 +- {core => depinject}/appconfig/config_test.go | 8 +- {core => depinject}/appconfig/doc.go | 0 depinject/appmodule/README.md | 232 ++++++++++++++++++ {core => depinject}/appmodule/option.go | 2 +- {core => depinject}/appmodule/register.go | 2 +- depinject/go.mod | 10 +- depinject/go.sum | 25 +- .../internal/appconfig}/buf.gen.yaml | 0 .../internal/appconfig}/buf.yaml | 0 .../internal/appconfig}/registry.go | 0 .../internal/appconfig}/testpb/test.proto | 0 .../internal/appconfig}/testpb/test.pulsar.go | 0 docs/build/building-modules/15-depinject.md | 28 ++- go.mod | 1 + go.sum | 2 - orm/go.mod | 2 + orm/go.sum | 2 - orm/model/ormdb/module_test.go | 8 +- orm/orm.go | 6 +- runtime/app.go | 4 +- runtime/module.go | 7 +- simapp/app_config.go | 2 +- simapp/go.mod | 1 + simapp/go.sum | 2 - simapp/gomod2nix.toml | 3 - tests/go.mod | 1 + tests/go.sum | 2 - tests/starship/tests/go.mod | 1 + tests/starship/tests/go.sum | 2 - testutil/configurator/configurator.go | 2 +- x/accounts/go.mod | 1 + x/accounts/go.sum | 2 - x/auth/go.mod | 1 + x/auth/go.sum | 2 - x/auth/module.go | 6 +- x/auth/tx/config/config.go | 2 +- x/auth/vesting/module.go | 8 +- x/authz/go.mod | 1 + x/authz/go.sum | 2 - x/authz/module/module.go | 6 +- x/bank/go.mod | 1 + x/bank/go.sum | 2 - x/bank/module.go | 6 +- x/circuit/go.mod | 1 + x/circuit/go.sum | 2 - x/circuit/module.go | 5 +- x/consensus/module.go | 8 +- x/counter/module.go | 8 +- x/crisis/module.go | 5 +- x/distribution/go.mod | 1 + x/distribution/go.sum | 2 - x/distribution/module.go | 6 +- x/evidence/go.mod | 1 + x/evidence/go.sum | 2 - x/evidence/module.go | 6 +- x/feegrant/go.mod | 1 + x/feegrant/go.sum | 2 - x/feegrant/module/module.go | 6 +- x/genutil/module.go | 5 +- x/gov/go.mod | 1 + x/gov/go.sum | 2 - x/gov/module.go | 7 +- x/group/go.mod | 1 + x/group/go.sum | 2 - x/group/module/module.go | 6 +- x/mint/go.mod | 1 + x/mint/go.sum | 2 - x/mint/module.go | 6 +- x/nft/go.mod | 1 + x/nft/go.sum | 2 - x/nft/module/module.go | 8 +- x/params/go.mod | 1 + x/params/go.sum | 2 - x/params/module.go | 6 +- x/protocolpool/go.mod | 1 + x/protocolpool/go.sum | 2 - x/protocolpool/module.go | 5 +- x/slashing/go.mod | 1 + x/slashing/go.sum | 2 - x/slashing/module.go | 5 +- x/staking/go.mod | 1 + x/staking/go.sum | 2 - x/staking/module.go | 8 +- x/upgrade/go.mod | 1 + x/upgrade/go.sum | 2 - x/upgrade/module.go | 7 +- 99 files changed, 432 insertions(+), 476 deletions(-) delete mode 100644 core/intermodule/client.go rename {core => depinject}/appconfig/config.go (98%) rename {core => depinject}/appconfig/config_test.go (96%) rename {core => depinject}/appconfig/doc.go (100%) create mode 100644 depinject/appmodule/README.md rename {core => depinject}/appmodule/option.go (96%) rename {core => depinject}/appmodule/register.go (94%) rename {core/internal => depinject/internal/appconfig}/buf.gen.yaml (100%) rename {core/internal => depinject/internal/appconfig}/buf.yaml (100%) rename {core/internal => depinject/internal/appconfig}/registry.go (100%) rename {core/internal => depinject/internal/appconfig}/testpb/test.proto (100%) rename {core/internal => depinject/internal/appconfig}/testpb/test.pulsar.go (100%) diff --git a/Dockerfile b/Dockerfile index d59d084de3..1f03e2fbe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ COPY x/auth/go.mod x/auth/go.sum ./x/auth/ COPY x/authz/go.mod x/authz/go.sum ./x/authz/ COPY x/bank/go.mod x/bank/go.sum ./x/bank/ COPY x/mint/go.mod x/mint/go.sum ./x/mint/ +COPY depinject/go.mod depinject/go.sum ./depinject/ RUN go mod download # Add source files diff --git a/UPGRADING.md b/UPGRADING.md index 326bee2c9a..8713095acb 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -116,6 +116,10 @@ Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a l #### `**all**` +##### Dependency Injection + +Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appmodule`. All modules using dependency injection must update their imports. + ##### Genesis Interface All genesis interfaces have been migrated to take context.Context instead of sdk.Context. diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index cece72c3d9..160ecac8a9 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -21,8 +21,8 @@ import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" "cosmossdk.io/core/address" - "cosmossdk.io/core/appconfig" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" diff --git a/client/v2/go.mod b/client/v2/go.mod index fda712d75b..6d281f9927 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -168,6 +168,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ./../../ replace ( + cosmossdk.io/depinject => ./../../depinject cosmossdk.io/x/auth => ./../../x/auth cosmossdk.io/x/bank => ./../../x/bank cosmossdk.io/x/distribution => ./../../x/distribution diff --git a/client/v2/go.sum b/client/v2/go.sum index 0a913cb49f..3cfefc2a7f 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index e7f78db098..0ed920028f 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -9,6 +9,7 @@ COPY api/go.mod api/go.sum /work/api/ COPY core/go.mod core/go.sum /work/core/ COPY collections/go.mod collections/go.sum /work/collections/ COPY store/go.mod store/go.sum /work/store/ +COPY store/go.mod store/go.sum /work/depinject/ COPY x/tx/go.mod x/tx/go.sum /work/x/tx/ COPY x/protocolpool/go.mod x/protocolpool/go.sum /work/x/protocolpool/ COPY x/gov/go.mod x/gov/go.sum /work/x/gov/ diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 71e06fa372..1af2b0fc30 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` to `x/tx`. * [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. +* [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`) ## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0) diff --git a/core/appmodule/README.md b/core/appmodule/README.md index ebcdeaf74c..5d02cc25bd 100644 --- a/core/appmodule/README.md +++ b/core/appmodule/README.md @@ -1,232 +1,8 @@ -# Wiring up app modules for use with appconfig +# Appmodule -The `appconfig` framework allows Cosmos SDK modules to be composed declaratively using a configuration file without -requiring the app developer to understand the details of inter-module dependencies. + -## 1. Create a module config protobuf message +This package defines what is needed for an module to be used in the Cosmos SDK. -The first step in creating a module that works with `appconfig`, is to create a protobuf message for the module configuration. The best practices for defining the module configuration message are: -* Use a dedicated protobuf package for the module configuration message instead of placing it in the API protobuf package. For example, the module configuration for bank would go in `cosmos.bank.module.v1` instead of just `cosmos.bank.v1`. This decouples the state machine version from the API version. -* The module configuration message is usually called simply `Module`, ex. `cosmos.bank.module.v1.Module`. -* Create a new protobuf package and configuration message for each state machine breaking version of the module, ex. `cosmos.bank.module.v2.Module`, etc. - -The module configuration message should include any parameters which should be initialized at application startup. For example, the auth module needs to know the bech32 prefix of the app and the permissions of module accounts. - -In the future, it may be possible to update the app config through a governance proposal at runtime. - -All module configuration messages should define a module descriptor, using the `cosmos.app.v1alpha1.module` message option. - -Here is an example module configuration message for the `auth` module: - -```protobuf -package cosmos.auth.module.v1; - -import "cosmos/app/v1alpha1/module.proto"; - -message Module { - option (cosmos.app.v1alpha1.module) = { - go_import: "cosmossdk.io/x/auth" - }; - string bech32_prefix = 1; - repeated ModuleAccountPermission module_account_permissions = 2; -} -``` - -## 2. Register module depinject providers and invokers - -Once we have a module config object, we need to register depinject providers and invokers for the module using the `cosmossdk.io/core/appmodule` package. - -At the most basic level, we must define an `init` function in the package listed as the `go_import` in the module descriptor. This `init` function must call `appmodule.Register` with an empty instance of the config object and some options for initializing the module, ex: - -```go -func init() { - appmodule.Register(&modulev1.Module{}, - // options - ) -} -``` - -### `depinject` Provider and Invoker Basics - -A `depinject` "provider" is a function which takes dependencies from other modules as inputs and returns outputs for -other modules to use as dependencies. A `depinject` "invoker" is function which takes optional dependencies as inputs, -returns no outputs, and is run at the end of initializing the dependency graph. Providers are much more common than -invokers and should be the preferred method of wiring up modules when possible. Providers and invokers can be registered -for modules by using `appmodule.Provide` and `appmodule.Invoke` to create options which get passed -to `appmodule.Register` in the module `init` function, ex: - -```go -func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(provideSomething, provideSomethingElse), - appmodule.Invoke(invokeSomething), - ) -} -``` - -### `depinject` Types - -`depinject` constructor functions support these classes of input and output parameter types: - -* regular golang types (with special treatment of interface types as input parameters) -* structs with `depinject.In` and `depinject.Out` embedded -* `depinject.OnePerModuleType`s -* `depinject.ManyPerContainerType`s -* `depinject.ModuleKey` (which can only be defined as an input type) -* `error` (which gets special treatment as an output type) - -#### Regular Golang Types - -Regular golang types (besides the special cases described above) can be provided as both input and output parameters -to providers and invokers. For `depinject` to match an output parameter of one provider to an input parameter of -another, there must be an exact match for the type unless the input parameter is an input type. For instance, if -a provider defines a dependency on `Foo` and some module provides `*Foo`, these two types will not match and there -will be an error. - -#### Interface Input Types - -When interfaces are used as input parameters to providers and invokers, `depinject` will search the container for -all types that implement this interface. If there is an unambiguously matching type, then this type will be used -to satisfy that interface. If there is a conflict between two types matching the interface, the app developer -can use `golang_bindings` options in their app config in order to resolve the conflict. - -#### Structs with embedded `depinject.In` and `depinject.Out` - -Structs that have `depinject.In` or `depinject.Out` as an embedded field are treated specially by `depinject`, where -all of these structs fields are treated as input or output parameters, respectively. These structs allow custom options -to be defined using struct field tags. Currently, the only supported custom option is `optional:"true"` which marks -a field as optional. - -#### `depinject.OnePerModuleType`s - -Any type which implements the `depinject.OnePerModuleType` interface can be provided at most once by every module. -These types can be collected as an input parameter to some provider or invoker by defining an input parameter which -is a map of module names as strings to this parameter type. For example if `Foo` is a `OnePerModuleType`, then -`map[string]Foo` can be declared as an input parameter by some provider (which obviously cannot provide an instance of -`Foo` itself because that would cause a circular dependency). - -`OnePerModuleType`s should be used whenever different modules may provide the type *and* there is a need to provide -an ordering of these types based on the module name. Generally, in blockchains there is always a need for deterministic -orderings so using module names to provide that ordering is generally a good strategy for this use case. Ordering based -on module names can either be done implicitly by sorting the module names or explicitly as a parameter in the module -configuration object. - -#### `depinject.ManyPerContainerType`s - -`ManyPerContainerType`s can be provided by as many providers in as many modules as the user would like. If a type `Bar` -is a `ManyPerContainerType`, a provider may define an output parameter of `Bar` or `[]Bar` to provide `Bar` instances -to the container. A provider may define an input parameter of `[]Bar` to get all of the `Bar` instances in the -container (such a provider may not also return `Bar` as that would cause a circular dependency). The ordering of `Bar` -instances in the `[]Bar` input type should be assumed to be deterministic. - -`ManyPerContainerType`s should be used only when 1) ordering is unimportant or 2) the ordering can be defined by -some parameter on the type. For instance, if `Bar` had a field `Name string`, that is supposed to be unique in the -container then that could be used to provide an ordering. An example of a type that could work as a -`ManyPerContainerType` in this way is a wrapper around `*cobra.Command`, ex. -`type QueryCommand struct {*cobra.Command}`. This could be used to collect all the query commands in an app and then -cobra would take care of ordering. If this type of ordering is not available, a `OnePerModuleType` is probably a better -bet. - -#### Module-scoped Providers/`depinject.ModuleKey` as an input - -If `depinject.ModuleKey` is used as input parameter for a provider, the provider function will be treated as a -"module-scoped provider" which means that the provider function will be called exactly once every time -one of its outputs is needed by a module so that the provider can provide a unique instance of the dependency to -each module. - -Module-scoped dependencies should be used to provide dependencies which are private and unique to each module. Examples -of these are store keys and param subspaces. - -#### `error` as an output parameter - -`error` can be used as the last output parameter on any provider or invoker. If a provider or invoker with an `error` -parameter returns a non-nil value for `error`, `depinject` will fail and propagate this error up to the caller. - -### Provider Invocation Details - -Providers are called lazily as they are needed and will be invoked at most once (except for "module-scoped providers" -described above) if and only if at least one of their outputs is needed somewhere in the dependency graph. Providers -will only get called if all of their non-optional inputs can successfully be resolved by some other module, otherwise an -error will occur. Modules should proactively mark dependencies as `optional` if the module can still be successfully -built without this dependency. - -### Invoker Invocation Details - -Invokers are called at the end of container initialization after all providers that were needed to build the graph -were called. All the dependencies of invokers are automatically marked as optional so invokers should `nil` check -every input parameter. Invokers may cause additional providers to get run if they have a dependency that wasn't built -yet. But if a dependency to an invoker cannot be provided for some reason, the invoker will still get called but with -`nil` for that input. This allows invokers to still work with the lazy invocation model of providers which only -builds things which are actually necessary as a dependency for some module or the caller. - -Invokers should generally be used sparingly to perform some initialization logic which can't be done in the initial -provider, usually because of a circular dependency, and which may be optional. - -### Best practices - -* make dependencies `optional` whenever possible! -* interface types should be used whenever possible to avoid tight couplings between two modules. -* `OnePerModuleType`s should be used when there is something occurs at most once per module and the module name is a -convenient way for providing a deterministic order. -* `ManyPerContainerType`s should be used only when there is an obvious way to create an ordering from the types or -when ordering *really* doesn't matter (which is rare). -* module-scoped providers should be used for private, module-scoped dependencies -* use different providers for unrelated or loosely components or to resolve circular dependencies (see below) -* use invokers sparingly and always `nil`-check the inputs. - -### Resolving Circular Dependencies - -Circular dependencies are inevitable to crop up and there are ways to avoid them. While `depinject` cannot handle -circular dependency graphs of providers, many of the above tools are designed to enable satisfying circular dependencies -between modules. - -One of the key tactics for resolving circular dependencies is to use different providers and/or invokers to allow a -circular dependency between components. For example, say the slashing keeper depends on the keeper module but the -staking keeper also depends on the staking module indirectly (in the form of "staking hooks"). The slashing module -can declare a dependency directly on the staking keeper (using an interface to avoid actually importing the staking -keeper package). It can also provide an instance of the slashing keeper wrapped as staking hooks in a `OnePerModuleType` -we'll call `StakingHooksWrapper`. Now, if the staking module directly depended on the staking hooks wrappers -(`map[string]StakingHooksWrapper`) we would have a circular dependency graph and `depinject` would fail. To fix this, -the staking module can define an invoker which depends on `map[string]StakingHooksWrapper` and the staking keeper -(which was provided by the staking module already in a separate provided). In this way `depinject` will be able to -satisfy this dependency graph which allows staking and slashing to depend on each other in this order: - -* provide staking keeper -> slashing keeper -* provide slashing keeper wrapped as `StakingHooksWrapper` -* get `map[string]StakingHooksWrapper` and the staking keeper and wire them together - -## 3. Testing and Debugging The Module - -In order to test and debug the module configuration, we need to build an app config, generally defined in a YAML file. -This configuration should be passed first to `appconfig.LoadYAML` to get an `depinject.Config` instance.Then the -`depinject.Config` can be passed to `depinject.Inject` and we can try to resolve dependencies in the app config. -Alternatively, the `depinject.Config` can be created via [pure Go code](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/simapp/app_config.go). - -Ex: - -```go -//go:embed app.yaml -var appConfig []byte - -var AppConfig = appconfig.LoadYAML(appConfig) - -func TestModule(t *testing.T) { - var keeper Keeper - assert.NilError(t, depinject.Inject(AppConfig, &keeper)) -} -``` - -### Debugging `depinject` Graphs - -Whenever there is an error in a `depinject` graph, by default `depinject` will dump a bunch of logging output to the -console, print the error message, and save the dependency graph in [GraphViz](https://graphviz.org) DOT format to -the file `debug_container.dot`. Inspecting the GraphViz output by converting it to an SVG and viewing it in a web -browser or using some other GraphViz tool is *highly recommended*. - -If `depinject` does not return an error but there is still some weird issue wiring up modules, inspecting the GraphViz -and logging output is still *highly recommended* and can be done using `depinject.InjectDebug` with the debug option -`depinject.Debug`. - -App developers should attempt to familiarize themselves with the GraphViz graph of their app to see which modules -depend on which other modules. +If you are looking at integrating Dependency injection into your module please see [depinject appmodule documentation](../../depinject/appmodule/README.md) diff --git a/core/appmodule/module.go b/core/appmodule/module.go index 4d31ae0a26..ff28987b17 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -4,8 +4,6 @@ import ( "context" "google.golang.org/grpc" - - "cosmossdk.io/depinject" ) // AppModule is a tag interface for app module implementations to use as a basis @@ -13,8 +11,6 @@ import ( // type that all valid app modules should provide so that they can be identified // by other modules (usually via depinject) as app modules. type AppModule interface { - depinject.OnePerModuleType - // IsAppModule is a dummy method to tag a struct as implementing an AppModule. IsAppModule() } diff --git a/core/go.mod b/core/go.mod index 5623e6ba3e..87cdcf5c38 100644 --- a/core/go.mod +++ b/core/go.mod @@ -3,34 +3,22 @@ module cosmossdk.io/core go 1.20 require ( - cosmossdk.io/api v0.7.2 - cosmossdk.io/depinject v1.0.0-alpha.4 - github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/stretchr/testify v1.8.4 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 - gotest.tools/v3 v3.5.1 - sigs.k8s.io/yaml v1.4.0 ) require ( - github.com/cockroachdb/errors v1.11.1 // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/redact v1.1.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/getsentry/sentry-go v0.23.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/core/go.sum b/core/go.sum index 12ea1612fc..dcb075db34 100644 --- a/core/go.sum +++ b/core/go.sum @@ -1,40 +1,20 @@ -cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4= -cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= -github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= -github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= -github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= -github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= @@ -42,43 +22,15 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= @@ -87,9 +39,6 @@ google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7 google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= -gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= -sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/core/intermodule/client.go b/core/intermodule/client.go deleted file mode 100644 index 0c6d5f33a4..0000000000 --- a/core/intermodule/client.go +++ /dev/null @@ -1,32 +0,0 @@ -package intermodule - -import ( - "context" - - "google.golang.org/grpc" -) - -// Client is an inter-module client as specified in ADR-033. It -// allows one module to send msg's and queries to other modules provided -// that the request is valid and can be properly authenticated. -type Client interface { - grpc.ClientConnInterface - - // InvokerByMethod resolves an invoker for the provided method or returns an error. - InvokerByMethod(method string) (Invoker, error) - - // InvokerByRequest resolves an invoker for the provided request type or returns an error. - // This only works for Msg's as they are routed based on type name in transactions already. - // For queries use InvokerByMethod instead. - InvokerByRequest(request any) (Invoker, error) - - // DerivedClient returns an inter-module client for the ADR-028 derived - // module address for the provided key. - DerivedClient(key []byte) Client - - // Address is the ADR-028 address of this client against which messages will be authenticated. - Address() []byte -} - -// Invoker is an inter-module invoker that has already been resolved to a specific method route. -type Invoker func(ctx context.Context, request any, opts ...grpc.CallOption) (res any, err error) diff --git a/core/appconfig/config.go b/depinject/appconfig/config.go similarity index 98% rename from core/appconfig/config.go rename to depinject/appconfig/config.go index 779eecee98..4bc44f6ace 100644 --- a/core/appconfig/config.go +++ b/depinject/appconfig/config.go @@ -13,8 +13,8 @@ import ( "sigs.k8s.io/yaml" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" - "cosmossdk.io/core/internal" "cosmossdk.io/depinject" + internal "cosmossdk.io/depinject/internal/appconfig" ) // LoadJSON loads an app config in JSON format. diff --git a/core/appconfig/config_test.go b/depinject/appconfig/config_test.go similarity index 96% rename from core/appconfig/config_test.go rename to depinject/appconfig/config_test.go index 0e13f0b4c6..8595f96b57 100644 --- a/core/appconfig/config_test.go +++ b/depinject/appconfig/config_test.go @@ -10,11 +10,11 @@ import ( "gotest.tools/v3/assert" - "cosmossdk.io/core/appconfig" - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/internal" - "cosmossdk.io/core/internal/testpb" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + "cosmossdk.io/depinject/appmodule" + internal "cosmossdk.io/depinject/internal/appconfig" + "cosmossdk.io/depinject/internal/appconfig/testpb" ) func expectContainerErrorContains(t *testing.T, option depinject.Config, contains string) { diff --git a/core/appconfig/doc.go b/depinject/appconfig/doc.go similarity index 100% rename from core/appconfig/doc.go rename to depinject/appconfig/doc.go diff --git a/depinject/appmodule/README.md b/depinject/appmodule/README.md new file mode 100644 index 0000000000..ebcdeaf74c --- /dev/null +++ b/depinject/appmodule/README.md @@ -0,0 +1,232 @@ +# Wiring up app modules for use with appconfig + +The `appconfig` framework allows Cosmos SDK modules to be composed declaratively using a configuration file without +requiring the app developer to understand the details of inter-module dependencies. + +## 1. Create a module config protobuf message + +The first step in creating a module that works with `appconfig`, is to create a protobuf message for the module configuration. The best practices for defining the module configuration message are: + +* Use a dedicated protobuf package for the module configuration message instead of placing it in the API protobuf package. For example, the module configuration for bank would go in `cosmos.bank.module.v1` instead of just `cosmos.bank.v1`. This decouples the state machine version from the API version. +* The module configuration message is usually called simply `Module`, ex. `cosmos.bank.module.v1.Module`. +* Create a new protobuf package and configuration message for each state machine breaking version of the module, ex. `cosmos.bank.module.v2.Module`, etc. + +The module configuration message should include any parameters which should be initialized at application startup. For example, the auth module needs to know the bech32 prefix of the app and the permissions of module accounts. + +In the future, it may be possible to update the app config through a governance proposal at runtime. + +All module configuration messages should define a module descriptor, using the `cosmos.app.v1alpha1.module` message option. + +Here is an example module configuration message for the `auth` module: + +```protobuf +package cosmos.auth.module.v1; + +import "cosmos/app/v1alpha1/module.proto"; + +message Module { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/x/auth" + }; + string bech32_prefix = 1; + repeated ModuleAccountPermission module_account_permissions = 2; +} +``` + +## 2. Register module depinject providers and invokers + +Once we have a module config object, we need to register depinject providers and invokers for the module using the `cosmossdk.io/core/appmodule` package. + +At the most basic level, we must define an `init` function in the package listed as the `go_import` in the module descriptor. This `init` function must call `appmodule.Register` with an empty instance of the config object and some options for initializing the module, ex: + +```go +func init() { + appmodule.Register(&modulev1.Module{}, + // options + ) +} +``` + +### `depinject` Provider and Invoker Basics + +A `depinject` "provider" is a function which takes dependencies from other modules as inputs and returns outputs for +other modules to use as dependencies. A `depinject` "invoker" is function which takes optional dependencies as inputs, +returns no outputs, and is run at the end of initializing the dependency graph. Providers are much more common than +invokers and should be the preferred method of wiring up modules when possible. Providers and invokers can be registered +for modules by using `appmodule.Provide` and `appmodule.Invoke` to create options which get passed +to `appmodule.Register` in the module `init` function, ex: + +```go +func init() { + appmodule.Register(&modulev1.Module{}, + appmodule.Provide(provideSomething, provideSomethingElse), + appmodule.Invoke(invokeSomething), + ) +} +``` + +### `depinject` Types + +`depinject` constructor functions support these classes of input and output parameter types: + +* regular golang types (with special treatment of interface types as input parameters) +* structs with `depinject.In` and `depinject.Out` embedded +* `depinject.OnePerModuleType`s +* `depinject.ManyPerContainerType`s +* `depinject.ModuleKey` (which can only be defined as an input type) +* `error` (which gets special treatment as an output type) + +#### Regular Golang Types + +Regular golang types (besides the special cases described above) can be provided as both input and output parameters +to providers and invokers. For `depinject` to match an output parameter of one provider to an input parameter of +another, there must be an exact match for the type unless the input parameter is an input type. For instance, if +a provider defines a dependency on `Foo` and some module provides `*Foo`, these two types will not match and there +will be an error. + +#### Interface Input Types + +When interfaces are used as input parameters to providers and invokers, `depinject` will search the container for +all types that implement this interface. If there is an unambiguously matching type, then this type will be used +to satisfy that interface. If there is a conflict between two types matching the interface, the app developer +can use `golang_bindings` options in their app config in order to resolve the conflict. + +#### Structs with embedded `depinject.In` and `depinject.Out` + +Structs that have `depinject.In` or `depinject.Out` as an embedded field are treated specially by `depinject`, where +all of these structs fields are treated as input or output parameters, respectively. These structs allow custom options +to be defined using struct field tags. Currently, the only supported custom option is `optional:"true"` which marks +a field as optional. + +#### `depinject.OnePerModuleType`s + +Any type which implements the `depinject.OnePerModuleType` interface can be provided at most once by every module. +These types can be collected as an input parameter to some provider or invoker by defining an input parameter which +is a map of module names as strings to this parameter type. For example if `Foo` is a `OnePerModuleType`, then +`map[string]Foo` can be declared as an input parameter by some provider (which obviously cannot provide an instance of +`Foo` itself because that would cause a circular dependency). + +`OnePerModuleType`s should be used whenever different modules may provide the type *and* there is a need to provide +an ordering of these types based on the module name. Generally, in blockchains there is always a need for deterministic +orderings so using module names to provide that ordering is generally a good strategy for this use case. Ordering based +on module names can either be done implicitly by sorting the module names or explicitly as a parameter in the module +configuration object. + +#### `depinject.ManyPerContainerType`s + +`ManyPerContainerType`s can be provided by as many providers in as many modules as the user would like. If a type `Bar` +is a `ManyPerContainerType`, a provider may define an output parameter of `Bar` or `[]Bar` to provide `Bar` instances +to the container. A provider may define an input parameter of `[]Bar` to get all of the `Bar` instances in the +container (such a provider may not also return `Bar` as that would cause a circular dependency). The ordering of `Bar` +instances in the `[]Bar` input type should be assumed to be deterministic. + +`ManyPerContainerType`s should be used only when 1) ordering is unimportant or 2) the ordering can be defined by +some parameter on the type. For instance, if `Bar` had a field `Name string`, that is supposed to be unique in the +container then that could be used to provide an ordering. An example of a type that could work as a +`ManyPerContainerType` in this way is a wrapper around `*cobra.Command`, ex. +`type QueryCommand struct {*cobra.Command}`. This could be used to collect all the query commands in an app and then +cobra would take care of ordering. If this type of ordering is not available, a `OnePerModuleType` is probably a better +bet. + +#### Module-scoped Providers/`depinject.ModuleKey` as an input + +If `depinject.ModuleKey` is used as input parameter for a provider, the provider function will be treated as a +"module-scoped provider" which means that the provider function will be called exactly once every time +one of its outputs is needed by a module so that the provider can provide a unique instance of the dependency to +each module. + +Module-scoped dependencies should be used to provide dependencies which are private and unique to each module. Examples +of these are store keys and param subspaces. + +#### `error` as an output parameter + +`error` can be used as the last output parameter on any provider or invoker. If a provider or invoker with an `error` +parameter returns a non-nil value for `error`, `depinject` will fail and propagate this error up to the caller. + +### Provider Invocation Details + +Providers are called lazily as they are needed and will be invoked at most once (except for "module-scoped providers" +described above) if and only if at least one of their outputs is needed somewhere in the dependency graph. Providers +will only get called if all of their non-optional inputs can successfully be resolved by some other module, otherwise an +error will occur. Modules should proactively mark dependencies as `optional` if the module can still be successfully +built without this dependency. + +### Invoker Invocation Details + +Invokers are called at the end of container initialization after all providers that were needed to build the graph +were called. All the dependencies of invokers are automatically marked as optional so invokers should `nil` check +every input parameter. Invokers may cause additional providers to get run if they have a dependency that wasn't built +yet. But if a dependency to an invoker cannot be provided for some reason, the invoker will still get called but with +`nil` for that input. This allows invokers to still work with the lazy invocation model of providers which only +builds things which are actually necessary as a dependency for some module or the caller. + +Invokers should generally be used sparingly to perform some initialization logic which can't be done in the initial +provider, usually because of a circular dependency, and which may be optional. + +### Best practices + +* make dependencies `optional` whenever possible! +* interface types should be used whenever possible to avoid tight couplings between two modules. +* `OnePerModuleType`s should be used when there is something occurs at most once per module and the module name is a +convenient way for providing a deterministic order. +* `ManyPerContainerType`s should be used only when there is an obvious way to create an ordering from the types or +when ordering *really* doesn't matter (which is rare). +* module-scoped providers should be used for private, module-scoped dependencies +* use different providers for unrelated or loosely components or to resolve circular dependencies (see below) +* use invokers sparingly and always `nil`-check the inputs. + +### Resolving Circular Dependencies + +Circular dependencies are inevitable to crop up and there are ways to avoid them. While `depinject` cannot handle +circular dependency graphs of providers, many of the above tools are designed to enable satisfying circular dependencies +between modules. + +One of the key tactics for resolving circular dependencies is to use different providers and/or invokers to allow a +circular dependency between components. For example, say the slashing keeper depends on the keeper module but the +staking keeper also depends on the staking module indirectly (in the form of "staking hooks"). The slashing module +can declare a dependency directly on the staking keeper (using an interface to avoid actually importing the staking +keeper package). It can also provide an instance of the slashing keeper wrapped as staking hooks in a `OnePerModuleType` +we'll call `StakingHooksWrapper`. Now, if the staking module directly depended on the staking hooks wrappers +(`map[string]StakingHooksWrapper`) we would have a circular dependency graph and `depinject` would fail. To fix this, +the staking module can define an invoker which depends on `map[string]StakingHooksWrapper` and the staking keeper +(which was provided by the staking module already in a separate provided). In this way `depinject` will be able to +satisfy this dependency graph which allows staking and slashing to depend on each other in this order: + +* provide staking keeper -> slashing keeper +* provide slashing keeper wrapped as `StakingHooksWrapper` +* get `map[string]StakingHooksWrapper` and the staking keeper and wire them together + +## 3. Testing and Debugging The Module + +In order to test and debug the module configuration, we need to build an app config, generally defined in a YAML file. +This configuration should be passed first to `appconfig.LoadYAML` to get an `depinject.Config` instance.Then the +`depinject.Config` can be passed to `depinject.Inject` and we can try to resolve dependencies in the app config. +Alternatively, the `depinject.Config` can be created via [pure Go code](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/simapp/app_config.go). + +Ex: + +```go +//go:embed app.yaml +var appConfig []byte + +var AppConfig = appconfig.LoadYAML(appConfig) + +func TestModule(t *testing.T) { + var keeper Keeper + assert.NilError(t, depinject.Inject(AppConfig, &keeper)) +} +``` + +### Debugging `depinject` Graphs + +Whenever there is an error in a `depinject` graph, by default `depinject` will dump a bunch of logging output to the +console, print the error message, and save the dependency graph in [GraphViz](https://graphviz.org) DOT format to +the file `debug_container.dot`. Inspecting the GraphViz output by converting it to an SVG and viewing it in a web +browser or using some other GraphViz tool is *highly recommended*. + +If `depinject` does not return an error but there is still some weird issue wiring up modules, inspecting the GraphViz +and logging output is still *highly recommended* and can be done using `depinject.InjectDebug` with the debug option +`depinject.Debug`. + +App developers should attempt to familiarize themselves with the GraphViz graph of their app to see which modules +depend on which other modules. diff --git a/core/appmodule/option.go b/depinject/appmodule/option.go similarity index 96% rename from core/appmodule/option.go rename to depinject/appmodule/option.go index 951bfc6e2d..df8f0c4994 100644 --- a/core/appmodule/option.go +++ b/depinject/appmodule/option.go @@ -1,7 +1,7 @@ package appmodule import ( - "cosmossdk.io/core/internal" + internal "cosmossdk.io/depinject/internal/appconfig" ) // Option is a functional option for implementing modules. diff --git a/core/appmodule/register.go b/depinject/appmodule/register.go similarity index 94% rename from core/appmodule/register.go rename to depinject/appmodule/register.go index 56004dbb86..ed68ebfcef 100644 --- a/core/appmodule/register.go +++ b/depinject/appmodule/register.go @@ -5,7 +5,7 @@ import ( "google.golang.org/protobuf/proto" - "cosmossdk.io/core/internal" + internal "cosmossdk.io/depinject/internal/appconfig" ) // Register registers a module with the global module registry. The provided diff --git a/depinject/go.mod b/depinject/go.mod index 713e5498c1..be6de69b96 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -3,10 +3,14 @@ module cosmossdk.io/depinject go 1.20 require ( + cosmossdk.io/api v0.7.2 github.com/cockroachdb/errors v1.11.1 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e + golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb + google.golang.org/protobuf v1.31.0 gotest.tools/v3 v3.5.1 + sigs.k8s.io/yaml v1.4.0 ) require ( @@ -15,13 +19,17 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/getsentry/sentry-go v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c // indirect + google.golang.org/grpc v1.58.3 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/depinject/go.sum b/depinject/go.sum index 09e7872345..7f566f79f2 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -1,9 +1,13 @@ +cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4= +cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -12,6 +16,11 @@ github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -36,14 +45,16 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -64,9 +75,19 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c h1:jHkCUWkseRf+W+edG5hMzr/Uh1xkDREY4caybAq4dpY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c/go.mod h1:4cYg8o5yUbm77w8ZX00LhMVNl/YVBFJRYWDc0uYWMs0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/core/internal/buf.gen.yaml b/depinject/internal/appconfig/buf.gen.yaml similarity index 100% rename from core/internal/buf.gen.yaml rename to depinject/internal/appconfig/buf.gen.yaml diff --git a/core/internal/buf.yaml b/depinject/internal/appconfig/buf.yaml similarity index 100% rename from core/internal/buf.yaml rename to depinject/internal/appconfig/buf.yaml diff --git a/core/internal/registry.go b/depinject/internal/appconfig/registry.go similarity index 100% rename from core/internal/registry.go rename to depinject/internal/appconfig/registry.go diff --git a/core/internal/testpb/test.proto b/depinject/internal/appconfig/testpb/test.proto similarity index 100% rename from core/internal/testpb/test.proto rename to depinject/internal/appconfig/testpb/test.proto diff --git a/core/internal/testpb/test.pulsar.go b/depinject/internal/appconfig/testpb/test.pulsar.go similarity index 100% rename from core/internal/testpb/test.pulsar.go rename to depinject/internal/appconfig/testpb/test.pulsar.go diff --git a/docs/build/building-modules/15-depinject.md b/docs/build/building-modules/15-depinject.md index f277e5b1db..8cfe4f6e30 100644 --- a/docs/build/building-modules/15-depinject.md +++ b/docs/build/building-modules/15-depinject.md @@ -104,18 +104,28 @@ All methods, structs and their fields must be public for `depinject`. 5. Create a function named `ProvideModule` (as called in 1.) and use the inputs for instantiating the module outputs. - ```go reference - https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/group/module/module.go#L220-L235 - ``` + ```go reference + https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/group/module/module.go#L220-L235 + ``` + + The `ProvideModule` function should return an instance of `cosmossdk.io/core/appmodule.AppModule` which implements + one or more app module extension interfaces for initializing the module. + + Following is the complete app wiring configuration for `group`: + + ```go reference + https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/group/module/module.go#L194-L235 + ``` + +6. All modules must implement `depinject.OnePerModuleType` interface. This is used in order to tell the dependency injection framework that the module can only be instantiated once. + + ```go reference + https://github.com/cosmos/cosmos-sdk/blob/f4bdec3433373cc4950f4680743e969495763fbb/x/group/module/module.go#L64-L65 + ``` + -The `ProvideModule` function should return an instance of `cosmossdk.io/core/appmodule.AppModule` which implements -one or more app module extension interfaces for initializing the module. -Following is the complete app wiring configuration for `group`: -```go reference -https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/group/module/module.go#L194-L235 -``` The module is now ready to be used with `depinject` by a chain developer. diff --git a/go.mod b/go.mod index 68e457662f..f6aea49a66 100644 --- a/go.mod +++ b/go.mod @@ -178,6 +178,7 @@ require ( // ) // TODO remove after all modules have their own go.mods replace ( + cosmossdk.io/depinject => ./depinject cosmossdk.io/x/auth => ./x/auth cosmossdk.io/x/bank => ./x/bank cosmossdk.io/x/distribution => ./x/distribution diff --git a/go.sum b/go.sum index ae1d53ed0d..acd42833b7 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/orm/go.mod b/orm/go.mod index a1180672a9..5149edc338 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -68,3 +68,5 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) + +replace cosmossdk.io/depinject => ../depinject diff --git a/orm/go.sum b/orm/go.sum index 75818fe95b..a7f10310c7 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -2,8 +2,6 @@ cosmossdk.io/api v0.7.2 h1:BO3i5fvKMKvfaUiMkCznxViuBEfyWA/k6w2eAF6q1C4= cosmossdk.io/api v0.7.2/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= cosmossdk.io/core v0.11.0/go.mod h1:LaTtayWBSoacF5xNzoF8tmLhehqlA9z1SWiPuNC6X1w= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index d224063714..a146aa78b8 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -16,11 +16,11 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" ormmodulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1" ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1" - "cosmossdk.io/core/appconfig" - "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" + am "cosmossdk.io/depinject/appmodule" _ "cosmossdk.io/orm" // required for ORM module registration "cosmossdk.io/orm/internal/testkv" "cosmossdk.io/orm/internal/testpb" @@ -36,8 +36,8 @@ import ( func init() { // this registers the test module with the module registry - appmodule.Register(&testpb.Module{}, - appmodule.Provide(NewKeeper), + am.Register(&testpb.Module{}, + am.Provide(NewKeeper), ) } diff --git a/orm/orm.go b/orm/orm.go index c970f2d21a..c9d7872508 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -10,16 +10,16 @@ import ( appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" modulev1alpha1 "cosmossdk.io/api/cosmos/orm/module/v1alpha1" ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1" - "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/orm/model/ormdb" "cosmossdk.io/orm/model/ormtable" ) func init() { - appmodule.Register(&modulev1alpha1.Module{}, - appmodule.Provide(ProvideModuleDB), + am.Register(&modulev1alpha1.Module{}, + am.Provide(ProvideModuleDB), ) } diff --git a/runtime/app.go b/runtime/app.go index 41746b0b1e..9b07970ff4 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -76,8 +76,8 @@ func (a *App) RegisterModules(modules ...module.AppModule) error { appModule.RegisterInterfaces(a.interfaceRegistry) appModule.RegisterLegacyAminoCodec(a.amino) - if module, ok := appModule.(module.HasServices); ok { - module.RegisterServices(a.configurator) + if mod, ok := appModule.(module.HasServices); ok { + mod.RegisterServices(a.configurator) } else if module, ok := appModule.(appmodule.HasServices); ok { if err := module.RegisterServices(a.configurator); err != nil { return err diff --git a/runtime/module.go b/runtime/module.go index 4440b3b8a3..0c4cbda7da 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -18,6 +18,7 @@ import ( "cosmossdk.io/core/genesis" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/tx/signing" @@ -58,8 +59,8 @@ type BaseAppOption func(*baseapp.BaseApp) func (b BaseAppOption) IsManyPerContainerType() {} func init() { - appmodule.Register(&runtimev1alpha1.Module{}, - appmodule.Provide( + am.Register(&runtimev1alpha1.Module{}, + am.Provide( ProvideApp, ProvideInterfaceRegistry, ProvideKVStoreKey, @@ -74,7 +75,7 @@ func init() { ProvideAppVersionModifier, ProvideAddressCodec, ), - appmodule.Invoke(SetupAppBuilder), + am.Invoke(SetupAppBuilder), ) } diff --git a/simapp/app_config.go b/simapp/app_config.go index 4f19426b81..7994125320 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -26,8 +26,8 @@ import ( txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" upgrademodulev1 "cosmossdk.io/api/cosmos/upgrade/module/v1" vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" - "cosmossdk.io/core/appconfig" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" _ "cosmossdk.io/x/auth/tx/config" // import for side-effects authtypes "cosmossdk.io/x/auth/types" _ "cosmossdk.io/x/auth/vesting" // import for side-effects diff --git a/simapp/go.mod b/simapp/go.mod index b47ec9ca82..6963edadf8 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -230,6 +230,7 @@ require ( replace ( cosmossdk.io/api => ../api cosmossdk.io/client/v2 => ../client/v2 + cosmossdk.io/depinject => ../depinject cosmossdk.io/tools/confix => ../tools/confix cosmossdk.io/x/accounts => ../x/accounts cosmossdk.io/x/auth => ../x/auth diff --git a/simapp/go.sum b/simapp/go.sum index 4863ae871b..6a3ef95352 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -188,8 +188,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/simapp/gomod2nix.toml b/simapp/gomod2nix.toml index 967ec3dbfd..c179d412a2 100644 --- a/simapp/gomod2nix.toml +++ b/simapp/gomod2nix.toml @@ -22,9 +22,6 @@ schema = 3 [mod."cosmossdk.io/core"] version = "v0.12.1-0.20231114100755-569e3ff6a0d7" hash = "sha256-I74lq2kZ9hOcvOU4uJZ8LhSoQ0RbgCvAvSXj1xI0iII=" - [mod."cosmossdk.io/depinject"] - version = "v1.0.0-alpha.4" - hash = "sha256-xpLH0K6ivQznFrLw2hmhWIIyYgqjstV47OhTEj/c1oQ=" [mod."cosmossdk.io/errors"] version = "v1.0.0" hash = "sha256-ZD1fhIefk3qkt9I4+ed9NBmBqTDvym9cXWmgFBh5qu0=" diff --git a/tests/go.mod b/tests/go.mod index 256f1f9e3c..f74fd5df0c 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -222,6 +222,7 @@ require ( replace ( cosmossdk.io/api => ../api cosmossdk.io/client/v2 => ../client/v2 + cosmossdk.io/depinject => ../depinject cosmossdk.io/x/accounts => ../x/accounts cosmossdk.io/x/auth => ../x/auth cosmossdk.io/x/authz => ../x/authz diff --git a/tests/go.sum b/tests/go.sum index 36cbb20360..0d8a193a5e 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -188,8 +188,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/tests/starship/tests/go.mod b/tests/starship/tests/go.mod index c35871ac4b..37ceefcded 100644 --- a/tests/starship/tests/go.mod +++ b/tests/starship/tests/go.mod @@ -14,6 +14,7 @@ replace ( replace ( cosmossdk.io/api => ../../../api cosmossdk.io/client/v2 => ../../../client/v2 + cosmossdk.io/depinject => ../../../depinject cosmossdk.io/simapp => ../../../simapp cosmossdk.io/x/accounts => ../../../x/accounts cosmossdk.io/x/auth => ../../../x/auth diff --git a/tests/starship/tests/go.sum b/tests/starship/tests/go.sum index 02f8526d6e..ab25503407 100644 --- a/tests/starship/tests/go.sum +++ b/tests/starship/tests/go.sum @@ -188,8 +188,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 8a42c5e45a..336e4ef145 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -23,8 +23,8 @@ import ( stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" - "cosmossdk.io/core/appconfig" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appconfig" "github.com/cosmos/cosmos-sdk/testutil" ) diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 10db0942b8..da29c0247c 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -160,6 +160,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. replace ( cosmossdk.io/api => ../../api + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/accounts/go.sum b/x/accounts/go.sum index 40a03db614..eb2bd1e4cb 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -4,8 +4,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/auth/go.mod b/x/auth/go.mod index 98730c5110..64fe7439bf 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -166,6 +166,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution cosmossdk.io/x/mint => ../mint diff --git a/x/auth/go.sum b/x/auth/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/auth/module.go b/x/auth/module.go index f5f5952ed3..534bcd43e0 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/simulation" "cosmossdk.io/x/auth/types" @@ -35,6 +36,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -173,8 +175,8 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/auth/tx/config/config.go b/x/auth/tx/config/config.go index ca61e53b8e..30397e33a9 100644 --- a/x/auth/tx/config/config.go +++ b/x/auth/tx/config/config.go @@ -11,8 +11,8 @@ import ( bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" txconfigv1 "cosmossdk.io/api/cosmos/tx/config/v1" "cosmossdk.io/core/address" - "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" + "cosmossdk.io/depinject/appmodule" "cosmossdk.io/x/auth/ante" "cosmossdk.io/x/auth/posthandler" "cosmossdk.io/x/auth/tx" diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 7dfbe79abe..085ef61387 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -11,6 +11,7 @@ import ( modulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/x/auth/keeper" "cosmossdk.io/x/auth/vesting/client/cli" "cosmossdk.io/x/auth/vesting/types" @@ -25,8 +26,7 @@ var ( _ module.AppModuleBasic = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the sub-vesting @@ -114,8 +114,8 @@ func (AppModule) ConsensusVersion() uint64 { return 1 } // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/authz/go.mod b/x/authz/go.mod index 41cf7be7f7..d8cfca3d49 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -172,6 +172,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( cosmossdk.io/api => ../../api + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/authz/go.sum b/x/authz/go.sum index 12fdb74329..4d5002c86b 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -4,8 +4,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 16a7f7e440..62156ebe87 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/client/cli" @@ -31,6 +32,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -147,9 +149,9 @@ func (am AppModule) BeginBlock(ctx context.Context) error { } func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/bank/go.mod b/x/bank/go.mod index d450ebf3aa..ccda0c7807 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -165,6 +165,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/distribution => ../distribution cosmossdk.io/x/mint => ../mint diff --git a/x/bank/go.sum b/x/bank/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/bank/module.go b/x/bank/module.go index 67889d2a5d..1d0c56ee76 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/core/appmodule" corestore "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/log" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/bank/client/cli" @@ -38,6 +39,7 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -187,8 +189,8 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // App Wiring Setup func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 474060ba6a..284bb521d5 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -165,6 +165,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/circuit/go.sum b/x/circuit/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/circuit/module.go b/x/circuit/module.go index bfbc4d3dc7..667a1fd970 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -13,6 +13,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/circuit/keeper" "cosmossdk.io/x/circuit/types" @@ -126,9 +127,9 @@ func (am AppModule) ExportGenesis(ctx context.Context, cdc codec.JSONCodec) json } func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/consensus/module.go b/x/consensus/module.go index 7091e5f80b..03c5edc110 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/event" storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/baseapp" @@ -29,8 +30,7 @@ const ConsensusVersion = 1 var ( _ module.AppModuleBasic = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the consensus module. @@ -90,9 +90,9 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/counter/module.go b/x/counter/module.go index 6c14ff2e5a..fae00c2140 100644 --- a/x/counter/module.go +++ b/x/counter/module.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/core/event" storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -21,8 +22,7 @@ import ( var ( _ module.AppModuleBasic = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the consensus module. @@ -74,9 +74,9 @@ func NewAppModule(keeper keeper.Keeper) AppModule { func (AppModule) ConsensusVersion() uint64 { return 1 } func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/crisis/module.go b/x/crisis/module.go index 1dfdb01499..6fee91a29f 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "github.com/cosmos/cosmos-sdk/client" @@ -163,9 +164,9 @@ func (am AppModule) EndBlock(ctx context.Context) error { // App Wiring Setup func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/distribution/go.mod b/x/distribution/go.mod index fb1d08e7d8..cfdfdbcbd5 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -167,6 +167,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/mint => ../mint diff --git a/x/distribution/go.sum b/x/distribution/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/distribution/module.go b/x/distribution/module.go index caa441ee2c..690ed300d2 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/distribution/client/cli" "cosmossdk.io/x/distribution/keeper" @@ -36,6 +37,7 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -199,8 +201,8 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/evidence/go.mod b/x/evidence/go.mod index e9dadaaf1f..1f9fe02fea 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -167,6 +167,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/evidence/go.sum b/x/evidence/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/evidence/module.go b/x/evidence/module.go index e72a562cee..3f5ff820a6 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/core/appmodule" store "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" eviclient "cosmossdk.io/x/evidence/client" "cosmossdk.io/x/evidence/client/cli" "cosmossdk.io/x/evidence/keeper" @@ -33,7 +34,6 @@ var ( _ module.HasGenesis = AppModule{} _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} ) @@ -180,8 +180,8 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 6aa36cacbb..4062ab71cb 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -169,6 +169,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index 0a913cb49f..3cfefc2a7f 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 97f30b7ef0..a76a0f835b 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/feegrant" "cosmossdk.io/x/feegrant/client/cli" @@ -30,6 +31,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasServices = AppModule{} _ module.HasGenesis = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -163,8 +165,8 @@ func (am AppModule) EndBlock(ctx context.Context) error { } func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/genutil/module.go b/x/genutil/module.go index 4959c8692f..403838ddda 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/genesis" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -120,8 +121,8 @@ func (am AppModule) ExportGenesis(_ context.Context, cdc codec.JSONCodec) json.R func (AppModule) ConsensusVersion() uint64 { return 1 } func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/gov/go.mod b/x/gov/go.mod index 7d82c8fb0b..1493b02322 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -169,6 +169,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. replace ( cosmossdk.io/api => ../../api + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/gov/go.sum b/x/gov/go.sum index 12fdb74329..4d5002c86b 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -4,8 +4,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/gov/module.go b/x/gov/module.go index 7eb791dc4b..f6b1750a7b 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -17,6 +17,7 @@ import ( "cosmossdk.io/core/appmodule" store "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" govclient "cosmossdk.io/x/gov/client" "cosmossdk.io/x/gov/client/cli" @@ -151,10 +152,10 @@ func (am AppModule) IsOnePerModuleType() {} func (am AppModule) IsAppModule() {} func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks), - appmodule.Provide(ProvideModule)) + am.Invoke(InvokeAddRoutes, InvokeSetHooks), + am.Provide(ProvideModule)) } type ModuleInputs struct { diff --git a/x/group/go.mod b/x/group/go.mod index 7fec2fc9b4..2561299279 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -172,6 +172,7 @@ replace github.com/cosmos/cosmos-sdk => ../../ replace ( cosmossdk.io/api => ../../api + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/authz => ../authz cosmossdk.io/x/bank => ../bank diff --git a/x/group/go.sum b/x/group/go.sum index 468ae76a8a..5f7b1ee548 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -4,8 +4,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/group/module/module.go b/x/group/module/module.go index 53938c4879..7ce3c2ed21 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/address" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" store "cosmossdk.io/store/types" "cosmossdk.io/x/group" "cosmossdk.io/x/group/client/cli" @@ -36,6 +37,7 @@ var ( _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} _ module.HasInvariants = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasEndBlocker = AppModule{} @@ -180,9 +182,9 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/mint/go.mod b/x/mint/go.mod index 9c66386da0..dfbe0cfffc 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -166,6 +166,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/mint/go.sum b/x/mint/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/mint/module.go b/x/mint/module.go index a28640f2df..4af6eeaa34 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/mint/keeper" "cosmossdk.io/x/mint/simulation" @@ -31,6 +32,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} _ module.HasServices = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -181,8 +183,8 @@ func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weighte // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/nft/go.mod b/x/nft/go.mod index 451da701f7..4077646eac 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -166,6 +166,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/nft/go.sum b/x/nft/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/nft/module/module.go b/x/nft/module/module.go index e1099c4e7c..79cc78dff3 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -12,6 +12,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" "cosmossdk.io/errors" "cosmossdk.io/x/nft" "cosmossdk.io/x/nft/keeper" @@ -29,8 +30,7 @@ var ( _ module.AppModuleSimulation = AppModule{} _ module.HasGenesis = AppModule{} - _ appmodule.AppModule = AppModule{} - _ appmodule.HasServices = AppModule{} + _ appmodule.AppModule = AppModule{} ) // AppModuleBasic defines the basic application module used by the nft module. @@ -156,8 +156,8 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), ) } diff --git a/x/params/go.mod b/x/params/go.mod index 35874b5f3e..5ae0f3f3ad 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -166,6 +166,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../.. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/params/go.sum b/x/params/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/params/module.go b/x/params/module.go index 44cb81cdfb..13ee912d94 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -8,6 +8,7 @@ import ( modulev1 "cosmossdk.io/api/cosmos/params/module/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" store "cosmossdk.io/store/types" govv1beta1 "cosmossdk.io/x/gov/types/v1beta1" "cosmossdk.io/x/params/keeper" @@ -25,6 +26,7 @@ var ( _ module.AppModuleBasic = AppModule{} _ module.AppModuleSimulation = AppModule{} _ module.HasServices = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} ) @@ -102,8 +104,8 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide( + am.Register(&modulev1.Module{}, + am.Provide( ProvideModule, ProvideSubspace, )) diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index 53e092ecd1..11e333aa78 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -167,6 +167,7 @@ require ( replace github.com/cosmos/cosmos-sdk => ../../. replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/protocolpool/module.go b/x/protocolpool/module.go index bb6c43eb7c..0afb3b152a 100644 --- a/x/protocolpool/module.go +++ b/x/protocolpool/module.go @@ -9,6 +9,7 @@ import ( "cosmossdk.io/core/appmodule" storetypes "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/protocolpool/keeper" "cosmossdk.io/x/protocolpool/simulation" @@ -97,9 +98,9 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } // func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 21e660eb5d..27acc25066 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -170,6 +170,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/slashing/go.sum b/x/slashing/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/slashing/module.go b/x/slashing/module.go index c758d8fbef..6a98425374 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -11,6 +11,7 @@ import ( "cosmossdk.io/core/appmodule" store "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/slashing/keeper" "cosmossdk.io/x/slashing/simulation" @@ -187,9 +188,9 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp // func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), + am.Provide(ProvideModule), ) } diff --git a/x/staking/go.mod b/x/staking/go.mod index 243e228399..f6e8fecc85 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -170,6 +170,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO remove post spinning out all modules replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/staking/go.sum b/x/staking/go.sum index ff10a22331..5701bb7ea5 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -6,8 +6,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/staking/module.go b/x/staking/module.go index 82fd4d533f..333d89d53b 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -15,6 +15,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/staking/client/cli" "cosmossdk.io/x/staking/keeper" @@ -41,6 +42,7 @@ var ( _ module.HasInvariants = AppModule{} _ module.HasABCIGenesis = AppModule{} _ module.HasABCIEndBlock = AppModule{} + _ depinject.OnePerModuleType = AppModule{} _ appmodule.AppModule = AppModule{} _ appmodule.HasBeginBlocker = AppModule{} @@ -180,10 +182,10 @@ func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error } func init() { - appmodule.Register( + am.Register( &modulev1.Module{}, - appmodule.Provide(ProvideModule), - appmodule.Invoke(InvokeSetStakingHooks), + am.Provide(ProvideModule), + am.Invoke(InvokeSetStakingHooks), ) } diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index b6e1f77fdc..e953879c6e 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -196,6 +196,7 @@ replace github.com/cosmos/cosmos-sdk => ../../. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 replace ( + cosmossdk.io/depinject => ../../depinject cosmossdk.io/x/auth => ../auth cosmossdk.io/x/bank => ../bank cosmossdk.io/x/distribution => ../distribution diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index ea3ac7a1d9..ed4034e9e0 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -190,8 +190,6 @@ cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7 h1:hOzi4yo2Fc7h3mod+xX4m4QA4+Uq+PkFRjY/yalZ0B8= cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7/go.mod h1:3v0JJNNd8ye0cOvJ+wUUvE7Ke0d2qxnNIDcXd5mziHk= -cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= -cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 7a0014178c..e821a4d8fa 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -14,6 +14,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/store" "cosmossdk.io/depinject" + am "cosmossdk.io/depinject/appmodule" authtypes "cosmossdk.io/x/auth/types" "cosmossdk.io/x/upgrade/client/cli" "cosmossdk.io/x/upgrade/keeper" @@ -165,9 +166,9 @@ func (am AppModule) PreBlock(ctx context.Context) (appmodule.ResponsePreBlock, e // func init() { - appmodule.Register(&modulev1.Module{}, - appmodule.Provide(ProvideModule), - appmodule.Invoke(PopulateVersionMap), + am.Register(&modulev1.Module{}, + am.Provide(ProvideModule), + am.Invoke(PopulateVersionMap), ) }