Skip to content

Commit

Permalink
docs(depinject): explain need appmodule.Module interface (backport #…
Browse files Browse the repository at this point in the history
…15880) (#15881)

Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
mergify[bot] and julienrbrt authored Apr 19, 2023
1 parent 48d3d99 commit 967efc6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/docs/building-modules/15-depinject.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ All methods, structs and their fields must be public for `depinject`.
https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/x/group/module/module.go#L199-L204
```

2. Define a struct that inherits `depinject.In` and define the module inputs (i.e. module dependencies):
2. Ensure that the module implements the `appmodule.AppModule` interface:

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/group/module/module.go#L58-L64
```

3. Define a struct that inherits `depinject.In` and define the module inputs (i.e. module dependencies):
* `depinject` provides the right dependencies to the module.
* `depinject` also checks that all dependencies are provided.

Expand All @@ -91,14 +97,14 @@ All methods, structs and their fields must be public for `depinject`.
https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/x/group/module/module.go#L206-L216
```

3. Define the module outputs with a public struct that inherits `depinject.Out`:
4. Define the module outputs with a public struct that inherits `depinject.Out`:
The module outputs are the dependencies that the module provides to other modules. It is usually the module itself and its keeper.

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/x/group/module/module.go#L218-L223
```

4. Create a function named `ProvideModule` (as called in 1.) and use the inputs for instantiating the module outputs.
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.47.0-rc1/x/group/module/module.go#L225-L235
Expand Down

0 comments on commit 967efc6

Please sign in to comment.