* encoding * working on baseapp doc * baseapp work * reorg * almost there * finish first draft * remove old files * module doc start * finish intro * working * workinnn * add transactions into core * hans comments * add transactions into core * working * gautier comments * clean * working * consolidate intro * querier * workiiiing * refactor for new module interface * karoly review * working on baseapp doc * baseapp work * reorg * almost there * finish first draft * remove old files * finish intro * workinnn * initial commit after rebase * query-lifecycle and started modules-interfaces * query-lifecycle first draft done * module interfaces first draft * rest and intro skeletons * rest and intro done * small edits and links * comments * revisions * cli.md comments * comments * minor edits * better flow for query lifecycle * add transactions into core * hans comments * add transactions into core * checkout master-docs files * deleted some * remove modules readme * cli.md comments * comments * module-interfaces comments * Merge PR #4857: Add Context concept doc * working * working * finish messages and queries * handler * querier * last comments! * punctuation * querier2 * consolidate intro * querier * workiiiing * refactor for new module interface * karoly review * working on baseapp doc * baseapp work * reorg * almost there * finish first draft * remove old files * finish intro * workinnn * initial commit after rebase * query-lifecycle and started modules-interfaces * query-lifecycle first draft done * module interfaces first draft * rest and intro skeletons * rest and intro done * small edits and links * comments * revisions * cli.md comments * comments * minor edits * better flow for query lifecycle * checkout master-docs files * deleted some * remove modules readme * cli.md comments * comments * module-interfaces comments * keeper * genesis * finish * Apply suggestions from code review Co-Authored-By: Hans Schoenburg <hschoenburg@users.noreply.github.com> * hans review * Update docs/core/baseapp.md Co-Authored-By: Hans Schoenburg <hschoenburg@users.noreply.github.com> * working * last comment * workin * Apply suggestions from code review * encoding and node * almost finish store * finish docs * fixes * fede comments + permalinks * hans review * add more permalinks * update docs theme version (#5239) * R4R: Docs Cleanup (#5246) * start * work * work * work * remove table of content * links intro * fix links * remove junk * cleanup * cleanup * work * finish cleanup * addback readmes * remove nft * fix links * remove dup * remove dup * remove dup * remove dup * remove dup * fix links * add subscribe events * refine rest * index page * sidebar * theme version * theme version * testing netlify * theme version * tooltip example * version * testing code embedding * reverting back * theme version * version * version * version * readme and version * cleanup * redo app anatomy * modules readme, theme version * theme version * fix modules list * theme version * new snippets * modules readme * update docs readme * modify synopsis * version * fix yaml * version * version * version * version * version * version * version * version * version * version * add hide banner * version * version * version * small fixes * modules readme, version * remove hotkeys dep, version * version * version * version * version * version * version * version * slight notice * fix links and hide * permalinks * small clean * version * resolve conflicts, add google analytics * fix merge remants * version * changelog 1/2 * Changelog: docs UI * version * remove merge conflicts * Code: Update link for Contributing to the docs to docs_readme * HTML/CSS: Update layout of homepage footer to match new layout in Figma * version * final modifs * modules, version * modules readme * link to module list from homepage * version * building modules link * version * version * fonts * version * version * fix link * fix package.json * links in explore sdk section * core concepts * version * change delimeters for frontmatter * frontmatter in comments * version * temp add tiny-cookie * fixed link issues * fixed styling issues, copy * hide frontmatter * hide frontmatter * layout fixes, padded ascii diagram * fira sans font for code
3.7 KiB
3.7 KiB
Recommended Folder Structure
Structure
A typical Cosmos SDK module can be structured as follows:
x/{module}
├── client
│ ├── cli
│ │ ├── query.go
│ │ └── tx.go
│ └── rest
│ ├── query.go
│ └── 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
├── abci.go
├── alias.go
├── genesis.go
├── handler.go
├── module.go
├── ...
└── simulation.go
abci.go: The module'sBeginBlockerandEndBlockerimplementations (if any).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 (excludinginternal/) but it is recommended thatalias.gohave everything exposed that other modules may need. The majority of the exported values here will typically come frominternal/(see below).client/: The module's CLI and REST client functionality implementation and testing.exported/: The module's exported types -- typically type interfaces. If a module relies on other module keepers, it is expected to receive them as interface contracts through theexpected_keepers.go(which are detailed below) design to avoid having a direct dependency on the implementing module. However, these contracts can define methods that operate on and/or return types that are specific to the contract's implementing module and this is whereexported/comes into play. Types defined here allow forexpected_keepers.goin other modules to define contracts that use single canonical types. This pattern allows for code to remain DRY and also alleviates import cycle chaos.genesis.go: The module's genesis related business logic (e.g.InitGenesis). Note, genesis types are defined ininternal/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 withalias.goin 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,KVStorekeys, parameter types, andexpected_keepers.gocontracts.internal/keeper: The module's keeper implementation along with any auxiliary implementations such as the querier and invariants.
module.go: The module's implementation of theAppModuleandAppModuleBasicinterfaces.simulation.go: The module's simulation messages and related types (if any).
Next {hide}
Learn about interfaces {hide}