Skip to content

Commit

Permalink
Update module spec (cosmos#5751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 5, 2020
1 parent ecc00bf commit bc863c9
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions docs/building-modules/structure.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!--
order: 12
synopsis: This document outlines the recommended structure of Cosmos SDK modules. These ideas are meant to be applied as suggestions. Application developers are encouraged to improve upon and contribute to module structure and development design.
synopsis: This document outlines the recommended structure of Cosmos SDK modules.These ideas are
meant to be applied as suggestions. Application developers are encouraged to improve upon and
contribute to module structure and development design.
-->

# Recommended Folder Structure
Expand All @@ -20,23 +22,24 @@ x/{module}
│   └── tx.go
├── exported
│   └── exported.go
├── internal
│   ├── keeper
│   │   ├── invariants.go
│   │   ├── keeper.go
│   │   ├── ...
│   │   └── querier.go
│   └── types
│   ├── codec.go
│   ├── errors.go
│   ├── events.go
│   ├── expected_keepers.go
│   ├── genesis.go
│   ├── keys.go
│   ├── msgs.go
│   ├── params.go
│   ├── ...
│   └── querier.go
├── keeper
│   ├── invariants.go
│   ├── keeper.go
│   ├── ...
│   └── querier.go
├── types
│ ├── codec.go
│ ├── errors.go
│ ├── events.go
│ ├── expected_keepers.go
│ ├── genesis.go
│ ├── keys.go
│ ├── msgs.go
│ ├── params.go
│ ├── types.pb.go
│ ├── types.proto
│ ├── ...
│ └── querier.go
├── simulation
│   ├── decoder.go
│   ├── genesis.go
Expand All @@ -55,9 +58,8 @@ x/{module}
- `alias.go`: The module's exported types, constants, and variables. These are mainly
to improve developer ergonomics by only needing to import a single package. Note,
there is nothing preventing developers from importing other packages from the module
(excluding`internal/`) but it is recommended that `alias.go` have everything
exposed that other modules may need. The majority of the exported values here will
typically come from `internal/` (see below).
but it is recommended that `alias.go` have everything exposed that other modules
may need.
- `client/`: The module's CLI and REST client functionality implementation and
testing.
- `exported/`: The module's exported types -- typically type interfaces. If a module
Expand All @@ -72,16 +74,10 @@ DRY and also alleviates import cycle chaos.
- `genesis.go`: The module's genesis related business logic (e.g. `InitGenesis`).
Note, genesis types are defined in `internal/types`.
- `handler.go`: The module's message handlers.
- `internal/`: The module's internal types and implementations. The purpose of
this package is mainly two fold. First, it signals that this package is not
intended to be used or imported anywhere outside the defining module. Secondly,
it goes hand-in-hand with `alias.go` in that it allows public types and functions
to be used internally while not being exposed outside to the outside world. This
allows for greater freedom of development while maintaining API stability.
- `internal/types`: The module's type definitions such as messages, `KVStore`
keys, parameter types, and `expected_keepers.go` contracts.
- `internal/keeper`: The module's keeper implementation along with any auxiliary
implementations such as the querier and invariants.
- `keeper/`: The module's keeper implementation along with any auxiliary
implementations such as the querier and invariants.
- `types/`: The module's type definitions such as messages, `KVStore` keys,
parameter types, Protocol Buffer definitions, and `expected_keepers.go` contracts.
- `module.go`: The module's implementation of the `AppModule` and `AppModuleBasic`
interfaces.
- `simulation/`: The module's simulation package defines all the required functions
Expand Down

0 comments on commit bc863c9

Please sign in to comment.